OpenEL 3.0.0

openEL.h
Go to the documentation of this file.
1
12 /*
13
14 Copyright (c) 2017,2018 Japan Embedded Systems Technology Association(JASA)
15 All rights reserved.
16
17 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
18
19 Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
20 Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
21 Neither the name of the Association nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25 #ifndef OPENEL_H
26 #define OPENEL_H
27
28 #ifdef __cplusplus
29 namespace el {
30 extern "C" {
31 #endif /* __cplusplus */
32
33 #include <stdint.h>
34
35 /* Macro (global scope) */
36 /*---------------------------------------------------------------------------*/
37
38 #define OPENEL_MAJOR 3
39 #define OPENEL_MINOR 0
40 #define OPENEL_PATCHLEVEL 0
41 #define OPENEL_VERSION "OpenEL 3.0.0"
42
43 /* C PSM */
44 enum ReturnCode {
45 HAL_OK = 0,
46 HAL_ERROR
47 };
48
49 /* typedef definition */
50 typedef float float32_t;
51 typedef double float64_t;
52 #if 1
53 typedef float32_t halfloat;
54 #else
55 typedef float64_t halfloat;
56 #endif
57
58 typedef struct HALId {
59 int32_t deviceKindId;
60 int32_t vendorId;
61 int32_t productId;
62 int32_t instanceId;
63 } HALID_T;
64
65 typedef struct Property {
66 HALID_T halId;
67 char deviceName[32];
68 char functionList[32][32];
69 } PROPERTY_T;
70
71 typedef union HalComponent HALCOMPONENT_T;
72
73 typedef struct HALObserver {
74 void (*notify_event)(HALCOMPONENT_T *halComponent, int32_t event_id);
75 void (*notify_error)(HALCOMPONENT_T *halComponent, int32_t error_id);
76 } HALOBSERVER_T;
77
78 typedef struct HALObserver HALOBSERVER_T;
79
80 #define HALCOMPONENT_MEMBER \
81 int32_t handle; \
82 HALID_T halId;\
83 PROPERTY_T property;\
84 HALOBSERVER_T observerList[8];\
85 int32_t time;
86
87 typedef struct HALComponent {
88 HALCOMPONENT_MEMBER
89 } HALCOMPONENT_CORE_T;
90
91 enum ReturnCode HalInit(HALCOMPONENT_T *halComponent);
92 enum ReturnCode HalReInit(HALCOMPONENT_T *halComponent);
93 enum ReturnCode HalFinalize(HALCOMPONENT_T *halComponent);
94 enum ReturnCode HalAddObserver(HALCOMPONENT_T *halComponent, HALOBSERVER_T *halObserver);
95 enum ReturnCode HalRemoveObserver(HALCOMPONENT_T *halComponent, HALOBSERVER_T *halObserver);
96 enum ReturnCode HalGetProperty(HALCOMPONENT_T *halComponent, PROPERTY_T *property);
97 enum ReturnCode HalGetTime(HALCOMPONENT_T *halComponent, int32_t *time);
98
99 typedef struct EventTimer EVENTTIMER_T;
100
101 typedef struct TimerObserver {
102 void (*notify_timer)(EVENTTIMER_T *eventTimer);
103 } TIMEROBSERVER_T;
104
105 typedef struct EventTimer {
106 TIMEROBSERVER_T observerList[8];
107 } EVENTTIMER_T;
108
109 enum ReturnCode HalEventTimerStartTimer(EVENTTIMER_T *eventTimer);
110 enum ReturnCode HalEventTimerStopTimer(EVENTTIMER_T *eventTimer);
111 enum ReturnCode HalEventTimerSetEventPeriod(EVENTTIMER_T *eventTimer, int32_t eventPeriod);
112 enum ReturnCode HalEventTimerAddObserver(EVENTTIMER_T *eventTimer, TIMEROBSERVER_T *timerObserver);
113 enum ReturnCode HalEventTimerRemoveObserver(EVENTTIMER_T *eventTimer, TIMEROBSERVER_T *timerObserver);
114
115
116 typedef struct PositionControlActuator {
117 /* HALCOMPONENT */
118 HALCOMPONENT_MEMBER
119 /* POSITIONCONTROLACTUATOR */
120 halfloat actualPosition;
121 } POSITIONCONTROLACTUATOR_T;
122
123 enum ReturnCode HalSetPosition(HALCOMPONENT_T *positionControlActuator, halfloat position);
124 enum ReturnCode HalGetPosition(HALCOMPONENT_T *positionControlActuator, halfloat *position);
125
126 typedef struct VelocityControlActuator {
127 /* HALCOMPONENT */
128 HALCOMPONENT_MEMBER
129 /* VELOCITYCONTROLACTUATOR */
130 halfloat actualVelocity;
131 } VELOCITYCONTROLACTUATOR_T;
132
133 enum ReturnCode HalSetVelocity(HALCOMPONENT_T *velocityControlActuator, halfloat velocity);
134 enum ReturnCode HalGetVelocity(HALCOMPONENT_T *velocityControlActuator, halfloat *velocity);
135
136 typedef struct TorqueControlActuator {
137 /* HALCOMPONENT */
138 HALCOMPONENT_MEMBER
139 /* TORQUECONTROLACTUATOR */
140 halfloat actualTorque;
141 } TORQUECONTROLACTUATOR_T;
142
143 enum ReturnCode HalSetTorque(HALCOMPONENT_T *torqueControlActuator, halfloat torque);
144 enum ReturnCode HalGetTorque(HALCOMPONENT_T *torqueControlActuator, halfloat *torque);
145
146 typedef struct TorqueSensor {
147 /* HALCOMPONENT */
148 HALCOMPONENT_MEMBER
149 /* SENSOR */
150 halfloat value[32];
151 char units[32][32];
152 } TORQUESENSOR_T;
153
154 enum ReturnCode HalTorqueSensorGetValue(HALCOMPONENT_T *torqueSensor, halfloat *list);
155 enum ReturnCode HalTorqueSensorGetTimedValue(HALCOMPONENT_T *torqueSensor, halfloat *list, int32_t *timer);
156 enum ReturnCode HalTorqueSensorSetUnit(HALCOMPONENT_T *torqueSensor, char units);
157 enum ReturnCode HalTorqueSensorGetUnit(HALCOMPONENT_T *torqueSensor, char *units);
158 enum ReturnCode HalTorqueSensorSetReset(HALCOMPONENT_T *torqueSensor);
159 enum ReturnCode HalTorqueSensorStart(HALCOMPONENT_T *torqueSensor);
160 enum ReturnCode HalTorqueSensorStop(HALCOMPONENT_T *torqueSensor);
161
162 typedef union HalComponent {
163 HALCOMPONENT_CORE_T halComponent_core;
164 POSITIONCONTROLACTUATOR_T positionControlActuator;
165 VELOCITYCONTROLACTUATOR_T velocityControlActuator;
166 TORQUECONTROLACTUATOR_T torqueControlActuator;
167 TORQUESENSOR_T torqueSensor;
168 } HALCOMPONENT_T;
169
170 /* The end of C PSM */
171
172 enum ReturnCode Dummy();
173
175 typedef struct elGenaralFncTblSt {
176 /* 0x00 */ enum ReturnCode (*pFncInit)();
177 /* 0x01 */ enum ReturnCode (*pFncReInit)();
178 /* 0x02 */ enum ReturnCode (*pFncFinalize)();
179 /* 0x03 */ enum ReturnCode (*pFncAddObserver)();
180 /* 0x04 */ enum ReturnCode (*pFncRemoveObserver)();
181 /* 0x05 */ enum ReturnCode (*pFncGetProperty)();
182 /* 0x06 */ enum ReturnCode (*pFncGetTime)();
183 /* 0x07 */ enum ReturnCode (*pFncDummy07)();
185 /* 0x08 */ enum ReturnCode (*pFncDummy08)();
186 /* 0x09 */ enum ReturnCode (*pFncDummy09)();
187 /* 0x0A */ enum ReturnCode (*pFncDummy0A)();
188 /* 0x0B */ enum ReturnCode (*pFncDummy0B)();
189 /* 0x0C */ enum ReturnCode (*pFncDummy0C)();
190 /* 0x0D */ enum ReturnCode (*pFncDummy0D)();
191 /* 0x0E */ enum ReturnCode (*pFncDummy0E)();
192 /* 0x0F */ enum ReturnCode (*pFncDummy0F)();
194 /* 0x10 */ enum ReturnCode (*pFncDummy10)();
195 /* 0x11 */ enum ReturnCode (*pFncDummy11)();
196 /* 0x12 */ enum ReturnCode (*pFncDummy12)();
197 /* 0x13 */ enum ReturnCode (*pFncDummy13)();
198 /* 0x14 */ enum ReturnCode (*pFncDummy14)();
199 /* 0x15 */ enum ReturnCode (*pFncDummy15)();
200 /* 0x16 */ enum ReturnCode (*pFncDummy16)();
201 /* 0x17 */ enum ReturnCode (*pFncDummy17)();
203 /* 0x18 */ enum ReturnCode (*pFncDummy18)();
204 /* 0x19 */ enum ReturnCode (*pFncDummy19)();
205 /* 0x1A */ enum ReturnCode (*pFncDummy1A)();
206 /* 0x1B */ enum ReturnCode (*pFncDummy1B)();
207 /* 0x1C */ enum ReturnCode (*pFncDummy1C)();
208 /* 0x1D */ enum ReturnCode (*pFncDummy1D)();
209 /* 0x1E */ enum ReturnCode (*pFncDummy1E)();
210 /* 0x1F */ enum ReturnCode (*pFncDummy1F)();
211 } EL_GENERAL_FNC_TBL_T;
212
214 typedef union elCommonFncTbl {
215 EL_GENERAL_FNC_TBL_T *pGeneral;
216 #define EL_SW_COMPOMENT_PROPERTY_TABLE 1
217 #include "openEL_profCnf.h"
218 #undef EL_SW_COMPOMENT_PROPERTY_TABLE
219 } EL_CMN_FNC_TBL_T;
220 extern const uint32_t elSzCompoTbl;
221
222 /* Variable (global scope) */
223 /*---------------------------------------------------------------------------*/
224 struct elPort_st {
225 uint32_t physicalPortID;
226 EL_CMN_FNC_TBL_T fncTbl;
227 uint32_t deviceID;
228 };
229
230 struct elCompoTbl_st {
231 uint32_t vendorID; /* vendor */
232 uint32_t componentID; /* component */
233 EL_CMN_FNC_TBL_T *pFncTbl;
234 };
235 extern const struct elCompoTbl_st elCompoTbl[];
236
237 #define EL_PORT_ID_MAX (16)
239 /* Variable (friend scope) */
240 /*---------------------------------------------------------------------------*/
241 #if 1==OPENEL_SW_SURFACE_FRIEND
242 extern struct elPort_st elPortTbl[EL_PORT_ID_MAX];
243 #endif /* OPENEL_SW_SURFACE_FRIEND */
244
245 /*---------------------------------------------------------------------------*/
247 int32_t elGetPhyicalPortID(uint32_t portID,uint32_t PropertyID);
248 /*---------------------------------------------------------------------------*/
249
250 /*---------------------------------------------------------------------------*/
251 /* openEL component Property Integrate */
252 #define EL_SW_COMPONENT_PROPERTY_HEADER 1
253 #include "openEL_profCnf.h"
254 /*---------------------------------------------------------------------------*/
255
256 #ifdef __cplusplus
257 } /* extern "C" */
258 } /* namespace el */
259 #endif /* __cplusplus */
260
261 #endif /* OPENEL_H */
HALID_T
struct HALId HALID_T
elPortTbl
struct elPort_st elPortTbl[EL_PORT_ID_MAX]
Definition: openEL.c:44
TIMEROBSERVER_T
struct TimerObserver TIMEROBSERVER_T
HalSetPosition
enum ReturnCode HalSetPosition(HALCOMPONENT_T *positionControlActuator, halfloat position)
Definition: openEL_motor.c:41
value
halfloat value
Definition: openEL_0000000080000001.c:72
HalTorqueSensorGetUnit
enum ReturnCode HalTorqueSensorGetUnit(HALCOMPONENT_T *torqueSensor, char *units)
elCompoTbl
const struct elCompoTbl_st elCompoTbl[]
Definition: openEL_compoCnf.c:31
PositionControlActuator::actualPosition
HALCOMPONENT_MEMBER halfloat actualPosition
Definition: openEL.h:120
PositionControlActuator
Definition: openEL.h:116
HalComponent::halComponent_core
HALCOMPONENT_CORE_T halComponent_core
Definition: openEL.h:163
HalEventTimerSetEventPeriod
enum ReturnCode HalEventTimerSetEventPeriod(EVENTTIMER_T *eventTimer, int32_t eventPeriod)
Definition: openEL.c:178
HalGetProperty
enum ReturnCode HalGetProperty(HALCOMPONENT_T *halComponent, PROPERTY_T *property)
Definition: openEL.c:157
HalTorqueSensorGetTimedValue
enum ReturnCode HalTorqueSensorGetTimedValue(HALCOMPONENT_T *torqueSensor, halfloat *list, int32_t *timer)
Definition: openEL_sensor.c:46
EL_GENERAL_FNC_TBL_T
struct elGenaralFncTblSt EL_GENERAL_FNC_TBL_T
elPort_st::fncTbl
EL_CMN_FNC_TBL_T fncTbl
Definition: openEL.h:226
VelocityControlActuator::actualVelocity
HALCOMPONENT_MEMBER halfloat actualVelocity
Definition: openEL.h:130
HALCOMPONENT_MEMBER
#define HALCOMPONENT_MEMBER
Definition: openEL.h:80
HALObserver
Definition: openEL.h:73
EVENTTIMER_T
struct EventTimer EVENTTIMER_T
Definition: openEL.h:99
elCommonFncTbl::pGeneral
EL_GENERAL_FNC_TBL_T * pGeneral
Definition: openEL.h:215
VelocityControlActuator
Definition: openEL.h:126
float32_t
float float32_t
Definition: openEL.h:50
VELOCITYCONTROLACTUATOR_T
struct VelocityControlActuator VELOCITYCONTROLACTUATOR_T
elCommonFncTbl
Definition: openEL.h:214
HalEventTimerStopTimer
enum ReturnCode HalEventTimerStopTimer(EVENTTIMER_T *eventTimer)
Definition: openEL.c:173
elPort_st::deviceID
uint32_t deviceID
Definition: openEL.h:227
HalTorqueSensorSetUnit
enum ReturnCode HalTorqueSensorSetUnit(HALCOMPONENT_T *torqueSensor, char units)
ReturnCode
ReturnCode
Definition: openEL.h:44
HALCOMPONENT_T
union HalComponent HALCOMPONENT_T
Definition: openEL.h:71
HalTorqueSensorGetValue
enum ReturnCode HalTorqueSensorGetValue(HALCOMPONENT_T *torqueSensor, halfloat *list)
Definition: openEL_sensor.c:30
Dummy
enum ReturnCode Dummy()
Definition: openEL_0000000012345678.c:82
elPort_st::physicalPortID
uint32_t physicalPortID
Definition: openEL.h:225
halfloat
float32_t halfloat
Definition: openEL.h:53
HALId::deviceKindId
int32_t deviceKindId
Definition: openEL.h:59
EL_PORT_ID_MAX
#define EL_PORT_ID_MAX
Definition: openEL.h:237
HALComponent
Definition: openEL.h:87
HalAddObserver
enum ReturnCode HalAddObserver(HALCOMPONENT_T *halComponent, HALOBSERVER_T *halObserver)
Definition: openEL.c:146
HalTorqueSensorStop
enum ReturnCode HalTorqueSensorStop(HALCOMPONENT_T *torqueSensor)
elCompoTbl_st::vendorID
uint32_t vendorID
Definition: openEL.h:231
HalGetPosition
enum ReturnCode HalGetPosition(HALCOMPONENT_T *positionControlActuator, halfloat *position)
Definition: openEL_motor.c:69
HALOBSERVER_T
struct HALObserver HALOBSERVER_T
Definition: openEL.h:78
HalTorqueSensorSetReset
enum ReturnCode HalTorqueSensorSetReset(HALCOMPONENT_T *torqueSensor)
TorqueControlActuator::actualTorque
HALCOMPONENT_MEMBER halfloat actualTorque
Definition: openEL.h:140
HalInit
enum ReturnCode HalInit(HALCOMPONENT_T *halComponent)
Definition: openEL.c:75
elCompoTbl_st::pFncTbl
EL_CMN_FNC_TBL_T * pFncTbl
Definition: openEL.h:233
HalGetTime
enum ReturnCode HalGetTime(HALCOMPONENT_T *halComponent, int32_t *time)
Definition: openEL.c:162
HalComponent
Definition: openEL.h:162
HalRemoveObserver
enum ReturnCode HalRemoveObserver(HALCOMPONENT_T *halComponent, HALOBSERVER_T *halObserver)
Definition: openEL.c:152
TORQUECONTROLACTUATOR_T
struct TorqueControlActuator TORQUECONTROLACTUATOR_T
HalTorqueSensorStart
enum ReturnCode HalTorqueSensorStart(HALCOMPONENT_T *torqueSensor)
HalEventTimerAddObserver
enum ReturnCode HalEventTimerAddObserver(EVENTTIMER_T *eventTimer, TIMEROBSERVER_T *timerObserver)
Definition: openEL.c:183
HalSetTorque
enum ReturnCode HalSetTorque(HALCOMPONENT_T *torqueControlActuator, halfloat torque)
HalFinalize
enum ReturnCode HalFinalize(HALCOMPONENT_T *halComponent)
Definition: openEL.c:130
elPort_st
Definition: openEL.h:224
HalComponent::torqueControlActuator
TORQUECONTROLACTUATOR_T torqueControlActuator
Definition: openEL.h:166
elCompoTbl_st
Definition: openEL.h:230
PROPERTY_T
struct Property PROPERTY_T
TORQUESENSOR_T
struct TorqueSensor TORQUESENSOR_T
TorqueControlActuator
Definition: openEL.h:136
HALCOMPONENT_CORE_T
struct HALComponent HALCOMPONENT_CORE_T
elCompoTbl_st::componentID
uint32_t componentID
Definition: openEL.h:232
elGetPhyicalPortID
int32_t elGetPhyicalPortID(uint32_t portID, uint32_t PropertyID)
Definition: openEL.c:196
EL_CMN_FNC_TBL_T
union elCommonFncTbl EL_CMN_FNC_TBL_T
HalEventTimerRemoveObserver
enum ReturnCode HalEventTimerRemoveObserver(EVENTTIMER_T *eventTimer, TIMEROBSERVER_T *timerObserver)
Definition: openEL.c:189
float64_t
double float64_t
Definition: openEL.h:51
HAL_OK
Definition: openEL.h:45
HalComponent::positionControlActuator
POSITIONCONTROLACTUATOR_T positionControlActuator
Definition: openEL.h:164
HALId::productId
int32_t productId
Definition: openEL.h:61
elSzCompoTbl
const uint32_t elSzCompoTbl
Definition: openEL_compoCnf.c:49
HalReInit
enum ReturnCode HalReInit(HALCOMPONENT_T *halComponent)
Definition: openEL.c:114
Property::halId
HALID_T halId
Definition: openEL.h:66
TorqueSensor
Definition: openEL.h:146
TimerObserver
Definition: openEL.h:101
HalSetVelocity
enum ReturnCode HalSetVelocity(HALCOMPONENT_T *velocityControlActuator, halfloat velocity)
HalEventTimerStartTimer
enum ReturnCode HalEventTimerStartTimer(EVENTTIMER_T *eventTimer)
Definition: openEL.c:167
POSITIONCONTROLACTUATOR_T
struct PositionControlActuator POSITIONCONTROLACTUATOR_T
HalGetVelocity
enum ReturnCode HalGetVelocity(HALCOMPONENT_T *velocityControlActuator, halfloat *velocity)
HalGetTorque
enum ReturnCode HalGetTorque(HALCOMPONENT_T *torqueControlActuator, halfloat *torque)
HalComponent::velocityControlActuator
VELOCITYCONTROLACTUATOR_T velocityControlActuator
Definition: openEL.h:165
openEL_profCnf.h
OpenEL Property Table 3.0.0.
HALId
Definition: openEL.h:58
EventTimer
Definition: openEL.h:105
HAL_ERROR
Definition: openEL.h:46
HalComponent::torqueSensor
TORQUESENSOR_T torqueSensor
Definition: openEL.h:167
Property
Definition: openEL.h:65
elGenaralFncTblSt
Definition: openEL.h:175
HALId::instanceId
int32_t instanceId
Definition: openEL.h:62
HALId::vendorId
int32_t vendorId
Definition: openEL.h:60