Skip to content
Snippets Groups Projects
Commit aced8cce authored by Marco De Marco's avatar Marco De Marco
Browse files

State machine added

parent 7aa2873a
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include <Configuration.h> #include <Configuration.h>
#include <PlainServer.h> #include <PlainServer.h>
#include <SSLServer.h> #include <SSLServer.h>
#include <bits/c++config.h> //@todo: controllare
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
...@@ -604,7 +603,8 @@ void MetadataExporter::importExportedTables(std::vector<std::string>& exportedTa ...@@ -604,7 +603,8 @@ void MetadataExporter::importExportedTables(std::vector<std::string>& exportedTa
std::string schema = exportedTables.at(i).substr(0, found); std::string schema = exportedTables.at(i).substr(0, found);
std::string table = exportedTables.at(i).substr(found+1, std::string::npos); std::string table = exportedTables.at(i).substr(found+1, std::string::npos);
INFO_STREAM << "SCHEMA: " << schema << " TABLE: " << table << endl; INFO_STREAM << "MetadataExporter::importExportedTables() schema "
<< schema << " table " << table << endl;
exportedTablesMap.insert(std::pair<const std::string, const std::string> (schema, table)); exportedTablesMap.insert(std::pair<const std::string, const std::string> (schema, table));
} }
...@@ -635,10 +635,12 @@ void MetadataExporter::importAuthorisedUsers(std::vector<std::string>& authorise ...@@ -635,10 +635,12 @@ void MetadataExporter::importAuthorisedUsers(std::vector<std::string>& authorise
std::string password = authorisedUsers.at(i).substr(found+1, std::string::npos); std::string password = authorisedUsers.at(i).substr(found+1, std::string::npos);
#ifdef VERBOSE_DEBUG #ifdef VERBOSE_DEBUG
INFO_STREAM << "USER: " << user << " PASSWORD: " << password << endl; INFO_STREAM << "MetadataExporter::importAuthorisedUsers() user "
<< user << " password " << password << endl;
#endif #endif
authorisedUsersMap.insert(std::pair<const std::string, const std::string>(user, password)); authorisedUsersMap.insert(std::pair<const std::string,
const std::string>(user, password));
} }
} }
...@@ -659,7 +661,7 @@ void MetadataExporter::checkIfFileExists(std::string fileName) ...@@ -659,7 +661,7 @@ void MetadataExporter::checkIfFileExists(std::string fileName)
throw std::invalid_argument(errorStream.str()); throw std::invalid_argument(errorStream.str());
} }
DEBUG_STREAM << "FILE: " << fileName << " -> OK" << endl; INFO_STREAM << "MetadataExporter::checkIfFileExists() " << fileName << endl;
} }
/*----- PROTECTED REGION END -----*/ // MetadataExporter::namespace_ending /*----- PROTECTED REGION END -----*/ // MetadataExporter::namespace_ending
......
...@@ -110,6 +110,8 @@ ...@@ -110,6 +110,8 @@
<type xsi:type="pogoDsl:VoidType"/> <type xsi:type="pogoDsl:VoidType"/>
</argout> </argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>ON</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands> </commands>
<commands name="Off" description="Deactivate fits importer" execMethod="off" displayLevel="OPERATOR" polledPeriod="0"> <commands name="Off" description="Deactivate fits importer" execMethod="off" displayLevel="OPERATOR" polledPeriod="0">
<argin description=""> <argin description="">
...@@ -119,7 +121,18 @@ ...@@ -119,7 +121,18 @@
<type xsi:type="pogoDsl:VoidType"/> <type xsi:type="pogoDsl:VoidType"/>
</argout> </argout>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<excludedStates>OFF</excludedStates>
<excludedStates>FAULT</excludedStates>
</commands> </commands>
<states name="ON" description="Metadata exporter is in ON state (ready to incoming connections)">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="OFF" description="Metadata exporter is in OFF state (not ready for incoming connections)">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<states name="FAULT" description="Metadata exporter is in FAULT state (an error occurred)">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/local/tango-8.1.2/share/pogo/preferences"/> <preferences docHome="./doc_html" makefileHome="/usr/local/tango-8.1.2/share/pogo/preferences"/>
</classes> </classes>
</pogoDsl:PogoSystem> </pogoDsl:PogoSystem>
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
//================================================================ //================================================================
// States | Description // States | Description
//================================================================ //================================================================
// ON | Metadata exporter is in ON state (ready to incoming connections)
// OFF | Metadata exporter is in OFF state (not ready for incoming connections)
// FAULT | Metadata exporter is in FAULT state (an error occurred)
namespace MetadataExporter_ns namespace MetadataExporter_ns
...@@ -61,10 +64,15 @@ namespace MetadataExporter_ns ...@@ -61,10 +64,15 @@ namespace MetadataExporter_ns
//-------------------------------------------------------- //--------------------------------------------------------
bool MetadataExporter::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any)) bool MetadataExporter::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(MetadataExporter::OnStateAllowed) ENABLED START -----*/ /*----- PROTECTED REGION ID(MetadataExporter::OnStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MetadataExporter::OnStateAllowed /*----- PROTECTED REGION END -----*/ // MetadataExporter::OnStateAllowed
return false;
}
return true; return true;
} }
...@@ -76,10 +84,15 @@ bool MetadataExporter::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any)) ...@@ -76,10 +84,15 @@ bool MetadataExporter::is_On_allowed(TANGO_UNUSED(const CORBA::Any &any))
//-------------------------------------------------------- //--------------------------------------------------------
bool MetadataExporter::is_Off_allowed(TANGO_UNUSED(const CORBA::Any &any)) bool MetadataExporter::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(MetadataExporter::OffStateAllowed) ENABLED START -----*/ /*----- PROTECTED REGION ID(MetadataExporter::OffStateAllowed) ENABLED START -----*/
/*----- PROTECTED REGION END -----*/ // MetadataExporter::OffStateAllowed /*----- PROTECTED REGION END -----*/ // MetadataExporter::OffStateAllowed
return false;
}
return true; return true;
} }
......
...@@ -81,7 +81,7 @@ protected: ...@@ -81,7 +81,7 @@ protected:
//Acceptor for incoming connection //Acceptor for incoming connection
boost::shared_ptr<boost::asio::ip::tcp::acceptor> m_acceptor_sp; boost::shared_ptr<boost::asio::ip::tcp::acceptor> m_acceptor_sp;
//Handler for all threads //Thread group container shared pointer
boost::shared_ptr<boost::thread_group> m_threadGroup_sp; boost::shared_ptr<boost::thread_group> m_threadGroup_sp;
//Tango state property mutex //Tango state property mutex
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment