OOSMOS API Reference
NOTE: For improved readability, the 'oosmos_' prefix has been suppressed from the table of contents and from each See Also list.
Allocate
AllocateVisible
AnalogMapAccurate
AnalogMapFast
ASSERT
ClockSpeedInMHz
COMPLETE
CompositeInit
Days2Hours
Days2Minutes
Days2MS
Days2Seconds
Days2US
Debug
DebugCode
DebugPrint
DEFAULT
DelayMS
DelaySeconds
DelayUS
Divide_Integral_Rounded
EndProgram
ENTER
EventCode
EXIT
FinalInit
FOREVER
GetFreeRunningMicroseconds
Hours2Days_Rounded
Hours2Days_Truncated
Hours2Minutes
Hours2MS
Hours2Seconds
Hours2US
IsInState
LeafInit
Minutes2Days_Rounded
Minutes2Days_Truncated
Minutes2Hours_Rounded
Minutes2Hours_Truncated
Minutes2MS
Minutes2Seconds
Minutes2US
MS2Days_Rounded
MS2Days_Truncated
MS2Hours_Rounded
MS2Hours_Truncated
MS2Minutes_Rounded
MS2Minutes_Truncated
MS2Seconds_Rounded
MS2Seconds_Truncated
MS2US
ORTHO
OrthoInit
OrthoRegionInit
POINTER_GUARD
POLL
PushEvent
PushEventCode
QueueConstruct
QueuePop
QueuePush
RegisterActiveObject
RunStateMachine
RunStateMachines
sActiveObject
sComposite
Seconds2Days_Rounded
Seconds2Days_Truncated
Seconds2Hours_Rounded
Seconds2Hours_Truncated
Seconds2Minutes_Rounded
Seconds2Minutes_Truncated
Seconds2MS
Seconds2US
sEvent
sFinal
sLeaf
sOrtho
sOrthoRegion
sQueue
sState
sStateMachine
sStateMachineNoQueue
sSubscriberList
StateMachineInit
StateMachineInitNoQueue
StateTimeoutMS
StateTimeoutSeconds
StateTimeoutUS
sTimeout
SubscriberListAdd
SubscriberListInit
SubscriberListNotify
SubscriberListNotifyWithArgs
ThreadBegin
ThreadDelayMS
ThreadEnd
ThreadFinally
ThreadWaitCond
ThreadWaitCond_TimeoutMS
ThreadWaitCond_TimeoutMS_Event
ThreadWaitCond_TimeoutMS_Exit
ThreadWaitEvent
ThreadWaitEvent_TimeoutMS
ThreadWaitEvent_TimeoutMS_Event
ThreadWaitEvent_TimeoutMS_Exit
ThreadYield
TIMEOUT
TimeoutHasExpired
TimeoutInMS
TimeoutInSeconds
TimeoutInUS
Transition
TransitionAction
UNUSED
US2Days_Rounded
US2Days_Truncated
US2Hours_Rounded
US2Hours_Truncated
US2Minutes_Rounded
US2Minutes_Truncated
US2MS_Rounded
US2MS_Truncated
US2Seconds_Rounded
US2Seconds_Truncated
Important: All of these APIs are available to you to code by hand, however many of them are generated by the OOSMOS code generator while parsing your UMLet state chart. We urge you to draw state charts and generate your code using the OOSMOS code generator.

oosmos_Allocate

oosmos_Allocate is a macro that returns a pointer to an unused object from a fixed number of statically preallocated objects. The static preallocation is done automatically within the macro. Once allocated, objects cannot be returned to the pool. See the example on line 82.
If you need dynamic memory, use malloc in place of this function and then create a complementary toggleDelete function and then do a free to release it.
1
2
3
 
Type * oosmos_Allocate(Pointer, Type, Elements, pOutOfMemory);
 
Prototype
Pointer
The name of the variable that will hold the pointer to the allocated object. You'll use this to initialize your object's members, including the state machine (if the object has one). You must return this pointer to the caller. (See toggle.c line 97 below.)
Type
The data type of the object. (See line 29 of toggle.h below.)
Elements
The number of objects to pre-allocate. You can specify a number here, but it would be better to use the macro technique used in lines 23-25 of the toggle.c where you specify a default amount that can be overridden on the compilation command line. This is commonly done with most compilers like this: -D toggleMax=10.
pOutOfMemory
The address of a subroutine to call if all preallocated objects have been exhausted. See type oosmos_tOutOfMemory for information about how to implement the called routine.
If NULL, oosmos_Allocate will loop forever when all objects of this type are exhausted.
See Also
1
22
23
28
29
30
31
32
33
[GPLv2]
 
[...]
 
typedef struct toggleTag toggle;
 
extern toggle * toggleNew(pin * pPin, uint32_t TimeOnMS, uint32_t TimeOffMS);
 
#endif
oosmos/Classes/toggle.h
1
22
23
24
25
26
27
79
80
81
82
83
84
[GPLv2]
 
#ifndef toggleMAX
#define toggleMAX 5
#endif
 
[...]
 
