
public abstract class Device extends Object implements HardwareController, HasLifecycle, UsesSubsystem
| Modifier and Type | Field and Description |
|---|---|
protected BitSet |
chanMask |
protected Map<String,Control> |
ctlChans |
protected boolean |
disabled |
protected String |
fullName
Data fields.
|
protected boolean |
inited |
protected int |
lineMask |
protected int |
lineState |
protected int |
lineWarm |
protected Logger |
log |
protected Monitor |
mon |
protected String |
name |
protected boolean |
online |
protected Subsystem |
s |
| Constructor and Description |
|---|
Device() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addChannel(int id)
Adds a channel to the device's list of monitored channels.
|
protected void |
addLine(int line)
Adds an output line to the known list.
|
protected int[] |
checkChannel(String name,
int hwChan,
String type,
String subtype)
Checks a monitor channel's parameters for validity.
|
TreeWalkerDiag |
checkHardware()
Override to initiate interaction with the hardware.
|
protected void |
checkHwLine(String name,
int line)
Checks the validity of an output line.
|
protected void |
checkLine(String name,
int line)
Checks the validity of an output line.
|
void |
checkOnline()
Checks the online state.
|
void |
checkStarted()
Override to check that all hardware is correctly initiated.
|
void |
checkStopped()
Override with specific code to stop the hardware.
|
protected void |
checkTimeout(Exception e,
Class<?> eClass)
Checks whether exception is a timeout.
|
protected abstract void |
close()
Closes the connection.
|
protected void |
configure(Monitor mon)
Performs common configuration.
|
void |
disable()
Disables the device.
|
protected void |
dropChannel(int id)
Drops a channel from the device's list of monitored channels.
|
void |
enable()
Enables the device.
|
String |
getFullName()
Gets the full name.
|
protected void |
getOutputLines()
Gets the states of all output lines and saves them.
|
void |
init()
Called from the enclosing
Subsystem at construction
phase. |
protected void |
initChannel(int hwChan,
int type,
int subtype)
Initializes a monitor channel.
|
protected void |
initChannel(String name,
int id,
int hwChan,
int type,
int subtype)
Initializes a monitor channel.
|
protected void |
initDevice()
Performs internal device initialization.
|
protected abstract void |
initialize()
Performs hardware initialization.
|
protected void |
initSensors()
Initializes all attached sensors.
|
protected boolean |
isHwLineSet(int line)
Gets an output line set state.
|
protected boolean |
isLineSet(int line)
Gets an output line set state.
|
boolean |
isOnline()
Gets the online state.
|
protected boolean |
isTimeout(Exception e)
Tests whether exception is a timeout.
|
protected double |
readChannel(int hwChan,
int type)
Reads a monitor channel.
|
protected void |
readChannelGroup()
Reads the monitor channel group.
|
protected double |
readChannelNow(int hwChan,
int type)
Reads a monitor channel immediately.
|
protected void |
readSensors()
Reads all attached sensors (monitor channels).
|
protected void |
setHwLine(int line,
boolean on)
Sets an output line on or off.
|
protected void |
setLine(int line,
boolean on)
Sets an output line on or off.
|
protected void |
setLineWarm(int line,
boolean on)
Sets the warm-start state of an output line.
|
protected void |
setOnline(boolean online)
Sets the online state.
|
protected void |
setOutputLines()
Sets all output lines from the saved state.
|
protected boolean |
testOnline()
Tests the online state.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpostInit, postShutdown, postStart, shutdownNow, startgetComponentConfigurationEnvironment, getComponentLookup, getName, getSubsystemprotected String fullName
protected BitSet chanMask
protected boolean disabled
protected boolean inited
protected boolean online
@LookupField(strategy=TREE) protected Monitor mon
protected Logger log
protected int lineMask
protected int lineWarm
protected int lineState
@LookupField(strategy=TOP) protected Subsystem s
@LookupName protected String name
public void init()
HasLifecycleSubsystem at construction
phase. This method is called before the children components of this
object have their init method called.
At the time it is called, connection to the messaging layer is not yet
done, so there should be no attempt to send messages in the body of
this method. Configuration for message listening can nevertheless be
done here, such as adding MessageListener
objects.
It is unnecessary to call super.init()
init in interface HasLifecycleprotected void initDevice()
public String getFullName()
public boolean isOnline()
public void disable()
public void enable()
protected void configure(Monitor mon)
mon - The associated monitorprotected int[] checkChannel(String name, int hwChan, String type, String subtype) throws Exception
name - The name of the channel.hwChan - The hardware channel number.type - The channel type string.subtype - The channel subtype string.Exception - if any errors found in the parametersprotected abstract void initialize()
protected abstract void close()
protected void initSensors()
protected void initChannel(int hwChan,
int type,
int subtype)
hwChan - The hardware channel number.type - The encoded channel type returned by checkChannel.subtype - The channel subtype returned by checkChannel.protected void initChannel(String name, int id, int hwChan, int type, int subtype)
name - The channel nameid - The channel IDhwChan - The hardware channel number.type - The encoded channel type returned by checkChannel.subtype - The channel subtype returned by checkChannel.protected void addChannel(int id)
id - The id of the channel.protected void dropChannel(int id)
id - The id of the channel.public void checkOnline()
protected boolean testOnline()
protected void setOnline(boolean online)
online - The online state to set: true or falseprotected void readSensors()
protected void readChannelGroup()
protected double readChannel(int hwChan,
int type)
hwChan - The hardware channel number.type - The encoded channel type returned by checkChannel.protected double readChannelNow(int hwChan,
int type)
hwChan - The hardware channel number.type - The encoded channel type returned by checkChannel.protected void checkTimeout(Exception e, Class<?> eClass) throws Exception
e - The exception to be checked.eClass - The class of the exception to be thrown.Exceptionprotected boolean isTimeout(Exception e)
e - The exception to be tested.protected void checkLine(String name, int line) throws Exception
name - The name of the output line.line - The hardware line number of the output line.Exception - if the line number is invalid.protected void checkHwLine(String name, int line) throws Exception
name - The name of the output line.line - The hardware line number of the output line.Exception - if the line number is invalid.protected void setLineWarm(int line,
boolean on)
line - The output line number.on - The warm-start on state to set: true or falseprotected void setLine(int line,
boolean on)
line - The output line number.on - The on state to set: true or falseprotected void setHwLine(int line,
boolean on)
line - The output line number.on - The on state to set: true or falseprotected boolean isLineSet(int line)
line - The output line number.protected boolean isHwLineSet(int line)
line - The output line number.protected void setOutputLines()
protected void getOutputLines()
protected void addLine(int line)
line - The output line number.public TreeWalkerDiag checkHardware() throws HardwareException
HardwareControllerPhaseState.INITIALIZING state.
If accessing the hardware is considered as having failed, this method
should throw an HardwareException. This will
interrupt the startup process and make the subsystem go to
OperationalState.ENGINEERING_FAULT. The startup process will be
resumed with a call to
Subsystem.completeInitialization() that will invoke
HardwareController.checkStarted()
If this method is considered having succeeded, the state remains to
OperationalState.ENGINEERING_OK
checkHardware in interface HardwareControllerTreeWalkerDiag indicating if
this component has already performed hardware checking for its own
components (HANDLING_CHILDREN) or if the framework should do it
(GO)HardwareException - if any failure interacting with the hardware
occurs. The exception is caught by the framework.public void checkStarted()
throws HardwareException
HardwareControllerSubsystem.completeInitialization()
If a failure in the way the hardware has been started is noticed, the
implementation should throw an HardwareException.
This will interrupt the startup process and make the subsystem remain in
OperationalState.ENGINEERING_FAULT. The startup process will be
resumed with a subsequent call to
Subsystem.completeInitialization()
checkStarted in interface HardwareControllerHardwareException - if a failure is noticed in the way
hardware is started.public void checkStopped()
throws HardwareException
HardwareControllerAgent.shutdown() or
Subsystem.stop(long). At the time it is called, the
enclosing subsystem is in PhaseState.CLOSING phase
If a failure in stopping hardware is noticed, the implementation should
throw an HardwareException. This will interrupt the
shutdown process
If no HardwareException is thrown, the shutdown process will
resume.
checkStopped in interface HardwareControllerHardwareException - if a failure occurs while stopping
the hardware.Copyright © 2017 LSST. All rights reserved.