Package xal.smf.scada
Class ScadaRecord
java.lang.Object
xal.smf.scada.ScadaRecord
- All Implemented Interfaces:
Cloneable
,DataListener
- Direct Known Subclasses:
ParameterSet
,Signal
,SignalAttrs
Base class for data records containing data or parameters sets managed by
related process variables on a hardware device. Typically the structure will
consist of a set of fields on a one-to-one basis with a related set of PVs.
Ported from XAL on Jul 15, 2014.
· Jonathan M. Freed
- Since:
- Dec 16, 2009
- Author:
- Christopher K. Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Used by enumerations in data structures to indicate that they known aspects of the data fields they represent. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Create a newScadaStruct
object.protected
ScadaRecord
(Class<? extends AScada.Record> clsRecord) Creates a new instance ofScadaRecord
initializing the connections from the SCADA records in the annotated argument.protected
ScadaRecord
(List<ScadaFieldDescriptor> lstFldDscr) Create a newScadaStruct
object.protected
ScadaRecord
(AcceleratorNode smfDev) Creates a newScadaStruct
object which is initialized from the data provided by the given hardware object.protected
ScadaRecord
(ScadaFieldDescriptor... arrFldDscr) Create a newScadaStruct
object.protected
ScadaRecord
(ScadaRecord clone) Creates a newScadaStruct
object which is a deep copy of the argument.protected
ScadaRecord
(DataAdaptor daptInitSrc) Creates a newScadaStruct
object which is initialized from the data stored behind the given data source. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
clone()
Make a deep copy of thisScadaStruct
object.getFieldDescriptor
(String strName) Returns the PV field descriptor for this structure with the given name.Returns a map of (field name, ScadaFieldDescriptor) pairs for this data structure.Returns the set of PV/data field descriptors for this data structure.void
loadHardwareValues
(AcceleratorNode smfDev) Populate the fields of this data set with the current Process Variable values of the given device.protected void
setFieldFromPV
(String strFldName, String strHndPv, AcceleratorNode smfDev) Set the value of of the given data field using the value obtained from the PV attached to the given device.void
setHardwareValues
(AcceleratorNode smfDev) Sets the parameters of the given hardware device, to the values in this data structure.protected void
setPvFromField
(String strFldName, String strHndPv, AcceleratorNode smfDev) Sets the given PV with the value of the data structure field given by name.toString()
Write out a text description of the data structure field values.void
update
(DataAdaptor daptSrc) Read in the values of the data structure fields from the data source behind the data adaptor interface.void
write
(DataAdaptor daptSink) Save the data structure field values to the given data sink behind theDataAdaptor
interface.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface xal.tools.data.DataListener
dataLabel
-
Constructor Details
-
ScadaRecord
Create a newScadaStruct
object. The field descriptors are taken from annotations in the source code. The structure fields in the derived class should be annotated using theAScada.Field
annotation to be recognized and included in the list of field descriptors.- Throws:
BadStructException
- no SCADA fields (@Scada.Field) were found in data structure, CKA: I have removed this for now- Since:
- Jan 18, 2011
-
ScadaRecord
Creates a newScadaStruct
object which is a deep copy of the argument.- Parameters:
clone
- theScadaStruct
to be cloned- Throws:
CloneNotSupportedException
- occurs when a definingScadaFieldDescriptor
cannot be copied- Since:
- Apr 19, 2012
-
ScadaRecord
Creates a new instance ofScadaRecord
initializing the connections from the SCADA records in the annotated argument.- Parameters:
clsRecord
- connects the SCADA connections as annotation metadata- Since:
- Feb 5, 2013
-
ScadaRecord
Creates a newScadaStruct
object which is initialized from the data stored behind the given data source.- Parameters:
daptInitSrc
- data source containing initialization information- Since:
- Jan 29, 2013
-
ScadaRecord
protected ScadaRecord(AcceleratorNode smfDev) throws ConnectionException, GetException, BadStructException Creates a newScadaStruct
object which is initialized from the data provided by the given hardware object.- Parameters:
smfDev
- device to be queried for initialization information- Throws:
BadStructException
- data structure fields are ill-defined/incompatibleConnectionException
- unable to connect to a descriptor read back channelGetException
- unable to get PV value from channel access or- Since:
- Jan 29, 2013
-
ScadaRecord
Create a newScadaStruct
object. Called by child classes to define their data fields and PVs (withScadaFieldDescriptor
s) directly. That is, without the annotation option.- Parameters:
lstFldDscr
- list of PV field descriptors for this data set- Throws:
BadStructException
- no SCADA fields (@Scada.Field) were found in data structure- Since:
- Dec 18, 2009
-
ScadaRecord
Create a newScadaStruct
object. Called by child classes to define their data fields and PVs (withScadaFieldDescriptor
s) directly. That is, without the annotation option.- Parameters:
arrFldDscr
- set of PV field descriptors for this data set- Throws:
BadStructException
- no SCADA fields (@Scada.Field) were found in data structure- Since:
- Dec 18, 2009
-
-
Method Details
-
getFieldDescriptor
Returns the PV field descriptor for this structure with the given name. The name is typically the name of the structure field itself.- Parameters:
strName
- field name- Returns:
- PV field descriptor with given field name or
null
if not found - Since:
- Oct 4, 2011
-
getFieldDescriptors
Returns the set of PV/data field descriptors for this data structure.- Returns:
- set of descriptors describing the fields of this data structure
- Since:
- Jan 13, 2010
-
getFieldDescriptorMap
Returns a map of (field name, ScadaFieldDescriptor) pairs for this data structure.- Returns:
- map of descriptors that characterize the fields of this data structure
- Since:
- Jan 28, 2013
-
loadHardwareValues
public void loadHardwareValues(AcceleratorNode smfDev) throws BadStructException, ConnectionException, GetException Populate the fields of this data set with the current Process Variable values of the given device. We assume that this data set has the appropriate fields for the given device.- Parameters:
smfDev
- hardware device from which values are obtained- Throws:
BadStructException
- data structure fields are ill-defined/incompatibleConnectionException
- unable to connect to a descriptor read back channelGetException
- unable to get PV value from channel access or- Since:
- Dec 18, 2009
-
setHardwareValues
public void setHardwareValues(AcceleratorNode smfDev) throws BadStructException, ConnectionException, PutException Sets the parameters of the given hardware device, to the values in this data structure.- Parameters:
smfDev
- hardware device to receive new parameter values- Throws:
BadStructException
- data structure fields are ill-defined/incompatibleConnectionException
- unable to connect to PV channelPutException
- general put exception (unable to set all parameter values)- Since:
- Dec 17, 2009
-
toString
Write out a text description of the data structure field values. -
update
Read in the values of the data structure fields from the data source behind the data adaptor interface. The attributes of the data source are the field names, the values are taken from there.- Specified by:
update
in interfaceDataListener
- Parameters:
daptSrc
- The adaptor from which to update the data- Throws:
MissingResourceException
- a data field was missing from the data sourceBadStructException
- data structure fields are ill-defined/incompatible- Since:
- Mar 3, 2010
- See Also:
-
write
Save the data structure field values to the given data sink behind theDataAdaptor
interface. Each value is stored as the value of an attribute being the field name.- Specified by:
write
in interfaceDataListener
- Parameters:
daptSink
- The adaptor to which the receiver's data is written- Throws:
TypeNotPresentException
- Bad structure definitionBadStructException
- data structure fields are ill-defined/incompatible- Since:
- Mar 3, 2010
- See Also:
-
clone
Make a deep copy of thisScadaStruct
object. The field descriptors do not need to be duplicated, however, for they are immutable.- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
- Since:
- Apr 19, 2012
- See Also:
-
setFieldFromPV
protected void setFieldFromPV(String strFldName, String strHndPv, AcceleratorNode smfDev) throws BadStructException, ConnectionException, GetException Set the value of of the given data field using the value obtained from the PV attached to the given device. The type of the field is determined using Java reflection. Supported typed are all the native types plus their array forms. The value of the PV is read in as the same type of the data field. This cowboy approach should be okay since the method is meant to be used only by child classes.- Parameters:
strFldName
- the name of the data field in this structurestrHndPv
- the (get) channel handle for the PVsmfDev
- the PV belongs to this device- Throws:
BadStructException
- data structure fields are ill-defined/incompatibleConnectionException
- unable to connect to descriptor read back channelGetException
- unable to get PV value- Since:
- Nov 14, 2009
-
setPvFromField
protected void setPvFromField(String strFldName, String strHndPv, AcceleratorNode smfDev) throws BadStructException, ConnectionException, PutException Sets the given PV with the value of the data structure field given by name. Of course all this is for the SMF hardware device given in the argument. Thus, the given device must contain the given PV, and this data structure must contain the named field.
We check the type of the named data field. The PV is set using this type (not the data type specified in the
PvDescriptor
given in the arguments.- Parameters:
strFldName
- name of the data field within this data structurestrHndPv
- handle of the (set) PV channelsmfDev
- Hardware device containing the PV- Throws:
BadStructException
- general field incompatibility exceptionConnectionException
- unable to connect to descriptor set value channelPutException
- unable to set PV value- Since:
- Dec 17, 2009
-