extern toggle * toggleNew(pin * pPin, uint32_t TimeOnMS, uint32_t TimeOffMS)
{
oosmos_Allocate(pToggle, toggle, toggleMAX, NULL);
 
[...]
oosmos/Classes/toggle.c

oosmos_AllocateVisible

oosmos_AllocateVisible is functionally the same as oosmos_Allocate but allows the user to allocate the array of objects in an outer scope thereby allowing access to that array by other parts of the implementation of the object. (See line 84 of the example below.)
1
2
3
 
Type * oosmos_AllocateVisible(Pointer, Type, List, Count, Elements, pOutOfMemory);
 
Prototype
Pointer
The name of the variable that will hold the pointer to the allocated object. You'll use this to initialize your object's members, including the state machine (if the object has one). You must return this pointer to the caller (see line 91).
Type
The data type of the object. (See line 32 of Interrupt.c.)
List
The address of the array of objects you pre-allocated. (See line 46.)
Count
The number of objects that have been returned from oosmos_AllocateVisible. (See line 47.)
Elements
The number of objects to pre-allocate.
pOutOfMemory
The address of a subroutine to call if all preallocated objects have been exhausted. See type oosmos_tOutOfMemory for information about how to implement the called routine.
If NULL is specified, oosmos_AllocateVisible will loop forever when all objects of this type are exhausted.
See Also
1
22
23
27
28
29
30
31
32
33
34
43
44
45
46
47
48
49
64
81
82
83
84
85
86
87
88
89
90
91
92
93
94
111
[GPLv2]
 
[...]
 
//
// Demonstrates structure of how to react to interrupts using OOSMOS.
//
 
typedef struct uartTag uart;
 
struct uartTag {...}
 
#define MAX_UARTS 5
 
static uart UartList[MAX_UARTS];
static int UartCount = 0;
 
static void ReceiverStateMachine(...) {...}
static void ISR(...) {...}
 
extern uart * uartNew(const int UartId)
{
oosmos_AllocateVisible(pUART, uart, UartList, UartCount, MAX_UARTS, NULL);
 
pUART->m_UartId = (uint8_t) UartId;
 
oosmos_QueueConstruct(&pUART->m_ReceiveDataQueue, pUART->m_ReceiveDataQueueData);
oosmos_RegisterActiveObject(pUART, ReceiverStateMachine, &pUART->m_ActiveObject);
 
return pUART;
}
 
extern int main(void) {...}
 
oosmos/Examples/Interrupt/Windows/Interrupt.c

oosmos_AnalogMapAccurate

Scales a value from a point within one range to the proportionate point in a different range. This function uses a floating point type to guarantee the most accurate result. If speed is more important than accuracy, use oosmos_AnalogMapFast.
See example on line 36, below.
1
2
3
 
float oosmos_AnalogMapAccurate(float Value, float InMin, float InMax, float OutMin, float OutMax);
 
Prototype
Value
The value to be scaled.
InMin
The low end of the source range.
InMax
The high end of the source range.
OutMin
The low end of the target range.
OutMax
The high end of the target range.
RETURN
Returns the scaled number as a floating point value.
See Also
1
22
23
33
34
35
36
37
38
39
40
41
42
43
44
[GPLv2]
 
[...]
 
static void TestAccurate(float Value, float InMin, float InMax, float OutMin, float OutMax)
{
const float Result = oosmos_AnalogMapAccurate(Value, InMin, InMax, OutMin, OutMax);
 
printf("Value:%f, InMin:%f, InMax:%f, OutMin:%f, OutMax:%f, Result:%f\n", Value, InMin, InMax, OutMin, OutMax, Result);
 
const long IntResult = (long) (Result + .5f);
AccurateDistribution[IntResult]++;
}
 
[...]
oosmos/Examples/AnalogMap/Windows/AnalogMap.c

oosmos_AnalogMapFast

Scales a value from a point within one range to the proportionate point in a different range. This function uses a long integral data type in order to calculate the result quickly. If accuracy is more important thqan speed, use oosmos_AnalogMapAccurate.
See example on line 46, below.
1
2
3
 
int32_t oosmos_AnalogMapFast(int32_t Value, int32_t InMin, int32_t InMax, int32_t OutMin, int32_t OutMax));
 
Prototype
Value
The value to be scaled.
InMin
The low end of the source range.
InMax
The high end of the source range.
OutMin
The low end of the target range.
OutMax
The high end of the target range.
RETURN
Returns the scaled number as a long integral value.
See Also
1
22
23
43
44
45
46
47
48
49
50
51
52
53
[GPLv2]
 
[...]
 
static void TestFast(int32_t Value, int32_t InMin, int32_t InMax, int32_t OutMin, int32_t OutMax)
{
const int32_t Result = oosmos_AnalogMapFast(Value, InMin, InMax, OutMin, OutMax);
printf("Value:%ld, InMin:%ld, InMax:%ld, OutMin:%ld, OutMax:%ld, Result:%ld\n",
(long) Value, (long) InMin, (long) InMax, (long) OutMin, (long) OutMax, (long) Result);
 
FastDistribution[Result]++;
}
 
[...]
oosmos/Examples/AnalogMap/Windows/AnalogMap.c

oosmos_ASSERT

