RTno is communicating library and framework which allows you to make your embedded device capable of communicating with RT-middleware world. RT-middleware is a platform software to realize Robotic system. In RTM, robots are developed by constructing robotics technologies\' elements (components) named RT-component. Therefore, the RTno helps you to create your own RT-component with your mbed and arduino. To know how to use your RTno device, visit here: http://ysuga.net/robot_e/rtm_e/rtc_e/1065?lang=en To know about RT-middleware and RT-component, visit http://www.openrtm.org
Dependencies: EthernetInterface mbed-rtos
ExecutionContext.cpp@0:5f7bc45bc2e8, 2013-06-24 (annotated)
- Committer:
- ysuga
- Date:
- Mon Jun 24 06:42:11 2013 +0000
- Revision:
- 0:5f7bc45bc2e8
[mbed] converted /RTnoV3/RTnoV3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ysuga | 0:5f7bc45bc2e8 | 1 | #define RTNO_SUBMODULE_DEFINE |
ysuga | 0:5f7bc45bc2e8 | 2 | |
ysuga | 0:5f7bc45bc2e8 | 3 | #include <stdint.h> |
ysuga | 0:5f7bc45bc2e8 | 4 | #include "RTno.h" |
ysuga | 0:5f7bc45bc2e8 | 5 | #include "Packet.h" |
ysuga | 0:5f7bc45bc2e8 | 6 | |
ysuga | 0:5f7bc45bc2e8 | 7 | #include "ExecutionContext.h" |
ysuga | 0:5f7bc45bc2e8 | 8 | |
ysuga | 0:5f7bc45bc2e8 | 9 | static int8_t m_Type; |
ysuga | 0:5f7bc45bc2e8 | 10 | static LifeCycleState m_Condition; |
ysuga | 0:5f7bc45bc2e8 | 11 | |
ysuga | 0:5f7bc45bc2e8 | 12 | void EC_init(int8_t Type) { |
ysuga | 0:5f7bc45bc2e8 | 13 | m_Type = Type; |
ysuga | 0:5f7bc45bc2e8 | 14 | m_Condition = RTC_STATE_INACTIVE; |
ysuga | 0:5f7bc45bc2e8 | 15 | } |
ysuga | 0:5f7bc45bc2e8 | 16 | |
ysuga | 0:5f7bc45bc2e8 | 17 | int8_t EC_get_type() { |
ysuga | 0:5f7bc45bc2e8 | 18 | return m_Type; |
ysuga | 0:5f7bc45bc2e8 | 19 | } |
ysuga | 0:5f7bc45bc2e8 | 20 | |
ysuga | 0:5f7bc45bc2e8 | 21 | LifeCycleState EC_get_component_state() { |
ysuga | 0:5f7bc45bc2e8 | 22 | return m_Condition; |
ysuga | 0:5f7bc45bc2e8 | 23 | } |
ysuga | 0:5f7bc45bc2e8 | 24 | |
ysuga | 0:5f7bc45bc2e8 | 25 | ReturnValue_t EC_activate_component() { |
ysuga | 0:5f7bc45bc2e8 | 26 | if(m_Condition != RTC_STATE_INACTIVE) { |
ysuga | 0:5f7bc45bc2e8 | 27 | return RTC_PRECONDITION_NOT_MET; |
ysuga | 0:5f7bc45bc2e8 | 28 | } |
ysuga | 0:5f7bc45bc2e8 | 29 | |
ysuga | 0:5f7bc45bc2e8 | 30 | if(RTno::onActivated() == RTC_OK) { |
ysuga | 0:5f7bc45bc2e8 | 31 | m_Condition = RTC_STATE_ACTIVE; |
ysuga | 0:5f7bc45bc2e8 | 32 | return RTC_OK; |
ysuga | 0:5f7bc45bc2e8 | 33 | } |
ysuga | 0:5f7bc45bc2e8 | 34 | |
ysuga | 0:5f7bc45bc2e8 | 35 | m_Condition = RTC_STATE_ERROR; |
ysuga | 0:5f7bc45bc2e8 | 36 | return RTC_ERROR; |
ysuga | 0:5f7bc45bc2e8 | 37 | } |
ysuga | 0:5f7bc45bc2e8 | 38 | |
ysuga | 0:5f7bc45bc2e8 | 39 | |
ysuga | 0:5f7bc45bc2e8 | 40 | ReturnValue_t EC_deactivate_component() { |
ysuga | 0:5f7bc45bc2e8 | 41 | if(m_Condition != RTC_STATE_ACTIVE) { |
ysuga | 0:5f7bc45bc2e8 | 42 | return RTC_PRECONDITION_NOT_MET; |
ysuga | 0:5f7bc45bc2e8 | 43 | } |
ysuga | 0:5f7bc45bc2e8 | 44 | |
ysuga | 0:5f7bc45bc2e8 | 45 | if(RTno::onDeactivated() == RTC_OK) { |
ysuga | 0:5f7bc45bc2e8 | 46 | m_Condition = RTC_STATE_INACTIVE; |
ysuga | 0:5f7bc45bc2e8 | 47 | return RTC_OK; |
ysuga | 0:5f7bc45bc2e8 | 48 | } else { |
ysuga | 0:5f7bc45bc2e8 | 49 | m_Condition = RTC_STATE_ERROR; |
ysuga | 0:5f7bc45bc2e8 | 50 | return RTC_ERROR; |
ysuga | 0:5f7bc45bc2e8 | 51 | } |
ysuga | 0:5f7bc45bc2e8 | 52 | } |
ysuga | 0:5f7bc45bc2e8 | 53 | |
ysuga | 0:5f7bc45bc2e8 | 54 | ReturnValue_t EC_execute() { |
ysuga | 0:5f7bc45bc2e8 | 55 | if(m_Condition != RTC_STATE_ACTIVE) { |
ysuga | 0:5f7bc45bc2e8 | 56 | return RTC_PRECONDITION_NOT_MET; |
ysuga | 0:5f7bc45bc2e8 | 57 | } |
ysuga | 0:5f7bc45bc2e8 | 58 | |
ysuga | 0:5f7bc45bc2e8 | 59 | if(RTno::onExecute() == RTC_OK) { |
ysuga | 0:5f7bc45bc2e8 | 60 | return RTC_OK; |
ysuga | 0:5f7bc45bc2e8 | 61 | } else { |
ysuga | 0:5f7bc45bc2e8 | 62 | m_Condition = RTC_STATE_ERROR; |
ysuga | 0:5f7bc45bc2e8 | 63 | return RTC_ERROR; |
ysuga | 0:5f7bc45bc2e8 | 64 | } |
ysuga | 0:5f7bc45bc2e8 | 65 | } |
ysuga | 0:5f7bc45bc2e8 | 66 | |
ysuga | 0:5f7bc45bc2e8 | 67 | ReturnValue_t EC_error() { |
ysuga | 0:5f7bc45bc2e8 | 68 | if(m_Condition != RTC_STATE_ERROR) { |
ysuga | 0:5f7bc45bc2e8 | 69 | return RTC_PRECONDITION_NOT_MET; |
ysuga | 0:5f7bc45bc2e8 | 70 | } |
ysuga | 0:5f7bc45bc2e8 | 71 | |
ysuga | 0:5f7bc45bc2e8 | 72 | RTno::onError(); |
ysuga | 0:5f7bc45bc2e8 | 73 | return RTC_OK; |
ysuga | 0:5f7bc45bc2e8 | 74 | } |
ysuga | 0:5f7bc45bc2e8 | 75 | |
ysuga | 0:5f7bc45bc2e8 | 76 | |
ysuga | 0:5f7bc45bc2e8 | 77 | #ifdef __cplusplus |
ysuga | 0:5f7bc45bc2e8 | 78 | extern "C" { |
ysuga | 0:5f7bc45bc2e8 | 79 | #endif |
ysuga | 0:5f7bc45bc2e8 | 80 | |
ysuga | 0:5f7bc45bc2e8 | 81 | void (*EC_start)(); |
ysuga | 0:5f7bc45bc2e8 | 82 | void (*EC_resume)(); |
ysuga | 0:5f7bc45bc2e8 | 83 | void (*EC_suspend)(); |
ysuga | 0:5f7bc45bc2e8 | 84 | |
ysuga | 0:5f7bc45bc2e8 | 85 | #ifdef __cplusplus |
ysuga | 0:5f7bc45bc2e8 | 86 | } |
ysuga | 0:5f7bc45bc2e8 | 87 | #endif |