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
A class to handle the tcpip connexion.
|
org.lsst.ccs.framework.Module.ValueUpdate| Modifier and Type | Field and Description |
|---|---|
protected Condition |
bootingCompleted |
protected FcsTcpProxy.ClientContext |
clientContext |
protected int |
fieldBusTimeout |
protected Condition |
hardwareBooted |
protected ArrayList<PieceOfHardware> |
hardwareList
An array of CANopen hardware controled by this subsystem.
|
protected Lock |
lock |
protected int |
portNumber |
protected boolean |
stopped |
protected boolean |
stopping |
protected boolean |
tcpServerStarted |
| Constructor and Description |
|---|
CanOpenProxy(int portNumber,
int fieldBusTimeout,
String clientName,
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 |
checkBootedCanOpenNodes()
Check if the list of the booted CANopen devices on the CANbus is
identical to the hardware list we have in the description.
|
protected void |
checkCanOpenCommand(String command)
Tests that a CANOpen command is valid.
|
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 |
checkNodeID(String nodeID)
Check that a nodeID entered by an end user at the console is a valid one:
- nodeID should be in the hardwareMapByNodeID.
|
void |
checkNumberOfBootedNodes()
This methods checks if the number of booted nodes is correct : it has to be equal
to the number of hardware that this tcpProxy manages.
|
void |
checkStarted() |
void |
checkStopped() |
void |
connectHardware()
This method is used when the loader CANbus is connected.
|
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.
|
String |
getClientName()
For simulation ONLY.
|
String |
getMyClientName() |
String |
getNodeName(String aNodeID)
For a piece of hardware that this tcpProxy manages, this methods returns the name of the device
when the CANopen node id is given as argument.
|
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 |
initialize()
This method initializes the fields of the tcpProxy.
|
void |
initModule() |
boolean |
isBooted(String aNodeID)
Check if the String nodeID already exists in the bootedNodes table.
|
boolean |
isCANDevicesReady()
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 |
isHardwareIdentified() |
boolean |
isReady(String clientName) |
boolean |
isTcpServerStarted()
returns true if this server is started.
|
String |
listBootedNodes()
List the can open bootedNodes which are in the bootedNodes table.
|
List<String> |
listHardwareNames()
Return an Array containing hardware names handled by this component.
|
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 |
printHardwareList()
Return a String with the list of hardware expected in this subsystem.
|
String |
printHardwareState()
Return a printed list of hardware with the initialization state.
|
String |
printPDOStorage()
For tests.
|
void |
processEmcyMessage(String message)
Process an emergency message received from a CANopen device on the status bus :
- ALARM or WARNING Alert is raised,
- a message is logged,
- Observers are notified (CANopen devices are CanOpenProxy Observers).
|
String |
processResponseToReadSDO(String response,
String nodeID,
String request)
Check a response to a readSDO command.
|
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 |
publishHardwareData(String nodeID)
Publish Data on status bus for trending data base and GUIs for a CANopen device.
|
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(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 |
readSDOCommand(String nodeID,
String index,
String subindex)
Command to be used by the end user at the console in engineering mode.
|
String |
sendCanOpenCommand(String command)
For end users, in engineering mode, this method can be used to send Can Open commands
to the Wrapper.
|
void |
setCanOpenNodeNumbersOK(boolean canOpenNodeNumbersOK)
For the simulator
|
void |
setHardwareBootProcessEnded(boolean hardwareBootProcessEnded) |
void |
setHardwareIdentified(boolean hardwareIdentified)
For the simulator
|
protected void |
setHardwareList(ArrayList<PieceOfHardware> devices)
Set hardwareList and initialize hardwareMapByNodeID.
|
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)
This method sends a message info,nodeID to the CANbus and update the CANopen device
information from data received from the device.
|
String |
writeSDO(String 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.
|
getNObserverThreads, getObservables, getTickMillis, init, listens, processUpdate, sendSignal, sendSignalWithTimeLimit, setNObserverThreads, setObservables, setTickMillis, signal, startTicking, tick, updateaddObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitraiseAlarm, raiseAlarm, raiseAlarm, raiseWarning, raiseWarning, raiseWarninggetComponentConfigurationEnvironment, getComponentLookup, getName, getSubsystemchange, dropSubmittedChanges, getChildren, getComponentByName, getEnvironment, getParent, getParentObject, getSubmittedChanges, isParameterConfigurable, postStart, printConfigurableParameters, setBulkParameter, submitChange, submitChanges, validateBulkChangeprotected ArrayList<PieceOfHardware> hardwareList
protected final Condition bootingCompleted
@ConfigurationParameter(isFinal=true,
range="1024..99000",
description="tcpip port number on which this tcpip server starts on.")
protected int portNumber
@ConfigurationParameter(description="Timeout in Millisecond. If a command sent to the CANbus doesn\'t respond during this amount of time, we considere that they could be an issue on the hardware.") protected int fieldBusTimeout
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(int portNumber,
int fieldBusTimeout,
String clientName,
long hardwareBootTimeout)
portNumber - fieldBusTimeout - clientName - hardwareBootTimeout - protected void setHardwareList(ArrayList<PieceOfHardware> devices)
devices - public String getMyClientName()
public PDOStorage getPdoStorage()
public boolean isHardwareIdentified()
public void setHardwareIdentified(boolean hardwareIdentified)
hardwareIdentified - public void setCanOpenNodeNumbersOK(boolean canOpenNodeNumbersOK)
canOpenNodeNumbersOK - public void setHardwareBootProcessEnded(boolean hardwareBootProcessEnded)
public void disconnectHardware()
disconnectHardware in interface TcpProxyInterfacepublic void connectHardware()
throws org.lsst.ccs.HardwareException
TcpProxyInterfaceconnectHardware in interface TcpProxyInterfaceorg.lsst.ccs.HardwareExceptionpublic void initModule()
public void initialize()
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.ConfigurableshutdownNow in interface org.lsst.ccs.framework.HasLifecyclepublic String getNodeName(String aNodeID)
aNodeID - @Command(type=QUERY,
level=3,
description="Return true if the device, with nodeID given as argument, is booted.")
public boolean isBooted(String aNodeID)
aNodeID - @Command(type=QUERY,
level=3,
description="Print the list of CANopen nodes which are booted on the CAN bus. (values are in HEXA)")
public String listBootedNodes()
@Command(type=ACTION,
level=3,
description="Send a CanOpen command to the Can Bus.")
public String sendCanOpenCommand(String command)
command - A Can Open command that the Wrapper should understand.FcsHardwareExceptionprotected void checkCanOpenCommand(String command)
command - CANOpen command to be testedpublic void checkNodeID(String nodeID)
nodeID - public String writeSDO(String nodeID, String index, String subindex, String size, String value)
nodeID - FORMAT=HEXAindex - FORMAT=HEXAsubindex - FORMAT=HEXAsize - FORMAT=HEXAvalue - FORMAT=HEXASDORequestException@Command(type=ACTION,
level=3,
description="Send a CanOpen writeSDO command to the Can Bus. \nValues of the argument are to be given in hexadecimal format for: index and subindex\n and in decimal format for size and value.\n size represents the number of bytes on which the value is encoded. See device documentation.")
public String writeSDO(String nodeID,
String index,
String subindex,
int size,
int value)
nodeID - FORMAT=hexaindex - FORMAT=HEXAsubindex - FORMAT=HEXAsize - FORMAT=decimalvalue - FORMAT=decimalFcsHardwareExceptionpublic String readSDO(String nodeID, String index, String subindex) throws ShortResponseToSDORequestException, FcsHardwareException
nodeID - FORMAT=hexaindex - FORMAT=hexasubindex - FORMAT=hexaSDORequestExceptionShortResponseToSDORequestExceptionFcsHardwareExceptionpublic String processResponseToReadSDO(String response, String nodeID, String request) throws ShortResponseToSDORequestException, SDORequestException
response - nodeID - request - ShortResponseToSDORequestExceptionSDORequestException@Command(type=QUERY,
level=3,
description="Send a CANOpen readSDO command to the Can Bus.")
public String readSDOCommand(String nodeID,
String index,
String subindex)
nodeID - FORMAT=hexaindex - FORMAT=hexasubindex - FORMAT=hexaFcsHardwareExceptionpublic String processSDORequestError(String request, String response, String nodeID, String errorCode, org.lsst.ccs.bus.states.AlertState alertState)
request - response - errorCode - nodeID - alertState - public PDOStorage readPDOs()
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.HardwareException@Command(type=QUERY,
level=1,
description="Update device information in sending to the CANbus a CANopen command : info,nodeID")
public void updateDeviceInfo(String bootedNodeID)
throws org.lsst.ccs.HardwareException
bootedNodeID - org.lsst.ccs.HardwareException@Command(type=QUERY,
level=0,
description="Return true if all CANopen devices are booted and identified.Identified means that the serial numbers match the CANopen nodeID which reside inconfiguration.")
public boolean isCANDevicesReady()
public void processEmcyMessage(String message)
message - public void checkBootedCanOpenNodes()
throws org.lsst.ccs.HardwareException
org.lsst.ccs.HardwareException@Command(type=QUERY,
level=0,
description="Checks if the number of booted nodes is correct : it has to be equal to the number of CANopen devices that this subsystem manages.")
public void checkNumberOfBootedNodes()
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 printed list of hardware.")
public String printHardwareList()
printHardwareList in interface TcpProxyInterface@Command(type=QUERY,
level=1,
description="Return a printed list of hardware with the initialization state.")
public String printHardwareState()
printHardwareState 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 - @Command(type=QUERY,
level=1,
description="Publish booting information for all CANopen devices.")
public void publishData()
publishData in interface TcpProxyInterfacepublic void publishHardwareData(PieceOfHardware device)
device - @Command(type=QUERY,
level=1,
description="Publish booting information for a CANopen device given by its CANopen nodeID.")
public void publishHardwareData(String nodeID)
nodeID - @Command(type=QUERY,
level=1,
description="Return a printed format of PDOStorage.")
public String printPDOStorage()
public String toString()
public boolean isTcpServerStarted()
public int getPortNumber()
public String getClientName()
public void start()
start in interface org.lsst.ccs.framework.Configurablestart in interface org.lsst.ccs.framework.HasLifecycle@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)
clientName - command - Copyright © 2016 LSST. All rights reserved.