org.lsst.ccs.subsystems.fcs.testbench
Class APCTestBenchMainModule

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

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

This is the main module for the control software of the APC test bench. When the TestBenchMainModule starts, it starts a a TCP-IP server. the can open wrapper software will connect. Then the TestBenchProxy and the Wrapper will communicate over this TCP connection with a protocol to be define. In a first version : 1- The TCP server is started and waits for a client connection, 2- When the client connects, it sends first a key word "TestBench". 3- When the server receives the key word "TestBench", it's ready to boot the hardware and receive commands.

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
 
Nested classes/interfaces inherited from interface org.lsst.ccs.framework.Configurable
org.lsst.ccs.framework.Configurable.Environment
 
Field Summary
 
Fields inherited from class org.lsst.ccs.framework.Module
environment, log, name, nObserverThreads, registry, tickMillis
 
Constructor Summary
APCTestBenchMainModule()
           
 
Method Summary
 CanOpenADC getAdc()
           
 CanOpenDAC getDac()
           
 String getMyClientName()
           
 int getNodeNB()
           
 int getReturnValue(String responseLine, int inputNB)
          Returns the value read on the socket for the input of the ADC given as an argument.
 CanOpenProxy getTcpProxy()
           
 void initModule()
           
 boolean isHardwareConnected()
          This method returns true if the C-Wrapper is connected to the tcp proxy.
 boolean isHardwareReady()
          returns true if the hardware is booted, identified and initialized.
 String readADC()
          Read the value of the first channel of the ADC.
 double readTemperature()
          Read the temperature : in the test bench, a thermometer is plugged on the input number 1 of the ADC.
 Object sendCanOpen(String command)
          For engineering mode, this method can be used to send Can Open commands to the Wrapper.
 void setAdc(CanOpenADC adc)
           
 void setDac(CanOpenDAC dac)
           
 void setTcpProxy(CanOpenProxy myTcpProxy)
           
 void shutdown()
           
 void turnOffLED()
           
 void turnOnLED()
           
 
Methods inherited from class org.lsst.ccs.framework.Module
change, checkHardware, dropConfigurationContext, getCheckedValueFromConfiguration, getChildren, getContext, getModule, getName, getNObserverThreads, getObservables, getSubsystem, getTickMillis, init, listens, newConfigurationContext, notifyChange, notifyChangeWithoutPreliminaryChecks, processUpdate, publishData, publishData, publishData, publishData, register, register, sendToReply, sendToStatus, setBeanName, setContext, setEnvironment, setName, setNObserverThreads, setObservables, setStateModularSubsystem, setStateModularSubsystem, setTickMillis, shutdownCommand, shutdownNow, start, startTicking, tick, 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
 

Constructor Detail

APCTestBenchMainModule

public APCTestBenchMainModule()
Method Detail

getTcpProxy

public CanOpenProxy getTcpProxy()
Returns:
the myTcpProxy

setTcpProxy

public void setTcpProxy(CanOpenProxy myTcpProxy)
Parameters:
myTcpProxy - the myTcpProxy to set

getNodeNB

public int getNodeNB()
Returns:
the nodeNB

getMyClientName

public String getMyClientName()
Returns:
the myClientName

isHardwareConnected

public boolean isHardwareConnected()
This method returns true if the C-Wrapper is connected to the tcp proxy. The C-Wrapper has to send the tcpProxy clientName as a keyword before any communication can begin. So if the C-Wrapper doesn't send the good keyword or if it doesn't connect to the tcp proxy, this method returns false.


getAdc

public CanOpenADC getAdc()
Returns:
the adc

setAdc

public void setAdc(CanOpenADC adc)
Parameters:
adc - the adc to set

getDac

public CanOpenDAC getDac()
Returns:
the dac

setDac

public void setDac(CanOpenDAC dac)
Parameters:
dac - the dac to set

isHardwareReady

public boolean isHardwareReady()
returns true if the hardware is booted, identified and initialized.


initModule

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

shutdown

public void shutdown()

sendCanOpen

public Object sendCanOpen(String command)
                   throws InterruptedException,
                          TimeoutException
For engineering mode, this method can be used to send Can Open commands to the Wrapper.

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

getReturnValue

public int getReturnValue(String responseLine,
                          int inputNB)
                   throws ReadingADCError
Returns the value read on the socket for the input of the ADC given as an argument.

Parameters:
responseLine - A string read on the socket.
inputNB - The numero if the input on the ADC. (1<=inputNB<=8)
Returns:
the value (int) given
Throws:
ReadingADCError

readTemperature

public double readTemperature()
                       throws SDORequestError,
                              HardwareNotDetectedException
Read the temperature : in the test bench, a thermometer is plugged on the input number 1 of the ADC.

Returns:
Throws:
ReadingADCError
SDORequestError
HardwareNotDetectedException

readADC

public String readADC()
               throws SDORequestError,
                      TimeoutException
Read the value of the first channel of the ADC. It just send the command rsdo,NODEid,6401,01 to the Can Open Wrapper

Returns:
Throws:
ReadingADCError
SDORequestError
TimeoutException

turnOnLED

public void turnOnLED()
               throws InterruptedException,
                      SDORequestError,
                      HardwareNotDetectedException
Throws:
InterruptedException
SDORequestError
HardwareNotDetectedException

turnOffLED

public void turnOffLED()
                throws InterruptedException,
                       SDORequestError
Throws:
InterruptedException
SDORequestError


Copyright © 2013 LSST. All Rights Reserved.