From 3b13b1da4a6517be1b7442cd0ff2d6cebbb9f62a Mon Sep 17 00:00:00 2001 From: gscalamera <graziano.scalamera@elettra.eu> Date: Fri, 1 Jan 2021 14:44:14 +0100 Subject: [PATCH] Add ExposureTime and SyncMode device properties --- src/OceanOptics.cpp | 69 ++++++++++++++++++++++++++++++++++++++-- src/OceanOptics.h | 22 ++++++++++++- src/OceanOptics.xmi | 16 ++++++++-- src/OceanOpticsClass.cpp | 30 +++++++++++++++-- 4 files changed, 129 insertions(+), 8 deletions(-) diff --git a/src/OceanOptics.cpp b/src/OceanOptics.cpp index fafe658..6e26c80 100644 --- a/src/OceanOptics.cpp +++ b/src/OceanOptics.cpp @@ -198,10 +198,16 @@ void OceanOptics::delete_device() rein.push_back(attr_RegionOfInterest_read[0]); rein.push_back(attr_RegionOfInterest_read[1]); ri << rein; + Tango::DbDatum et("ExposureTime"); + et << *attr_ExposureTime_read; + Tango::DbDatum sm("SyncMode"); + sm << *attr_SyncMode_read; Tango::DbData data; data.push_back(gr); data.push_back(ar); data.push_back(ri); + data.push_back(et); + data.push_back(sm); Tango::Database *db = new Tango::Database(); try { @@ -387,6 +393,9 @@ void OceanOptics::init_device() pReferenceData = NULL; pFrameBuffer = NULL; + *attr_ExposureTime_read = exposureTime; + *attr_SyncMode_read = syncMode; + attr_AnalysisRegion_read[0] = attr_RegionOfInterest_read[0] = defaultStartRegion; attr_AnalysisRegion_read[1] = attr_RegionOfInterest_read[1] = defaultEndRegion; if(regionOfInterest.size() >= 2) @@ -520,6 +529,8 @@ void OceanOptics::get_device_property() dev_prop.push_back(Tango::DbDatum("AnalysisRegion")); dev_prop.push_back(Tango::DbDatum("RegionOfInterest")); dev_prop.push_back(Tango::DbDatum("AutoStart")); + dev_prop.push_back(Tango::DbDatum("ExposureTime")); + dev_prop.push_back(Tango::DbDatum("SyncMode")); // is there at least one property to be read ? if (dev_prop.size()>0) @@ -754,6 +765,28 @@ void OceanOptics::get_device_property() // And try to extract AutoStart value from database if (dev_prop[i].is_empty()==false) dev_prop[i] >> autoStart; + // Try to initialize ExposureTime from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> exposureTime; + else { + // Try to initialize ExposureTime from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> exposureTime; + } + // And try to extract ExposureTime value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> exposureTime; + + // Try to initialize SyncMode from class property + cl_prop = ds_class->get_class_property(dev_prop[++i].name); + if (cl_prop.is_empty()==false) cl_prop >> syncMode; + else { + // Try to initialize SyncMode from default device value + def_prop = ds_class->get_default_device_property(dev_prop[i].name); + if (def_prop.is_empty()==false) def_prop >> syncMode; + } + // And try to extract SyncMode value from database + if (dev_prop[i].is_empty()==false) dev_prop[i] >> syncMode; + } /*----- PROTECTED REGION ID(OceanOptics::get_device_property_after) ENABLED START -----*/ @@ -1056,7 +1089,23 @@ void OceanOptics::write_IncrSensitivity(Tango::WAttribute &attr) //-------------------------------------------------------- /** * Read attribute SyncMode related method - * Description: 0: The camera operates without synchronization.\nSpectra are read out periodically in accordance with NumReadouts attribute.\n\n1: Readout is performed periodically in accordance with NumReadouts attribute.\nAt the beginning of the first readout a positive sync pulse is formed.\n\n2: A sync pulse is formed at beginning of each readout.\n\n3: One sync pulse of negative polarity is generated for the entire readout time.\n\n4: The camera will wait for one sync pulse.\nThe first readout will start at the rising edge of an external sync pulse.\nAll other readouts will be performed as soon as possible.\nNo blanks within limit\n\n5: Each readout starts at the rising edge of an external sync pulse.\nThe camera will wait fo as many sync pulses as much readouts are set. + * Description: 0: The camera operates without synchronization. + * Spectra are read out periodically in accordance with NumReadouts attribute. + * + * 1: Readout is performed periodically in accordance with NumReadouts attribute. + * At the beginning of the first readout a positive sync pulse is formed. + * + * 2: A sync pulse is formed at beginning of each readout. + * + * 3: One sync pulse of negative polarity is generated for the entire readout time. + * + * 4: The camera will wait for one sync pulse. + * The first readout will start at the rising edge of an external sync pulse. + * All other readouts will be performed as soon as possible. + * No blanks within limit + * + * 5: Each readout starts at the rising edge of an external sync pulse. + * The camera will wait fo as many sync pulses as much readouts are set. * * Data type: Tango::DevLong * Attr type: Scalar @@ -1159,7 +1208,23 @@ void OceanOptics::read_SyncMode(Tango::Attribute &attr) //-------------------------------------------------------- /** * Write attribute SyncMode related method - * Description: 0: The camera operates without synchronization.\nSpectra are read out periodically in accordance with NumReadouts attribute.\n\n1: Readout is performed periodically in accordance with NumReadouts attribute.\nAt the beginning of the first readout a positive sync pulse is formed.\n\n2: A sync pulse is formed at beginning of each readout.\n\n3: One sync pulse of negative polarity is generated for the entire readout time.\n\n4: The camera will wait for one sync pulse.\nThe first readout will start at the rising edge of an external sync pulse.\nAll other readouts will be performed as soon as possible.\nNo blanks within limit\n\n5: Each readout starts at the rising edge of an external sync pulse.\nThe camera will wait fo as many sync pulses as much readouts are set. + * Description: 0: The camera operates without synchronization. + * Spectra are read out periodically in accordance with NumReadouts attribute. + * + * 1: Readout is performed periodically in accordance with NumReadouts attribute. + * At the beginning of the first readout a positive sync pulse is formed. + * + * 2: A sync pulse is formed at beginning of each readout. + * + * 3: One sync pulse of negative polarity is generated for the entire readout time. + * + * 4: The camera will wait for one sync pulse. + * The first readout will start at the rising edge of an external sync pulse. + * All other readouts will be performed as soon as possible. + * No blanks within limit + * + * 5: Each readout starts at the rising edge of an external sync pulse. + * The camera will wait fo as many sync pulses as much readouts are set. * * Data type: Tango::DevLong * Attr type: Scalar diff --git a/src/OceanOptics.h b/src/OceanOptics.h index 3cbe4cf..b30c54f 100644 --- a/src/OceanOptics.h +++ b/src/OceanOptics.h @@ -189,6 +189,10 @@ public: vector<Tango::DevDouble> regionOfInterest; // AutoStart: AutoStart Tango::DevBoolean autoStart; + // ExposureTime: ExposureTime + Tango::DevDouble exposureTime; + // SyncMode: SyncMode + Tango::DevLong syncMode; // Attribute data members public: @@ -319,7 +323,23 @@ public: virtual bool is_IncrSensitivity_allowed(Tango::AttReqType type); /** * Attribute SyncMode related methods - * Description: 0: The camera operates without synchronization.\nSpectra are read out periodically in accordance with NumReadouts attribute.\n\n1: Readout is performed periodically in accordance with NumReadouts attribute.\nAt the beginning of the first readout a positive sync pulse is formed.\n\n2: A sync pulse is formed at beginning of each readout.\n\n3: One sync pulse of negative polarity is generated for the entire readout time.\n\n4: The camera will wait for one sync pulse.\nThe first readout will start at the rising edge of an external sync pulse.\nAll other readouts will be performed as soon as possible.\nNo blanks within limit\n\n5: Each readout starts at the rising edge of an external sync pulse.\nThe camera will wait fo as many sync pulses as much readouts are set. + * Description: 0: The camera operates without synchronization. + * Spectra are read out periodically in accordance with NumReadouts attribute. + * + * 1: Readout is performed periodically in accordance with NumReadouts attribute. + * At the beginning of the first readout a positive sync pulse is formed. + * + * 2: A sync pulse is formed at beginning of each readout. + * + * 3: One sync pulse of negative polarity is generated for the entire readout time. + * + * 4: The camera will wait for one sync pulse. + * The first readout will start at the rising edge of an external sync pulse. + * All other readouts will be performed as soon as possible. + * No blanks within limit + * + * 5: Each readout starts at the rising edge of an external sync pulse. + * The camera will wait fo as many sync pulses as much readouts are set. * * Data type: Tango::DevLong * Attr type: Scalar diff --git a/src/OceanOptics.xmi b/src/OceanOptics.xmi index ec60165..21ec5bf 100644 --- a/src/OceanOptics.xmi +++ b/src/OceanOptics.xmi @@ -88,6 +88,14 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <DefaultPropValue>true</DefaultPropValue> </deviceProperties> + <deviceProperties name="ExposureTime" description="ExposureTime"> + <type xsi:type="pogoDsl:DoubleType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> + <deviceProperties name="SyncMode" description="SyncMode"> + <type xsi:type="pogoDsl:IntType"/> + <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + </deviceProperties> <commands name="State" description="This command gets the device state (stored in its <i>device_state</i> data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0"> <argin description="none."> <type xsi:type="pogoDsl:VoidType"/> @@ -268,10 +276,11 @@ </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> - <attributes name="ExposureTime" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true"> + <attributes name="ExposureTime" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" allocReadMember="false" 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="Exposure time in milliseconds" label="" unit="ms" standardUnit="1.0" displayUnit="ms" format="%6.2f" maxValue="" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> @@ -282,12 +291,13 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="false: use standard sensitivity\ntrue: use increased sensitivity" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> - <attributes name="SyncMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true"> + <attributes name="SyncMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" allocReadMember="false" isDynamic="false"> <dataType xsi:type="pogoDsl:IntType"/> <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="0: The camera operates without synchronization.\nSpectra are read out periodically in accordance with NumReadouts attribute.\n\n1: Readout is performed periodically in accordance with NumReadouts attribute.\nAt the beginning of the first readout a positive sync pulse is formed.\n\n2: A sync pulse is formed at beginning of each readout.\n\n3: One sync pulse of negative polarity is generated for the entire readout time.\n\n4: The camera will wait for one sync pulse.\nThe first readout will start at the rising edge of an external sync pulse.\nAll other readouts will be performed as soon as possible.\nNo blanks within limit\n\n5: Each readout starts at the rising edge of an external sync pulse.\nThe camera will wait fo as many sync pulses as much readouts are set." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="5" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> + <properties description="0: The camera operates without synchronization.
Spectra are read out periodically in accordance with NumReadouts attribute.

1: Readout is performed periodically in accordance with NumReadouts attribute.
At the beginning of the first readout a positive sync pulse is formed.

2: A sync pulse is formed at beginning of each readout.

3: One sync pulse of negative polarity is generated for the entire readout time.

4: The camera will wait for one sync pulse.
The first readout will start at the rising edge of an external sync pulse.
All other readouts will be performed as soon as possible.
No blanks within limit

5: Each readout starts at the rising edge of an external sync pulse.
The camera will wait fo as many sync pulses as much readouts are set." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="5" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="NoiseSubtraction" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="0" maxY="0" memorized="true" memorizedAtInit="true"> <dataType xsi:type="pogoDsl:BooleanType"/> diff --git a/src/OceanOpticsClass.cpp b/src/OceanOpticsClass.cpp index 18d1b96..069d91b 100644 --- a/src/OceanOpticsClass.cpp +++ b/src/OceanOpticsClass.cpp @@ -826,6 +826,32 @@ void OceanOpticsClass::set_default_property() } else add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "ExposureTime"; + prop_desc = "ExposureTime"; + prop_def = ""; + vect_data.clear(); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); + prop_name = "SyncMode"; + prop_desc = "SyncMode"; + prop_def = ""; + vect_data.clear(); + if (prop_def.length()>0) + { + Tango::DbDatum data(prop_name); + data << vect_data ; + dev_def_prop.push_back(data); + add_wiz_dev_prop(prop_name, prop_desc, prop_def); + } + else + add_wiz_dev_prop(prop_name, prop_desc); } //-------------------------------------------------------- @@ -954,7 +980,7 @@ void OceanOpticsClass::attribute_factory(vector<Tango::Attr *> &att_list) // Not Polled exposuretime->set_disp_level(Tango::OPERATOR); exposuretime->set_memorized(); - exposuretime->set_memorized_init(true); + exposuretime->set_memorized_init(false); att_list.push_back(exposuretime); // Attribute : IncrSensitivity @@ -1004,7 +1030,7 @@ void OceanOpticsClass::attribute_factory(vector<Tango::Attr *> &att_list) // Not Polled syncmode->set_disp_level(Tango::OPERATOR); syncmode->set_memorized(); - syncmode->set_memorized_init(true); + syncmode->set_memorized_init(false); att_list.push_back(syncmode); // Attribute : NoiseSubtraction -- GitLab