public class CanOpenProxy extends Object implements org.lsst.ccs.framework.HardwareController, org.lsst.ccs.framework.ClearAlertHandler, BridgeToHardware
| Modifier and Type | Class and Description |
|---|---|
protected static class |
FcsTcpProxy.ClientContext
A class to handle the tcpip connexion.
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
bootedDeviceNB |
protected Condition |
bootingCompleted |
protected FcsTcpProxy.ClientContext |
clientContext |
static org.lsst.ccs.utilities.logging.Logger |
COMMAND_LOG
A Logger for CommandDispenser.
|
protected int |
fieldBusTimeout |
protected Condition |
hardwareBooted |
protected boolean |
hardwareBootProcessEnded |
protected Map<String,PieceOfHardware> |
hardwareMapByName |
protected Map<Integer,PieceOfHardware> |
hardwareMapByNodeID
This map of PieceOfHardware which key is CANopen nodeID of the hardware
represents the list of pieces of hardware (CANopen devices) this
CanOpenProxy manages.
|
protected Lock |
lock |
protected String |
name |
protected int |
portNumber |
protected boolean |
stopped |
protected boolean |
stopping |
protected boolean |
tcpServerStarted |
alertSeparater| 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 |
|---|---|
boolean |
allDevicesBooted()
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.
|
void |
bootProcess()
Check if all pieces of hardware in the configuration are booted with the corect serial number.
|
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 |
checkNodeID(int nodeID)
Check that a nodeID entered by an end user at the console is a valid one:
- nodeID should be in the hardwareMapByNodeID.
|
void |
checkStarted() |
void |
connectHardware()
This method is used when the loader CANbus is connected.
|
void |
disconnectHardware()
***********************************************************************************************
******************** END OF SETTERS AND GETTERS
**********************************************
***********************************************************************************************
/**
/**
This methods stops the CWrapper client, and the TCP server.
|
String |
getMyClientName() |
String |
getNodeName(int 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() |
void |
init() |
void |
initialize()
This method initializes the fields of the tcpProxy.
|
boolean |
isCWrapperConnected()
This method returns true if the C-Wrapper is connected to the tcp proxy.
|
boolean |
isReady(String clientName) |
boolean |
isRealHardware() |
String |
listBootedNodes()
List the can open bootedNodes which are in the bootedNodes table.
|
List<String> |
listHardwareNames()
For the GUI : Return an Array containing hardware names handled by this
component.
|
void |
postStart()
check that all pieces of hardware is booted.
|
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.
|
protected void |
processCommand(String command)
Processes a command received from the tcp client.
|
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,
int nodeID,
String request)
Check a response to a readSDO command.
|
void |
processSDORequestError(String request,
String response,
int nodeID,
int 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.
|
protected void |
processUnknownCommand(String message)
Process a message received from the CAN bus when this message is an unknown message.
|
void |
publishData()
Publish Data on status bus for trending data base and GUIs.
|
PDOStorage |
readPDOs()
This method sends a sync command to the can open stack and returns the
reply.
|
int |
readSDO(int nodeID,
int index,
int subindex)
Read a SDO with the given index and subindex RETURNS the value read in
hexa (String) if no error occured or throws an Exception if an error
occured.
|
String |
readSDOCommand(int nodeID,
int index,
int subindex)
Command to be used by the end user at the console in engineering mode.
|
int |
readSDOLong(int nodeID,
int index,
int subindex) |
void |
retrieveHardwareInfo()
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.
|
protected String |
sendCanOpen(String command)
Send a command on the CANbus.
|
String |
sendCanOpenCommand(String command)
For end users, in engineering mode, this method can be used to send Can
Open commands to the Wrapper.
|
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() |
String |
writeSDO(int nodeID,
int index,
int subindex,
int size,
int value)
Command to be used by the end user at the console.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcheckHardware, checkStoppedstartServer, startThreadReaderraiseAlarm, raiseAlarm, raiseAlarm, raiseAlarm, raiseAlarm, raiseAlarm, raiseWarning, raiseWarning, raiseWarning, raiseWarning, raiseWarningprotected final Map<Integer,PieceOfHardware> hardwareMapByNodeID
@LookupField(strategy=CHILDREN) protected final Map<String,PieceOfHardware> hardwareMapByName
protected boolean hardwareBootProcessEnded
protected int bootedDeviceNB
protected final Condition bootingCompleted
public static final org.lsst.ccs.utilities.logging.Logger COMMAND_LOG
@LookupName protected String name
@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 - public String getMyClientName()
public PDOStorage getPdoStorage()
public void disconnectHardware()
disconnectHardware in interface BridgeToHardwarepublic void connectHardware()
BridgeToHardwareconnectHardware in interface BridgeToHardwarepublic void init()
init in interface org.lsst.ccs.framework.HasLifecyclepublic void initialize()
@Command(type=ACTION,
description="Check if all pieces of hardware are booted with the corect serial number.")
public void bootProcess()
bootProcess in interface BridgeToHardwarepublic void postStart()
postStart in interface org.lsst.ccs.framework.HasLifecyclepublic void checkStarted()
checkStarted in interface org.lsst.ccs.framework.HardwareControllerpublic void shutdownNow()
shutdownNow in interface org.lsst.ccs.framework.HasLifecyclepublic String getNodeName(int 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.FcsHardwareExceptionpublic void checkNodeID(int nodeID)
nodeID - protected String sendCanOpen(String command)
command - FcsHardwareException@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(int nodeID,
int index,
int subindex,
int size,
int value)
nodeID - FORMAT=hexaindex - FORMAT=HEXAsubindex - FORMAT=HEXAsize - FORMAT=decimal between 0 and 4.value - FORMAT=decimalFcsHardwareExceptionpublic int readSDO(int nodeID,
int index,
int subindex)
nodeID - index - subindex - SDORequestExceptionShortResponseToSDORequestExceptionpublic int readSDOLong(int nodeID,
int index,
int subindex)
public String processResponseToReadSDO(String response, int nodeID, String request)
response - nodeID - request - ShortResponseToSDORequestExceptionSDORequestException@Command(type=QUERY,
level=3,
description="Send a CANOpen readSDO command to the Can Bus.")
public String readSDOCommand(int nodeID,
int index,
int subindex)
nodeID - the node idindex - the indexsubindex - the sub indexFcsHardwareExceptionpublic void processSDORequestError(String request, String response, int nodeID, int errorCode, org.lsst.ccs.bus.states.AlertState alertState)
request - response - errorCode - nodeID - alertState - public PDOStorage readPDOs()
readPDOs in interface BridgeToHardwareFcsHardwareException@Command(type=QUERY,
level=0,
description="Identification of the hardware : we want to retrieve the information stored in the hardware of the CANopen devices")
public void retrieveHardwareInfo()
@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 allDevicesBooted()
allDevicesBooted in interface BridgeToHardwarepublic void processEmcyMessage(String message)
message - @Command(type=QUERY,
level=1,
description="Return a printed list of hardware expected in this subsystem.")
public String printHardwareList()
printHardwareList in interface BridgeToHardware@Command(type=QUERY,
level=1,
description="Return a printed list of hardware with the initialization state.")
public String printHardwareState()
printHardwareState in interface BridgeToHardware@Command(type=QUERY,
level=1,
description="Return an Array containing hardware names handled by this component.")
public List<String> listHardwareNames()
listHardwareNames in interface BridgeToHardwarepublic 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 BridgeToHardware@Command(type=QUERY,
level=1,
description="Return a printed format of PDOStorage.")
public String printPDOStorage()
public String toString()
public boolean isCWrapperConnected()
BridgeToHardwareisCWrapperConnected in interface BridgeToHardwarepublic boolean isRealHardware()
isRealHardware in interface BridgeToHardwarepublic void start()
start 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()
protected void processCommand(String command)
public void stopServer()
public boolean isReady(String clientName)
public Object call(String clientName, String command)
clientName - command - protected void processUnknownCommand(String message)
nodeID - Copyright © 2017 LSST. All rights reserved.