org.lsst.ccs.subsystems.fcs.drivers
Class CanOpenProxy

java.lang.Object
  extended by java.util.Observable
      extended by org.lsst.ccs.framework.Module
          extended by org.lsst.ccs.subsystems.fcs.drivers.CanOpenProxy
All Implemented Interfaces:
Serializable, Observer

public class CanOpenProxy
extends org.lsst.ccs.framework.Module

This Module starts a tcpip server, waits for the connection of a client whose name is the value of the field myClientName. This client is supposed to be a CanOpen C-wrapper. When the client starts it scans the can open network and send to the server some information on the can open nodes living on the network.

Author:
virieux
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.lsst.ccs.framework.Module
org.lsst.ccs.framework.Module.ValueUpdate
 
Field Summary
 PieceOfHardware[] hardwareList
           
 
Fields inherited from class org.lsst.ccs.framework.Module
configMethods, log, name, nObserverThreads, registry, tickMillis
 
Constructor Summary
CanOpenProxy()
           
 
Method Summary
 Object call(String clientName, String command)
          This methods send a command to the tcp client.
 boolean checkCanOpenNodeConfiguration(PieceOfHardware pieceOfHardware)
          When the hardware is booted and we have retrieve the information, we want to check for each piece of hardware that the node ID stored in the Configuration data base is the same than the node ID which is stored on the hardware with a switch.
 boolean checkCanOpenNodes()
           
 String configAsHeartbeatConsumer(int nodeID, int producerNodeID, int heartbeat_time)
          Configure a node as a hearbeat consumer.
 String configAsHeartbeatProducer(int nodeID, int heartbeat_time)
          Command to be used by the end users.
 String configAsHeartbeatProducer(String nodeID, String heartbeat_time)
          Configure a node as a hearbeat producer.
 int getBootedNodesNB()
           
 CanOpenNode getDetectedNodeForSerialNumber(String aSerialNB)
          This method returns the can open detected on the can open network for a piece of hardware identified by its serial number.
 int getExpectedNodesNB()
           
 String getMyClientName()
           
 int getPortNumber()
           
 void identifieHardware()
          Identification of the hardware : we want to retrieve the information stored in the hardware of the booted nodes and update the array of nodes with this information.
 void initializeHardware()
           
 void initModule()
           
 boolean isBooted(PieceOfHardware piece)
           
 boolean isBooted(String aNodeID)
           
 boolean isConfigOK(PieceOfHardware piece)
          Check if a piece of hardware is booted and if its can open node ID is correct.
 boolean isHardwareIdentified()
           
 boolean isHardwareReady()
          This method returns true if : all the hardware items are booted and identified and the hardware have the node ID expected within the configuration.
 boolean isReady(String clientName)
           
 String listHardware()
           
 String listNodes()
          List the can open nodes which are in the nodes table.
 String readSDO(int nodeID, String index, String subindex)
          Command to be used by the end user at the console in engineering mode.
 String readSDO(String nodeID, String index, String subindex)
          Read a SDO with the given index and subindex RETURNS the value read in hexa (String) if no error occured or returns the error code if a error was detected.
 String sendCanOpen(String command)
          For engineering mode, this method can be used to send Can Open commands to the Wrapper.
 void setExpectedNodesNB(int nodeNB)
           
 void setMyClientName(String myClientName)
           
 void setPortNumber(int portNumber)
           
protected  void startTheadReader()
          Starts a thread which read on the tcp socket, waiting for messages coming from tcp proxy.
 void stop()
           
 void tick()
           
 String writeSDO(int nodeID, String index, String subindex, int size, int value)
          Command to be used by the end user at the console.
 String writeSDO(String nodeID, String index, String subindex, String size, String value)
          Write a SDO request and send it to the can open stack, then analyses the response or throws an exception if the request failed.
 
