Loading src/EventThread.cpp +98 −76 Original line number Diff line number Diff line Loading @@ -61,10 +61,12 @@ EventThread::SP EventThread::create(FitsImporter* fitsImporter_p, //============================================================================== // EventThread::start() //============================================================================== void EventThread::start() throw(std::runtime_error) void EventThread::start() { DEBUG_STREAM << "EventThread::start()" << endl; try { initEventBuffer(); initINotify(); Loading @@ -75,6 +77,19 @@ void EventThread::start() throw(std::runtime_error) initThreadGroup(); } catch(std::exception& ex) { std::stringstream error_stream; error_stream << "Event thread not running " << ex.what(); writeState(Tango::ALARM); writeStatus(error_stream.str()); } catch(...) { writeState(Tango::ALARM); writeStatus("Event thread unknown exception"); } } //============================================================================== // EventThread::stop() Loading Loading @@ -119,6 +134,30 @@ std::string EventThread::readStatus() return m_status; } //============================================================================== // EventThread::writeState() //============================================================================== void EventThread::writeState(Tango::DevState state) { DEBUG_STREAM << "Client::writeState()" << endl; boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = state; } //============================================================================== // EventThread::writeStatus() //============================================================================== void EventThread::writeStatus(std::string status) { DEBUG_STREAM << "Client::writeStatus()" << endl; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = status; } //============================================================================== // EventThread::initEventBuffer() //============================================================================== Loading Loading @@ -264,28 +303,19 @@ void EventThread::eventLoop() { if(errno != EINTR && errno != EAGAIN) { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ALARM; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread error on watch path read"; writeState(Tango::ALARM); writeStatus("Event thread error on watch path read"); } else { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ON; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread running"; writeState(Tango::ON); writeStatus("Event thread running"); } } else { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ON; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread new data found"; writeState(Tango::ON); writeStatus("Event thread new data found"); } struct inotify_event *event; Loading Loading @@ -316,30 +346,22 @@ void EventThread::eventLoop() { DEBUG_STREAM << "EventThread::eventLoop() stopping loop" << endl; boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::OFF; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread not running"; writeState(Tango::OFF); writeStatus("Event thread not running"); break; } catch(std::exception& ex) { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ALARM; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread "; m_status.append(ex.what()); std::stringstream error_stream; error_stream << "Event thread not running " << ex.what(); writeState(Tango::ALARM); writeStatus(error_stream.str()); } catch(...) { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ALARM; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread unknown exception"; writeState(Tango::ALARM); writeStatus("Event thread unknown exception"); } } //while } Loading src/EventThread.h +38 −25 Original line number Diff line number Diff line Loading @@ -46,20 +46,33 @@ protected: public: //------------------------------------------------------------------------------ // [Public] Users methods // [Public] Class creation method //------------------------------------------------------------------------------ static EventThread::SP create(FitsImporter*, Configuration::SP, Instrument::SPVector, Instrument::SP); virtual void start() throw(std::runtime_error); //------------------------------------------------------------------------------ // [Public] Thread management methods //------------------------------------------------------------------------------ virtual void start(); virtual void stop(); //------------------------------------------------------------------------------ // [Public] Read state and status methods //------------------------------------------------------------------------------ virtual Tango::DevState readState(); virtual std::string readStatus(); protected: //------------------------------------------------------------------------------ // [Protected] Write state and status methods //------------------------------------------------------------------------------ virtual void writeState(Tango::DevState); virtual void writeStatus(std::string); //------------------------------------------------------------------------------ // [Protected] Utilities methods //------------------------------------------------------------------------------ Loading Loading
src/EventThread.cpp +98 −76 Original line number Diff line number Diff line Loading @@ -61,10 +61,12 @@ EventThread::SP EventThread::create(FitsImporter* fitsImporter_p, //============================================================================== // EventThread::start() //============================================================================== void EventThread::start() throw(std::runtime_error) void EventThread::start() { DEBUG_STREAM << "EventThread::start()" << endl; try { initEventBuffer(); initINotify(); Loading @@ -75,6 +77,19 @@ void EventThread::start() throw(std::runtime_error) initThreadGroup(); } catch(std::exception& ex) { std::stringstream error_stream; error_stream << "Event thread not running " << ex.what(); writeState(Tango::ALARM); writeStatus(error_stream.str()); } catch(...) { writeState(Tango::ALARM); writeStatus("Event thread unknown exception"); } } //============================================================================== // EventThread::stop() Loading Loading @@ -119,6 +134,30 @@ std::string EventThread::readStatus() return m_status; } //============================================================================== // EventThread::writeState() //============================================================================== void EventThread::writeState(Tango::DevState state) { DEBUG_STREAM << "Client::writeState()" << endl; boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = state; } //============================================================================== // EventThread::writeStatus() //============================================================================== void EventThread::writeStatus(std::string status) { DEBUG_STREAM << "Client::writeStatus()" << endl; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = status; } //============================================================================== // EventThread::initEventBuffer() //============================================================================== Loading Loading @@ -264,28 +303,19 @@ void EventThread::eventLoop() { if(errno != EINTR && errno != EAGAIN) { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ALARM; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread error on watch path read"; writeState(Tango::ALARM); writeStatus("Event thread error on watch path read"); } else { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ON; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread running"; writeState(Tango::ON); writeStatus("Event thread running"); } } else { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ON; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread new data found"; writeState(Tango::ON); writeStatus("Event thread new data found"); } struct inotify_event *event; Loading Loading @@ -316,30 +346,22 @@ void EventThread::eventLoop() { DEBUG_STREAM << "EventThread::eventLoop() stopping loop" << endl; boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::OFF; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread not running"; writeState(Tango::OFF); writeStatus("Event thread not running"); break; } catch(std::exception& ex) { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ALARM; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread "; m_status.append(ex.what()); std::stringstream error_stream; error_stream << "Event thread not running " << ex.what(); writeState(Tango::ALARM); writeStatus(error_stream.str()); } catch(...) { boost::mutex::scoped_lock stateLock(m_stateMutex); m_state = Tango::ALARM; boost::mutex::scoped_lock statusLock(m_statusMutex); m_status = "Event thread unknown exception"; writeState(Tango::ALARM); writeStatus("Event thread unknown exception"); } } //while } Loading
src/EventThread.h +38 −25 Original line number Diff line number Diff line Loading @@ -46,20 +46,33 @@ protected: public: //------------------------------------------------------------------------------ // [Public] Users methods // [Public] Class creation method //------------------------------------------------------------------------------ static EventThread::SP create(FitsImporter*, Configuration::SP, Instrument::SPVector, Instrument::SP); virtual void start() throw(std::runtime_error); //------------------------------------------------------------------------------ // [Public] Thread management methods //------------------------------------------------------------------------------ virtual void start(); virtual void stop(); //------------------------------------------------------------------------------ // [Public] Read state and status methods //------------------------------------------------------------------------------ virtual Tango::DevState readState(); virtual std::string readStatus(); protected: //------------------------------------------------------------------------------ // [Protected] Write state and status methods //------------------------------------------------------------------------------ virtual void writeState(Tango::DevState); virtual void writeStatus(std::string); //------------------------------------------------------------------------------ // [Protected] Utilities methods //------------------------------------------------------------------------------ Loading