Loading Makefile +4 −2 Original line number Diff line number Diff line Loading @@ -7,17 +7,19 @@ INSTALL_DIR=/usr/local/bin INC_DIR=/usr/local/omniORB/include \ /usr/local/zeromq/include/zmq \ /usr/local/tango/include/tango \ /usr/local/boost/include \ ./src LIB_DIR=/usr/local/omniORB/lib \ /usr/local/zeromq/lib \ /usr/local/tango/lib /usr/local/tango/lib \ /usr/local/boost/lib #================================================================================ CC=g++ CXX_DEBUG_FLAGS=-g -DVERBOSE_DEBUG CXX_RELEASE_FLAGS=-O3 CXX_DEFAULT_FLAGS=-c -Wall -Wextra -std=c++11 -std=gnu++11 LDFLAGS=-Wall -lomniORB4 -lomniDynamic4 -lCOS4 -lomnithread -ltango -llog4tango \ -lboost_thread -lboost_filesystem -lboost_system -lboost_thread -lboost_filesystem -lboost_system -lboost_chrono INC_PARM=$(foreach d, $(INC_DIR), -I$d) LIB_PARM=$(foreach d, $(LIB_DIR), -L$d) #================================================================================ Loading script/script.sh→script/fits.sh +104 −0 Original line number Diff line number Diff line #!/bin/bash #----------------------------------------------------------------------- # User parameters #----------------------------------------------------------------------- #Verify tool path VERIFY_TOOL="/home/mdm/workspace/nexecs/test/tools/fitsverify" CHECK_STRING="conform to the FITS format" #: Title : fits.sh #: Date : 2014/03/03 #: Author : "Marco De Marco" <demarco@oats.inaf.it> #: Version : 0.1 #: Description : Fits verification and preproccessing script #: Usage : #: Response : FATAL_ERROR="Fatal" EOF_ERROR="End-of-file" #----------------------------------------------------------------------- # Verify script #----------------------------------------------------------------------- if [ "$1" == "CHECK" ]; then #: Section : CHECK #: Parameter : none #: Response : CHECK OK #: : CHECK FATAL VERIFY_TOOL="/usr/local/bin/fitsverify" CHECK_STRING="conform to the FITS format" res=$($VERIFY_TOOL 2>&1) check=$(echo $res | grep "$CHECK_STRING" | wc | awk '{print $1}') if [ "$check" -ge "1" ]; then echo "CHECK OK" else echo "NOT OK" echo "CHECK FATAL" fi exit 0 else #Check regular expression -> fatal file=$1 elif [ "$1" == "VERIFY" ]; then #: Section : VERIFY #: Parameter : file path #: Response : VERIFY OK #: : VERIFY WAIT #: : VERIFY FATAL VERIFY_TOOL="/usr/local/bin/fitsverify" FATAL_ERROR="Fatal" EOF_ERROR="End-of-file" file=$2 file_name=${file##*/} if [[ ! "${file_name,,}" =~ ^[^\.].*\.(fits|fts).*$ ]]; then echo "FATAL" #Check regular expression -> fatal if [[ ! "${file_name,,}" =~ ^[^\.].*\.(fits|fit|fts).*$ ]]; then echo "VERIFY FATAL : error on regular expression" exit 0 fi #if fits verify tools exists -> fatal if [ ! -x $VERIFY_TOOL ]; then echo "FATAL" echo "VERIFY FATAL : verify tools not exists" exit 0 fi #if fits file not exists -> fatal if [ ! -f $1 ]; then echo "FATAL" if [ ! -f $file ]; then echo "VERIFY FATAL : file not exists" exit 0 fi #Check with fits verify res=$($VERIFY_TOOL $1 2>&1) res=$($VERIFY_TOOL $file 2>&1) #if fitsverify return fatal error -> wait fatal=$(echo $res | grep "$FATAL_ERROR" | wc | awk '{print $1}') if [ "$fatal" -ge "1" ]; then echo "WAIT" echo "VERIFY WAIT" exit 0 fi #if fitsverify return end of file -> wait eof=$(echo $res | grep "$EOF_ERROR" | wc | awk '{print $1}') if [ "$eof" -ge "1" ]; then echo "WAIT" echo "VERIFY WAIT" exit 0 fi #else -> ok echo "OK" echo "VERIFY OK" exit 0 elif [ "$1" == "PROCESS" ]; then #: Section : PROCESS #: Parameter : file path #: Response : PROCESS OK #: : PROCESS FATAL echo "PROCESS OK" exit 0 else #: Section : DEFAULT #: Parameter : none #: Response : UNKNOWN echo "UNKNOWN" exit 0 fi #----------------------------------------------------------------------- src/EventThread.cpp +13 −19 Original line number Diff line number Diff line #include <EventThread.h> #include <PreProcessor.h> #include <ScriptManager.h> #include <WorkerThread.h> #include <cassert> Loading @@ -9,6 +10,7 @@ #include <boost/filesystem.hpp> #include <boost/scoped_ptr.hpp> #include <boost/chrono.hpp> namespace PreProcessor_ns { Loading Loading @@ -62,8 +64,6 @@ void EventThread::start() try { initScriptManager(); initEventBuffer(); initINotify(); Loading Loading @@ -151,14 +151,6 @@ void EventThread::writeStatus(std::string status) m_status = status; } //============================================================================== // EventThread::initScriptManager() //============================================================================== void EventThread::initScriptManager() throw(std::runtime_error) { DEBUG_STREAM << "EventThread::initScriptManager()" << endl; } //============================================================================== // EventThread::initEventBuffer() //============================================================================== Loading Loading @@ -228,12 +220,15 @@ void EventThread::initThreadGroup() throw(std::runtime_error) { DEBUG_STREAM << "EventThread::initThreadGroup()" << endl; m_threadGroup_sp.reset(new boost::thread_group); ScriptManager::SP fileManager_sp = ScriptManager::create(m_preProcessor_p, m_configuration_sp); unsigned int workerNumber = m_configuration_sp->getWorkerNumber(); fileManager_sp->checkScriptCompliance(); WorkerThread worker(m_preProcessor_p, m_eventBuffer_sp, fileManager_sp, m_configuration_sp); //Create a worker thread and pass all arguments WorkerThread worker(m_preProcessor_p, m_eventBuffer_sp, m_configuration_sp); m_threadGroup_sp.reset(new boost::thread_group); try { Loading @@ -241,6 +236,8 @@ void EventThread::initThreadGroup() throw(std::runtime_error) m_threadGroup_sp->add_thread( new boost::thread(&EventThread::eventLoop, this)); unsigned int workerNumber = m_configuration_sp->getWorkerNumber(); //Add to thread group worker threads for(unsigned int i=0; i<workerNumber; i++) m_threadGroup_sp->add_thread( Loading Loading @@ -295,8 +292,6 @@ void EventThread::eventLoop() { event = ( struct inotify_event * ) &buffer[ i ]; DEBUG_STREAM << "EVENT: " << event->name << endl; //TODO: delete me //Add path to file name boost::filesystem::path file(event->name); boost::filesystem::path path(watchPath); Loading @@ -311,8 +306,7 @@ void EventThread::eventLoop() DEBUG_STREAM << "EventThread::eventLoop() sleep for " << sleepTime << endl; boost::posix_time::milliseconds sleepPosixTime(sleepTime); boost::this_thread::sleep(sleepPosixTime); boost::this_thread::sleep_for(boost::chrono::seconds(sleepTime)); } catch(boost::thread_interrupted& ex) { Loading @@ -335,7 +329,7 @@ void EventThread::eventLoop() writeState(Tango::ALARM); writeStatus("Event thread unknown exception"); } } //while } //thread loop } } //namespace src/EventThread.h +0 −2 Original line number Diff line number Diff line Loading @@ -72,8 +72,6 @@ protected: //------------------------------------------------------------------------------ // [Protected] Initialization methods //------------------------------------------------------------------------------ virtual void initScriptManager() throw(std::runtime_error); virtual void initEventBuffer() throw(std::runtime_error); virtual void initINotify() throw(std::runtime_error); Loading src/PreProcessor.cpp +36 −24 Original line number Diff line number Diff line Loading @@ -157,6 +157,17 @@ void PreProcessor::init_device() /*----- PROTECTED REGION ID(PreProcessor::init_device) ENABLED START -----*/ //Initialize regular file counters to zero *attr_RegularFileCounter_read = 0; //Initialize warning file counters to zero *attr_WarningFileCounter_read = 0; //Initialize error file counters to zero *attr_ErrorFileCounter_read = 0; if(get_state() != Tango::FAULT) { try { //Create event thread Loading @@ -165,7 +176,7 @@ void PreProcessor::init_device() //Start device if auto start enabled if(autoStart) { INFO_STREAM << "FitsImporter::init_device() auto start enabled " << endl; INFO_STREAM << "PreProcessor::init_device() auto start enabled " << endl; on(); } } Loading @@ -181,6 +192,7 @@ void PreProcessor::init_device() set_state(Tango::FAULT); set_status("PreProcessor::init_device() unknown error"); } } /*----- PROTECTED REGION END -----*/ // PreProcessor::init_device } Loading Loading @@ -356,8 +368,8 @@ void PreProcessor::get_device_property() if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER) throw(invalid_argument("WorkerNumber property out of range or not defined")); m_configuration_sp = Configuration::create(watchPath, destPath, scriptPath, workerNumber, sleepTime, waitTime, inotifyMask); m_configuration_sp = Configuration::create(watchPath, destPath, scriptPath, workerNumber, sleepTime, waitTime, inotifyMask); } catch(invalid_argument& ex) { Loading @@ -378,7 +390,7 @@ void PreProcessor::get_device_property() //-------------------------------------------------------- void PreProcessor::always_executed_hook() { INFO_STREAM << "PreProcessor::always_executed_hook() " << device_name << endl; DEBUG_STREAM << "PreProcessor::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(PreProcessor::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) Loading Loading
Makefile +4 −2 Original line number Diff line number Diff line Loading @@ -7,17 +7,19 @@ INSTALL_DIR=/usr/local/bin INC_DIR=/usr/local/omniORB/include \ /usr/local/zeromq/include/zmq \ /usr/local/tango/include/tango \ /usr/local/boost/include \ ./src LIB_DIR=/usr/local/omniORB/lib \ /usr/local/zeromq/lib \ /usr/local/tango/lib /usr/local/tango/lib \ /usr/local/boost/lib #================================================================================ CC=g++ CXX_DEBUG_FLAGS=-g -DVERBOSE_DEBUG CXX_RELEASE_FLAGS=-O3 CXX_DEFAULT_FLAGS=-c -Wall -Wextra -std=c++11 -std=gnu++11 LDFLAGS=-Wall -lomniORB4 -lomniDynamic4 -lCOS4 -lomnithread -ltango -llog4tango \ -lboost_thread -lboost_filesystem -lboost_system -lboost_thread -lboost_filesystem -lboost_system -lboost_chrono INC_PARM=$(foreach d, $(INC_DIR), -I$d) LIB_PARM=$(foreach d, $(LIB_DIR), -L$d) #================================================================================ Loading
script/script.sh→script/fits.sh +104 −0 Original line number Diff line number Diff line #!/bin/bash #----------------------------------------------------------------------- # User parameters #----------------------------------------------------------------------- #Verify tool path VERIFY_TOOL="/home/mdm/workspace/nexecs/test/tools/fitsverify" CHECK_STRING="conform to the FITS format" #: Title : fits.sh #: Date : 2014/03/03 #: Author : "Marco De Marco" <demarco@oats.inaf.it> #: Version : 0.1 #: Description : Fits verification and preproccessing script #: Usage : #: Response : FATAL_ERROR="Fatal" EOF_ERROR="End-of-file" #----------------------------------------------------------------------- # Verify script #----------------------------------------------------------------------- if [ "$1" == "CHECK" ]; then #: Section : CHECK #: Parameter : none #: Response : CHECK OK #: : CHECK FATAL VERIFY_TOOL="/usr/local/bin/fitsverify" CHECK_STRING="conform to the FITS format" res=$($VERIFY_TOOL 2>&1) check=$(echo $res | grep "$CHECK_STRING" | wc | awk '{print $1}') if [ "$check" -ge "1" ]; then echo "CHECK OK" else echo "NOT OK" echo "CHECK FATAL" fi exit 0 else #Check regular expression -> fatal file=$1 elif [ "$1" == "VERIFY" ]; then #: Section : VERIFY #: Parameter : file path #: Response : VERIFY OK #: : VERIFY WAIT #: : VERIFY FATAL VERIFY_TOOL="/usr/local/bin/fitsverify" FATAL_ERROR="Fatal" EOF_ERROR="End-of-file" file=$2 file_name=${file##*/} if [[ ! "${file_name,,}" =~ ^[^\.].*\.(fits|fts).*$ ]]; then echo "FATAL" #Check regular expression -> fatal if [[ ! "${file_name,,}" =~ ^[^\.].*\.(fits|fit|fts).*$ ]]; then echo "VERIFY FATAL : error on regular expression" exit 0 fi #if fits verify tools exists -> fatal if [ ! -x $VERIFY_TOOL ]; then echo "FATAL" echo "VERIFY FATAL : verify tools not exists" exit 0 fi #if fits file not exists -> fatal if [ ! -f $1 ]; then echo "FATAL" if [ ! -f $file ]; then echo "VERIFY FATAL : file not exists" exit 0 fi #Check with fits verify res=$($VERIFY_TOOL $1 2>&1) res=$($VERIFY_TOOL $file 2>&1) #if fitsverify return fatal error -> wait fatal=$(echo $res | grep "$FATAL_ERROR" | wc | awk '{print $1}') if [ "$fatal" -ge "1" ]; then echo "WAIT" echo "VERIFY WAIT" exit 0 fi #if fitsverify return end of file -> wait eof=$(echo $res | grep "$EOF_ERROR" | wc | awk '{print $1}') if [ "$eof" -ge "1" ]; then echo "WAIT" echo "VERIFY WAIT" exit 0 fi #else -> ok echo "OK" echo "VERIFY OK" exit 0 elif [ "$1" == "PROCESS" ]; then #: Section : PROCESS #: Parameter : file path #: Response : PROCESS OK #: : PROCESS FATAL echo "PROCESS OK" exit 0 else #: Section : DEFAULT #: Parameter : none #: Response : UNKNOWN echo "UNKNOWN" exit 0 fi #-----------------------------------------------------------------------
src/EventThread.cpp +13 −19 Original line number Diff line number Diff line #include <EventThread.h> #include <PreProcessor.h> #include <ScriptManager.h> #include <WorkerThread.h> #include <cassert> Loading @@ -9,6 +10,7 @@ #include <boost/filesystem.hpp> #include <boost/scoped_ptr.hpp> #include <boost/chrono.hpp> namespace PreProcessor_ns { Loading Loading @@ -62,8 +64,6 @@ void EventThread::start() try { initScriptManager(); initEventBuffer(); initINotify(); Loading Loading @@ -151,14 +151,6 @@ void EventThread::writeStatus(std::string status) m_status = status; } //============================================================================== // EventThread::initScriptManager() //============================================================================== void EventThread::initScriptManager() throw(std::runtime_error) { DEBUG_STREAM << "EventThread::initScriptManager()" << endl; } //============================================================================== // EventThread::initEventBuffer() //============================================================================== Loading Loading @@ -228,12 +220,15 @@ void EventThread::initThreadGroup() throw(std::runtime_error) { DEBUG_STREAM << "EventThread::initThreadGroup()" << endl; m_threadGroup_sp.reset(new boost::thread_group); ScriptManager::SP fileManager_sp = ScriptManager::create(m_preProcessor_p, m_configuration_sp); unsigned int workerNumber = m_configuration_sp->getWorkerNumber(); fileManager_sp->checkScriptCompliance(); WorkerThread worker(m_preProcessor_p, m_eventBuffer_sp, fileManager_sp, m_configuration_sp); //Create a worker thread and pass all arguments WorkerThread worker(m_preProcessor_p, m_eventBuffer_sp, m_configuration_sp); m_threadGroup_sp.reset(new boost::thread_group); try { Loading @@ -241,6 +236,8 @@ void EventThread::initThreadGroup() throw(std::runtime_error) m_threadGroup_sp->add_thread( new boost::thread(&EventThread::eventLoop, this)); unsigned int workerNumber = m_configuration_sp->getWorkerNumber(); //Add to thread group worker threads for(unsigned int i=0; i<workerNumber; i++) m_threadGroup_sp->add_thread( Loading Loading @@ -295,8 +292,6 @@ void EventThread::eventLoop() { event = ( struct inotify_event * ) &buffer[ i ]; DEBUG_STREAM << "EVENT: " << event->name << endl; //TODO: delete me //Add path to file name boost::filesystem::path file(event->name); boost::filesystem::path path(watchPath); Loading @@ -311,8 +306,7 @@ void EventThread::eventLoop() DEBUG_STREAM << "EventThread::eventLoop() sleep for " << sleepTime << endl; boost::posix_time::milliseconds sleepPosixTime(sleepTime); boost::this_thread::sleep(sleepPosixTime); boost::this_thread::sleep_for(boost::chrono::seconds(sleepTime)); } catch(boost::thread_interrupted& ex) { Loading @@ -335,7 +329,7 @@ void EventThread::eventLoop() writeState(Tango::ALARM); writeStatus("Event thread unknown exception"); } } //while } //thread loop } } //namespace
src/EventThread.h +0 −2 Original line number Diff line number Diff line Loading @@ -72,8 +72,6 @@ protected: //------------------------------------------------------------------------------ // [Protected] Initialization methods //------------------------------------------------------------------------------ virtual void initScriptManager() throw(std::runtime_error); virtual void initEventBuffer() throw(std::runtime_error); virtual void initINotify() throw(std::runtime_error); Loading
src/PreProcessor.cpp +36 −24 Original line number Diff line number Diff line Loading @@ -157,6 +157,17 @@ void PreProcessor::init_device() /*----- PROTECTED REGION ID(PreProcessor::init_device) ENABLED START -----*/ //Initialize regular file counters to zero *attr_RegularFileCounter_read = 0; //Initialize warning file counters to zero *attr_WarningFileCounter_read = 0; //Initialize error file counters to zero *attr_ErrorFileCounter_read = 0; if(get_state() != Tango::FAULT) { try { //Create event thread Loading @@ -165,7 +176,7 @@ void PreProcessor::init_device() //Start device if auto start enabled if(autoStart) { INFO_STREAM << "FitsImporter::init_device() auto start enabled " << endl; INFO_STREAM << "PreProcessor::init_device() auto start enabled " << endl; on(); } } Loading @@ -181,6 +192,7 @@ void PreProcessor::init_device() set_state(Tango::FAULT); set_status("PreProcessor::init_device() unknown error"); } } /*----- PROTECTED REGION END -----*/ // PreProcessor::init_device } Loading Loading @@ -356,8 +368,8 @@ void PreProcessor::get_device_property() if(workerNumber<1 || workerNumber>MAX_WORKER_NUMBER) throw(invalid_argument("WorkerNumber property out of range or not defined")); m_configuration_sp = Configuration::create(watchPath, destPath, scriptPath, workerNumber, sleepTime, waitTime, inotifyMask); m_configuration_sp = Configuration::create(watchPath, destPath, scriptPath, workerNumber, sleepTime, waitTime, inotifyMask); } catch(invalid_argument& ex) { Loading @@ -378,7 +390,7 @@ void PreProcessor::get_device_property() //-------------------------------------------------------- void PreProcessor::always_executed_hook() { INFO_STREAM << "PreProcessor::always_executed_hook() " << device_name << endl; DEBUG_STREAM << "PreProcessor::always_executed_hook() " << device_name << endl; /*----- PROTECTED REGION ID(PreProcessor::always_executed_hook) ENABLED START -----*/ if(get_state() != Tango::FAULT) Loading