ArtExecutionContext.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 /*
00020  * $Log$
00021  */
00022 
00023 #include "ArtExecutionContext.h"
00024 #include <rtm/ECFactory.h>
00025 #include <linux/art_task.h>
00026 
00027 #include <iostream>
00028 
00029 namespace RTC
00030 {
00031   ArtExecutionContext::ArtExecutionContext()
00032     : PeriodicExecutionContext(),
00033       m_priority(ART_PRIO_MAX-1)
00034   {
00035       rtclog.setName("ArtEC");
00036       coil::Properties& prop(Manager::instance().getConfig());
00037 
00038       // Priority
00039       getProperty(prop, "exec_cxt.periodic.priority", m_priority);
00040       getProperty(prop, "exec_cxt.periodic.art.priority", m_priority);
00041       RTC_DEBUG(("Priority: %d", m_priority));
00042 
00043   }
00044 
00045   ArtExecutionContext::~ArtExecutionContext()
00046   {
00047   }
00048 
00049 
00050   int ArtExecutionContext::svc(void)
00051   {
00052     int usec(m_period.sec() * 1000000 + m_period.usec());
00053     if (art_enter(m_priority, ART_TASK_PERIODIC, usec) == -1)
00054       {
00055         std::cerr << "fatal error: art_enter" << std::endl;
00056       }
00057     do
00058       {
00059         std::for_each(m_comps.begin(), m_comps.end(), invoke_worker());
00060         //      while (!m_running) {ACE_OS::sleep(tv);}
00061         if (art_wait() == -1)
00062           {
00063             std::cerr << "fatal error: art_wait " << std::endl;
00064           }
00065       } while (m_running);
00066 
00067     if (art_exit() == -1)
00068       {
00069         std::cerr << "fatal error: art_exit" << std::endl;
00070       }
00071     return 0;
00072   }
00073 };
00074 
00075 
00076 extern "C"
00077 {
00078   void ArtExecutionContextInit(RTC::Manager* manager)
00079   {
00080     RTC::Manager::instance().registerECFactory("ArtExecutionContext",
00081                                RTC::ECCreate<RTC::ArtExecutionContext>,
00082                                RTC::ECDelete<RTC::ArtExecutionContext>);
00083     
00084   }
00085 };


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:03