Daily Archives

Articles indexed Friday June 15 2012

Page 9/14 | < Previous Page | 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Cocos2D: Change animation based on joystick direction

    - by Blade
    I'm trying to get my figure to look in the right directions, based on the input of the joystick. So if I tilt left it looks left and the left animation is used, if I used right, it looks right and right animation is used, if up, then up, down, down and so on. I just get animation for front and back. Also if I press up I see the back of the figure correctly, but it won't go back into the original state when I don't press up anymore. -(void)applyJoystick:(SneakyJoystick *)aJoystick forTimeDelta:(float) deltaTime { CGPoint scaledVelocity = ccpMult(aJoystick.velocity, 128.0f); CGPoint oldPosition = [self position]; CGPoint newPosition = ccp(oldPosition.x + scaledVelocity.x * deltaTime, oldPosition.y + scaledVelocity.y * deltaTime); [self setPosition:newPosition]; id action = nil; int extra = 50; if ((int) aJoystick.degrees > 180 - extra && aJoystick.degrees < 180 + extra) { action = [CCAnimate actionWithAnimation:walkingAnimLeft restoreOriginalFrame:NO]; } else if ((int) aJoystick.degrees > 360 - extra && aJoystick.degrees < 360 + extra) { action = [CCAnimate actionWithAnimation:walkingAnimRight restoreOriginalFrame:NO]; } else if ((int) aJoystick.degrees > 90 - extra && aJoystick.degrees < 90 + extra) { action = [CCAnimate actionWithAnimation:walkingAnimBack restoreOriginalFrame:NO]; } else if ((int) aJoystick.degrees > 270 - extra && aJoystick.degrees < 270 + extra) { action = [CCAnimate actionWithAnimation:walkingAnimFront restoreOriginalFrame:NO]; } if (action != nil) { [self runAction:action]; } } }

    Read the article

  • How to reduce the time it takes to load my web game? [closed]

    - by Danial
    I created a puzzle game with Unity and uploaded it to one server. This works fine, but I bought a new server and uploaded my game to it as well. There, the loading time is much longer. These are the servers: http://pinheadsinteractive.com/Mozzie/ (fast) http://operation-mozzie-free.com/ (slow) The Unity files are exactly the same from one server to the next. My client is dissatisfied with the new, slow loading time. So, how can I reduce the time my Unity game takes to load? Even in some cases they faced the problem that they could not load the game at all. For the the moment, I'm using an iframe on the new sever as a workaround, but the issue still remains unsolved.

    Read the article

  • Events and objects being skipped in GameMaker

    - by skeletalmonkey
    Update: Turns out it's not an issue with this code (or at least not entirely). Somehow the objects I use for keylogging and player automation (basic ai that plays the game) are being 'skipped' or not loaded about half the time. These are invisible objects in a room that have basic effects such are simulating button presses, or logging them. I don't know how to better explain this problem without putting up all my code, so unless someone has heard of this issue I guess I'll be banging my head against the desk for a bit /Update I've been continuing work on modifying Spelunky, but I've run into a pretty major issue with GameMaker, which I hope is me just doing something wrong. I have the code below, which is supposed to write log files named sequentially. It's placed in a End Room event such that when a player finishes a level, it'll write all their keypress's to file. The problem is that it randomly skips files, and when it reaches about 30 logs it stops creating any new files. var file_name; file_count = 4; file_name = file_find_first("logs/*.txt", 0); while (file_name != "") { file_count += 1; file_name = file_find_next(); } file_find_close(); file = file_text_open_write("logs/log" + string(file_count) + ".txt"); for(i = 0; i < ds_list_size(keyCodes); i += 1) { file_text_write_string(file, string(ds_list_find_value(keyCodes, i))); file_text_write_string(file, " "); file_text_write_string(file, string(ds_list_find_value(keyTimes, i))); file_text_writeln(file); } file_text_close(file); My best guess is that the first counting loop is taking too long and the whole thing is getting dropped? Also, if anyone can tell me of a better way to have sequentially numbered log files that would also be great. Log files have to continue counting over multiple start/stops of the game.

    Read the article

  • Collision within a poly

    - by G1i1ch
    For an html5 engine I'm making, for speed I'm using a path poly. I'm having trouble trying to find ways to get collision with the walls of the poly. To make it simple I just have a vector for the object and an array of vectors for the poly. I'm using Cartesian vectors and they're 2d. Say poly = [[550,0],[169,523],[-444,323],[-444,-323],[169,-523]], it's just a pentagon I generated. The object that will collide is object, object.pos is it's position and object.vel is it's velocity. They're both 2d vectors too. I've had some success to get it to find a collision, but it's just black box code I ripped from a c++ example. It's very obscure inside and all it does though is return true/false and doesn't return what vertices are collided or collision point, I'd really like to be able to understand this and make my own so I can have more meaningful collision. I'll tackle that later though. Again the question is just how does one find a collision to walls of a poly given you know the poly vertices and the object's position + velocity? If more info is needed please let me know. And if all anyone can do is point me to the right direction that's great.

    Read the article

  • Is the STL efficient enough for mobile devices?

    - by mx2
    When it comes to mobile game development on iOS and Android NDK, some developers write their own C++ containers, while others claim that STL is more than adequate for mobile game development (For example, the author of iPhone 3D Programming uses STL rather than Objective-C in his examples. His defense is that STL is no slower than Objective-C). Then there are also mobile developers who abandon C++ entirely and develop games entirely (or mostly) in the C language (C89/C90). What are the benefits and drawbacks of each approach?

    Read the article

  • How to improve Minecraft-esque voxel world performance?

    - by SomeXnaChump
    After playing Minecraft I marveled a bit at its large worlds but at the same time I found them extremely slow to navigate, even with a quad core and meaty graphics card. Now I assume Minecraft is fairly slow because: A) It's written in Java, and as most of the spatial partitioning and memory management activities happen in there, it would naturally be slower than a native C++ version. B) It doesn't partition its world very well. I could be wrong on both assumptions; however it got me thinking about the best way to manage large voxel worlds. As it is a true 3D world, where a block can exist in any part of the world, it is basically a big 3D array [x][y][z], where each block in the world has a type (i.e BlockType.Empty = 0, BlockType.Dirt = 1 etc.) Now, I am assuming to make this sort of world perform well you would need to: A) Use a tree of some variety (oct/kd/bsp) to split all the cubes out; it seems like an oct/kd would be the better option as you can just partition on a per cube level not a per triangle level. B) Use some algorithm to work out which blocks can currently be seen, as blocks closer to the user could obfuscate the blocks behind, making it pointless to render them. C) Keep the block object themselves lightweight, so it is quick to add and remove them from the trees. I guess there is no right answer to this, but I would be interested to see peoples' opinions on the subject. How would you improve performance in a large voxel-based world?

    Read the article

  • Placing text on UIView in custom location

    - by JAM
    I am trying to calculate a position to place label on the screen. The goal is to place "word" label in lower right corner of the first square block If yellowish square is defined as myView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 70, 70)]; [self.view addSubview:myView]; [myView setBackgroundColor:[UIColor colorWithHexString:@"FFFFEC"]]; Using it, i'd like to place a label in it's lower right corner l1 = [[UILabel alloc] init]; [l1 setText:@"word"]; [l1 setFrame:CGRectMake(myView.frame.origin.x + myView.frame.size.width, myView.frame.origin.y + myView.frame.size.height, 700, 700)]; [l1 setFont:[UIFont fontWithName:@"Arial" size:10.0]]; [l1 setBackgroundColor:[UIColor colorWithHexString:@"CCFFFEC"]]; [l1 setTextAlignment:UITextAlignmentRight]; [l1 sizeToFit]; This is what happens: The matter here obviously, is in a correct offset. Knowing the font and size of text, how can one correctly calculate it?

    Read the article

  • Debug not working in Monodroid with a Galaxy Nexus

    - by MaxM
    I'm starting to work with Monodroid testing on a Galaxy Nexus from MonoDevelop for Mac. Running the default Android project without debugging works. But if I try to debug it either says this in the Application Output pane: Error trying to detect already running process Or it outputs the following to logcat: I/ActivityManager( 448): Start proc monotest.monotest for activity monotest.monotest/monotest.Activity1: pid=3075 uid=10068 gids={3003} D/dalvikvm( 3063): GC_CONCURRENT freed 98K, 89% free 478K/4096K, paused 0ms+1ms I/dalvikvm( 3075): Turning on JNI app bug workarounds for target SDK version 8... V/PhoneStatusBar( 524): setLightsOn(true) I/ActivityThread( 3075): Pub monotest.monotest.__mono_init__: mono.MonoRuntimeProvider D/dalvikvm( 3075): Trying to load lib /data/data/monotest.monotest/lib/libmonodroid.so 0x41820850 D/dalvikvm( 3075): Added shared lib /data/data/monotest.monotest/lib/libmonodroid.so 0x41820850 D/OpenGLRenderer( 683): Flushing caches (mode 1) E/mono ( 3075): WARNING: The runtime version supported by this application is unavailable. E/mono ( 3075): Using default runtime: v2.0.50727 D/OpenGLRenderer( 683): Flushing caches (mode 0) I/monodroid-gc( 3075): environment supports jni NewWeakGlobalRef I/mono ( 3075): Stacktrace: I/mono ( 3075): D/AndroidRuntime( 3093): D/AndroidRuntime( 3093): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< D/AndroidRuntime( 3093): CheckJNI is OFF D/AndroidRuntime( 3093): Calling main entry com.android.commands.am.Am D/dalvikvm( 3021): GC_CONCURRENT freed 359K, 3% free 15630K/16071K, paused 2ms+4ms D/Zygote ( 119): Process 3075 terminated by signal (11) I/ActivityManager( 448): Process monotest.monotest (pid 3075) has died. I tried using another device (a Galaxy Tab) and it worked fine. I also tried the suggestion from here and it didn't help.

    Read the article

  • Connecting to TFS via ASP.NET, jQuery and Phonegap

    - by Tony D.
    I want to develop a mobile application that would allow the user the ability to run a suite of automated test cases housed in TFS. This is something I thought of this morning so it's all still very preliminary. But I'm curious as to what would be the best route for something like this? Or if it's even possible? Because the mobile devices from the users will vary from iphones to droids, I would probably want to incorporate something like Phonegap for it's cross platform capabilities. My initial thought was to develop in ASP.net/C# (which would be stored on a remote server), and have jQuery make calls to that server. Not sure if that would be the most appropriate way of handling this. I'm not too familiar with JSON but I have seen it as a suggestion on various sites to handle the returned data. Any thoughts or suggestions are appreciated. Thanks.

    Read the article

  • Retrieving license type (linux/windows/windows+sqlserver) for an Amazon EC2 instance via the API?

    - by Geir
    I need to calculate the hourly running costs for my Amazon EC2 instances. This varies even between instances with same hardware configs (instance types) because I use different amazon images (AMIs): some plain windows server and some windows server with sql server (both of them have additional costs compared with plain linux instances) The EC2 Java API has a describeInstances() method which returns Instance objects with metadata such as instance id, instance type (m1.small/large...), state (running,stopped..) public ip, etc. This Instance object also has a .getLicense().getPool() which according to the Java API should return "The license pool from which this license was used (ex: 'windows')." I thought this is were it may also give 'windows+sqlserver' or something to that effect. The getLicense() method does however return null.. I've navigated around the EC2 web console, not being able to find this information, but I'm hoping that it is possible - otherwise it would mean that you cannot identify the true hourly cost of an particular instance unless you know which AMI was used to create it in the first place (plain windows server or windows server with sql server). Anyone? Thanks :) /Geir

    Read the article

  • Freetype2 (error-)return value documentation

    - by Awaki
    In short, I'm looking for documentation that would limit the error situations to check for after a Freetype library function failed, much like the OpenGL and Win32 APIs document the error codes generated by their respective functions. I can't seem to find such documentation though, so I was wondering how to best handle translation of Freetype errors to typed exceptions. Background: I am currently in the process of implementing font-rendering capability (using Freetype) for my GUI framework, which makes strong use of typed exceptions to indicate error situations. However, the Freetype docs seem to completely omit what errors can be expected from what functions. That, if such documentation does indeed not exist, would basically leave me with two options: either guessing which errors make sense for a certain Freetype function (obviously prone to mistakes on my part), or considering every error code for translation into appropriate exceptions (less verbose since I would have to write the translation only once). Performance isn't really critical in the code that calls the Freetype library, so even the latter option would probably be acceptable, but surely there must be some kind of documentation on which library calls may return what Freetype error? Is there any such documentation which I just somehow managed to not find? Should I go the route of generically expecting every error code for translation? Or are there other ways to approach this problem? By the way, I wanted to avoid introducing some kind of generic FreetypeException (containing a description of the Freetype error) since I intended to completely hide what libraries I'm using (not from a legal point-of-view, mind you), but I guess I can be convinced to do this anyway if the consensus is that it would be the best option. I don't think it matters for this question, but I'm writing in C++.

    Read the article

  • python 3 self class dict

    - by Jjang
    I am trying to create my own class of dictionary in python 3 which has a field of dict variable and setitem and getitem methods. Though, it doesnt work for some reason. Tried to look around but couldn't find the answer. class myDictionary: def __init(self): self.myDic={} def __setitem__(self, key, value): self.myDic[key]=value I'm getting: 'myDictionary' object has no attribute 'myDic' Any ideas? :)

    Read the article

  • PHP array value becomes blank. What is going on?

    - by Michael Bruce
    I have written a web page that works fine expect for some weird behavior. The code below gets all expected values and populates them correctly except for $v-data["quick_phone_id"] and $v-data["quick_email_id"] which are integers. Those values come out blank in the string I am creating. The value for $v-data["id"] is another integer and works as expected. My only clue is that when I uncomment the commented out line, the code works properly. So I'm guessing this has to do with referencing getting broken for the array. Any ideas? I'd like to fix my code and my PHP knowledge. $contacts = ContactInfo::loadMyContacts($userId); $sb = new StringBuilder(); $idx = 0; //$vals = "vals: ".$contacts[0]->data["quick_phone_id"]; $sb->append(' dataRows = ['); foreach($contacts as $k => $v) { $sb->append('{ id:"'.strval($v->data["id"]).'",'); $sb->append('url:"edit_contact.php?id='.$v->data["id"].'",'); $sb->append('gname:"'.$v->data["given_name"].'",'); $sb->append('fname:"'.$v->data["family_name"].'",'); $sb->append('phone1id2:"'.strval($v->data["quick_phone_id"]).'",'); $sb->append('phone1type:"'.$v->data["quick_phone_type"].'",'); $sb->append('phone1:"'.$v->data["quick_phone"].'",'); $sb->append("email1id2:'".strval($v->data["quick_email_id"])."',"); $sb->append('email1type:"'.$v->data["quick_email_type"].'",'); $sb->append("email1:'".$v->data["quick_email"]."',"); $sb->append("dirty:false },\n"); } $sb->append('];');

    Read the article

  • How to use Scala interpreter options with SBT?

    - by John Threepwood
    When using the Scala interpreter, one could start it with an option like: C:\Users\John>scala -unchecked Welcome to Scala version 2.9.2 (Java HotSpot(TM) Client VM, Java 1.6.0_32). Type in expressions to have them evaluated. Type :help for more information. scala> When using sbt, how can one start the Scala interpreter with options ? The following try will not work: C:\Users\John\Test Scala Project 1>sbt [...] [info] Loading global plugins from C:\Users\John\.sbt\plugins [info] Set current project to default-8d4ecc (in build file:/C:/Users/John/Tes t%20Scala%20Project%201/) > console -unchecked [error] Expected end of input. [error] console -unchecked [error] ^ With Google & Co I could not figure out how to do this from within the sbt shell. Does anyone know ?

    Read the article

  • C# Regex - Match and replace, Auto Increment

    - by Marc Still
    I have been toiling with a problem and any help would be appreciated. Problem: I have a paragraph and I want to replace a variable which appears several times (Variable = @Variable). This is the easy part, but the portion which I am having difficulty is trying to replace the variable with different values. I need for each occurrence to have a different value. For instance, I have a function that does a calculation for each variable. What I have thus far is below: private string SetVariables(string input, string pattern){ Regex rx = new Regex(pattern); MatchCollection matches = rx.Matches(input); int i = 1; if(matches.Count > 0) { foreach(Match match in matches) { rx.Replace(match.ToString(), getReplacementNumber(i)); i++ } } I am able to replace each variable that I need to with the number returned from getReplacementNumber(i) function, but how to I put it back into my original input with the replaced values, in the same order found in the match collection? Thanks in advance! Marcus

    Read the article

  • Designing operation (a,b) -> (c,d)

    - by golergka
    I have an operation that I need to design. That operation takes two objects of a certain class X, and returns two new objects of the same class (I may need the originals later). The logic that dictates the selection of this object is contained in class Y. On one hand, I don't want class Y to know details about class X implementation; on the other, I don't want class X to know details about selecting the different objects to perform this operation on. If that was all the problem, I'd just create a static method on class A. However, the methods in language I'm working on return only one object. Also, the operation needs to be robust, and calling operation two times to get C and D respectively isn't possible, as both C & D both rely on a single random number. How should I design such operation? Update: I'm using Obejctive C.

    Read the article

  • Error loading CMSMS website

    - by adeniyi makinde
    I just uploaded a CMSMS website, but cannot view the website. Am getting the error: Warning: require(/home/inkbran1/public_html/century21nigeria/lib/smarty/Smarty.class.php) [function.require]: failed to open stream: No such file or directory in /home/inkbran1/public_html/century21nigeria/include.php on line 153 Fatal error: require() [function.require]: Failed opening required '/home/inkbran1/public_html/century21nigeria/lib/smarty/Smarty.class.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/inkbran1/public_html/century21nigeria/include.php on line 153 Please, what can i do? I am a PHP dummy.

    Read the article

  • My first c# app and first null object exception

    - by Fresheyeball
    Total noob here. This is my first c# attempt, its a console application that simulates a drinking game called 'Left Right Center'. In the console I receive the following: CONSOLE Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object at LeftRightCenter.MainClass.Main (System.String[] args) [0x00038] in /Users/apple/Projects/LearningC/LearningC/Main.cs:80 [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object at LeftRightCenter.MainClass.Main (System.String[] args) [0x00038] in /Users/apple/Projects/LearningC/LearningC/Main.cs:80 C# using System; namespace LeftRightCenter { class Player { //fields private int _quarters = 4; public int Quarters { get{ return _quarters; } set{ _quarters += value; } } public Player (string name) { } } class Dice { Random random = new Random(); public int Roll () { random = new Random (); int diceSide; diceSide = random.Next (0, 6); diceSide = (diceSide > 2) ? 3 : diceSide; return diceSide; } } class MainClass { static int activePlayer = 0; static int theCup = 0; static Player[] thePlayers = { new Player ("Jessica"), new Player ("Isaac"), new Player ("Ed"), new Player ("Bella"), new Player ("Elisa"), new Player ("Fake RedHead"), new Player ("Linda"), new Player ("MJ"), new Player ("Irene"), new Player("Devin") }; static Dice[] theDice = new Dice[2]; private static void MoveQuarter (int direction) { int numberOfPlayers = thePlayers.Length - 1; switch (direction) { case 0: thePlayers [activePlayer].Quarters = -1; theCup++; break; case 1: thePlayers [activePlayer].Quarters = -1; int leftPlayer = (activePlayer == 0) ? numberOfPlayers : activePlayer - 1; thePlayers [leftPlayer].Quarters = +1; break; case 2: thePlayers [activePlayer].Quarters = -1; int rightPlayer = (activePlayer == numberOfPlayers) ? 0 : activePlayer + 1; thePlayers [rightPlayer].Quarters = +1; break; } } public static void Main (string[] args) { int cupEndPoint = thePlayers.Length * 4 - 1; while (theCup < cupEndPoint) { foreach (Dice rattle in theDice) { if (thePlayers [activePlayer].Quarters > 0) { MoveQuarter (rattle.Roll ()); // this line seems to be the problem } } Console.WriteLine ("{0} Quarters In the Cup", theCup); } } } } I have no idea what the problem is or why, and my googling have proven more use confusing than helpful.

    Read the article

  • seo custom domains

    - by BamBam
    I'm trying to do the following: I have website like apartments.com. sometimes, I want to expand to different cities, so for SEO purposes, I might create a separate domain like bostonapartments.com or newyorkapartments.com for only boston and new york apartments. bostonapartments.com and the main domain apartments.com are all hosted on 1 server. what I did was I used Virtual Host apache config to direct bostonapartments.com to a directory on that server, and then used an iframe to load content for bostonapartments.com from apartments.com. So all the content will be hosted on apartments.com, but bostonapartments.com will get the content from apartments.com. how can I accomplish this effectively in a scalable way using php, apache, mysql? btw, I do not own apartments.com, I'm just using that as an example.

    Read the article

  • Using a variable derived from a drop-down list as the column name in a select statement ... Access DB

    - by user1459698
    I'm working with the world's worst DB that was already here so don't blame me for that. So, here's what I have so far ... module = txtModule.value presstype = txtPressType.value SQL_query = "SELECT * FROM tbl_spareparts WHERE '"& module &"' <> '""' AND '"& module &"' = '"& presstype &"' AND Manufacturer = '"& txtsrch.value &"' ORDER BY SAP_Part_No" Set rsData = conn.Execute(SQL_query) This brings up the following SQL statement: SELECT * FROM tbl_spareparts WHERE 'Banyan_Module' <> '"' AND 'Banyan_Module' = 'PB' AND Manufacturer = 'Tester' ORDER BY SAP_Part_No Is there any way I can use the module variable as a column name - obviously the ''s around the column name are causing an error. This is really bothering me. BTW, I'm writing this in VBScript inside a .HTA application page as it has to run locally on tech PCs. Thanks. R.

    Read the article

  • How does Ruby's Enumerator object iterate externally over an internal iterator?

    - by Salman Paracha
    As per Ruby's documentation, the Enumerator object uses the each method (to enumerate) if no target method is provided to the to_enum or enum_for methods. Now, let's take the following monkey patch and its enumerator, as an example o = Object.new def o.each yield 1 yield 2 yield 3 end e = o.to_enum loop do puts e.next end Given that the Enumerator object uses the each method to answer when next is called, how do calls to the each method look like, every time next is called? Does the Enumeartor class pre-load all the contents of o.each and creates a local copy for enumeration? Or is there some sort of Ruby magic that hangs the operations at each yield statement until next is called on the enumeartor? If an internal copy is made, is it a deep copy? What about I/O objects that could be used for external enumeration? I'm using Ruby 1.9.2.

    Read the article

  • Retrieve nested list from XDocument with LINQ

    - by twreid
    Ok I want my link query to return a list of users. Below is the XML <section type="Users"> <User type="WorkerProcessUser"> <default property="UserName" value="Main"/> <default property="Password" value=""/> <default property="Description" value=""/> <default property="Group" value=""/> </User> <User type="AnonymousUser"> <default property="UserName" value="Second"/> <default property="Password" value=""/> <default property="Description" value=""/> <default property="Group" value=""/> </User> </section> And my current LINQ Query that doesn't work. doc is an XDocument var users = (from iis in doc.Descendants("section") where iis.Attribute("type").Value == "Users" from user in iis.Elements("User") from prop in user.Descendants("default") select new { Type = user.Attribute("type").Value, UserName = prop.Attribute("UserName").Value }); This does not work can anyone tell me what I need to fix? Here is my second attempt after fixing for the wrong property name. However this one does not seem to enumerate the UserName value for me when I try to use it or at least when I try to write it to the console. Also this returns 8 total results I should only have 2 results as I only have 2 users. (from iis in doc.Descendants("section") where iis.Attribute("type").Value == "Users" from user in iis.Elements("User") from prop in user.Descendants("default") select new { Type = user.Attribute("type").Value, UserName = (from name in prop.Attributes("property") where name.Value == "UserName" select name.NextAttribute.Value).ToString() });

    Read the article

  • Android RestTemplate Ok on emulator but fails on real device

    - by Hossein
    I'm using spring RestTemplate and it works perfect on emulator but if I run my app on real device I get HttpMessageNotWritableException ............ nested exception is java.net.SocketException: Broken pipe Here is some lines of my code(keep in mind my app works perfect on emulator) ............ LoggerUtil.logToFile(TAG, "url is [" + url + "]"); LoggerUtil.logToFile(TAG, "NetworkInfo - " + connectivityManager.getActiveNetworkInfo()); ResponseEntity<T> responseEntity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, clazz); ............. I know my device's network works perfect because all other applications on my device are working and also using device browser I'm able to connect to my server so my server is available. My server is up and running and my device is able to connect to my server so why I get java.net.SocketException: Broken pipe ?!!!!!!! Before I call restTemplate.exchange() I log NetworkInfo and it looks ok -type: WIFI -status: CONNECTED/CONNECTED -isAvailable: true Thanks in advance. Update: It is really weird Even if I use HttpURLConnection, it works perfectly on emulator but on real device I get 400 Bad Request Here is my code HttpURLConnection con = null; try { String url = ....; LoggerUtil.logToFile(TAG, "url [" + url + "]" ); con = (HttpURLConnection) new URL(url).openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Connection", "Keep-Alive"); con.setDoInput(true); con.setDoOutput(true); con.setUseCaches(false); con.connect(); LoggerUtil.logToFile(TAG, "con.getResponseCode is " + con.getResponseCode()); LoggerUtil.logToFile(TAG, "con.getResponseMessage is " + con.getResponseMessage()); } catch(Throwable t){ LoggerUtil.logToFile(TAG, "*** failed [" + t + "]" ); } in log file I see con.getResponseCode is 400 con.getResponseMessage is Bad Request

    Read the article

  • Python multiprocessing global variable updates not returned to parent

    - by user1459256
    I am trying to return values from subprocesses but these values are unfortunately unpicklable. So I used global variables in threads module with success but have not been able to retrieve updates done in subprocesses when using multiprocessing module. I hope I'm missing something. The results printed at the end are always the same as initial values given the vars dataDV03 and dataDV04. The subprocesses are updating these global variables but these global variables remain unchanged in the parent. import multiprocessing # NOT ABLE to get python to return values in passed variables. ants = ['DV03', 'DV04'] dataDV03 = ['', ''] dataDV04 = {'driver': '', 'status': ''} def getDV03CclDrivers(lib): # call global variable global dataDV03 dataDV03[1] = 1 dataDV03[0] = 0 # eval( 'CCL.' + lib + '.' + lib + '( "DV03" )' ) these are unpicklable instantiations def getDV04CclDrivers(lib, dataDV04): # pass global variable dataDV04['driver'] = 0 # eval( 'CCL.' + lib + '.' + lib + '( "DV04" )' ) if __name__ == "__main__": jobs = [] if 'DV03' in ants: j = multiprocessing.Process(target=getDV03CclDrivers, args=('LORR',)) jobs.append(j) if 'DV04' in ants: j = multiprocessing.Process(target=getDV04CclDrivers, args=('LORR', dataDV04)) jobs.append(j) for j in jobs: j.start() for j in jobs: j.join() print 'Results:\n' print 'DV03', dataDV03 print 'DV04', dataDV04 I cannot post to my question so will try to edit the original. Here is the object that is not picklable: In [1]: from CCL import LORR In [2]: lorr=LORR.LORR('DV20', None) In [3]: lorr Out[3]: <CCL.LORR.LORR instance at 0x94b188c> This is the error returned when I use a multiprocessing.Pool to return the instance back to the parent: Thread getCcl (('DV20', 'LORR'),) Process PoolWorker-1: Traceback (most recent call last): File "/alma/ACS-10.1/casa/lib/python2.6/multiprocessing/process.py", line 232, in _bootstrap self.run() File "/alma/ACS-10.1/casa/lib/python2.6/multiprocessing/process.py", line 88, in run self._target(*self._args, **self._kwargs) File "/alma/ACS-10.1/casa/lib/python2.6/multiprocessing/pool.py", line 71, in worker put((job, i, result)) File "/alma/ACS-10.1/casa/lib/python2.6/multiprocessing/queues.py", line 366, in put return send(obj) UnpickleableError: Cannot pickle <type 'thread.lock'> objects In [5]: dir(lorr) Out[5]: ['GET_AMBIENT_TEMPERATURE', 'GET_CAN_ERROR', 'GET_CAN_ERROR_COUNT', 'GET_CHANNEL_NUMBER', 'GET_COUNT_PER_C_OP', 'GET_COUNT_REMAINING_OP', 'GET_DCM_LOCKED', 'GET_EFC_125_MHZ', 'GET_EFC_COMB_LINE_PLL', 'GET_ERROR_CODE_LAST_CAN_ERROR', 'GET_INTERNAL_SLAVE_ERROR_CODE', 'GET_MAGNITUDE_CELSIUS_OP', 'GET_MAJOR_REV_LEVEL', 'GET_MINOR_REV_LEVEL', 'GET_MODULE_CODES_CDAY', 'GET_MODULE_CODES_CMONTH', 'GET_MODULE_CODES_DIG1', 'GET_MODULE_CODES_DIG2', 'GET_MODULE_CODES_DIG4', 'GET_MODULE_CODES_DIG6', 'GET_MODULE_CODES_SERIAL', 'GET_MODULE_CODES_VERSION_MAJOR', 'GET_MODULE_CODES_VERSION_MINOR', 'GET_MODULE_CODES_YEAR', 'GET_NODE_ADDRESS', 'GET_OPTICAL_POWER_OFF', 'GET_OUTPUT_125MHZ_LOCKED', 'GET_OUTPUT_2GHZ_LOCKED', 'GET_PATCH_LEVEL', 'GET_POWER_SUPPLY_12V_NOT_OK', 'GET_POWER_SUPPLY_15V_NOT_OK', 'GET_PROTOCOL_MAJOR_REV_LEVEL', 'GET_PROTOCOL_MINOR_REV_LEVEL', 'GET_PROTOCOL_PATCH_LEVEL', 'GET_PROTOCOL_REV_LEVEL', 'GET_PWR_125_MHZ', 'GET_PWR_25_MHZ', 'GET_PWR_2_GHZ', 'GET_READ_MODULE_CODES', 'GET_RX_OPT_PWR', 'GET_SERIAL_NUMBER', 'GET_SIGN_OP', 'GET_STATUS', 'GET_SW_REV_LEVEL', 'GET_TE_LENGTH', 'GET_TE_LONG_FLAG_SET', 'GET_TE_OFFSET_COUNTER', 'GET_TE_SHORT_FLAG_SET', 'GET_TRANS_NUM', 'GET_VDC_12', 'GET_VDC_15', 'GET_VDC_7', 'GET_VDC_MINUS_7', 'SET_CLEAR_FLAGS', 'SET_FPGA_LOGIC_RESET', 'SET_RESET_AMBSI', 'SET_RESET_DEVICE', 'SET_RESYNC_TE', 'STATUS', '_HardwareDevice__componentName', '_HardwareDevice__hw', '_HardwareDevice__stickyFlag', '_LORRBase__logger', '__del__', '__doc__', '__init__', '__module__', '_devices', 'clearDeviceCommunicationErrorAlarm', 'getControlList', 'getDeviceCommunicationErrorCounter', 'getErrorMessage', 'getHwState', 'getInternalSlaveCanErrorMsg', 'getLastCanErrorMsg', 'getMonitorList', 'hwConfigure', 'hwDiagnostic', 'hwInitialize', 'hwOperational', 'hwSimulation', 'hwStart', 'hwStop', 'inErrorState', 'isMonitoring', 'isSimulated'] In [6]:

    Read the article

  • JDBC programms running long time performance issue

    - by phyerbarte
    My program has an issue with Oracle query performance, I believe the SQL have good performance, because it returns quickly in SQLPlus. But when my program has been running for a long time, like 1 week, the SQL query (using JDBC) becomes slower (In my logs, the query time is much longer than when I originally started the program). When I restart my program, the query performance comes back to normal. I think it is could be something wrong with the way I use the preparedStatement, because the SQL I'm using does not use placeholders "?" at all. Just a complex select query. The query process is done by a util class. Here is the pertinent code building the query: public List<String[]> query(String sql, String[] args) { Connection conn = null; conn = openConnection(); conn.setAutocommit(true); .... PreparedStatement preStatm = null; ResultSet rs = null; ....//set preparedstatment arg code rs = preStatm.executeQuery(); .... finally{ //close rs //close prestatm //close connection } } In my case, the args is always null, so it just passes a query sql to this query method. Is that possible this way could slow down the DB query after program long time running? Or I should use statement instead, or just pass args with "?" in the SQL? How can I find out the root cause for my issue? Thanks.

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14  | Next Page >