public class CanOpenProxy extends org.lsst.ccs.framework.Module implements org.lsst.ccs.framework.HardwareController, org.lsst.ccs.framework.ClearAlertHandler, TcpProxyInterface
| Modifier and Type | Class and Description |
|---|---|
protected static class |
FcsTcpProxy.ClientContext |
org.lsst.ccs.framework.Module.ValueUpdate| Modifier and Type | Field and Description |
|---|---|
protected Condition |
bootingCompleted |
protected FcsTcpProxy.ClientContext |
clientContext |
protected Condition |
hardwareBooted |
protected PieceOfHardware[] |
hardwareList
An array of CANopen hardware controled by this subsystem.
|
protected Lock |
lock |
protected boolean |
stopped |
protected boolean |
stopping |
protected boolean |
tcpServerStarted |
| Constructor and Description |
|---|
CanOpenProxy(String aName,
int aTickMillis,
int portNumber,
String aClientName,
long hardwareBootTimeout)
Creates a CanOpenProxy with a tcpip port number to start the tcp server on,
a client name, and a hardware booting process timeout.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
call(String clientName,
String command)
This methods send a command to the tcp client.
|
org.lsst.ccs.framework.ClearAlertHandler.ClearAlertCode |
canClearAlert(org.lsst.ccs.bus.data.Alert alert)
Overridden method from ClearAlertHandler interface to define conditions when Alerts can be cleared.
|
void |
checkCanOpenNodes()
Check if the list of the booted CANopen devices on the CANbus is
identical to the hardware list we have in the description.
|
org.lsst.ccs.framework.TreeWalkerDiag |
checkHardware()
This method has to be tested on test benches.
|
void |
checkHardwareID(PieceOfHardware pieceOfHardware)
When the hardware is booted and we have retrieve the information (serial
number), we want to check for each piece of hardware that we have the
good node ID and the good serial number: so we compare the serial number
found on the CANopen bus (in Map bootedNodes) with the serial number in the configuration
file.
|
void |
checkNewHardware()
checkNewHardware is called by command checkStarted() in higher level
Modules and is executed when a command completeInitialization is sent to
the subsystem.
|
void |
checkStarted() |
void |
checkStopped() |
String |
configAsHeartbeatConsumer(int nodeID,
int producerNodeID,
int heartbeatTime)
Configure a node as a hearbeat consumer.
|
String |
configAsHeartbeatProducer(int nodeID,
int heartbeatTime)
Command to be used by the end users.
|
String |
configAsHeartbeatProducer(String nodeID,
String heartbeatTime)
Configure a node as a hearbeat producer.
|
void |
connectHardware() |
void |
disconnectHardware()
This methods stops the CWrapper client, and the TCP server.
|
CanOpenNode |
getBootedNodeBySerialNumber(String sn)
Find a node by its serial number in the list of booted bootedNodes.
|
int |
getExpectedNodesNB() |
long |
getHardwareBootTimeout() |
PieceOfHardware[] |
getHardwareList() |
String |
getMyClientName() |
String |
getNodeName(String aNodeID) |
PDOStorage |
getPdoStorage() |
int |
getPortNumber() |
void |
identifyHardware()
Identification of the hardware : we want to retrieve the information
stored in the hardware of the booted bootedNodes and update the array of
bootedNodes with this information.
|
void |
initModule() |
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 and the hardware is initialized.
|
boolean |
isReady(String clientName) |
boolean |
isTcpServerStarted() |
String |
listHardware()
Return a String with the list of hardware expected in this subsystem.
|
List<String> |
listHardwareNames()
Return an Array containing hardware names handled by this component.
|
String |
listNodes()
List the can open bootedNodes which are in the bootedNodes table.
|
String |
printBootedNodeBySerialNumber(String sn)
Returns a String representation of a CANopen node booted on the CANbus
for the device which serial number is given as a parameter.
|
String |
processSDORequestError(String request,
String response,
String nodeID,
String errorCode,
org.lsst.ccs.bus.states.AlertState alertState)
When we receive a response with an error to a SDO request, this methods retreives the errorName
in the CANOpen tables, create an error message and raise an Alert.
|
void |
publishData()
Publish Data on status bus for trending data base and GUIs.
|
void |
publishHardwareData(PieceOfHardware device)
Publish Data on status bus for trending data base and GUIs.
|
void |
readDevicesInfo(long beginTime,
long timeout)
This method is called in the checkHardware method during the initialization process.
|
PDOStorage |
readPDOs()
This method sends a sync command to the can open stack and returns the
reply.
|
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 |
sendCanOpenCommand(String command)
For end users, in engineering mode, this method can be used to send Can Open commands
to the Wrapper.
|
void |
setHardwareBootTimeout(int hardwareBootTimeout) |
void |
setHardwareBootTimeout(long hardwareBootTimeout) |
protected void |
setHardwareList(PieceOfHardware[] hardwareList) |
void |
shutdownNow()
This shutdowns the scheduler.
|
void |
start() |
void |
startServer()
Starts the server tcp on the port portNumber.
|
void |
startThreadReader()
Starts a thread which read on the tcp socket, waiting for messages coming
from tcp proxy.
|
void |
stopServer()
Stops the tcp server.
|
String |
toString() |
void |
updateDeviceInfo(String bootedNodeID,
CanOpenNode bootedNode) |
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.
|
getComponentTree, getEnvironment, getModule, getName, getNObserverThreads, getObservables, getSubsystem, getTickMillis, init, listens, postStart, processUpdate, sendSignal, sendSignalWithTimeLimit, setEnvironment, setName, setNObserverThreads, setObservables, setTickMillis, signal, startTicking, tick, updateaddObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitchange, getCheckedValueFromConfiguration, getChildren, getComponentByName, getFullPath, getParent, getParentObject, injectResources, listChildren, notifyChange, notifyChangeWithoutPreliminaryChecks, setBulkParameter, submitChange, submitChanges, validateBulkChangeprotected PieceOfHardware[] hardwareList
protected final Condition bootingCompleted
protected volatile boolean stopped
protected volatile boolean stopping
protected volatile boolean tcpServerStarted
protected FcsTcpProxy.ClientContext clientContext
protected final Lock lock
protected final Condition hardwareBooted
public CanOpenProxy(String aName, int aTickMillis, int portNumber, String aClientName, long hardwareBootTimeout)
aName - aTickMillis - portNumber - aClientName - hardwareBootTimeout - public int getExpectedNodesNB()
public long getHardwareBootTimeout()
@ConfigChanger public void setHardwareBootTimeout(long hardwareBootTimeout)
@ConfigChanger public void setHardwareBootTimeout(int hardwareBootTimeout)
public PieceOfHardware[] getHardwareList()
protected void setHardwareList(PieceOfHardware[] hardwareList)
public String getMyClientName()
public PDOStorage getPdoStorage()
public boolean isHardwareIdentified()
public void disconnectHardware()
disconnectHardware in interface TcpProxyInterfacepublic void connectHardware()
throws org.lsst.ccs.HardwareException
connectHardware in interface TcpProxyInterfaceorg.lsst.ccs.HardwareExceptionpublic void initModule()
public org.lsst.ccs.framework.TreeWalkerDiag checkHardware()
throws org.lsst.ccs.HardwareException
checkHardware in interface org.lsst.ccs.framework.HardwareControllerorg.lsst.ccs.HardwareExceptionpublic void readDevicesInfo(long beginTime,
long timeout)
beginTime - timeout - @Command(type=QUERY,
level=0,
description="Retrieve information for booted devices and checks if CANopen node ID and serial number match thosein description file .")
public void checkNewHardware()
throws org.lsst.ccs.HardwareException
checkNewHardware in interface TcpProxyInterfaceorg.lsst.ccs.HardwareExceptionpublic void checkStarted()
throws org.lsst.ccs.HardwareException
checkStarted in interface org.lsst.ccs.framework.HardwareControllerorg.lsst.ccs.HardwareExceptionpublic void checkStopped()
throws org.lsst.ccs.HardwareException
checkStopped in interface org.lsst.ccs.framework.HardwareControllerorg.lsst.ccs.HardwareExceptionpublic void shutdownNow()
shutdownNow in interface org.lsst.ccs.framework.Configurable@Command(type=QUERY,
level=3,
description="Print the list of CANopen nodes which are booted on the CAN bus.")
public String listNodes()
@Command(type=ACTION,
level=3,
description="Send a CanOpen command to the Can Bus.")
public String sendCanOpenCommand(String command)
throws FcsHardwareException
command - A Can Open command that the Wrapper should understand.FcsHardwareExceptionpublic String writeSDO(String nodeID, String index, String subindex, String size, String value) throws FcsHardwareException
nodeID - FORMAT=HEXAindex - FORMAT=HEXAsubindex - FORMAT=HEXAsize - FORMAT=HEXAvalue - FORMAT=HEXASDORequestExceptionFcsHardwareException@Command(type=ACTION,
level=3,
description="Send a CanOpen writeSDO command to the Can Bus.")
public String writeSDO(int nodeID,
String index,
String subindex,
int size,
int value)
throws FcsHardwareException
nodeID - FORMAT=decimalindex - FORMAT=HEXAsubindex - FORMAT=HEXAsize - FORMAT=decimalvalue - FORMAT=decimalFcsHardwareExceptionpublic String readSDO(String nodeID, String index, String subindex) throws ShortResponseToSDORequestException, FcsHardwareException
nodeID - index - subindex - SDORequestExceptionShortResponseToSDORequestExceptionFcsHardwareExceptionpublic String processSDORequestError(String request, String response, String nodeID, String errorCode, org.lsst.ccs.bus.states.AlertState alertState)
request - response - errorCode - nodeID - alertState - @Command(type=ACTION,
level=3,
description="Send a CanOpen readSDO command to the Can Bus.")
public String readSDO(int nodeID,
String index,
String subindex)
throws SDORequestException,
org.lsst.ccs.messaging.BadCommandException,
ShortResponseToSDORequestException,
FcsHardwareException
nodeID - FORMAT=decimalindex - FORMAT=hexasubindex - FORMAT=hexaSDORequestExceptionorg.lsst.ccs.messaging.BadCommandExceptionShortResponseToSDORequestExceptionFcsHardwareExceptionpublic PDOStorage readPDOs() throws FcsHardwareException
FcsHardwareException@Command(type=QUERY,
level=0,
description="Identification of the hardware : we want to retrieve the information \n * stored in the hardware of the booted nodes and update the array of nodes\n * with this information.")
public void identifyHardware()
throws org.lsst.ccs.HardwareException
org.lsst.ccs.HardwareExceptionpublic void updateDeviceInfo(String bootedNodeID, CanOpenNode bootedNode) throws org.lsst.ccs.HardwareException
bootedNodeID - bootedNode - org.lsst.ccs.HardwareException@Command(type=QUERY,
level=0,
description="Return true if all hardware is booted and identified.")
public boolean isHardwareReady()
public void checkCanOpenNodes()
throws org.lsst.ccs.HardwareException
org.lsst.ccs.HardwareExceptionpublic void checkHardwareID(PieceOfHardware pieceOfHardware) throws org.lsst.ccs.HardwareException
pieceOfHardware - org.lsst.ccs.HardwareExceptionpublic CanOpenNode getBootedNodeBySerialNumber(String sn)
sn - @Command(type=QUERY,
level=0,
description="Returns a String representation of a CANopen node booted on the CANbus for the device which serial number is given as a parameter.")
public String printBootedNodeBySerialNumber(String sn)
sn - @Command(type=QUERY,
level=1,
description="Return a String with the list of hardware.")
public String listHardware()
listHardware in interface TcpProxyInterface@Command(type=QUERY,
level=1,
description="Return an Array containing hardware names handled by this component.")
public List<String> listHardwareNames()
listHardwareNames in interface TcpProxyInterfacepublic org.lsst.ccs.framework.ClearAlertHandler.ClearAlertCode canClearAlert(org.lsst.ccs.bus.data.Alert alert)
canClearAlert in interface org.lsst.ccs.framework.ClearAlertHandleralert - public String configAsHeartbeatProducer(String nodeID, String heartbeatTime) throws TimeoutException, org.lsst.ccs.messaging.BadCommandException, FcsHardwareException
nodeID - node ID in hexaheartbeatTime - FORMAT=hexa UNIT=millisecondsSDORequestExceptionTimeoutExceptionorg.lsst.ccs.messaging.BadCommandExceptionFcsHardwareExceptionpublic String configAsHeartbeatProducer(int nodeID, int heartbeatTime) throws TimeoutException, org.lsst.ccs.messaging.BadCommandException, FcsHardwareException
nodeID - FORMAT=decimalheartbeatTime - FORMAT=decimal UNIT=millisecondsSDORequestExceptionTimeoutExceptionorg.lsst.ccs.messaging.BadCommandExceptionFcsHardwareExceptionpublic String configAsHeartbeatConsumer(int nodeID, int producerNodeID, int heartbeatTime) throws TimeoutException, org.lsst.ccs.messaging.BadCommandException, FcsHardwareException
nodeID - node ID in decimalproducerNodeID - heartbeatTime - FORMAT=decimal UNIT=millisecondsSDORequestExceptionTimeoutExceptionorg.lsst.ccs.messaging.BadCommandExceptionFcsHardwareExceptionpublic void publishData()
publishData in interface TcpProxyInterfacepublic void publishHardwareData(PieceOfHardware device)
device - public String toString()
public boolean isTcpServerStarted()
public int getPortNumber()
public void start()
@Command(type=ACTION,
level=1,
description="Starts the tcp server.")
public void startServer()
@Command(type=ACTION,
level=1,
description="Starts to listen to the tcp client.")
public void startThreadReader()
public void stopServer()
public boolean isReady(String clientName)
public Object call(String clientName, String command) throws CWrapperNotConnected, CanOpenCallTimeoutException
clientName - command - CWrapperNotConnectedCanOpenCallTimeoutExceptionCopyright © 2016 LSST. All rights reserved.