oosmos_ASSERT works just like the standard C assert, but instead of aborting the program (which doesn't mean much on an embedded system), it will loop endlessly.
1
22
23
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
[GPLv2]
 
[...]
 
extern void regSamples(reg * pReg, const regSample * pSamples, uint32_t Samples)
{
const float MeanX = MeanOfX(pSamples, Samples);
const float MeanY = MeanOfY(pSamples, Samples);
 
float SumXY = 0.0f;
float SumXX = 0.0f;
 
for (uint32_t SampleIndex = 0; SampleIndex < Samples; SampleIndex++) {
const regSample * pSample = &pSamples[SampleIndex];
 
const float XiMinusMeanX = pSample->X - MeanX;
const float YiMinusMeanY = pSample->Y - MeanY;
 
SumXY += XiMinusMeanX * YiMinusMeanY;
SumXX += XiMinusMeanX * XiMinusMeanX;
}
 
oosmos_ASSERT(SumXX > 0.0f);
 
pReg->m_Slope = SumXY / SumXX;
pReg->m_Intercept = MeanY - pReg->m_Slope * MeanX;
}
 
[...]
oosmos/Classes/reg.c

oosmos_ClockSpeedInMHz

oosmos_ClockSpeedInMHz tells OOSMOS the speed of the processor as configured externally. This call only applies to the PIC32 architecture.
1
2
3
 
void oosmos_ClockSpeedInMHz(uint32_t ClockSpeedMHz);
 
Prototype

oosmos_COMPLETE

oosmos_COMPLETE is one of the six predefined event macros. This event is generated when the final states within all orthogonal regions have been entered. See The User's Guide for more information.
See Also

oosmos_CompositeInit

oosmos_CompositeInit initializes an oosmos_sComposite state.
See line 122 of the code snippet below for an example.
1
2
3
 
void oosmos_CompositeInit(pObject, CompositeState, ParentState, DefaultState, pCode);
 
Prototype
pObject
The address of the object that contains the state machine.
CompositeState
The name of the composite state.
ParentState
The name of the parent state.
DefaultState
The name of the default state.
pCode
Pointer to event handler function.
1
22
23
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
[GPLv2]
 
[...]
 
static test * testNew(void)
{
oosmos_Allocate(pTest, test, 1, NULL);
 
//>>>INIT
oosmos_StateMachineInitNoQueue(pTest, ROOT, NULL, A_State);
oosmos_CompositeInit(pTest, A_State, ROOT, A_Choice1_State, A_State_Code);
oosmos_LeafInit(pTest, A_Choice1_State, A_State, A_Choice1_State_Code);
oosmos_LeafInit(pTest, A_Left_State, A_State, A_Left_State_Code);
oosmos_LeafInit(pTest, A_Right_State, A_State, A_Right_State_Code);
oosmos_FinalInit(pTest, A_Final1_State, A_State, NULL);
oosmos_LeafInit(pTest, B_State, ROOT, NULL);
 
oosmos_Debug(pTest, NULL);
//<<<INIT
 
return pTest;
}
 
[...]
oosmos/Examples/Basic/Windows/Final.c

oosmos_Days2Hours

oosmos_Days2Hours is a macro that converts days to hours.
1
2
3
 
oosmos_Days2Hours(Days)
 
Macro
See Also
Divide_Integral_Rounded, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Days2Minutes

oosmos_Days2Minutes is a macro that converts days to minutes.
1
2
3
 
oosmos_Days2Minutes(Days)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Days2MS

oosmos_Days2MS is a macro that converts days to milliseconds.
1
2
3
 
oosmos_Days2MS(Days)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Days2Seconds

oosmos_Days2Seconds is a macro that converts days to seconds.
1
2
3
 
oosmos_Days2Seconds(Days)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Days2US

oosmos_Days2US is a macro that converts days to microseconds.
1
2
3
 
oosmos_Days2US(Days)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Debug

A call to oosmos_Debug is generated by the OOSMOS code generator when the debug option is specified in your .json generator configuration file. oosmos_Debug enables debug output indicating when transitions are made into and out of states and when events occur. See line 165 in the code snippet below for an example.
1
2
3
 
oosmos_Debug(oosmos_sStateMachine * pStateMachine, const char * (*pNameTable)(int));
 
Prototype
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
Completion.c: ==> Ortho_State
Completion.c: ==> Ortho_Region2_Idle_State
Completion.c: ==> Ortho_Region1_Idle_State
Completion.c: EVENT: evA (1)
Completion.c: Ortho_Region1_Idle_State -->
Completion.c: --> Ortho_Region1_Moving_State
Completion.c: EVENT: evB (2)
Completion.c: Ortho_Region2_Idle_State -->
Completion.c: --> Ortho_Region2_Moving_State
Completion.c: EVENT: evStop (3)
Completion.c: Ortho_Region2_Moving_State -->
Completion.c: --> Ortho_Region2_Final2_State
Completion.c: Ortho_Region1_Moving_State -->
Completion.c: --> Ortho_Region1_Final1_State
Completion.c: ((( Ortho_State Complete )))
Completion.c: Ortho_Region2_Final2_State -->
Completion.c: Ortho_Region1_Final1_State -->
Completion.c: Ortho_State -->
Completion.c: --> Complete_State
 
--Goal State Achieved--
SUCCESS
 
Output from running Completion.exe
pStateMachine
The address of the object's state machine.
pNameTable
This argument specifies the address of a function that returns the string representation of an event code.
See Also
1
22
23
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
[GPLv2]
 
[...]
 
//>>>INIT
oosmos_StateMachineInit(pTest, ROOT, NULL, Ortho_State);
oosmos_OrthoInit(pTest, Ortho_State, ROOT, Ortho_State_Code);
oosmos_OrthoRegionInit(pTest, Ortho_Region1_State, Ortho_State, Ortho_Region1_Idle_State, NULL);
oosmos_LeafInit(pTest, Ortho_Region1_Moving_State, Ortho_Region1_State, Ortho_Region1_Moving_State_Code);
oosmos_LeafInit(pTest, Ortho_Region1_Idle_State, Ortho_Region1_State, Ortho_Region1_Idle_State_Code);
oosmos_FinalInit(pTest, Ortho_Region1_Final1_State, Ortho_Region1_State, NULL);
oosmos_OrthoRegionInit(pTest, Ortho_Region2_State, Ortho_State, Ortho_Region2_Idle_State, NULL);
oosmos_LeafInit(pTest, Ortho_Region2_Idle_State, Ortho_Region2_State, Ortho_Region2_Idle_State_Code);
oosmos_LeafInit(pTest, Ortho_Region2_Moving_State, Ortho_Region2_State, Ortho_Region2_Moving_State_Code);
oosmos_FinalInit(pTest, Ortho_Region2_Final2_State, Ortho_Region2_State, NULL);
oosmos_LeafInit(pTest, Complete_State, ROOT, Complete_State_Code);
 
oosmos_Debug(pTest, OOSMOS_EventNames);
//<<<INIT
 
return pTest;
}
 
[...]
oosmos/Examples/Ortho/Windows/Completion.c

oosmos_DebugCode

oosmos_DebugCode is the same as surrounding the code in an #ifdef oosmos_DEBUG block.

oosmos_DebugPrint

oosmos_DebugPrint
1
22
23
86
87
88
89
90
91
92
93
94
95
96
97
98
99
[GPLv2]
 
[...]
//<<<DECL
};
 
static void ToggleOption1(control * pControl)
{
pControl->m_Option1 = !(pControl->m_Option1);
oosmos_DebugPrint("Option1: %d\n", pControl->m_Option1);
}
 
