dcsimg
running a script within Java code: pause/resume needed
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Maurice_Manning
Posted On:   Thursday, November 16, 2006 12:49 PM

I do understand that that pause/resume are deprecated, I am using a pattern described here: http://www.cs.wisc.edu/~cs368-1/JavaTutorial/jdk1.2/guide/misc/threadPrimitiveDeprecation.html. The script language I would like to use is Python but I am flexible. The script will move a robot arm as well as control a sensor device and a camera by calling a Java API for the deveices. The user may need to stop the process if there are problems with the hardware or some items (cleaning basin, fluids) were not correctly prepared. I have the client/server set up as a web service and the script is passed in the envelope. My Manager class then spins off a thread for a ScriptRunner class which contains the script to evaluate. This scriptrunner class contains the hal   More>>

I do understand that that pause/resume are deprecated, I am using a pattern described here: http://www.cs.wisc.edu/~cs368-1/JavaTutorial/jdk1.2/guide/misc/threadPrimitiveDeprecation.html. The script language I would like to use is Python but I am flexible.

The script will move a robot arm as well as control a sensor device and a camera by calling a Java API for the deveices. The user may need to stop the process if there are problems with the hardware or some items (cleaning basin, fluids) were not correctly prepared. I have the client/server set up as a web service and the script is passed in the envelope. My Manager class then spins off a thread for a ScriptRunner class which contains the script to evaluate. This scriptrunner class contains the halt/pause/resume methods which are patterned after the article. The Manager can receive the pause command from the client and relay it to the ScriptRunner class. My classes are wired together with the Spring framework. The problem is that when I call jythonInterpreter.exec(thisScript), that creates a separate thread that I do not have access to. I also tried javascript/Rhino (which I do not like) because it looked like it shared the same thread as the class which spawns it but I was not successful in getting the pause/resume to work. Am I missing something?

I do not want the script to have to contain a bunch of code that checks if the thread has paused or halted, I would like it to only contain commands to run the robot. I need each instruction (moveRobotArm(vector))to execute atomically. (No database interaction, btw) I need loops and control structures; otherwise I could just exec each Python statement in the script separately within my ScriptRunner run loop. From the Python docs:

“The design of this module is loosely based on Java's threading model. However, where Java makes locks and condition variables basic behavior of every object, they are separate objects in Python. Python's Thread class supports a subset of the behavior of Java's Thread class; currently, there are no priorities, no thread groups, and threads cannot be destroyed, stopped, suspended, resumed, or interrupted. The static methods of Java's Thread class, when implemented, are mapped to module-level functions.”

If you are still reading, I am amazed. I would be interested in any ideas on design options. Thanks again for your interest/response.

Mo

   <<Less

Re: running a script within Java code: pause/resume needed

Posted By:   Anonymous  
Posted On:   Tuesday, December 12, 2006 04:45 AM

way too much to read!
Please specify in points what your looking for!
About | Sitemap | Contact