Methods inherited from class org.lsst.ccs.framework.Module
change, checkHardware, dropConfigurationContext, getCheckedValueFromConfiguration, getContext, getModule, getName, getNObserverThreads, getObservables, getSubsystem, getTickMillis, init, listens, newConfigurationContext, notifyChange, notifyChangeWithoutPreliminaryChecks, processUpdate, publishData, publishData, publishData, publishData, register, register, sendToReply, sendToStatus, setBeanName, setContext, setName, setNObserverThreads, setObservables, setStateModularSubsystem, setStateModularSubsystem, setTickMillis, shutdownCommand, shutdownNow, start, startTicking, update
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

hardwareList

public PieceOfHardware[] hardwareList
Constructor Detail

CanOpenProxy

public CanOpenProxy()
Method Detail

getExpectedNodesNB

public int getExpectedNodesNB()
Returns:
the expectedNodesNB

setExpectedNodesNB

public void setExpectedNodesNB(int nodeNB)
Parameters:
expectedNodesNB - the expectedNodesNB to set

getBootedNodesNB

public int getBootedNodesNB()
Returns:
the bootedNodesNB

getMyClientName

public String getMyClientName()
Returns:
the myClientName

setMyClientName

public void setMyClientName(String myClientName)
Parameters:
myClientName - the myClientName to set

initModule

public void initModule()

isHardwareIdentified

public boolean isHardwareIdentified()

tick

public void tick()
Overrides:
tick in class org.lsst.ccs.framework.Module

isBooted

public boolean isBooted(String aNodeID)

isBooted

public boolean isBooted(PieceOfHardware piece)

isConfigOK

public boolean isConfigOK(PieceOfHardware piece)
Check if a piece of hardware is booted and if its can open node ID is correct.


listNodes

public String listNodes()
List the can open nodes which are in the nodes table.

Returns:
the list of can open nodes and the information stored in this.nodes.

sendCanOpen

public String sendCanOpen(String command)
                   throws TimeoutException
For engineering mode, this method can be used to send Can Open commands to the Wrapper. Test if the command is valid before sending it to the can open stack.

Parameters:
command - A Can Open command that the Wrapper should understand.
Returns:
the response from the Wrapper
Throws:
TimeoutException

writeSDO

public String writeSDO(String nodeID,
                       String index,
                       String subindex,
                       String size,
                       String value)
                throws SDORequestError
Write a SDO request and send it to the can open stack, then analyses the response or throws an exception if the request failed. The parameters are given in HEXA.

Parameters:
nodeID - FORMAT=HEXA
index - FORMAT=HEXA
subindex - FORMAT=HEXA
size - FORMAT=HEXA
value - FORMAT=HEXA
Returns:
"writeSDO request OK" if OK
Throws:
SDORequestError

writeSDO

public String writeSDO(int nodeID,
                       String index,
                       String subindex,
                       int size,
                       int value)
                throws SDORequestError
Command to be used by the end user at the console. Write a SDO message and send it to the can open stack. The parameters are given in the following format:

Parameters:
nodeID - FORMAT=decimal
index - FORMAT=HEXA
subindex - FORMAT=HEXA
size - FORMAT=decimal
value - FORMAT=decimal
Returns:
Throws:
SDORequestError

readSDO

public String readSDO(String nodeID,
                      String index,
                      String subindex)
               throws SDORequestError
Read a SDO with the given index and subindex RETURNS the value read in hexa (String) if no error occured or returns the error code if a error was detected.

Throws:
SDORequestError

readSDO

public String readSDO(int nodeID,
                      String index,
                      String subindex)
               throws SDORequestError
Command to be used by the end user at the console in engineering mode.

Parameters:
nodeID - FORMAT=decimal
index - FORMAT=hexa
subindex - FORMAT=hexa
Returns:
the value sent by the can open stack if the read SDO request succeded.
Throws:
SDORequestError

identifieHardware

public void identifieHardware()
                       throws TimeoutException
Identification of the hardware : we want to retrieve the information stored in the hardware of the booted nodes and update the array of nodes with this information. The Can Open node ID is a main information to retrieve.

Throws:
TimeoutException

isHardwareReady

public boolean isHardwareReady()
This method returns true if : all the hardware items are booted and identified and the hardware have the node ID expected within the configuration.