static void ToggleOption2(control * pControl)
{
pControl->m_Option2 = !(pControl->m_Option2);
oosmos_DebugPrint("Option2: %d\n", pControl->m_Option1);
[...]
oosmos/Examples/EventDemo/Windows/control.c

oosmos_DEFAULT

oosmos_DEFAULT is one of the six predefined event macros. This event is sent to the state once, before the state is entered, to allow the user the opportunity to execute initialization code. See line 61 in the code snippet below for an example.
See Also
1
22
23
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
[GPLv2]
 
[...]
static bool A_State_Code(void * pObject, oosmos_sState * pState, const oosmos_sEvent * pEvent)
{
test * pTest = (test *) pObject;
 
switch (oosmos_EventCode(pEvent)) {
case oosmos_DEFAULT: {
Default();
return true;
}
case oosmos_COMPLETE: {
return oosmos_Transition(pTest, pState, B_State);
}
}
 
return false;
}
[...]
oosmos/Examples/Basic/Windows/Final.c

oosmos_DelayMS

oosmos_DelayMS suspends all processing for a specified number of milliseconds. oosmos_DelayMS is a thread blocker, not an object blocker. If you want to suspend only the current object, use the oosmos_TimeoutInMS or oosmos_ThreadDelayMS (inside of a thread group) instead. See line 31 of the snippet below for an example.
1
2
3
 
void oosmos_DelayMS(uint32_t Milliseconds);
 
Prototype
See Also
1
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[GPLv2]
 
#include <stdio.h>
#include "oosmos.h"
 
extern int main(void)
{
int LoopCount;
 
for (LoopCount = 1; LoopCount <= 5; LoopCount++) {
oosmos_DelayMS(500);
printf("Work...\n");
}
 
printf("SUCCESS\n");
 
return 0;
}
DelayMS.c

oosmos_DelaySeconds

oosmos_DelaySeconds suspends all processing for a specified number of seconds. See line 31 of the snippet below for an example.
oosmos_DelaySeconds is a thread blocker, not an object blocker. If you want to suspend only the current object, use the oosmos_TimeoutInSeconds or oosmos_ThreadDelayMS inside of a thread group instead.
1
2
3
 
void oosmos_DelaySeconds(uint32_t Seconds);
 
Prototype
1
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[GPLv2]
 
#include <stdio.h>
#include "oosmos.h"
 
extern int main(void)
{
int LoopCount;
 
for (LoopCount = 1; LoopCount <= 5; LoopCount++) {
oosmos_DelaySeconds(1);
printf("Work...\n");
}
 
printf("SUCCESS\n");
 
return 0;
}
DelaySeconds.c

oosmos_DelayUS

oosmos_DelayUS suspends all processing for a specified number of microseconds. See line 29 of the snippet below for an example.
If you want to suspend only the current object, use the oosmos_TimeoutInUS instead.
Note that oosmos_DelayUS is not implemented on Windows.
1
2
3
 
void oosmos_DelayUS(uint32_t Microseconds);
 
Prototype
1
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
[GPLv2]
 
#include <stdio.h>
#include "oosmos.h"
 
extern int main(void)
{
for (int LoopCount = 1; LoopCount <= 5; LoopCount++) {
oosmos_DelayUS(1000 * 1000);
printf("Work...\n");
}
 
printf("SUCCESS\n");
 
return 0;
}
DelayUS.c

oosmos_Divide_Integral_Rounded

oosmos_Divide_Integral_Rounded is a macro that is used internally by the time unit conversion APIs, but it is externalized for your use.
1
2
3
 
oosmos_Divide_Integral_Rounded(Dividend, Divisor)
 
Macro
See Also
Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_EndProgram

oosmos_EndProgram exits the program on platforms where that makes sense, like Windows and Linux. On other platforms, it is implemented as an endless loop, effectively stopping the program.

oosmos_ENTER

oosmos_ENTER is one of the six predefined event macros. This event is generated when the state is being entered. See line 52 in the code snippet below for an example.
See Also
1
22
23
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[GPLv2]
 
[...]
 
//>>>CODE
static bool Off_State_Code(void * pObject, oosmos_sState * pState, const oosmos_sEvent * pEvent)
{
toggle * pToggle = (toggle *) pObject;
 
switch (oosmos_EventCode(pEvent)) {
case oosmos_ENTER: {
return oosmos_StateTimeoutMS(pState, (uint32_t) pToggle->m_TimeOffMS);
}
case oosmos_TIMEOUT: {
return oosmos_Transition(pToggle, pState, On_State);
}
}
 
return false;
}
 
[...]
oosmos/Classes/toggle_state.c (State machine version)

oosmos_EventCode

oosmos_EventCode is a macro that accesses the event code from within an OOSMOS event structure to improve readability of the generated code.
See line 51 for an example.
See Also
1
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
[...]
static bool Off_State_Code(void * pObject, oosmos_sState * pState, const oosmos_sEvent * pEvent)
{
toggle * pToggle = (toggle *) pObject;
 
switch (oosmos_EventCode(pEvent)) {
case oosmos_ENTER: {
return oosmos_StateTimeoutMS(pState, (uint32_t) pToggle->m_TimeOffMS);
}
case oosmos_TIMEOUT: {
return oosmos_Transition(pToggle, pState, On_State);
}
}
 
return false;
}
[...]
oosmos/Classes/toggle_state.c (State machine version)

oosmos_EXIT

oosmos_EXIT is one of the six predefined event macros. This event is generated when the state is being exited as part of a transition to another state. See line 72 in the code snippet below for an example.
See Also
1
22
23
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
[GPLv2]
 
[...]
 
static bool On_State_Code(void * pObject, oosmos_sState * pState, const oosmos_sEvent * pEvent)
{
toggle * pToggle = (toggle *) pObject;
 
switch (oosmos_EventCode(pEvent)) {
case oosmos_ENTER: {
pinOn(pToggle->m_pPin);
return oosmos_StateTimeoutMS(pState, (uint32_t) pToggle->m_TimeOnMS);
}
case oosmos_EXIT: {
pinOff(pToggle->m_pPin);
return true;
}
case oosmos_TIMEOUT: {
return oosmos_Transition(pToggle, pState, Off_State);
}
}
 
return false;
}
[...]
oosmos/Classes/toggle_state.c (State machine version)

oosmos_FinalInit

Intializes a Final state. See line 126 for an example.
1
2
3
 
void oosmos_FinalInit(pObject, StateName, Parent, pCode);
 
Prototype
pObject
Pointer to the object that holds the state machine.
StateName
State name of the Final element.
Parent
The name of this state's parent state.
pCode
Pointer to event handler function. NULL if there is no function to call.
1
22
23
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
[GPLv2]
 
[...]
 
static test * testNew(void)
{
oosmos_Allocate(pTest, test, 1, NULL);
 
//>>>INIT
oosmos_StateMachineInitNoQueue(pTest, ROOT, NULL, A_State);
oosmos_CompositeInit(pTest, A_State, ROOT, A_Choice1_State, A_State_Code);
oosmos_LeafInit(pTest, A_Choice1_State, A_State, A_Choice1_State_Code);
oosmos_LeafInit(pTest, A_Left_State, A_State, A_Left_State_Code);
oosmos_LeafInit(pTest, A_Right_State, A_State, A_Right_State_Code);
oosmos_FinalInit(pTest, A_Final1_State, A_State, NULL);
oosmos_LeafInit(pTest, B_State, ROOT, NULL);
 
oosmos_Debug(pTest, NULL);
//<<<INIT
 
return pTest;
}
 
[...]
oosmos/Examples/Basic/Windows/Final.c

oosmos_FOREVER

oosmos_FOREVER loops forever. Useful to stop a program once a problem has been programmatically identified.
See Also

oosmos_GetFreeRunningMicroseconds

oosmos_GetFreeRunningMicroseconds returns the number of microseconds since program start. Returning a uint32_t, the maximum number of microseconds that can be represented is 4,294,967,295, which is a little over 1 hour. Therefore, this value will wrap around to 0 about once an hour. The OOSMOS timeout capabilities handle the wrap around correctly, as does the accum class.
1
2
3
 
uint32_t oosmos_GetFreeRunningMicroseconds(void)
 
Prototype
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Hours2Days_Rounded

oosmos_Hours2Days_Rounded is a macro that converts hours to days with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_Hours2Days_Rounded(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Hours2Days_Truncated

oosmos_Hours2Days_Truncated is a macro that converts hours to days with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_Hours2Days_Truncated(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Hours2Minutes

oosmos_Hours2Minutes is a macro that converts hours to minutes.
1
2
3
 
oosmos_Hours2Minutes(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Hours2MS

oosmos_Hours2MS is a macro that converts hours to milliseconds.
1
2
3
 
oosmos_Hours2MS(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Hours2Seconds

oosmos_Hours2Seconds is a macro that converts hours to seconds.
1
2
3
 
oosmos_Hours2Seconds(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Hours2US

oosmos_Hours2US is a macro that converts hours to microseconds.
1
2
3
 
oosmos_Hours2US(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_IsInState

oosmos_IsInState returns true if the object is in state pState or any of its substates, false otherwise. See line 142 of the code snippet below for an example.
1
2
3
 
bool oosmos_IsInState(const oosmos_sStateMachine * pStateMachine, const oosmos_sState * pState);
 
Prototype
pStateMachine
The address of the state machine within the object.
pState
The address of the state within the current object.
RETURN
Returns true if the object is in the state specified by pState or any of its subordinate states, false otherwise.
1
22
23
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
[GPLv2]
 
[...]
 
extern int main(void)
{
test * pTest = (test *) testNew();
 
for (;;) {
oosmos_RunStateMachines();
 
if (oosmos_IsInState(pTest, &pTest->B_State)) {
printf("SUCCESS.\n");
break;
}
 
oosmos_DelayMS(1);
}
}
oosmos/Examples/Basic/Windows/Final.c

oosmos_LeafInit

oosmos_LeafInit initializes an oosmos_sLeaf state.
See line 86 in the code snippet below for an example.
1
2
3
 
void oosmos_LeafInit(pObject, LeafState, ParentState, pCode);
 
Prototype
pObject
The address of the object that contains the state machine.
LeafState
The name of the leaf state.
ParentState
The name of the parent state.
pCode
The address of the event code function or NULL.
1
22
23
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
[GPLv2]
 
[...]
 
extern toggle * toggleNew(pin * pPin, uint32_t TimeOnMS, uint32_t TimeOffMS)
{
oosmos_Allocate(pToggle, toggle, toggleMAX, NULL);
 
//>>>INIT
oosmos_StateMachineInitNoQueue(pToggle, ROOT, NULL, Running_State);
oosmos_LeafInit(pToggle, Running_State, ROOT, Running_State_Code);
//<<<INIT
 
pToggle->m_pPin = pPin;
pToggle->m_TimeOnMS = TimeOnMS;
pToggle->m_TimeOffMS = TimeOffMS;
 
return pToggle;
}
oosmos/Classes/toggle.c

oosmos_Minutes2Days_Rounded

oosmos_Minutes2Days_Rounded is a macro that converts minutes to days with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_Minutes2Days_Rounded(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Minutes2Days_Truncated

oosmos_Minutes2Days_Truncated is a macro that converts minutes to days with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_Minutes2Days_Truncated(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Minutes2Hours_Rounded

oosmos_Minutes2Hours_Rounded is a macro that converts minutes to hours with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_Minutes2Hours_Rounded(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Minutes2Hours_Truncated

oosmos_Minutes2Hours_Truncated is a macro that converts minutes to hours with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_Minutes2Hours_Truncated(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Minutes2MS

oosmos_Minutes2MS is a macro that converts minutes to milliseconds.
1
2
3
 
oosmos_Minutes2MS(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Minutes2Seconds

oosmos_Minutes2Seconds is a macro that converts minutes to seconds.
1
2
3
 
oosmos_Minutes2Seconds(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Minutes2US

oosmos_Minutes2US is a macro that converts minutes to microseconds.
1
2
3
 
oosmos_Minutes2US(Minutes)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Days_Rounded

oosmos_MS2Days_Rounded is a macro that converts milliseconds to days with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_MS2Days_Rounded(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Days_Truncated

oosmos_MS2Days_Truncated is a macro that converts milliseconds to days with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_MS2Days_Truncated(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Hours_Rounded

oosmos_MS2Hours_Rounded is a macro that converts milliseconds to hours with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_MS2Hours_Rounded(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Hours_Truncated

oosmos_MS2Hours_Truncated is a macro that converts milliseconds to hours with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_MS2Hours_Truncated(Hours)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Minutes_Rounded

oosmos_MS2Minutes_Rounded is a macro that converts milliseconds to minutes with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_MS2Minutes_Rounded(Milliseconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Minutes_Truncated

oosmos_MS2Minutes_Truncated is a macro that converts milliseconds to minutes with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_MS2Minutes_Truncated(Milliseconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Seconds_Rounded

oosmos_MS2Seconds_Rounded is a macro that converts milliseconds to seconds with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_MS2Seconds_Rounded(Milliseconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2Seconds_Truncated

oosmos_MS2Seconds_Truncated is a macro that converts milliseconds to seconds with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_MS2Seconds_Truncated(Milliseconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_MS2US

oosmos_MS2US is a macro that converts milliseconds to microseconds.
1
2
3
 
oosmos_MS2US(Milliseconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_ORTHO

oosmos_ORTHO is a preprocessor macro that, when defined, compiles in all the OOSMOS orthogonal state machine features.
The default is #undef which will compile the smallest possible footprint. Of course if you use orthogonal states in any object in your build, you will have to #define it during compilation.
You can either define it on the compilation command line (usually -Doosmos_ORTHO), or add a #define oosmos_ORTHO at the top of both oosmos.h and oosmos.c.
See Also

oosmos_OrthoInit

oosmos_OrthoInit initializes an oosmos_sOrtho state.
See line 154 of the code snippet below for an example.
1
2
3
 
void oosmos_OrthoInit(pObject, OrthoState, ParentState, pCode)
 
Prototype
pObject
The address of the object that contains the state machine.
OrthoState
The name of the Ortho state.
ParentState
The name of the parent state.
pCode
The address of the event code function or NULL.
1
22
23
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
[GPLv2]
 
[...]
 
//>>>INIT
oosmos_StateMachineInit(pTest, ROOT, NULL, Ortho_State);
oosmos_OrthoInit(pTest, Ortho_State, ROOT, Ortho_State_Code);
oosmos_OrthoRegionInit(pTest, Ortho_Region1_State, Ortho_State, Ortho_Region1_Idle_State, NULL);
oosmos_LeafInit(pTest, Ortho_Region1_Moving_State, Ortho_Region1_State, Ortho_Region1_Moving_State_Code);
oosmos_LeafInit(pTest, Ortho_Region1_Idle_State, Ortho_Region1_State, Ortho_Region1_Idle_State_Code);
oosmos_FinalInit(pTest, Ortho_Region1_Final1_State, Ortho_Region1_State, NULL);
oosmos_OrthoRegionInit(pTest, Ortho_Region2_State, Ortho_State, Ortho_Region2_Idle_State, NULL);
oosmos_LeafInit(pTest, Ortho_Region2_Idle_State, Ortho_Region2_State, Ortho_Region2_Idle_State_Code);
oosmos_LeafInit(pTest, Ortho_Region2_Moving_State, Ortho_Region2_State, Ortho_Region2_Moving_State_Code);
oosmos_FinalInit(pTest, Ortho_Region2_Final2_State, Ortho_Region2_State, NULL);
oosmos_LeafInit(pTest, Complete_State, ROOT, Complete_State_Code);
 
oosmos_Debug(pTest, OOSMOS_EventNames);
//<<<INIT
 
return pTest;
}
 
[...]
oosmos/Examples/Ortho/Windows/Completion.c

oosmos_OrthoRegionInit

oosmos_OrthoRegionInit initializes an oosmos_sOrthoRegion state.
See line 98 of the code snippet below for an example.
1
2
3
 
void oosmos_OrthoRegionInit(pObject, LeafState, ParentState, DefaultState, pCode);
 
Prototype
pObject
The address of the object that contains state machine.
OrthoState
The name of the ortho state.
ParentState
The name of the parent state.
DefaultState
The name of the default state.
pCode
The address of the event code function or NULL.
1
22
23
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[GPLv2]
 
[...]
 
static test * testNew(void)
{
oosmos_Allocate(pTest, test, 1, NULL);
 
//>>>INIT
oosmos_StateMachineInit(pTest, ROOT, NULL, Active_State);
oosmos_OrthoInit(pTest, Active_State, ROOT, Active_State_Code);
oosmos_OrthoRegionInit(pTest, Active_Region1_State, Active_State, Active_Region1_Moving_State, NULL);
oosmos_LeafInit(pTest, Active_Region1_Moving_State, Active_Region1_State, NULL);
oosmos_OrthoRegionInit(pTest, Active_Region2_State, Active_State, Active_Region2_Outer_State, NULL);
oosmos_CompositeInit(pTest, Active_Region2_Outer_State, Active_Region2_State, Active_Region2_Outer_Inner_State, NULL);
oosmos_LeafInit(pTest, Active_Region2_Outer_Inner_State, Active_Region2_Outer_State, NULL);
oosmos_OrthoRegionInit(pTest, Active_Region3_State, Active_State, Active_Region3_Leaf_State, NULL);
oosmos_LeafInit(pTest, Active_Region3_Leaf_State, Active_Region3_State, Active_Region3_Leaf_State_Code);
oosmos_LeafInit(pTest, Active_Region3_Running_State, Active_Region3_State, NULL);
 
oosmos_Debug(pTest, OOSMOS_EventNames);
//<<<INIT
 
return pTest;
}
 
[...]
oosmos/Examples/Ortho/Windows/EnterExit.c

oosmos_POINTER_GUARD

oosmos_POINTER_GUARD guarantees that the passed argument is not NULL. See line 50 in the code snippet below for an example.
See Also
1
22
23
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
[GPLv2]
 
[...]
 
static void ToggleThread(const toggle * pToggle, oosmos_sState * pState)
{
oosmos_POINTER_GUARD(pToggle);
oosmos_POINTER_GUARD(pState);
 
oosmos_ThreadBegin();
for (;;) {
pinOn(pToggle->m_pPin);
oosmos_ThreadDelayMS(pToggle->m_TimeOnMS);
 
pinOff(pToggle->m_pPin);
oosmos_ThreadDelayMS(pToggle->m_TimeOffMS);
}
oosmos_ThreadEnd();
}
 
[...]
oosmos/Classes/toggle.c (thread version)

oosmos_POLL

oosmos_POLL is one of the six predefined event macros. This event is generated each time the state machine is executed and this is the current active state. See line 70 in the code snippet below for an example.
See Also
1
22
23
65
66
67
68
69
70
71
72
73
74
75
76
77
78
[GPLv2]
 
[...]
static bool Running_State_Code(void * pObject, oosmos_sState * pState, const oosmos_sEvent * pEvent)
{
toggle * pToggle = (toggle *) pObject;
 
switch (oosmos_EventCode(pEvent)) {
case oosmos_POLL: {
ToggleThread(pToggle, pState);
return true;
}
}
 
return false;
}
[...]
oosmos/Classes/toggle.c (thread version)

oosmos_PushEvent

Allows you to push a complex event onto the object's event queue. Useful for pushing complex events. That is, events that hold more than just an event code.
1
2
3
 
oosmos_PushEvent(pObject, Event)
 
Macro
pObject
Pointer to the object pointer.
Event
Event object to push onto the object's event queue.
See Also
1
22
23
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
[GPLv2]
 
[...]
oosmos_ThreadEnd();
}
 
static void EventDriverThread(const test * pTest, oosmos_sState * pState)
{
oosmos_ThreadBegin();
printf("EventDriverThread: Enter\n");
oosmos_ThreadDelayMS(1000);
 
printf("EventDriverThread: Push 998\n");
const sTestEvent TestEvent998 = { { evTestEvent, NULL }, 998 };
oosmos_PushEvent(pTest, TestEvent998);
 
printf("EventDriverThread: Push 999\n");
const sTestEvent TestEvent999 = { { evTestEvent, NULL }, 999 };
oosmos_PushEvent(pTest, TestEvent999);
oosmos_ThreadEnd();
[...]
oosmos/Tests/ThreadEvents.c

oosmos_PushEventCode

oosmos_PushEventCode sends an event to an OOSMOS object. (It actually pushes the event to the object's event queue.) If the event is handled by the current state or any of its parent states, then the appropriate action is taken in that state. If the current active state (or its parents) do not handle the event, it will be popped from the queue and no action will take place.
See line 127 for an example.
1
2
3
 
bool oosmos_PushEventCode(void * pObject, int EventCode);
 
Prototype
pObject
Pointer to the object that will react to the event.
EventCode
The event code to send. Will always be an event defined inside the implementation's .c file.
RETURN
Always returns true.
1
22
23
122
123
124
125
126
127
128
[GPLv2]
 
[...]
oosmos_PushEventCode(pMotor, evStart);
}
 
extern void motorOff(const motor * pMotor)
{
oosmos_PushEventCode(pMotor, evStop);
}
oosmos/Examples/EventDemo/Windows/motor.c

oosmos_QueueConstruct

Constructs a queue of type oosmos_sQueue.
See lines 247 and 249 in the code snippet below for examples.
1
2
3
 
bool oosmos_QueueConstruct(oosmos_sQueue * pQueue, void * pQueueData);
 
Prototype
pQueue
Pointer to a oosmos_sQueue item that holds the meta data for the queue.
pQueueData
A pointer to an array that will hold the data for the queue.
oosmos_QueueConstruct is a macro that requires that the memory area be an array in order to properly calculate queue limits.
See Also
1
22
23
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
[GPLv2]
 
[...]
 
//
// 'UartModule' is 1, 2, etc.
//
extern uart * uartNew(const int UartModule, const int BaudRate)
{
oosmos_AllocateVisible(pUART, uart, UartList, UartCount, MaxUARTS, NULL);
 
pUART->m_UartModule = UartModule;
 
const int PlibUartID = UartIndex_to_PlibUartId[UartModule-1];
pUART->m_PlibUartID = PlibUartID;
 
UARTConfigure(PlibUartID, UART_ENABLE_PINS_TX_RX_ONLY);
UARTSetFifoMode(PlibUartID, UART_INTERRUPT_ON_TX_NOT_FULL | UART_INTERRUPT_ON_RX_NOT_EMPTY);
UARTSetLineControl(PlibUartID, UART_DATA_SIZE_8_BITS | UART_PARITY_NONE | UART_STOP_BITS_1);
UARTSetDataRate(PlibUartID, GetPeripheralClock(), BaudRate);
 
const int Priority = 1;
INTSetVectorPriority(INT_VECTOR_UART(PlibUartID), GetPriorityBits(Priority));
INTSetVectorSubPriority(INT_VECTOR_UART(PlibUartID), INT_SUB_PRIORITY_LEVEL_0);
 
oosmos_QueueConstruct(&pUART->m_SendDataQueue, pUART->m_SendDataQueueData);
 
oosmos_QueueConstruct(&pUART->m_ReceiveDataQueue, pUART->m_ReceiveDataQueueData);
oosmos_SubscriberListInit(pUART->m_ReceivedByteEventSubscribers);
 
oosmos_RegisterActiveObject(pUART, RunStateMachine, &pUART->m_ActiveObject);
 
return pUART;
}
 
[...]
oosmos/Classes/PIC32/uart.c

oosmos_QueuePop

If the queue is not empty, oosmos_QueuePop will pop an element off the queue and copy it into an item that you allocate.
See lines 123 and 138 in the code snippet below for examples.
1
2
3
 
bool oosmos_QueuePop(oosmos_sQueue * pQueue, void * pPoppedItem, size_t ElementSize);
 
Prototype
pQueue
Pointer to a oosmos_sQueue item that holds the meta data for the queue.
pPoppedItem
A pointer to an item of ElementSize size into which the queue item will be popped.
ElementSize
Size of one element of the queue.
RETURN
Returns true if an item was popped off the queue, false otherwise.
See Also
1
22
23
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[GPLv2]
 
[...]
 
static void RunReceiverStateMachine(void * pObject)
{
uart * pUART = (uart *) pObject;
uint8_t Byte;
 
DisableInterrupt(pUART);
const bool PopSuccess = oosmos_QueuePop(&pUART->m_ReceiveDataQueue, &Byte, sizeof(Byte));
EnableInterrupt(pUART);
 
if (PopSuccess) {
uart_sReceivedByteEvent ReceivedByteEvent = { oosmos_EMPTY_EVENT, Byte };
oosmos_SubscriberListNotifyWithArgs(pUART->m_ReceivedByteEventSubscribers, ReceivedByteEvent);
}
}
 
static void RunSenderStateMachine(void * pObject)
{
uart * pUART = (uart *) pObject;
 
switch (pUART->m_SendState) {
case sendAwaitingCharToSend_State: {
const bool PopSuccess = oosmos_QueuePop(&pUART->m_SendDataQueue, &pUART->m_CharToSend, sizeof(pUART->m_CharToSend));
 
if (PopSuccess)
pUART->m_SendState = sendAwaitingReady_State;
 
break;
}
case sendAwaitingReady_State: {
if (UARTTransmitterIsReady(pUART->m_PlibUartID)) {
UARTSendDataByte(pUART->m_PlibUartID, pUART->m_CharToSend);
pUART->m_SendState = sendAwaitingComplete_State;
}
 
break;
}
case sendAwaitingComplete_State: {
if (UARTTransmissionHasCompleted(pUART->m_PlibUartID))
pUART->m_SendState = sendAwaitingCharToSend_State;
 
break;
}
}
}
 
[...]
oosmos/Classes/PIC32/uart.c

oosmos_QueuePush

Pushes a single item of size ElementSize onto the queue specified by pQueue.
If the queue is already full at the time of this call, the program will loop forever.
See lines 182 and 206 in the code snippet below for examples.
1
2
3
 
void oosmos_QueuePush(oosmos_sQueue * pQueue, const void * pItemToPush, size_t ElementSize);
 
Prototype
pQueue
Pointer to a oosmos_sQueue item that holds the meta data for the queue.
pItemToPush
A pointer to an item of ElementSize size that will be pushed (i.e. copied) onto the queue.
ElementSize
Size of one element of the queue.
See Also
1
22
23
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
203
204
205
206
207
208
209
[GPLv2]
 
[...]
 
static void ISR(const int UartModule)
{
uart * pUART = UartList;
 
for (int Count = 1; Count <= UartCount; pUART++, Count++) {
if (UartModule <= pUART->m_UartModule)
break;
}
 
const int PlibUartId = pUART->m_PlibUartID;
 
if (INTGetFlag(INT_SOURCE_UART_RX(PlibUartId))) {
while (UARTReceivedDataIsAvailable(PlibUartId)) {
const uint8_t Byte = UARTGetDataByte(PlibUartId);
oosmos_QueuePush(&pUART->m_ReceiveDataQueue, &Byte, sizeof(Byte));
}
 
INTClearFlag(INT_SOURCE_UART_RX(PlibUartId));
}
}
 
[...]
 
extern void uartSendChar(uart * pUART, const char Char)
{
oosmos_QueuePush(&pUART->m_SendDataQueue, &Char, sizeof(Char));
}
 
[...]
oosmos/Classes/PIC32/uart.c

oosmos_RegisterActiveObject

An active OOSMOS object is an object that has reactive behavior but does not have the complexity to warrant using a full OOSMOS state machine object.
To establish your object as an active object, you must register it with OOSMOS like this: create a subroutine for OOSMOS to call (line 118), then create an oosmos_sActiveObject member in your object (line 54) and then finally call oosmos_RegisterActiveObject (line 66).
1
2
3
 
void oosmos_RegisterActiveObject(void * pObject, void (*pFunction)(void *), oosmos_sActiveObject * pActiveObject);
 
Prototype
pObject
Pointer to your active object.
pFunction
Address of the function to call each time through the OOSMOS main loop.
pActiveObject
Pointer to the oosmos_sActiveObject object member.
See Also
1
22
23
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
[GPLv2]
 
[...]
 
struct swTag
{
pin * m_pPin;
eStates m_State;
 
oosmos_sActiveObject m_ActiveObject;
oosmos_sSubscriberList m_CloseEvent[swMaxCloseSubscribers];
oosmos_sSubscriberList m_OpenEvent[swMaxOpenSubscribers];
};
 
extern sw * swNewDetached(pin * pPin)
{
oosmos_Allocate(pSwitch, sw, swMaxSwitches, NULL);
 
pSwitch->m_pPin = pPin;
pSwitch->m_State = Unknown_State;
 
oosmos_RegisterActiveObject(pSwitch, swRunStateMachine, &pSwitch->m_ActiveObject);
 
oosmos_SubscriberListInit(pSwitch->m_CloseEvent);
oosmos_SubscriberListInit(pSwitch->m_OpenEvent);
 
return pSwitch;
}
 
[...]
 
extern void swRunStateMachine(void * pObject)
{
oosmos_POINTER_GUARD(pObject);
 
sw * pSwitch = (sw *) pObject;
 
switch (pSwitch->m_State) {
case Open_State: {
if (pinIsOn(pSwitch->m_pPin)) {
pSwitch->m_State = Closed_State;
oosmos_SubscriberListNotify(pSwitch->m_CloseEvent);
}
 
break;
}
case Closed_State: {
if (pinIsOff(pSwitch->m_pPin)) {
pSwitch->m_State = Open_State;
oosmos_SubscriberListNotify(pSwitch->m_OpenEvent);
}
 
break;
}
case Unknown_State: {
pSwitch->m_State = pinIsOn(pSwitch->m_pPin) ? Closed_State : Open_State;
break;
}
}
}
oosmos/Classes/sw.c

oosmos_RunStateMachine

This API is experimental and may change. See example on line 220 in the code snippet.
1
2
3
 
void oosmos_RunStateMachine(oosmos_sStateMachine * pStateMachine);
 
Prototype
pStateMachine
Address of the state machine within the object.
See Also
1
22
23
216
217
218
219
220
221
222
223
[GPLv2]
 
[...]
 
static void QueueEvent(motion * pMotion, int EventCode)
{
oosmos_PushEventCode(pMotion, EventCode);
oosmos_RunStateMachine(pMotion);
}
 
[...]
oosmos/Examples/Ortho/Windows/Motion.c

oosmos_RunStateMachines

oosmos_RunStateMachines runs all OOSMOS state machine objects as well as all registered Active Objects (see oosmos_RegisterActiveObject.)
See line 42 in the code snippet below for an example.
1
2
3
 
void oosmos_RunStateMachines();
 
Prototype
See Also
1
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
[GPLv2]
 
#include "oosmos.h"
#include "pin.h"
#include "toggle.h"
 
static void SetupToggle(int Pin, int OnTimeMS, int OffTimeMS)
{
pin * pPin = pinNew(Pin, pinOut, pinActiveHigh);
toggleNew(pPin, OnTimeMS, OffTimeMS);
}
 
extern void setup()
{
SetupToggle(13, 50, 500);
SetupToggle(12, 2000, 2000);
SetupToggle(11, 50, 1500);
}
 
extern void loop()
{
oosmos_RunStateMachines();
}
oosmos/Examples/Blink/Arduino/BlinkExample/BlinkExample.ino

oosmos_sActiveObject

See oosmos_RegisterActiveObject.

oosmos_sComposite

oosmos_sComposite declares a composite state in an OOSMOS state machine object.
See line 36 in the code snippet below for an example.
1
22
23
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
[GPLv2]
 
[...]
 
struct testTag
{
//>>>DECL
oosmos_sStateMachineNoQueue(ROOT);
oosmos_sComposite A_State;
oosmos_sLeaf A_Choice1_State;
oosmos_sLeaf A_Left_State;
oosmos_sLeaf A_Right_State;
oosmos_sFinal A_Final1_State;
oosmos_sLeaf B_State;
//<<<DECL
};
 
[...]
oosmos/Examples/Basic/Windows/Final.c

oosmos_Seconds2Days_Rounded

oosmos_Seconds2Days_Rounded is a macro that converts seconds to days with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_Seconds2Days_Rounded(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2Days_Truncated

oosmos_Seconds2Days_Truncated is a macro that converts seconds to days with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_Seconds2Days_Truncated(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2Hours_Rounded

oosmos_Seconds2Hours_Rounded is a macro that converts seconds to hours with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_Seconds2Hours_Rounded(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2Hours_Truncated

oosmos_Seconds2Hours_Truncated is a macro that converts seconds to hours with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_Seconds2Hours_Truncated(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2Minutes_Rounded

oosmos_Seconds2Minutes_Rounded is a macro that converts seconds to minutes with the result being rounded for better precision. If speed is more important than accuracy, see the truncated version of this macro.
1
2
3
 
oosmos_Seconds2Minutes_Rounded(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2Minutes_Truncated

oosmos_Seconds2Minutes_Truncated is a macro that converts seconds to minutes with the result being truncated due to default integral division behavior. If precision is important, see the rounded version of this macro.
1
2
3
 
oosmos_Seconds2Minutes_Truncated(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Rounded, Seconds2MS, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2MS

oosmos_Seconds2MS is a macro that converts seconds to milliseconds.
1
2
3
 
oosmos_Seconds2MS(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2US, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_Seconds2US

oosmos_Seconds2US is a macro that converts seconds to microseconds.
1
2
3
 
oosmos_Seconds2US(Seconds)
 
Macro
See Also
Divide_Integral_Rounded, Days2Hours, Days2Minutes, Days2Seconds, Days2MS, Days2US, Hours2Days_Truncated, Hours2Days_Rounded, Hours2Minutes, Hours2Seconds, Hours2MS, Hours2US, Minutes2Days_Truncated, Minutes2Days_Rounded, Minutes2Hours_Truncated, Minutes2Hours_Rounded, Minutes2Seconds, Minutes2MS, Minutes2US, Seconds2Days_Truncated, Seconds2Days_Rounded, Seconds2Hours_Truncated, Seconds2Hours_Rounded, Seconds2Minutes_Truncated, Seconds2Minutes_Rounded, Seconds2MS, MS2Days_Truncated, MS2Days_Rounded, MS2Hours_Truncated, MS2Hours_Rounded, MS2Minutes_Truncated, MS2Minutes_Rounded, MS2Seconds_Truncated, MS2Seconds_Rounded, MS2US, US2Days_Truncated, US2Days_Rounded, US2Hours_Truncated, US2Hours_Rounded, US2Minutes_Truncated, US2Minutes_Rounded, US2Seconds_Truncated, US2Seconds_Rounded, US2MS_Truncated, US2MS_Rounded

oosmos_sEvent

oosmos_sEvent is the principle event structure. It holds an event code called Code and a context pointer called pContext.
See line 47 for an example of use.
1
2
3
4
5
6
7
 
typedef struct
{
int m_Code;
void * m_pContext;
} oosmos_sEvent;
 
oosmos_sEvent Data Type
Code
Member m_Code holds the event code to be delivered.
pContext
Member m_pContext is a user-defined pointer to help the notified entity determine the context of the action.
See Also
1
22
23
27
28
29
44
45
46
47
48
49
50
51
52
53
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
103
104
105
106
107
108
109
110
115
116
117
118
119
120
[GPLv2]
 
[...]
 
//>>>EVENTS
[Code Generated by OOSMOS]
//<<<EVENTS
 
typedef union {
oosmos_sEvent Event;
} uEvents;
 
struct motorTag
{
//>>>DECL
[Code Generated by OOSMOS]
//<<<DECL
};
 
#ifndef motorMAX
#define motorMAX 3
#endif
 
static void MovingThread(oosmos_sState * pState)
{
oosmos_ThreadBegin();
for (;;) {
printf("motor: MOVING...\n");
oosmos_ThreadDelayMS(500);
}
oosmos_ThreadEnd();
}
 
//>>>CODE
[Code Generated by OOSMOS]