Package xal.smf.scada

Class ScadaRecord

java.lang.Object
xal.smf.scada.ScadaRecord
All Implemented Interfaces:
Cloneable, DataListener
Direct Known Subclasses:
ParameterSet, Signal, SignalAttrs

public abstract class ScadaRecord extends Object implements DataListener, Cloneable
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
  • Constructor Details

    • ScadaRecord

      protected ScadaRecord() throws BadStructException
      Create a new ScadaStruct object. The field descriptors are taken from annotations in the source code. The structure fields in the derived class should be annotated using the AScada.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

      protected ScadaRecord(ScadaRecord clone) throws CloneNotSupportedException
      Creates a new ScadaStruct object which is a deep copy of the argument.
      Parameters:
      clone - the ScadaStruct to be cloned
      Throws:
      CloneNotSupportedException - occurs when a defining ScadaFieldDescriptor cannot be copied
      Since:
      Apr 19, 2012
    • ScadaRecord

      protected ScadaRecord(Class<? extends AScada.Record> clsRecord)
      Creates a new instance of ScadaRecord 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

      protected ScadaRecord(DataAdaptor daptInitSrc)
      Creates a new ScadaStruct 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 new ScadaStruct 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/incompatible
      ConnectionException - unable to connect to a descriptor read back channel
      GetException - unable to get PV value from channel access or
      Since:
      Jan 29, 2013
    • ScadaRecord

      protected ScadaRecord(List<ScadaFieldDescriptor> lstFldDscr)
      Create a new ScadaStruct object. Called by child classes to define their data fields and PVs (with ScadaFieldDescriptors) 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

      protected ScadaRecord(ScadaFieldDescriptor... arrFldDscr)
      Create a new ScadaStruct object. Called by child classes to define their data fields and PVs (with ScadaFieldDescriptors) 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

      public ScadaFieldDescriptor getFieldDescriptor(String strName)
      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

      public List<ScadaFieldDescriptor> 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

      public Map<String,ScadaFieldDescriptor> 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/incompatible
      ConnectionException - unable to connect to a descriptor read back channel
      GetException - 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/incompatible
      ConnectionException - unable to connect to PV channel
      PutException - general put exception (unable to set all parameter values)
      Since:
      Dec 17, 2009
    • toString

      public String toString()
      Write out a text description of the data structure field values.
      Overrides:
      toString in class Object
      Returns:
      string representation of the data structure values
      Since:
      Feb 5, 2010
      See Also:
    • update

      public void update(DataAdaptor daptSrc) throws MissingResourceException, BadStructException
      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 interface DataListener
      Parameters:
      daptSrc - The adaptor from which to update the data
      Throws:
      MissingResourceException - a data field was missing from the data source
      BadStructException - data structure fields are ill-defined/incompatible
      Since:
      Mar 3, 2010
      See Also:
    • write

      public void write(DataAdaptor daptSink) throws BadStructException
      Save the data structure field values to the given data sink behind the DataAdaptor interface. Each value is stored as the value of an attribute being the field name.
      Specified by:
      write in interface DataListener
      Parameters:
      daptSink - The adaptor to which the receiver's data is written
      Throws:
      TypeNotPresentException - Bad structure definition
      BadStructException - data structure fields are ill-defined/incompatible
      Since:
      Mar 3, 2010
      See Also:
    • clone

      protected Object clone() throws CloneNotSupportedException
      Make a deep copy of this ScadaStruct object. The field descriptors do not need to be duplicated, however, for they are immutable.
      Overrides:
      clone in class Object
      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 structure
      strHndPv - the (get) channel handle for the PV
      smfDev - the PV belongs to this device
      Throws:
      BadStructException - data structure fields are ill-defined/incompatible
      ConnectionException - unable to connect to descriptor read back channel
      GetException - 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 structure
      strHndPv - handle of the (set) PV channel
      smfDev - Hardware device containing the PV
      Throws:
      BadStructException - general field incompatibility exception
      ConnectionException - unable to connect to descriptor set value channel
      PutException - unable to set PV value
      Since:
      Dec 17, 2009