|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgov.sandia.ccaffeine.dc.user_iface.MVC.PythonStub
public class PythonStub
This java client sends Python code to a remote interface that is attached to the cca server. The code usually instructs the cca server to perform an action; for example, this client can instruct the cca server to instantiate component. The remote interface sends XML text to this java client; the XML text contains inforation on the state of the cca server; for example, the cca server can send the names of all loaded components.
This class opens a socket connection to the remote interface. Python code is sent from this client to the cca server's remote interface.
Field Summary | |
---|---|
protected ClientSocket |
clientSocket
|
protected java.util.Hashtable |
hashtable
Stores (methodName,ThreadWaitForReturnValue) pairs. |
Constructor Summary | |
---|---|
PythonStub()
|
Method Summary | |
---|---|
void |
addPythonControllerListener(PythonControllerListener listener)
|
protected void |
broadcastCcaConnectionsBetweenTwoPorts(CcaConnectionBetweenTwoPorts[] ccaConnections)
|
protected void |
broadcastCcaConnectionsBetweenTwoPorts(CcaConnectionsBetweenTwoPortsEvent event)
|
protected void |
broadcastCloseComponent(CloseComponentEvent event)
|
protected void |
broadcastCloseComponent(java.lang.String componentInstanceName)
|
protected void |
broadcastComponentClassNames(ComponentClassNamesEvent event)
|
protected void |
broadcastComponentClassNames(java.lang.String[] componentClassNames)
|
protected void |
broadcastComponentInstances(CcaComponent[] componentInstances)
|
protected void |
broadcastComponentInstances(ComponentInstancesEvent event)
|
protected void |
broadcastComponentProperties(CcaComponentPropertyValue[] ccaComponentPropertyValues)
|
protected void |
broadcastComponentProperties(CcaComponentPropertyValuesEvent event)
|
protected void |
broadcastComponentProperty(CcaComponentPropertyValue ccaComponentPropertyValue)
|
protected void |
broadcastComponentProperty(CcaComponentPropertyValueEvent event)
|
protected void |
broadcastConnectTwoPorts(CcaConnectionBetweenTwoPorts ccaConnection)
|
protected void |
broadcastConnectTwoPorts(CcaConnectTwoPortsEvent event)
|
protected void |
broadcastDisconnectTwoPorts(CcaConnectionBetweenTwoPorts ccaConnection)
|
protected void |
broadcastDisconnectTwoPorts(CcaDisconnectTwoPortsEvent event)
|
protected void |
broadcastFixSharedLibrary()
|
protected void |
broadcastFixSharedLibrary(FixSharedLibraryEvent event)
|
protected void |
broadcastInstantiateComponent(CcaComponent ccaComponent)
|
protected void |
broadcastInstantiateComponent(InstantiateComponentEvent event)
|
protected void |
broadcastLaunchGoOnAllComponents()
|
protected void |
broadcastLaunchGoOnAllComponents(LaunchGoOnAllComponentsEvent event)
|
protected void |
broadcastLaunchGoOnOneComponent(CcaCommandLaunchGoOnOneComponent commandGo)
|
protected void |
broadcastLaunchGoOnOneComponent(LaunchGoOnOneComponentEvent event)
|
protected void |
broadcastLoadComponent(LoadComponentEvent event)
|
protected void |
broadcastLoadComponent(java.lang.String componentClassName)
|
protected void |
broadcastOpenCcaFramework()
|
protected void |
broadcastOpenCcaFramework(OpenCcaFrameworkEvent event)
|
protected void |
broadcastPortParameters(CcaPortParametersEvent event)
|
protected void |
broadcastPortParameters(java.lang.String xmlPortParameters)
|
protected void |
broadcastRemoveInstantiatedComponent(RemoveInstantiatedComponentEvent event)
|
protected void |
broadcastRemoveInstantiatedComponent(java.lang.String componentInstanceName)
|
protected void |
broadcastRemoveInstantiatedComponents(CcaComponentInstanceNames componentInstanceNames)
|
protected void |
broadcastRemoveInstantiatedComponents(RemoveInstantiatedComponentsEvent event)
|
protected void |
broadcastSetComponentProperty(CcaComponentPropertySetValueEvent event)
|
protected void |
broadcastSetComponentProperty(CcaComponentPropertyValue ccaComponentPropertyValue)
|
protected void |
broadcastSetDebugFlag(boolean debug)
|
protected void |
broadcastSetDebugFlag(SetDebugFlagEvent event)
|
protected void |
broadcastSetPathsToCcaComponents(SetPathsToCcaComponentsEvent event)
|
protected void |
broadcastSetPathsToCcaComponents(java.lang.String[] paths)
|
protected void |
broadcastSetPathToCcaComponents(SetPathToCcaComponentsEvent event)
|
protected void |
broadcastSetPathToCcaComponents(java.lang.String path)
|
protected void |
broadcastSetPortParameter(CcaPortParameterSetValueEvent event)
|
protected void |
broadcastSetPortParameter(CcaPortParameterValue ccaPortParameterValue)
|
java.lang.String |
closeComponent(java.lang.String componentInstanceName)
Tell the python server to close the cca component. |
void |
closeSessionWithCcaServer()
Close out the session with the python server. |
CcaConnectionBetweenTwoPorts |
connectTwoPorts(java.lang.String providesServiceComponentName,
java.lang.String providesServicePortName,
java.lang.String usesServiceComponentName,
java.lang.String usesServicePortName)
Tell the python server to connect two ports; the two ports may be in different components. |
CcaConnectionBetweenTwoPorts |
disconnectTwoPorts(java.lang.String providesServiceComponentName,
java.lang.String providesServicePortName,
java.lang.String usesServiceComponentName,
java.lang.String usesServicePortName)
Tell the python server to disconnect two ports; the two ports may be in different components. |
void |
fixSharedLibrary()
fix C++ shared library problem. |
java.lang.String[] |
getComponentClassNames()
Tell the python server to send back the names of all the classes that are loaded in the palette. |
CcaComponent[] |
getComponentInstances()
Tell the python server to send back the names of all the classes that are instantiated in the arena. |
CcaComponentPropertyValue[] |
getComponentProperties(java.lang.String componentInstanceName)
Ask the python server to send us the values of all the properties that belong to a component. |
CcaComponentPropertyValue |
getComponentProperty(java.lang.String componentInstanceName,
java.lang.String propertyName)
Ask the python server to send us the value of component property. |
CcaConnectionBetweenTwoPorts[] |
getConnections()
Tell the python server to send back info on every connection. |
java.lang.String |
getPortParameters(java.lang.String componentInstanceName,
java.lang.String portInstanceName)
|
CcaComponent |
instantiateComponent(java.lang.String componentClassName,
java.lang.String componentInstanceName)
Tell the python server to instantiate a cca component. |
void |
launchGoOnAllComponents()
Tell the python server to launch the run. |
CcaCommandLaunchGoOnOneComponent |
launchGoOnOneComponent(java.lang.String componentInstanceName)
Tell the python server to launch the run. |
CcaCommandLaunchGoOnOneComponent |
launchGoOnOneComponent(java.lang.String componentInstanceName,
java.lang.String portInstanceName)
Tell the python server to launch the run. |
java.lang.String |
loadComponentClass(java.lang.String componentClassName)
Tell the python server to load a component class. |
static void |
main(java.lang.String[] args)
|
void |
openFramework()
Open a connection to the python server. |
void |
openSessionWithCcaServer(ClientSocket clientSocket)
Open a session with the cca server. |
protected void |
printComponent(CcaComponent component)
Print useful information on a component. |
protected void |
printConnection(CcaConnectionBetweenTwoPorts connection)
Print useful information on a connection. |
protected void |
printDisconnection(CcaConnectionBetweenTwoPorts connection)
Print useful information on a disconnection. |
protected java.lang.String |
readPython()
Read a line of text from the python server. |
void |
removeInstantiatedComponent(java.lang.String componentInstanceName)
Tell the python server to remove an instantiated cca component. |
CcaComponentInstanceNames |
removeInstantiatedComponents()
Tell the python server to remove all instantiated cca components. |
void |
removePythonControllerListener(PythonControllerListener listener)
|
protected void |
resultSet(java.lang.String resultSet)
Parse and display result set. |
CcaComponentPropertyValue |
setComponentProperty(java.lang.String componentInstanceName,
java.lang.String propertyName,
java.lang.String propertyValue)
Tell the python server to set the value of a component property. |
boolean |
setDebugFlag(boolean debug)
Tell the python server to set the debug flag. |
java.lang.String[] |
setPathsToCcaComponents(java.lang.String[] paths)
Tell the python server the names of the folders that contains all of the cca components. |
java.lang.String |
setPathToCcaComponents(java.lang.String path)
Tell the python server the name of the folder that contains all of the cca components. |
CcaPortParameterValue |
setPortParameter(java.lang.String componentInstanceName,
java.lang.String portInstanceName,
java.lang.String fieldName,
java.lang.String fieldValue)
|
void |
test(ClientSocket clientSocket)
test the Framework |
protected void |
writePython(java.lang.String s)
Write a line of python code to the python server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ClientSocket clientSocket
protected java.util.Hashtable hashtable
The pairs are needed so that a method can send a command to the cca server, wait for a response from the cca server, return the response to the caller.
When this client invokes a method on the cca server:
*)This client creates a ThreadWaitForReturnValue
*)This client saves (methodName,ThreadWaitForReturnValue)
*)This client waits for the thread to finish its run
When the receiver gets a response from the server,
the receiver looks up the response in this hashtable.
If a match is found then the ThreadWaitforReturnValue is
released.
Constructor Detail |
---|
public PythonStub()
Method Detail |
---|
protected void writePython(java.lang.String s)
s
- The line of python code that will be
sent to the python server.protected java.lang.String readPython()
public void openSessionWithCcaServer(ClientSocket clientSocket) throws CanNotCommunicateWithCcaServerException
A socket communication channel is established with the cca server. During this session, this comm channel will be used to send commands to the cca server and to receive state information from the cca server.
Open a socket connection to the cca server. Then send Python code to initialize this session.
CanNotCommunicateWithCcaServerException
public boolean setDebugFlag(boolean debug) throws CanNotCommunicateWithCcaServerException, CanNotSetDebugFlagException
debug
- The value of the debug flag.
CanNotCommunicateWithCcaServerException
CanNotSetDebugFlagException
public void fixSharedLibrary() throws CanNotCommunicateWithCcaServerException, CanNotFixSharedLibraryException
CanNotCommunicateWithCcaServerException
- Communication
error.
CanNotFixSharedLibraryException
- cca's Python server
can not fix the shared library problem.public void openFramework() throws CanNotCommunicateWithCcaServerException, CanNotOpenCcaFrameworkException
CanNotCommunicateWithCcaServerException
CanNotOpenCcaFrameworkException
public java.lang.String setPathToCcaComponents(java.lang.String path) throws CanNotCommunicateWithCcaServerException, CanNotSetPathToCcaComponentsException
path
- The name of the folder that contains
all of the cca components.
CanNotCommunicateWithCcaServerException
CanNotSetPathToCcaComponentsException
public java.lang.String[] setPathsToCcaComponents(java.lang.String[] paths) throws CanNotCommunicateWithCcaServerException, CanNotSetPathToCcaComponentsException
paths
- The names of all the folders that
contain cca components.
CanNotCommunicateWithCcaServerException
CanNotSetPathToCcaComponentsException
public CcaComponent instantiateComponent(java.lang.String componentClassName, java.lang.String componentInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotInstantiateComponentException
componentClassName
- The class name of the component.componentInstanceName
- The instance name of the component.
CanNotCommunicateWithCcaServerException
CanNotInstantiateComponentException
public void removeInstantiatedComponent(java.lang.String componentInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotRemoveInstantiatedComponentException
componentClassName
- The class name of the component.componentInstanceName
- The instance name of the component.
CanNotCommunicateWithCcaServerException
CanNotRemoveInstantiatedComponentException
public CcaComponentInstanceNames removeInstantiatedComponents() throws CanNotCommunicateWithCcaServerException, CanNotRemoveInstantiatedComponentException
CanNotCommunicateWithCcaServerException
CanNotRemoveInstantiatedComponentException
public java.lang.String loadComponentClass(java.lang.String componentClassName) throws CanNotCommunicateWithCcaServerException, CanNotLoadComponentException
componentClassName
- The class name
of the component.
CanNotCommunicateWithServerException
- Thrown if
the server does not respond to the laod component command.
CanNotCommunicateWithCcaServerException
CanNotLoadComponentException
public CcaConnectionBetweenTwoPorts connectTwoPorts(java.lang.String providesServiceComponentName, java.lang.String providesServicePortName, java.lang.String usesServiceComponentName, java.lang.String usesServicePortName) throws CanNotCommunicateWithCcaServerException, CanNotConnectTwoPortsException
providesServiceComponentName
- The
name of the component that contains the providers port.providesServicePortName
- The name of
the providers port.usesServiceComponentName
- the name of the component
that contains the consumer port.usesServicePortName
- The name of the consumer port.
CanNotCommunicateWithCcaServerException
CanNotConnectTwoPortsException
public CcaComponentPropertyValue setComponentProperty(java.lang.String componentInstanceName, java.lang.String propertyName, java.lang.String propertyValue) throws CanNotCommunicateWithCcaServerException, CanNotSetComponentPropertyException
componentInstanceName
- The name of the componentpropertyName
- The name of the propertypropertyValue
- The value of the property
CanNotCommunicateWithCcaServerException
CanNotSetComponentPropertyException
public CcaComponentPropertyValue getComponentProperty(java.lang.String componentInstanceName, java.lang.String propertyName) throws CanNotCommunicateWithCcaServerException, CanNotGetComponentPropertyException
componentInstanceName
- The name of the component.propertyName
- The name of the property.
CanNotCommunicateWithCcaServerException
CanNotGetComponentPropertyException
public CcaComponentPropertyValue[] getComponentProperties(java.lang.String componentInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotGetComponentPropertyException
componentInstanceName
- The name of the component.
CanNotCommunicateWithCcaServerException
CanNotGetComponentPropertyException
public CcaCommandLaunchGoOnOneComponent launchGoOnOneComponent(java.lang.String componentInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotLaunchGoCommandOnOneComponentException
componentInstanceName
- The name of the
component that contains a GO port. The run
is launched from this port.the
- go command that the server sent back to us
CanNotCommunicateWithCcaServerException
CanNotLaunchGoCommandOnOneComponentException
public CcaCommandLaunchGoOnOneComponent launchGoOnOneComponent(java.lang.String componentInstanceName, java.lang.String portInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotLaunchGoCommandOnOneComponentException
componentInstanceName
- The name of the
component that contains a GO port. The run
is launched from this port.portInstanceName
- the name of the GO port.3
CanNotCommunicateWithCcaServerException
CanNotLaunchGoCommandOnOneComponentException
public void launchGoOnAllComponents() throws CanNotCommunicateWithCcaServerException, CanNotLaunchGoCommandOnAllComponentsException
CanNotCommunicateWithCcaServerException
CanNotLaunchGoCommandOnAllComponentsException
public CcaConnectionBetweenTwoPorts disconnectTwoPorts(java.lang.String providesServiceComponentName, java.lang.String providesServicePortName, java.lang.String usesServiceComponentName, java.lang.String usesServicePortName) throws CanNotCommunicateWithCcaServerException, CanNotDisconnectTwoPortsException
providesServiceComponentName
- The
name of the component that contains the providers port.providesServicePortName
- The name of
the providers port.usesServiceComponentName
- the name of the component
that contains the consumer port.usesServicePortName
- The name of the consumer port.
CanNotCommunicateWithCcaServerException
CanNotDisconnectTwoPortsException
public java.lang.String closeComponent(java.lang.String componentInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotCloseComponentException
componentInstanceName
- The name of the
component.
CanNotCommunicateWithCcaServerException
CanNotCloseComponentException
public java.lang.String[] getComponentClassNames() throws CanNotCommunicateWithCcaServerException
CanNotCommunicateWithCcaServerException
public CcaComponent[] getComponentInstances() throws CanNotCommunicateWithCcaServerException
CanNotCommunicateWithCcaServerException
public CcaConnectionBetweenTwoPorts[] getConnections() throws CanNotCommunicateWithCcaServerException
CanNotCommunicateWithCcaServerException
public CcaPortParameterValue setPortParameter(java.lang.String componentInstanceName, java.lang.String portInstanceName, java.lang.String fieldName, java.lang.String fieldValue) throws CanNotCommunicateWithCcaServerException, CanNotSetPortParameterException
CanNotCommunicateWithCcaServerException
CanNotSetPortParameterException
public java.lang.String getPortParameters(java.lang.String componentInstanceName, java.lang.String portInstanceName) throws CanNotCommunicateWithCcaServerException, CanNotGetPortParametersException
CanNotCommunicateWithCcaServerException
CanNotGetPortParametersException
public void closeSessionWithCcaServer()
protected void printComponent(CcaComponent component)
component
- Information about this component
will be printed on the screen.protected void printConnection(CcaConnectionBetweenTwoPorts connection)
connection
- Information about this connection
will be printed on the screen.protected void printDisconnection(CcaConnectionBetweenTwoPorts connection)
connection
- Information about this connection
will be printed on the screen.protected void resultSet(java.lang.String resultSet)
Whenever we send a query to the cca server, the cca server will send us back a result set.
resultSet
- The result set that is to be
parsed and displayed.public void addPythonControllerListener(PythonControllerListener listener)
public void removePythonControllerListener(PythonControllerListener listener)
protected void broadcastFixSharedLibrary()
protected void broadcastFixSharedLibrary(FixSharedLibraryEvent event)
protected void broadcastOpenCcaFramework()
protected void broadcastOpenCcaFramework(OpenCcaFrameworkEvent event)
protected void broadcastSetDebugFlag(boolean debug)
protected void broadcastSetDebugFlag(SetDebugFlagEvent event)
protected void broadcastSetPathToCcaComponents(java.lang.String path)
protected void broadcastSetPathToCcaComponents(SetPathToCcaComponentsEvent event)
protected void broadcastSetPathsToCcaComponents(java.lang.String[] paths)
protected void broadcastSetPathsToCcaComponents(SetPathsToCcaComponentsEvent event)
protected void broadcastLoadComponent(java.lang.String componentClassName)
protected void broadcastLoadComponent(LoadComponentEvent event)
protected void broadcastComponentClassNames(java.lang.String[] componentClassNames)
protected void broadcastComponentClassNames(ComponentClassNamesEvent event)
protected void broadcastInstantiateComponent(CcaComponent ccaComponent)
protected void broadcastInstantiateComponent(InstantiateComponentEvent event)
protected void broadcastRemoveInstantiatedComponent(java.lang.String componentInstanceName)
protected void broadcastRemoveInstantiatedComponent(RemoveInstantiatedComponentEvent event)
protected void broadcastRemoveInstantiatedComponents(CcaComponentInstanceNames componentInstanceNames)
protected void broadcastRemoveInstantiatedComponents(RemoveInstantiatedComponentsEvent event)
protected void broadcastComponentInstances(CcaComponent[] componentInstances)
protected void broadcastComponentInstances(ComponentInstancesEvent event)
protected void broadcastConnectTwoPorts(CcaConnectionBetweenTwoPorts ccaConnection)
protected void broadcastConnectTwoPorts(CcaConnectTwoPortsEvent event)
protected void broadcastCcaConnectionsBetweenTwoPorts(CcaConnectionBetweenTwoPorts[] ccaConnections)
protected void broadcastCcaConnectionsBetweenTwoPorts(CcaConnectionsBetweenTwoPortsEvent event)
protected void broadcastLaunchGoOnOneComponent(CcaCommandLaunchGoOnOneComponent commandGo)
protected void broadcastLaunchGoOnOneComponent(LaunchGoOnOneComponentEvent event)
protected void broadcastLaunchGoOnAllComponents()
protected void broadcastLaunchGoOnAllComponents(LaunchGoOnAllComponentsEvent event)
protected void broadcastDisconnectTwoPorts(CcaConnectionBetweenTwoPorts ccaConnection)
protected void broadcastDisconnectTwoPorts(CcaDisconnectTwoPortsEvent event)
protected void broadcastCloseComponent(java.lang.String componentInstanceName)
protected void broadcastCloseComponent(CloseComponentEvent event)
protected void broadcastPortParameters(java.lang.String xmlPortParameters)
protected void broadcastPortParameters(CcaPortParametersEvent event)
protected void broadcastSetPortParameter(CcaPortParameterValue ccaPortParameterValue)
protected void broadcastSetPortParameter(CcaPortParameterSetValueEvent event)
protected void broadcastSetComponentProperty(CcaComponentPropertyValue ccaComponentPropertyValue)
protected void broadcastSetComponentProperty(CcaComponentPropertySetValueEvent event)
protected void broadcastComponentProperty(CcaComponentPropertyValue ccaComponentPropertyValue)
protected void broadcastComponentProperty(CcaComponentPropertyValueEvent event)
protected void broadcastComponentProperties(CcaComponentPropertyValue[] ccaComponentPropertyValues)
protected void broadcastComponentProperties(CcaComponentPropertyValuesEvent event)
public void test(ClientSocket clientSocket)
public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |