diff --git a/StatsCrosslet-DS/StatsCrosslet.py b/StatsCrosslet-DS/StatsCrosslet.py index 92805d9e9924887ca2dcb7e704573e1bef9721fe..8c8998751a6102a9048585b0ccb5c9b8db0dc6ab 100644 --- a/StatsCrosslet-DS/StatsCrosslet.py +++ b/StatsCrosslet-DS/StatsCrosslet.py @@ -93,7 +93,7 @@ class StatsCrosslet(Device): OPC_Server_Name = device_property( dtype='DevString', - default_value="okeanos" + default_value="okeanos-kabel" ) OPC_Server_Port = device_property( @@ -125,35 +125,35 @@ class StatsCrosslet(Device): # Attributes # ---------- - subband = attribute( + Subband = attribute( dtype='DevUShort', access=AttrWriteType.READ_WRITE, ) - integration_time = attribute( + Integration_time = attribute( dtype='DevDouble', ) - time_stamp = attribute( + Time_stamp = attribute( dtype='DevString', ) - pause_time = attribute( + Pause_time = attribute( dtype='DevDouble', access=AttrWriteType.READ_WRITE, ) - rcu_modes = attribute( + RCU_modes = attribute( dtype=('DevString',), max_dim_x=96, ) - visibilities_imag = attribute( + Visibilities_imag = attribute( dtype=(('DevDouble',),), max_dim_x=96, max_dim_y=96, ) - visibilities_real = attribute( + Visibilities_real = attribute( dtype=(('DevDouble',),), max_dim_x=96, max_dim_y=96, ) @@ -166,6 +166,18 @@ class StatsCrosslet(Device): """Initialises the attributes and properties of the StatsCrosslet.""" Device.init_device(self) # PROTECTED REGION ID(StatsCrosslet.init_device) ENABLED START # + self.set_state(DevState.INIT) + # Set default values in the read/write attributes. + self._time_stamp = '' + self._rcu_modes = ('',) + self._visibilities_imag = ((0.0,),) + self._visibilities_real = ((0.0,),) + + # Set defaults to property values. + self._subband = self.Default_subband + self._integration_time = self.Default_integration_time + self._pause_time = self.Default_pause_time + try: self.debug_stream("Connecting to OPC-UA server %s:%d...", self.OPC_Server_Name, self.OPC_Server_Port) self.client = opcua.Client("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), self.OPC_Time_out * 1000) @@ -175,23 +187,13 @@ class StatsCrosslet(Device): self.record_cross = "{}:record_cross".format(ns) self.debug_stream("Connecting to OPC-UA server %s:%d done.", self.OPC_Server_Name, self.OPC_Server_Port) - # Set default values in the read/write attributes. -# self._subband = 0 - self._subband = self.Default_subband -# self._integration_time = 0.0 - self._integration_time = self.Default_integration_time - self._time_stamp = '' -# self._pause_time = 0.0 - self._pause_time = self.Default_pause_time - self._rcu_modes = ('',) - self._visibilities_imag = ((0.0,),) - self._visibilities_real = ((0.0,),) - self.data_read_loop = threading.Thread(target = self.read_data) self.data_acquisition_is_active = False self.stop_data_read_loop = False self.data_read_loop.start() + self.set_state(DevState.ON) except Exception as e: + self.set_state(DevState.FAULT) self.error_stream("Cannot connect to the OPC-UA server %s. Trace: %s" % (self.OPC_Server_Name, traceback.format_exc())) raise e # PROTECTED REGION END # // StatsCrosslet.init_device @@ -209,6 +211,8 @@ class StatsCrosslet(Device): destructor and by the device Init command. """ # PROTECTED REGION ID(StatsCrosslet.delete_device) ENABLED START # + self.set_state(DevState.OFF) + self.debug_stream("Shutting down...") self.data_acquisition_is_active = False self.stop_data_read_loop = True @@ -224,92 +228,92 @@ class StatsCrosslet(Device): # Attributes methods # ------------------ - def read_subband(self): - # PROTECTED REGION ID(StatsCrosslet.subband_read) ENABLED START # - """Return the subband attribute.""" - return self._subband - # PROTECTED REGION END # // StatsCrosslet.subband_read + def read_Subband(self): + # PROTECTED REGION ID(StatsCrosslet.Subband_read) ENABLED START # + """Return the Subband attribute.""" + return self.__subband + # PROTECTED REGION END # // StatsCrosslet.Subband_read - def write_subband(self, value): - # PROTECTED REGION ID(StatsCrosslet.subband_write) ENABLED START # - """Set the subband attribute.""" - self._subband = value - # PROTECTED REGION END # // StatsCrosslet.subband_write + def write_Subband(self, value): + # PROTECTED REGION ID(StatsCrosslet.Subband_write) ENABLED START # + """Set the Subband attribute.""" + pass + # PROTECTED REGION END # // StatsCrosslet.Subband_write - def is_subband_allowed(self, attr): - # PROTECTED REGION ID(StatsCrosslet.is_subband_allowed) ENABLED START # + def is_Subband_allowed(self, attr): + # PROTECTED REGION ID(StatsCrosslet.is_Subband_allowed) ENABLED START # if attr==attr.READ_REQ: return self.get_state() not in [DevState.STANDBY] else: return self.get_state() not in [DevState.STANDBY] - # PROTECTED REGION END # // StatsCrosslet.is_subband_allowed + # PROTECTED REGION END # // StatsCrosslet.is_Subband_allowed - def read_integration_time(self): - # PROTECTED REGION ID(StatsCrosslet.integration_time_read) ENABLED START # - """Return the integration_time attribute.""" - return self._integration_time - # PROTECTED REGION END # // StatsCrosslet.integration_time_read + def read_Integration_time(self): + # PROTECTED REGION ID(StatsCrosslet.Integration_time_read) ENABLED START # + """Return the Integration_time attribute.""" + return self.__integration_time + # PROTECTED REGION END # // StatsCrosslet.Integration_time_read - def is_integration_time_allowed(self, attr): - # PROTECTED REGION ID(StatsCrosslet.is_integration_time_allowed) ENABLED START # + def is_Integration_time_allowed(self, attr): + # PROTECTED REGION ID(StatsCrosslet.is_Integration_time_allowed) ENABLED START # return self.get_state() not in [DevState.ON,DevState.OFF,DevState.INIT] - # PROTECTED REGION END # // StatsCrosslet.is_integration_time_allowed + # PROTECTED REGION END # // StatsCrosslet.is_Integration_time_allowed - def read_time_stamp(self): - # PROTECTED REGION ID(StatsCrosslet.time_stamp_read) ENABLED START # - """Return the time_stamp attribute.""" - return self._time_stamp - # PROTECTED REGION END # // StatsCrosslet.time_stamp_read + def read_Time_stamp(self): + # PROTECTED REGION ID(StatsCrosslet.Time_stamp_read) ENABLED START # + """Return the Time_stamp attribute.""" + return self.__time_stamp + # PROTECTED REGION END # // StatsCrosslet.Time_stamp_read - def is_time_stamp_allowed(self, attr): - # PROTECTED REGION ID(StatsCrosslet.is_time_stamp_allowed) ENABLED START # + def is_Time_stamp_allowed(self, attr): + # PROTECTED REGION ID(StatsCrosslet.is_Time_stamp_allowed) ENABLED START # return self.get_state() not in [DevState.ON,DevState.OFF,DevState.INIT] - # PROTECTED REGION END # // StatsCrosslet.is_time_stamp_allowed - - def read_pause_time(self): - # PROTECTED REGION ID(StatsCrosslet.pause_time_read) ENABLED START # - """Return the pause_time attribute.""" - return self._pause_time - # PROTECTED REGION END # // StatsCrosslet.pause_time_read - - def write_pause_time(self, value): - # PROTECTED REGION ID(StatsCrosslet.pause_time_write) ENABLED START # - """Set the pause_time attribute.""" - self._pause_time = value - # PROTECTED REGION END # // StatsCrosslet.pause_time_write - - def read_rcu_modes(self): - # PROTECTED REGION ID(StatsCrosslet.rcu_modes_read) ENABLED START # - """Return the rcu_modes attribute.""" + # PROTECTED REGION END # // StatsCrosslet.is_Time_stamp_allowed + + def read_Pause_time(self): + # PROTECTED REGION ID(StatsCrosslet.Pause_time_read) ENABLED START # + """Return the Pause_time attribute.""" + return self.__pause_time + # PROTECTED REGION END # // StatsCrosslet.Pause_time_read + + def write_Pause_time(self, value): + # PROTECTED REGION ID(StatsCrosslet.Pause_time_write) ENABLED START # + """Set the Pause_time attribute.""" + pass + # PROTECTED REGION END # // StatsCrosslet.Pause_time_write + + def read_RCU_modes(self): + # PROTECTED REGION ID(StatsCrosslet.RCU_modes_read) ENABLED START # + """Return the RCU_modes attribute.""" return self._rcu_modes - # PROTECTED REGION END # // StatsCrosslet.rcu_modes_read + # PROTECTED REGION END # // StatsCrosslet.RCU_modes_read - def is_rcu_modes_allowed(self, attr): - # PROTECTED REGION ID(StatsCrosslet.is_rcu_modes_allowed) ENABLED START # + def is_RCU_modes_allowed(self, attr): + # PROTECTED REGION ID(StatsCrosslet.is_RCU_modes_allowed) ENABLED START # return self.get_state() not in [DevState.ON,DevState.OFF,DevState.INIT] - # PROTECTED REGION END # // StatsCrosslet.is_rcu_modes_allowed + # PROTECTED REGION END # // StatsCrosslet.is_RCU_modes_allowed - def read_visibilities_imag(self): - # PROTECTED REGION ID(StatsCrosslet.visibilities_imag_read) ENABLED START # - """Return the visibilities_imag attribute.""" - return self._visibilities_imag - # PROTECTED REGION END # // StatsCrosslet.visibilities_imag_read + def read_Visibilities_imag(self): + # PROTECTED REGION ID(StatsCrosslet.Visibilities_imag_read) ENABLED START # + """Return the Visibilities_imag attribute.""" + return self.__visibilities_imag + # PROTECTED REGION END # // StatsCrosslet.Visibilities_imag_read - def is_visibilities_imag_allowed(self, attr): - # PROTECTED REGION ID(StatsCrosslet.is_visibilities_imag_allowed) ENABLED START # + def is_Visibilities_imag_allowed(self, attr): + # PROTECTED REGION ID(StatsCrosslet.is_Visibilities_imag_allowed) ENABLED START # return self.get_state() not in [DevState.ON,DevState.OFF,DevState.INIT] - # PROTECTED REGION END # // StatsCrosslet.is_visibilities_imag_allowed + # PROTECTED REGION END # // StatsCrosslet.is_Visibilities_imag_allowed - def read_visibilities_real(self): - # PROTECTED REGION ID(StatsCrosslet.visibilities_real_read) ENABLED START # - """Return the visibilities_real attribute.""" - return self._visibilities_real - # PROTECTED REGION END # // StatsCrosslet.visibilities_real_read + def read_Visibilities_real(self): + # PROTECTED REGION ID(StatsCrosslet.Visibilities_real_read) ENABLED START # + """Return the Visibilities_real attribute.""" + return self.__visibilities_real + # PROTECTED REGION END # // StatsCrosslet.Visibilities_real_read - def is_visibilities_real_allowed(self, attr): - # PROTECTED REGION ID(StatsCrosslet.is_visibilities_real_allowed) ENABLED START # + def is_Visibilities_real_allowed(self, attr): + # PROTECTED REGION ID(StatsCrosslet.is_Visibilities_real_allowed) ENABLED START # return self.get_state() not in [DevState.ON,DevState.OFF,DevState.INIT] - # PROTECTED REGION END # // StatsCrosslet.is_visibilities_real_allowed + # PROTECTED REGION END # // StatsCrosslet.is_Visibilities_real_allowed # -------- # Commands @@ -329,6 +333,7 @@ class StatsCrosslet(Device): """ if self.is_start_acquisition_allowed() is True: self.data_acquisition_is_active = True + self.set_state(DevState.RUNNING) # PROTECTED REGION END # // StatsCrosslet.start_acquisition def is_start_acquisition_allowed(self): @@ -347,6 +352,7 @@ class StatsCrosslet(Device): :return:None """ if self.is_stop_acquisition_allowed() is True: + self.set_state(DevState.ON) self.data_acquisition_is_active = False # PROTECTED REGION END # // StatsCrosslet.stop_acquisition @@ -355,6 +361,78 @@ class StatsCrosslet(Device): return self.get_state() not in [DevState.ON,DevState.INIT,DevState.RUNNING] # PROTECTED REGION END # // StatsCrosslet.is_stop_acquisition_allowed + @command( + ) + @DebugIt() + def On(self): + # PROTECTED REGION ID(StatsCrosslet.On) ENABLED START # + """ + + :return:None + """ + pass + # PROTECTED REGION END # // StatsCrosslet.On + + @command( + ) + @DebugIt() + def Local(self): + # PROTECTED REGION ID(StatsCrosslet.Local) ENABLED START # + """ + + :return:None + """ + pass + # PROTECTED REGION END # // StatsCrosslet.Local + + @command( + ) + @DebugIt() + def Remote(self): + # PROTECTED REGION ID(StatsCrosslet.Remote) ENABLED START # + """ + + :return:None + """ + pass + # PROTECTED REGION END # // StatsCrosslet.Remote + + @command( + ) + @DebugIt() + def Reset(self): + # PROTECTED REGION ID(StatsCrosslet.Reset) ENABLED START # + """ + + :return:None + """ + pass + # PROTECTED REGION END # // StatsCrosslet.Reset + + @command( + ) + @DebugIt() + def Off(self): + # PROTECTED REGION ID(StatsCrosslet.Off) ENABLED START # + """ + + :return:None + """ + pass + # PROTECTED REGION END # // StatsCrosslet.Off + + @command( + ) + @DebugIt() + def Init(self): + # PROTECTED REGION ID(StatsCrosslet.Init) ENABLED START # + """ + + :return:None + """ + pass + # PROTECTED REGION END # // StatsCrosslet.Init + # ---------- # Run server # ---------- diff --git a/StatsCrosslet-DS/StatsCrosslet.xmi b/StatsCrosslet-DS/StatsCrosslet.xmi index 4a1222bc688b4be9378859e1a76feeeade555ecb..946eb73e55492283d852b903793f9a60812585f0 100644 --- a/StatsCrosslet-DS/StatsCrosslet.xmi +++ b/StatsCrosslet-DS/StatsCrosslet.xmi @@ -61,10 +61,9 @@ <type xsi:type="pogoDsl:VoidType"/> </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <excludedStates>ON</excludedStates> <excludedStates>OFF</excludedStates> - <excludedStates>STANDBY</excludedStates> <excludedStates>RUNNING</excludedStates> + <excludedStates>FAULT</excludedStates> </commands> <commands name="stop_acquisition" description="Stop the data acquisition." execMethod="stop_acquisition" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> <argin description=""> @@ -74,11 +73,65 @@ <type xsi:type="pogoDsl:VoidType"/> </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <excludedStates>ON</excludedStates> <excludedStates>INIT</excludedStates> <excludedStates>RUNNING</excludedStates> + <excludedStates>FAULT</excludedStates> </commands> - <attributes name="subband" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <commands name="On" description="" execMethod="on" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Local" description="" execMethod="local" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Remote" description="" execMethod="remote" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Reset" description="" execMethod="reset" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Off" description="" execMethod="off" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <commands name="Init" description="" execMethod="init" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <argin description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argin> + <argout description=""> + <type xsi:type="pogoDsl:VoidType"/> + </argout> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </commands> + <attributes name="Subband" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:UShortType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -88,7 +141,7 @@ <readExcludedStates>STANDBY</readExcludedStates> <writeExcludedStates>STANDBY</writeExcludedStates> </attributes> - <attributes name="integration_time" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Integration_time" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -99,7 +152,7 @@ <readExcludedStates>OFF</readExcludedStates> <readExcludedStates>INIT</readExcludedStates> </attributes> - <attributes name="time_stamp" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Time_stamp" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:StringType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -110,7 +163,7 @@ <readExcludedStates>OFF</readExcludedStates> <readExcludedStates>INIT</readExcludedStates> </attributes> - <attributes name="pause_time" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Pause_time" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -118,7 +171,7 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="rcu_modes" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="96" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="RCU_modes" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="96" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:StringType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -129,7 +182,7 @@ <readExcludedStates>OFF</readExcludedStates> <readExcludedStates>INIT</readExcludedStates> </attributes> - <attributes name="visibilities_imag" attType="Image" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="96" maxY="96" allocReadMember="true" isDynamic="false"> + <attributes name="Visibilities_imag" attType="Image" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="96" maxY="96" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -140,7 +193,7 @@ <readExcludedStates>OFF</readExcludedStates> <readExcludedStates>INIT</readExcludedStates> </attributes> - <attributes name="visibilities_real" attType="Image" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="96" maxY="96" allocReadMember="true" isDynamic="false"> + <attributes name="Visibilities_real" attType="Image" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="96" maxY="96" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> @@ -157,15 +210,15 @@ <states name="OFF" description=""> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </states> - <states name="STANDBY" description=""> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </states> <states name="INIT" description=""> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </states> <states name="RUNNING" description=""> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </states> + <states name="FAULT" description=""> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </states> <preferences docHome="./doc_html" makefileHome="/usr/local/share/pogo/preferences"/> </classes> </pogoDsl:PogoSystem>