Commit 2fd6c48a authored by Claudio Scafuri's avatar Claudio Scafuri 💬
Browse files

add minReadInterval property

parent ca0b95b1
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding:utf-8 -*-
......@@ -90,8 +90,9 @@ class PBPM071 (PyTango.LatestDeviceImpl):
self.attr_Voltage3_read = 0.0
self.attr_VerticalPosition1_read = 0.0
self.attr_VerticalPosition2_read = 0.0
self.attr_Voltages_read = [0.0, 0.0, 0.0, 0.0]
self.attr_Voltages_read = [0.0]
#----- PROTECTED REGION ID(PBPM071.init_device) ENABLED START -----#
self.attr_Voltages_read = [0.0, 0.0, 0.0, 0.0]
msgRaw='GETN 0,1,2,3\r\n'
self.msg=msgRaw.encode()
self.socket = None
......@@ -99,7 +100,7 @@ class PBPM071 (PyTango.LatestDeviceImpl):
self.set_state(PyTango.DevState.INIT)
self.get_device_properties(self.get_device_class())
self.net_errors = 0
self.last_readout_time = 0
self.last_readout_time = 0.0
try:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.connect((self.IP_addres, self.PORT))
......@@ -134,8 +135,6 @@ class PBPM071 (PyTango.LatestDeviceImpl):
def read_Voltage0(self, attr):
self.debug_stream("In read_Voltage0()")
#----- PROTECTED REGION ID(PBPM071.Voltage0_read) ENABLED START -----#
if (time.time() - self.last_readout_time) > 1:
self.read_all_data()
self.attr_Voltage0_read = self.attr_Voltages_read[0]
attr.set_value(self.attr_Voltage0_read)
......@@ -207,7 +206,7 @@ class PBPM071 (PyTango.LatestDeviceImpl):
def read_attr_hardware(self, data):
self.debug_stream("In read_attr_hardware()")
#----- PROTECTED REGION ID(PBPM071.read_attr_hardware) ENABLED START -----#
if (time.time() - self.last_readout_time) > 1:
if (time.time() - self.last_readout_time) > self.minReadInterval:
self.read_all_data()
#----- PROTECTED REGION END -----# // PBPM071.read_attr_hardware
......@@ -284,6 +283,10 @@ class PBPM071Class(PyTango.DeviceClass):
[PyTango.DevFloat,
"Minimum voltage threshold for each PBPM blade readout",
[0.5]],
'minReadInterval':
[PyTango.DevFloat,
"minimum time between redings from the instrument, in seconds",
[1.0]],
}
......@@ -323,7 +326,7 @@ class PBPM071Class(PyTango.DeviceClass):
PyTango.SPECTRUM,
PyTango.READ, 4],
{
'label': "attr_Voltages_read",
'label': "voltages",
} ],
}
......
......@@ -32,6 +32,11 @@
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>0.5</DefaultPropValue>
</deviceProperties>
<deviceProperties name="minReadInterval" description="minimum time between redings from the instrument, in seconds">
<type xsi:type="pogoDsl:FloatType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>1.0</DefaultPropValue>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its &lt;i>device_state&lt;/i> data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
<argin description="none.">
<type xsi:type="pogoDsl:VoidType"/>
......@@ -92,7 +97,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="Voltages" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="4" maxY="1" allocReadMember="false" isDynamic="false">
<attributes name="Voltages" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="4" maxY="1" allocReadMember="true" isDynamic="false">
<dataType xsi:type="pogoDsl:FloatType"/>
<changeEvent fire="false" libCheckCriteria="false"/>
<archiveEvent fire="false" libCheckCriteria="false"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment