From d331bf5505f594749660aebefc876b700d67300e Mon Sep 17 00:00:00 2001 From: Marco De Marco <demarco@oats.inaf.it> Date: Mon, 2 Dec 2013 10:36:59 +0100 Subject: [PATCH] State machine modified --- src/DataExporter.cpp | 10 +++++----- src/DataExporter.h | 4 ++-- src/DataExporter.xmi | 4 ++++ src/DataExporterStateMachine.cpp | 14 ++++++++++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/DataExporter.cpp b/src/DataExporter.cpp index 1242d12..76287bb 100644 --- a/src/DataExporter.cpp +++ b/src/DataExporter.cpp @@ -50,7 +50,7 @@ /** * DataExporter class description: - * + * */ //================================================================ @@ -143,11 +143,11 @@ void DataExporter::init_device() set_status("Initializing device"); /*----- PROTECTED REGION END -----*/ // DataExporter::init_device_before - + // Get the device properties from database get_device_property(); - + /*----- PROTECTED REGION ID(DataExporter::init_device) ENABLED START -----*/ @@ -220,7 +220,7 @@ void DataExporter::get_device_property() // Call database and extract values if (Tango::Util::instance()->_UseDb==true) get_db_device()->get_property(dev_prop); - + // get instance on DataExporterClass to get class property Tango::DbDatum def_prop, cl_prop; DataExporterClass *ds_class = @@ -480,7 +480,7 @@ void DataExporter::get_device_property() //-------------------------------------------------------- void DataExporter::always_executed_hook() { - DEBUG_STREAM << "DataExporter::always_executed_hook() " << device_name << endl; + INFO_STREAM << "DataExporter::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(DataExporter::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) diff --git a/src/DataExporter.h b/src/DataExporter.h index 0aaf826..91333b2 100644 --- a/src/DataExporter.h +++ b/src/DataExporter.h @@ -48,7 +48,7 @@ /** * DataExporter class description: - * + * */ namespace DataExporter_ns @@ -150,7 +150,7 @@ public: DataExporter(Tango::DeviceClass *cl,const char *s,const char *d); /** * The device object destructor. - */ + */ ~DataExporter() {delete_device();}; diff --git a/src/DataExporter.xmi b/src/DataExporter.xmi index 6d53e1a..2267959 100644 --- a/src/DataExporter.xmi +++ b/src/DataExporter.xmi @@ -118,6 +118,8 @@ <type xsi:type="pogoDsl:VoidType"/> </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <excludedStates>ON</excludedStates> + <excludedStates>FAULT</excludedStates> </commands> <commands name="Off" description="Deactivate data exporter" execMethod="off" displayLevel="OPERATOR" polledPeriod="0"> <argin description=""> @@ -127,6 +129,8 @@ <type xsi:type="pogoDsl:VoidType"/> </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> + <excludedStates>OFF</excludedStates> + <excludedStates>FAULT</excludedStates> </commands> <states name="ON" description="Data exporter is in ON state (ready to incoming connections)"> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> diff --git a/src/DataExporterStateMachine.cpp b/src/DataExporterStateMachine.cpp index 0a16fee..77ea472 100644 --- a/src/DataExporterStateMachine.cpp +++ b/src/DataExporterStateMachine.cpp @@ -64,10 +64,15 @@ namespace DataExporter_ns //-------------------------------------------------------- bool DataExporter::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any)) { - // Not any excluded states for On command. + // Compare device state with not allowed states. + if (get_state()==Tango::ON || + get_state()==Tango::FAULT) + { /*----- PROTECTED REGION ID(DataExporter::OnStateAllowed) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // DataExporter::OnStateAllowed + return false; + } return true; } @@ -79,10 +84,15 @@ bool DataExporter::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any)) //-------------------------------------------------------- bool DataExporter::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any)) { - // Not any excluded states for Off command. + // Compare device state with not allowed states. + if (get_state()==Tango::OFF || + get_state()==Tango::FAULT) + { /*----- PROTECTED REGION ID(DataExporter::OffStateAllowed) ENABLED START -----*/ /*----- PROTECTED REGION END -----*/ // DataExporter::OffStateAllowed + return false; + } return true; } -- GitLab