Esempio n. 1
0
File: server.c Progetto: GDXN/oosmos
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;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
extern matrix * matrixNew(int Rows, int Columns, ...)
{
  oosmos_Allocate(pMatrix, matrix, matrixMAX, NULL);

  pMatrix->m_Rows    = 0;
  pMatrix->m_Columns = 0;

  int RowIndex;

  for (RowIndex = 0; RowIndex < matrixMAX_ROWS; RowIndex++) {
    pMatrix->m_pRowPins[RowIndex] = NULL;

    int ColumnIndex;

    for (ColumnIndex = 0; ColumnIndex < matrixMAX_COLS; ColumnIndex++) {
      pMatrix->m_pColumnPins[ColumnIndex]       = NULL;
      pMatrix->m_pSwitch[RowIndex][ColumnIndex] = NULL;
    }
  }

  //                                      StateName      Parent        Default
  //                            =====================================================
  oosmos_StateMachineInitNoQueue(pMatrix, StateMachine,  NULL,         Running_State);
    oosmos_LeafInit             (pMatrix, Running_State, StateMachine               );
    
  va_list ArgList;
  va_start(ArgList, Columns);

  int Row;
  
  for (Row = 1; Row <= Rows; Row += 1)
    AddRow(pMatrix, Row, va_arg(ArgList, pin *));

  int Column;
  
  for (Column = 1; Column <= Columns; Column += 1)
    AddColumn(pMatrix, Column, va_arg(ArgList, pin *));

  va_end(ArgList);
  
  return pMatrix;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
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;
}