getDetectedNodeForSerialNumber

public CanOpenNode getDetectedNodeForSerialNumber(String aSerialNB)
This method returns the can open detected on the can open network for a piece of hardware identified by its serial number. It can return NULL if the Serial Number is not on the can open network.

Parameters:
serialNB -
Returns:

checkCanOpenNodes

public boolean checkCanOpenNodes()
                          throws org.lsst.ccs.bus.BadCommandException,
                                 ErrorInBootingHardwareProcess,
                                 ConfigNodeIDMismatchException,
                                 HardwareNotDetectedException
Throws:
org.lsst.ccs.bus.BadCommandException
ErrorInBootingHardwareProcess
ConfigNodeIDMismatchException
HardwareNotDetectedException

checkCanOpenNodeConfiguration

public boolean checkCanOpenNodeConfiguration(PieceOfHardware pieceOfHardware)
                                      throws org.lsst.ccs.bus.BadCommandException,
                                             ConfigNodeIDMismatchException,
                                             HardwareNotDetectedException
When the hardware is booted and we have retrieve the information, we want to check for each piece of hardware that the node ID stored in the Configuration data base is the same than the node ID which is stored on the hardware with a switch.

Returns:
Throws:
org.lsst.ccs.bus.BadCommandException
ConfigNodeIDMismatchException
HardwareNotDetectedException

listHardware

public String listHardware()

initializeHardware

public void initializeHardware()

configAsHeartbeatProducer

public String configAsHeartbeatProducer(String nodeID,
                                        String heartbeat_time)
                                 throws SDORequestError,
                                        TimeoutException
Configure a node as a hearbeat producer. Every heartbeat_time milliseconds this node will produce a message like: 0x700+nodeID: 05 - 1340268404.980000

Parameters:
nodeID - node ID in hexa
heartbeat_time - FORMAT=hexa UNIT=milliseconds
Throws:
SDORequestError
TimeoutException

configAsHeartbeatProducer

public String configAsHeartbeatProducer(int nodeID,
                                        int heartbeat_time)
                                 throws SDORequestError,
                                        TimeoutException
Command to be used by the end users. Configure a node as a heartbeat producer. Parameters given in decimal format.

Parameters:
nodeID - FORMAT=decimal
heartbeat_time - FORMAT=decimal UNIT=milliseconds
Throws:
SDORequestError
TimeoutException

configAsHeartbeatConsumer

public String configAsHeartbeatConsumer(int nodeID,
                                        int producerNodeID,
                                        int heartbeat_time)
                                 throws SDORequestError,
                                        TimeoutException
Configure a node as a hearbeat consumer. Every heartbeat_time milliseconds this node will produce a message like: 0x700+nodeID: 05 - 1340268404.980000

Parameters:
nodeID - node ID in decimal
heartbeat_time - FORMAT=decimal UNIT=milliseconds
Throws:
SDORequestError
TimeoutException

getPortNumber

public int getPortNumber()

setPortNumber

public void setPortNumber(int portNumber)

startTheadReader

protected void startTheadReader()
Starts a thread which read on the tcp socket, waiting for messages coming from tcp proxy. If the message has a known token (already registred in commandDispenser) it is a response to a can open command that we had sent to the proxy. If the token of the message is null, that means that is's an unsynchronous message coming from the can open stack and transmitted directly from the tcp proxy. That can be : - a boot message : "boot,nodeID" - an emergency message : "sync,80+NodeID"


stop

public void stop()

isReady

public boolean isReady(String clientName)

call

public Object call(String clientName,
                   String command)
            throws TimeoutException
This methods send a command to the tcp client. The command is a String and can be understood by the client. Example for a Can Open command : rsdo,1,1018,0 The command is stored in the command dispenser with a token and command corelation. When the response comes back from the proxy we can retrieve it from the dispenser with the call token.

Parameters:
clientName -
command -
Returns:
result of the call or null if the call failed
Throws:
TimeoutException


Copyright © 2012 LSST. All Rights Reserved.