extern server * serverNew(sock * pSock) { server * pServer = (server *) malloc(sizeof(server)); /* StateName Parent Default */ /* ====================================================== */ oosmos_StateMachineInit(pServer, StateMachine, NULL, Running_State); oosmos_LeafInit (pServer, Running_State, StateMachine ); pServer->m_pSock = pSock; return pServer; }
extern encodertest * encodertestNew(pin * pPinA, pin * pPinB, int Max) { oosmos_Allocate(pEncoderTest, encodertest, MAX_ENCODERTESTS, NULL); // StateName Parent Default // ====================================================== oosmos_StateMachineInit(pEncoderTest, StateMachine, NULL, Idle_State); oosmos_LeafInit (pEncoderTest, Idle_State, StateMachine ); encoder * pEncoder = encoderNew(pPinA, pPinB, Max); encoderSubscribeChangeEvent(pEncoder, &pEncoderTest->EventQueue, ChangeEvent, NULL); pEncoderTest->m_pEncoder = pEncoder; return pEncoderTest; }
extern switchtest * switchtestNew(pin * pPin) { oosmos_Allocate(pSwitchTest, switchtest, MAX_SWITCHTESTS, NULL); /* StateName Parent Default */ /* ===================================================== */ oosmos_StateMachineInit(pSwitchTest, StateMachine, NULL, Idle_State); oosmos_LeafInit (pSwitchTest, Idle_State, StateMachine ); sw * pSwitch = swNew(pPin); swSubscribeOpenEvent(pSwitch, &pSwitchTest->EventQueue, OpenEvent, NULL); swSubscribeCloseEvent(pSwitch, &pSwitchTest->EventQueue, ClosedEvent, NULL); return pSwitchTest; }
static test * testNew(void) { oosmos_Allocate(pTest, test, 1, NULL); // StateName Parent Default // ================================================================================================= oosmos_StateMachineInit (pTest, StateMachine, NULL, Active_State ); oosmos_OrthoInitNoCode (pTest, Active_State, StateMachine ); oosmos_OrthoRegionInitNoCode(pTest, Active_Top_State, Active_State, Active_Top_Moving_State ); oosmos_LeafInitNoCode (pTest, Active_Top_Moving_State, Active_Top_State ); oosmos_OrthoRegionInit (pTest, Active_Middle_State, Active_State, Active_Middle_Idle_State ); oosmos_CompositeInitNoCode(pTest, Active_Middle_Idle_State, Active_Middle_State, Active_Middle_Idle_Inner_State); oosmos_LeafInitNoCode (pTest, Active_Middle_Idle_Inner_State, Active_Middle_Idle_State ); oosmos_OrthoRegionInitNoCode(pTest, Active_Base_State, Active_State, Active_Base_Leaf_State ); oosmos_LeafInit (pTest, Active_Base_Leaf_State, Active_Base_State ); oosmos_LeafInitNoCode (pTest, Active_Base_Running_State, Active_Base_State ); oosmos_Debug(&pTest->StateMachine, true, NULL); return pTest; }
extern keypad * keypadNew(matrix * pMatrix) { oosmos_Allocate(pKeypad, keypad, 1, NULL); // StateName Parent Default // ================================================ oosmos_StateMachineInit(pKeypad, StateMachine, NULL, Idle_State); oosmos_LeafInit (pKeypad, Idle_State, StateMachine ); NewSwitchWithContext(pKeypad, pMatrix, 1, 1, "1"); NewSwitchWithContext(pKeypad, pMatrix, 1, 2, "2"); NewSwitchWithContext(pKeypad, pMatrix, 1, 3, "3"); NewSwitchWithCodes (pKeypad, pMatrix, 2, 1, FourPressedEvent, FourReleasedEvent); NewSwitchWithContext(pKeypad, pMatrix, 2, 2, "5"); NewSwitchWithContext(pKeypad, pMatrix, 2, 3, "6"); NewSwitchWithContext(pKeypad, pMatrix, 3, 1, "7"); NewSwitchWithContext(pKeypad, pMatrix, 3, 2, "8"); NewSwitchWithContext(pKeypad, pMatrix, 3, 3, "9"); return pKeypad; }