From f0b8cfd96c9ad58a5a44329e7379dc187e65ec2b Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Mon, 18 May 2020 15:46:01 +0200
Subject: [PATCH] Add properties with default values for R/W attributes

The attributes cannot be used before they get written to or otherwise
somehow magically updated.  Therefore I added peoprties with default
values that I assign in the init_device method.
---
 StatsCrosslet-DS/StatsCrosslet.py  | 27 +++++++++++++++++++++++++++
 StatsCrosslet-DS/StatsCrosslet.xmi | 15 +++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/StatsCrosslet-DS/StatsCrosslet.py b/StatsCrosslet-DS/StatsCrosslet.py
index 2e0bb6ebe..335c3783e 100644
--- a/StatsCrosslet-DS/StatsCrosslet.py
+++ b/StatsCrosslet-DS/StatsCrosslet.py
@@ -44,6 +44,12 @@ class StatsCrosslet(Device):
             - Type:'DevULong'
         OPC_time_out
             - Type:'DevULong'
+        Default_pause_time
+            - Type:'DevDouble'
+        Default_subband
+            - Type:'DevULong'
+        Default_integration_time
+            - Type:'DevDouble'
     """
     # PROTECTED REGION ID(StatsCrosslet.class_variable) ENABLED START #
     client = 0
@@ -97,6 +103,21 @@ class StatsCrosslet(Device):
         default_value=1000
     )
 
+    Default_pause_time = device_property(
+        dtype='DevDouble',
+        default_value=60.0
+    )
+
+    Default_subband = device_property(
+        dtype='DevULong',
+        default_value=150
+    )
+
+    Default_integration_time = device_property(
+        dtype='DevDouble',
+        default_value=1.0
+    )
+
     # ----------
     # Attributes
     # ----------
@@ -158,6 +179,12 @@ class StatsCrosslet(Device):
             ns = self.client.get_namespace_index("http://lofar.eu")
             self.obj = self.client.get_root_node().get_child(["0:Objects", "{}:StationMetrics".format(ns),                                            "{}:RCU".format(ns)])
             self.record_cross = "{}:record_cross".format(ns)
+
+            # Set default values in the read/write attributes
+            self._pause_time = self.Default_pause_time
+            self._integration_time = self.Default_integration_time
+            self._subband = self.Default_subband
+
             self.data_read_loop = threading.Thread(target = self.read_data)
             self.data_acquisition_is_active.set()
             self.stop_data_read_loop.clear()
diff --git a/StatsCrosslet-DS/StatsCrosslet.xmi b/StatsCrosslet-DS/StatsCrosslet.xmi
index 884ebb33d..6f8c58792 100644
--- a/StatsCrosslet-DS/StatsCrosslet.xmi
+++ b/StatsCrosslet-DS/StatsCrosslet.xmi
@@ -20,6 +20,21 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <DefaultPropValue>1000</DefaultPropValue>
     </deviceProperties>
+    <deviceProperties name="Default_pause_time" description="">
+      <type xsi:type="pogoDsl:DoubleType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <DefaultPropValue>60.0</DefaultPropValue>
+    </deviceProperties>
+    <deviceProperties name="Default_subband" description="">
+      <type xsi:type="pogoDsl:UIntType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+      <DefaultPropValue>150</DefaultPropValue>
+    </deviceProperties>
+    <deviceProperties name="Default_integration_time" description="">
+      <type xsi:type="pogoDsl:DoubleType"/>
+      <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 device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
       <argin description="none">
         <type xsi:type="pogoDsl:VoidType"/>
-- 
GitLab