diff --git a/simple_device/PowerSupply.py b/simple_device/PowerSupply.py old mode 100644 new mode 100755 index 5687d735059bdb0493caabb4a7957cc53c70e1fb..fc20271286d12b3835396448b17ae61f0ccb2b23 --- a/simple_device/PowerSupply.py +++ b/simple_device/PowerSupply.py @@ -7,8 +7,9 @@ # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. -""" bla +""" Power Supply +Dummy Power Supply for testing """ # PyTango imports @@ -22,6 +23,7 @@ from PyTango import AttrQuality, DispLevel, DevState from PyTango import AttrWriteType, PipeWriteType # Additional import # PROTECTED REGION ID(PowerSupply.additionnal_import) ENABLED START # +import time # PROTECTED REGION END # // PowerSupply.additionnal_import __all__ = ["PowerSupply", "main"] @@ -29,9 +31,11 @@ __all__ = ["PowerSupply", "main"] class PowerSupply(Device): """ + Dummy Power Supply for testing """ __metaclass__ = DeviceMeta # PROTECTED REGION ID(PowerSupply.class_variable) ENABLED START # + # PROTECTED REGION END # // PowerSupply.class_variable # ----------------- @@ -43,22 +47,29 @@ class PowerSupply(Device): mandatory=True ) - HWUpdateTime = device_property( - dtype='double', - mandatory=True + HWUpdatetime = device_property( + dtype='double', default_value=1 ) # ---------- # Attributes # ---------- - current = attribute( + Voltage = attribute( dtype='double', + access=AttrWriteType.READ_WRITE, + label="PSV", + unit="V", + max_value=100, + min_value=0, + max_alarm=50, + max_warning=30, + memorized=True, ) - voltage = attribute( + Current = attribute( dtype='double', - access=AttrWriteType.READ_WRITE, + unit="A", ) # --------------- @@ -68,42 +79,43 @@ class PowerSupply(Device): def init_device(self): Device.init_device(self) # PROTECTED REGION ID(PowerSupply.init_device) ENABLED START # - self.voltage = 0.0 - self.current = 0.0 + self.voltage = 0. + self.current = 0. self.set_state(DevState.OFF) # PROTECTED REGION END # // PowerSupply.init_device def always_executed_hook(self): # PROTECTED REGION ID(PowerSupply.always_executed_hook) ENABLED START # - t = 'Voltage = %s, Current = %s' % (self.voltage, self.current) + t = '%s state is %s\n' % (self.get_name(), self.get_state()) + t += 'Voltage = %s, Current = %s' % (self.voltage, self.current) self.set_status(t) print(t) # PROTECTED REGION END # // PowerSupply.always_executed_hook def delete_device(self): # PROTECTED REGION ID(PowerSupply.delete_device) ENABLED START # - pass + self.set_state(DevState.UNKNOWN) # PROTECTED REGION END # // PowerSupply.delete_device # ------------------ # Attributes methods # ------------------ - def read_current(self): - # PROTECTED REGION ID(PowerSupply.current_read) ENABLED START # - return self.current - # PROTECTED REGION END # // PowerSupply.current_read - - def read_voltage(self): - # PROTECTED REGION ID(PowerSupply.voltage_read) ENABLED START # + def read_Voltage(self): + # PROTECTED REGION ID(PowerSupply.Voltage_read) ENABLED START # return self.voltage - # PROTECTED REGION END # // PowerSupply.voltage_read + # PROTECTED REGION END # // PowerSupply.Voltage_read - def write_voltage(self, value): - # PROTECTED REGION ID(PowerSupply.voltage_write) ENABLED START # + def write_Voltage(self, value): + # PROTECTED REGION ID(PowerSupply.Voltage_write) ENABLED START # self.voltage = value self.current = self.voltage / self.LoadImpedance - # PROTECTED REGION END # // PowerSupply.voltage_write + # PROTECTED REGION END # // PowerSupply.Voltage_write + + def read_Current(self): + # PROTECTED REGION ID(PowerSupply.Current_read) ENABLED START # + return self.current + # PROTECTED REGION END # // PowerSupply.Current_read # -------- diff --git a/simple_device/PowerSupply.xmi b/simple_device/PowerSupply.xmi old mode 100644 new mode 100755 index 34e8a8e07a66b079a3242f5bab56a45a317fed86..c02e0f55dedb9e2c497c626c8d85c9cacaf0d6ed --- a/simple_device/PowerSupply.xmi +++ b/simple_device/PowerSupply.xmi @@ -1,17 +1,18 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="PowerSupply" pogoRevision="9.6"> - <description description="" title="bla" sourcePath="/hosthome" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="Dummy Power Supply for testing" title="Power Supply" sourcePath="/hosthome" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> - <identification contact="at astron.nl - jurges" author="jurges" emailDomain="astron.nl" classFamily="PowerSupply" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> + <identification contact="at cells.es - srubio" author="srubio" emailDomain="cells.es" classFamily="PowerSupply" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="none" reference=""/> </description> - <deviceProperties name="LoadImpedance" mandatory="true" description=""> + <deviceProperties name="LoadImpedance" mandatory="true" description="Impedance at the output"> <type xsi:type="pogoDsl:DoubleType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </deviceProperties> - <deviceProperties name="HWUpdateTime" mandatory="true" description=""> + <deviceProperties name="HWUpdatetime" description=""> <type xsi:type="pogoDsl:DoubleType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>1</DefaultPropValue> </deviceProperties> <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> @@ -31,7 +32,7 @@ </argout> <status abstract="true" inherited="true" concrete="true"/> </commands> - <commands name="On" description="" execMethod="on" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> + <commands name="On" description="setting state to ON" execMethod="on" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> </argin> @@ -49,21 +50,21 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> - <attributes name="current" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Voltage" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:DoubleType"/> <changeEvent fire="false" libCheckCriteria="false"/> <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <properties description="" label="PSV" unit="V" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="50" minAlarm="" maxWarning="30" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="voltage" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Current" 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"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <properties description="" label="" unit="A" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <states name="ON" description=""> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> diff --git a/ska_device/SKAPowerSupply.py b/ska_device/SKAPowerSupply.py old mode 100644 new mode 100755 index cea3f97749ab549037144c0814990a956b1b3e66..5eff79951c26979fcd79b2d965bbce2f5d73ad28 --- a/ska_device/SKAPowerSupply.py +++ b/ska_device/SKAPowerSupply.py @@ -7,7 +7,7 @@ # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. -""" blah +""" Power Supply for SKA """ @@ -20,10 +20,11 @@ from PyTango.server import attribute, command from PyTango.server import device_property from PyTango import AttrQuality, DispLevel, DevState from PyTango import AttrWriteType, PipeWriteType -from skabase.SKABaseDevice import SKABaseDevice +#from SKABaseDevice import SKABaseDevice # Additional import # PROTECTED REGION ID(SKAPowerSupply.additionnal_import) ENABLED START # import time +from skabase.SKABaseDevice import SKABaseDevice #<<< # PROTECTED REGION END # // SKAPowerSupply.additionnal_import __all__ = ["SKAPowerSupply", "main"] @@ -34,6 +35,13 @@ class SKAPowerSupply(SKABaseDevice): """ __metaclass__ = DeviceMeta # PROTECTED REGION ID(SKAPowerSupply.class_variable) ENABLED START # + + @command() + def Reset(self): + """ Reset command overloading SKABaseDevice.Reset """ + self.set_state(DevState.OFF) + + # PROTECTED REGION END # // SKAPowerSupply.class_variable # ----------------- @@ -44,14 +52,12 @@ class SKAPowerSupply(SKABaseDevice): - HWUpdateTime = device_property( - dtype='double', - mandatory=True + LoadImpedance = device_property( + dtype='double', default_value=2.7 ) - LoadImpedance = device_property( - dtype='double', - mandatory=True + HWUpdateTime = device_property( + dtype='double', default_value=1 ) # ---------- @@ -66,13 +72,23 @@ class SKAPowerSupply(SKABaseDevice): - Current = attribute( + Voltage = attribute( dtype='double', + access=AttrWriteType.READ_WRITE, + label="V", + unit="V", + max_value=100, + min_value=0, + max_alarm=70, + min_alarm=0, + max_warning=60, + min_warning=0, ) - Voltage = attribute( + Current = attribute( dtype='double', - access=AttrWriteType.READ_WRITE, + label="I", + unit="A", ) @@ -83,43 +99,47 @@ class SKAPowerSupply(SKABaseDevice): def init_device(self): SKABaseDevice.init_device(self) # PROTECTED REGION ID(SKAPowerSupply.init_device) ENABLED START # - self.Voltage = 0.0 - self.Current = 0.0 + self.voltage = 0.0 + self.current = 0.0 self.set_state(DevState.OFF) + self.set_change_event('State', True, False) + self.set_change_event('Voltage', True, True) + self.set_change_event('Current', True, False) # PROTECTED REGION END # // SKAPowerSupply.init_device def always_executed_hook(self): # PROTECTED REGION ID(SKAPowerSupply.always_executed_hook) ENABLED START # - t = 'Voltage = %s, Current = %s' % (self.Voltage, self.Current) - self.set_status(t) - print(t) + st = '%s is %s' % (self.get_name(), self.get_state()) + st += '\nVoltage = %s, Current = %s' % (self.voltage, self.current) + self.set_status(st) + self.logger.info(self.get_status()) # PROTECTED REGION END # // SKAPowerSupply.always_executed_hook def delete_device(self): # PROTECTED REGION ID(SKAPowerSupply.delete_device) ENABLED START # - pass + self.set_state(DevState.UNKNOWN) # PROTECTED REGION END # // SKAPowerSupply.delete_device # ------------------ # Attributes methods # ------------------ - def read_Current(self): - # PROTECTED REGION ID(SKAPowerSupply.Current_read) ENABLED START # - return self.Current - # PROTECTED REGION END # // SKAPowerSupply.Current_read - def read_Voltage(self): # PROTECTED REGION ID(SKAPowerSupply.Voltage_read) ENABLED START # - return self.Voltage + return self.voltage # PROTECTED REGION END # // SKAPowerSupply.Voltage_read def write_Voltage(self, value): # PROTECTED REGION ID(SKAPowerSupply.Voltage_write) ENABLED START # - self.Voltage = value - self.Current = self.Voltage / self.LoadImpedance + self.voltage = value + self.current = self.voltage / self.LoadImpedance # PROTECTED REGION END # // SKAPowerSupply.Voltage_write + def read_Current(self): + # PROTECTED REGION ID(SKAPowerSupply.Current_read) ENABLED START # + return self.current + # PROTECTED REGION END # // SKAPowerSupply.Current_read + # -------- # Commands @@ -139,7 +159,7 @@ class SKAPowerSupply(SKABaseDevice): def Off(self): # PROTECTED REGION ID(SKAPowerSupply.Off) ENABLED START # self.set_state(DevState.OFF) - # PROTECTED REGION END # // SKAPowerSupply.Off + # PROTECTED REGION END # // SKAPowerSupply.Off # ---------- # Run server diff --git a/ska_device/SKAPowerSupply.xmi b/ska_device/SKAPowerSupply.xmi old mode 100644 new mode 100755 index f1dab4ca5c4bf892a299f0a38cce2cd4bab36d47..116a5e34f83c3c03334c069c691c155802dae2c1 --- a/ska_device/SKAPowerSupply.xmi +++ b/ska_device/SKAPowerSupply.xmi @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="ASCII"?> <pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl"> <classes name="SKAPowerSupply" pogoRevision="9.6"> - <description description="" title="blah" sourcePath="/hosthome/foo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="true" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> + <description description="" title="Power Supply for SKA" sourcePath="/hosthome/foo" language="PythonHL" filestogenerate="XMI file,Code files,Protected Regions" license="GPL" copyright="" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false"> <inheritances classname="Device_Impl" sourcePath=""/> <inheritances classname="SKABaseDevice" sourcePath="../lmc-base-classes/skabase/SKABaseDevice"/> - <identification contact="at astron.nl - jurges" author="jurges" emailDomain="astron.nl" classFamily="PowerSupply" siteSpecific="" platform="Unix Like" bus="Not Applicable" manufacturer="none" reference=""/> + <identification contact="at cells.es - srubio" author="srubio" emailDomain="cells.es" classFamily="PowerSupply" siteSpecific="" platform="All Platforms" bus="Testing" manufacturer="none" reference=""/> </description> <deviceProperties name="SkaLevel" description="Indication of importance of the device in the SKA hierarchy 
to support drill-down navigation: 1..6, with 1 highest.
Default is 4, making provision for 
EltMaster, EltAlarms, EltTelState = 1
SubEltMaster = 2
Subarray, Capability = 2/3
Others = 4 (or 5 or 6)"> <type xsi:type="pogoDsl:ShortType"/> @@ -24,22 +24,24 @@ <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="true" concrete="true"/> </deviceProperties> - <deviceProperties name="HWUpdateTime" mandatory="true" description=""> + <deviceProperties name="LoadImpedance" description=""> <type xsi:type="pogoDsl:DoubleType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>2.7</DefaultPropValue> </deviceProperties> - <deviceProperties name="LoadImpedance" mandatory="true" description=""> + <deviceProperties name="HWUpdateTime" description=""> <type xsi:type="pogoDsl:DoubleType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <DefaultPropValue>1</DefaultPropValue> </deviceProperties> - <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> + <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="1000"> <argin description="none"> <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="Device state"> <type xsi:type="pogoDsl:StateType"/> </argout> - <status abstract="true" inherited="true" concrete="true"/> + <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> </commands> <commands name="Status" description="This command gets the device status (stored in its device_status data member) and returns it to the caller." execMethod="dev_status" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none"> @@ -128,21 +130,21 @@ <status abstract="false" inherited="true" concrete="true"/> <properties description="The test mode of the device. 
Either no test mode or an indication of the test mode." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="Current" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Voltage" 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"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <properties description="" label="V" unit="V" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="70" minAlarm="0" maxWarning="60" minWarning="0" deltaTime="" deltaValue=""/> </attributes> - <attributes name="Voltage" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> + <attributes name="Current" 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"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <properties description="" label="I" unit="A" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="loggingTargets" attType="Spectrum" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="3" maxY="" allocReadMember="true"> <dataType xsi:type="pogoDsl:StringType"/> @@ -179,5 +181,6 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </states> <preferences docHome="./doc_html" makefileHome="/usr/local/share/pogo/preferences"/> + <overlodedPollPeriodObject name="State" type="command" pollPeriod="1000"/> </classes> </pogoDsl:PogoSystem>