示例#1
0
文件: main.c 项目: trampi/eds-ss15
/*..........................................................................*/
int main() {

    /* initialize the framework and the underlying RT kernel */
    QF_init();

    /* initialize event pools... have to be initialized in increasing size order */
    QF_poolInit(l_smlPoolSto_4, sizeof(l_smlPoolSto_4), sizeof(QEvt));
    QF_poolInit(l_smlPoolSto_6, sizeof(l_smlPoolSto_6), sizeof(SetEvt));
    QF_poolInit(l_smlPoolSto_14, sizeof(l_smlPoolSto_14), sizeof(RtcEvt));

    /*create the coffe active object*/
    CoffeeAO_ctor(&l_CoffeeAO);

    /*start active object*/
    QActive_start((QActive *)&l_CoffeeAO, 3,
                  (const QEvt**)l_smlPoolSto_14, Q_DIM(l_smlPoolSto_14),
                  (void *)0, 0, (QEvt *)0);

    /*initialize bsp after pools*/
    BSP_Init();

    //printf("%i\n", sizeof(QEvt));
    //printf("%i\n", sizeof(SetEvt));
    //printf("%i\n", sizeof(AdEvt));
    //printf("%i\n", sizeof(RtcEvt));

    /* run the QF application */
    QF_run();

    return 0;
}
示例#2
0
/*..........................................................................*/
void main(int argc, char *argv[]) {
                          /* explicitly invoke the active objects' ctors... */
    Missile_ctor();
    Ship_ctor();
    Tunnel_ctor();

    BSP_init(argc, argv);           /* initialize the Board Support Package */

    QF_init();     /* initialize the framework and the underlying RT kernel */

                                           /* initialize the event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
    QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));

    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));   /* init publish-subscribe */

                            /* send object dictionaries for event queues... */
    QS_OBJ_DICTIONARY(l_missileQueueSto);
    QS_OBJ_DICTIONARY(l_shipQueueSto);
    QS_OBJ_DICTIONARY(l_tunnelQueueSto);

                             /* send object dictionaries for event pools... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
    QS_OBJ_DICTIONARY(l_medPoolSto);

               /* send signal dictionaries for globally published events... */
    QS_SIG_DICTIONARY(TIME_TICK_SIG,      0);
    QS_SIG_DICTIONARY(PLAYER_TRIGGER_SIG, 0);
    QS_SIG_DICTIONARY(PLAYER_QUIT_SIG,    0);
    QS_SIG_DICTIONARY(GAME_OVER_SIG,      0);

                                             /* start the active objects... */
    QActive_start(AO_Missile,
                  1,                                            /* priority */
                  l_missileQueueSto, Q_DIM(l_missileQueueSto), /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvent *)0);                  /* no initialization event */
    QActive_start(AO_Ship,
                  2,                                            /* priority */
                  l_shipQueueSto,    Q_DIM(l_shipQueueSto),    /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvent *)0);                  /* no initialization event */
    QActive_start(AO_Tunnel,
                  3,                                            /* priority */
                  l_tunnelQueueSto,  Q_DIM(l_tunnelQueueSto),  /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvent *)0);                  /* no initialization event */

    QF_run();                                     /* run the QF application */
}
示例#3
0
/*..........................................................................*/
int main(int argc, char *argv[]) {
    UI_ctor();                          /* instantiate the UI Active Object */

    BSP_init(argc, argv);           /* initialize the Board Support Package */

    QF_init();     /* initialize the framework and the underlying RT kernel */

                                           /* initialize the event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
//  QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));

    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));   /* init publish-subscribe */

                                                 /* setup the QS filters... */
                            /* send object dictionaries for event queues... */
    QS_OBJ_DICTIONARY(l_uiQueueSto);

                             /* send object dictionaries for event pools... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
//    QS_OBJ_DICTIONARY(l_medPoolSto);

               /* send signal dictionaries for globally published events... */
    QS_SIG_DICTIONARY(QUIT_SIG, 0);

                                             /* start the active objects... */
    QActive_start(AO_UI,
                  1,                                            /* priority */
                  l_uiQueueSto, Q_DIM(l_uiQueueSto),           /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvt *)0);                  /* no initialization event */

    return QF_run();                              /* run the QF application */
}
/*..........................................................................*/
int main(void) {
    uint8_t n;

    Philo_ctor();             /* instantiate all Philosopher active objects */
    Table_ctor();                    /* instantiate the Table active object */

    BSP_init();           /* initialize the Board Support Package */

    QF_init();     /* initialize the framework and the underlying RT kernel */

                                                  /* object dictionaries... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
    QS_OBJ_DICTIONARY(l_tableQueueSto);
    QS_OBJ_DICTIONARY(l_philoQueueSto[0]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[1]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[2]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[3]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[4]);

    //QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));  /* init publish-subscribe */

                                                /* initialize event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

    for (n = 0; n < N_PHILO; ++n) {           /* start the active objects... */
        QActive_start(AO_Philo[n], (uint8_t)(n + 1),
                      l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
                      (void *)0, 0, (QEvt *)0);
    }
    QActive_start(AO_Table, (uint8_t)(N_PHILO + 1),
                  l_tableQueueSto, Q_DIM(l_tableQueueSto),
                  (void *)0, 0, (QEvt *)0);

    return QF_run();                              /* run the QF application */
}
示例#5
0
文件: comp.c 项目: roland-wilhelm/iot
/*..........................................................................*/
int comp_main(int argc, char *argv[]) {
    printf("Orthogonal Component pattern\nQEP version: %s\nQF  version: %s\n"
           "Press 'o' to turn the Alarm ON\n"
           "Press 'f' to turn the Alarm OFF\n"
           "Press '0'..'9' to set the Alarm time\n"
           "Press 'a' to set the Clock in 12-hour mode\n"
           "Press 'b' to set the Clock in 24-hour mode\n"
           "Press ESC to quit...\n",
           QEP_getVersion(), QF_getVersion());

   

    QF_init();    /* initialize the framework and the underlying RT kernel */

    

                                               /* initialize event pools... */

    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

                             /* instantiate and start the active objects... */
    AlarmClock_ctor(&l_alarmClock);
    QActive_start((QActive *)&l_alarmClock, 1,
                  l_alarmClockQSto, Q_DIM(l_alarmClockQSto),
                  (void *)0, 0, (QEvent *)0);

    QF_run();                                     /* run the QF application */

    return 0;
}
示例#6
0
文件: main.c 项目: henrychoi/realtime
/*..........................................................................*/
int main(
#ifdef WIN32
    int argc, char *argv[]
#endif
) {
    uint8_t i;
    for(i = 0; i < N_CLOOP; ++i) {/* Instantiate the control loop active
                                  objects; this is unnecessary in C++, as the
                                  ctor is called even for a static object */
        CLoop_ctor(&l_cloop[i]);
    }

#ifdef WIN32
    BSP_init(argc, argv);           /* initialize the Board Support Package */
#elif defined(__MICROBLAZE__)
    BSP_init();
#endif
    QF_init();     /* initialize the framework and the underlying RT kernel */
    declareQSDictionary();/* TODO: send object dictionaries on (re)connection
                           * with QSpy */
    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));   /* init publish-subscribe */
                                    /* initialize event pools; NOTE: plural */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

    for(i = 0; i < N_CLOOP; ++i) {           /* start the active objects... */
        QActive_start((QActive*)&l_cloop[i], i+1   /* lowest AO priority: 1 */
                      , l_cloopQueueSto[i], Q_DIM(l_cloopQueueSto[i])
                      , NULL/* I don't supply stack */, BSP_STACK_SIZE
                      , NULL/* no data to supply to initial transition */);
    }

    return QF_run();                              /* run the QF application */
}
示例#7
0
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO]; /* small pool */
    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */

    QF_init();    /* initialize the framework and the underlying RT kernel */
    BSP_init();   /* initialize the Board Support Package */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    /* initialize publish-subscribe... */
    QF_psInit(subscrSto, Q_DIM(subscrSto));

    /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0U; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n],           /* AO to start */
                      (uint_fast8_t)(n + 1), /* QP priority of the AO */
                      philoQueueSto[n],      /* event queue storage */
                      Q_DIM(philoQueueSto[n]), /* queue length [events] */
                      (void *)0,             /* stack storage (not used) */
                      0U,                    /* size of the stack (default) */
                     (QEvt *)0);             /* initialization event */
    }

    /* Table AO uses the custom stack size.
    * NOTE: Remember to configure sufficient number of threads with
    * user-provided stack size OS_PRIVCNT in RTX_Conf_CM.c
    */
    QF_setRtxPrio(AO_Table, osPriorityHigh); /* set RTX priority */
    QACTIVE_START(AO_Table,                  /* AO to start */
                  (uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */
                  tableQueueSto,             /* event queue storage */
                  Q_DIM(tableQueueSto),      /* queue length [events] */
                  (void *)0,                 /* stack storage (not used) */
                  128U*4U,                   /* stack size [bytes] (or 0) */
                  (QEvt *)0);                /* initialization event */

    return QF_run(); /* run the QF application */
}
示例#8
0
文件: main.c 项目: KnightSch/qpc
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO]; /* small pool */
    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */

    QF_init();    /* initialize the framework and the underlying RT kernel */
    BSP_init();   /* initialize the Board Support Package */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    /* initialize publish-subscribe... */
    QF_psInit(subscrSto, Q_DIM(subscrSto));

    /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0U; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n],           /* AO to start */
                      (uint_fast8_t)(n + 1), /* QP priority of the AO */
                      philoQueueSto[n],      /* event queue storage */
                      Q_DIM(philoQueueSto[n]), /* queue length [events] */
                      (void *)0,             /* stack storage (not used) */
                      0U,                    /* size of the stack [bytes] */
                     (QEvt *)0);             /* initialization event */
    }
    QACTIVE_START(AO_Table,                  /* AO to start */
                  (uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */
                  tableQueueSto,             /* event queue storage */
                  Q_DIM(tableQueueSto),      /* queue length [events] */
                  (void *)0,                 /* stack storage (not used) */
                  0U,                        /* size of the stack [bytes] */
                  (QEvt *)0);                /* initialization event */

    return QF_run(); /* run the QF application */
}
示例#9
0
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO];       /* small pool */
    uint8_t n;

    Philo_ctor();             /* instantiate all Philosopher active objects */
    Table_ctor();                    /* instantiate the Table active object */

    QF_init();     /* initialize the framework and the underlying RT kernel */
    BSP_init();                     /* initialize the Board Support Package */

                                                  /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    QF_psInit(subscrSto, Q_DIM(subscrSto));       /* init publish-subscribe */

                                               /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    for (n = 0U; n < N_PHILO; ++n) {         /* start the active objects... */
        QACTIVE_START(AO_Philo[n], (uint8_t)(n + 1),
                      philoQueueSto[n], Q_DIM(philoQueueSto[n]),
                      (void *)0, 0U, (QEvt *)0);
    }
    QACTIVE_START(AO_Table, (uint8_t)(N_PHILO + 1),
                  tableQueueSto, Q_DIM(tableQueueSto),
                  (void *)0, 0U, (QEvt *)0);

    return QF_run();                              /* run the QF application */
}
示例#10
0
/*..........................................................................*/
int main(int argc, char *argv[]) {
    printf("Reminder state pattern\nQEP version: %s\nQF  version: %s\n"
           "Press 'e' to echo the current value...\n"
           "Press ESC to quit...\n",
           QEP_getVersion(), QF_getVersion());

    Cruncher_ctor(&l_cruncher);

    BSP_init(argc, argv);                             /* initialize the BSP */

    QF_init();     /* initialize the framework and the underlying RT kernel */

    /* publish-subscribe not used, no call to QF_psInit() */

    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

                             /* instantiate and start the active objects... */
    QACTIVE_START((QActive *)&l_cruncher, 1,
                  l_cruncherQSto, Q_DIM(l_cruncherQSto),
                  (void *)0, 1024, (QEvt *)0);

    return QF_run();                              /* run the QF application */
}
示例#11
0
文件: qf_main.c 项目: KnightSch/qpc
int main(void) {
    static QEvt const *l_tableQueueSto[N_PHILO];
    static QEvt const *l_philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList l_subscrSto[MAX_PUB_SIG];

    /* storage for event pools... */
    static QF_MPOOL_EL(TableEvt) l_smlPoolSto[2*N_PHILO]; /* small pool */

    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */

    QF_init();  /* initialize the framework and the underlying RT kernel */
    BSP_init(); /* initialize the BSP */

    /* send object dictionaries for event pools... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);

   /* init publish-subscribe... */
    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));

    /* initialize event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n], (uint8_t)(n + 1),
                      l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
                      (void *)0, 0U, (QEvt *)0);
    }
    QACTIVE_START(AO_Table, (uint8_t)(N_PHILO + 1),
                  l_tableQueueSto, Q_DIM(l_tableQueueSto),
                  (void *)0, 0U, (QEvt *)0);

    return QF_run(); /* run the QF application, QF_run() does not return  */
}
示例#12
0
/*............................................................................*/
int main(void)
{
   /*!< At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/
       startup_stm32f429_439xx.s/startup_stm32f401xx.s) before to branch to
       application main. To reconfigure the default setting of SystemInit()
       function, refer to system_stm32f4xx.c file
    */

   /* Enable debugging for select modules - Note: this has no effect in rel
    * builds since all DBG level logging is disabled and only LOG and up msgs
    * will get printed. */
   DBG_setDefaults();

   /* initialize the Board Support Package */
   BSP_init();

   dbg_slow_printf("Initialized BSP\n");
   log_slow_printf("Starting Bootloader version %s built on %s\n", FW_VER, BUILD_DATE);

   /* Instantiate the Active objects by calling their "constructors"         */
   dbg_slow_printf("Initializing AO constructors\n");

   /* Make sure the comm interfaces are up first */
   SerialMgr_ctor();
   LWIPMgr_ctor();

   /* Iterate though the available I2C busses on the system and call the ctor()
    * for each instance of the I2CBusMgr AO for each bus. */
   for( uint8_t i = 0; i < MAX_I2C_BUS; ++i ) {
      I2CBusMgr_ctor( i );      /* Start this instance of AO for this bus. */
   }

   I2C1DevMgr_ctor();
   CommMgr_ctor();
   FlashMgr_ctor();
   SysMgr_ctor();

   dbg_slow_printf("Initializing QF\n");
   QF_init();       /* initialize the framework and the underlying RT kernel */

   /* object dictionaries... */
   dbg_slow_printf("Initializing object dictionaries for QSPY\n");
   QS_OBJ_DICTIONARY(l_smlPoolSto);
   QS_OBJ_DICTIONARY(l_medPoolSto);
   QS_OBJ_DICTIONARY(l_lrgPoolSto);
   QS_OBJ_DICTIONARY(l_SerialMgrQueueSto);
   QS_OBJ_DICTIONARY(l_LWIPMgrQueueSto);
   QS_OBJ_DICTIONARY(l_I2CBusMgrQueueSto);
   QS_OBJ_DICTIONARY(l_I2C1DevMgrQueueSto);
   QS_OBJ_DICTIONARY(l_CommMgrQueueSto);
   QS_OBJ_DICTIONARY(l_FlashMgrQueueSto);
   QS_OBJ_DICTIONARY(l_SysMgrQueueSto);

   QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));     /* init publish-subscribe */

   /* initialize the general memory pool */
   dbg_slow_printf("Initializing general purpose memory pool in CCMRAM\n");
   QMPool_init(
         p_glbMemPool,
         l_memPoolSto,
         sizeof(l_memPoolSto),
         DC3_MAX_MEM_BLK_SIZE
   );

   /* initialize event pools... */
   dbg_slow_printf("Initializing small event storage pool\n");
   QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
   dbg_slow_printf("Initializing medium event storage pool\n");
   QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));
   dbg_slow_printf("Initializing large event storage pool\n");
   QF_poolInit(l_lrgPoolSto, sizeof(l_lrgPoolSto), sizeof(l_lrgPoolSto[0]));

   /* Start Active objects */
   dbg_slow_printf("Starting Active Objects\n");

   QACTIVE_START(AO_SerialMgr,
         SERIAL_MGR_PRIORITY,                                    /* priority */
         l_SerialMgrQueueSto, Q_DIM(l_SerialMgrQueueSto),       /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "SerialMgr"                                     /* Name of the task */
   );

   QACTIVE_START(AO_LWIPMgr,
         ETH_PRIORITY,                                           /* priority */
         l_LWIPMgrQueueSto, Q_DIM(l_LWIPMgrQueueSto),           /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "LWIPMgr"                                       /* Name of the task */
   );

   /* Iterate though the available I2C busses on the system and start an
    * instance of the I2CBusMgr AO for each bus.
    * WARNING!!!: make sure that the priorities for them are all together since
    * this loop will iterates through them and will take another AO's priority.
    * You will end up with clashing priorities for your AOs.*/
   for( uint8_t i = 0; i < MAX_I2C_BUS; ++i ) {
      QACTIVE_START(AO_I2CBusMgr[i],
            I2CBUS1MGR_PRIORITY + i,                                /* priority */
            l_I2CBusMgrQueueSto[i], Q_DIM(l_I2CBusMgrQueueSto[i]), /* evt queue */
            (void *)0, 0,                              /* per-thread stack size */
            (QEvt *)0,                               /* no initialization event */
            "I2CBusMgr"                                     /* Name of the task */
      );
   }

   QACTIVE_START(AO_I2C1DevMgr,
         I2C1DEVMGR_PRIORITY,                                    /* priority */
         l_I2C1DevMgrQueueSto, Q_DIM(l_I2C1DevMgrQueueSto),     /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "I2CDevMgr"                                     /* Name of the task */
   );

   QACTIVE_START(AO_CommMgr,
         COMM_MGR_PRIORITY,                                      /* priority */
         l_CommMgrQueueSto, Q_DIM(l_CommMgrQueueSto),           /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "CommMgr"                                       /* Name of the task */
   );

   QACTIVE_START(AO_FlashMgr,
         FLASH_MGR_PRIORITY,                                     /* priority */
         l_FlashMgrQueueSto, Q_DIM(l_FlashMgrQueueSto),         /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "FlashMgr"                                      /* Name of the task */
   );

   QACTIVE_START(AO_SysMgr,
         SYS_MGR_PRIORITY,                                       /* priority */
         l_SysMgrQueueSto, Q_DIM(l_SysMgrQueueSto),             /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "SysMgr"                                        /* Name of the task */
   );
   log_slow_printf("Starting QPC. All logging from here on out shouldn't show 'SLOW'!!!\n\n");
   QF_run();                                       /* run the QF application */

   return(0);
}
示例#13
0
/*..........................................................................*/
int main(void) {

    Table_ctor();               /* instantiate the Table active object */
    LwIPMgr_ctor();             /* instantiate all LwIP-Manager active object */
    MgtProtocolHandler_ctor();  /* instantiate the MgtProtocolHandler active object */
    IceMgr_ctor();              /* instantiate the IceMgr active object */
    ModIo2Mgr_ctor();           /* instantiate the ModIo2Mgr active object */
    IceDetectionMgr_ctor();     /* instantiate the IceDetectionMgr active object */

    BSP_init();                 /* initialize the Board Support Package */

    QF_init();                  /* initialize the framework and the underlying RT kernel */

    /*
    ModLED8x8_init();
    while (1) {
      ModLED8x8_scrollString("*** RES Smart Cocktail Factory ***", SCROLL_RIGHT);
      delayMs(500);
      ModLED8x8_scrollString("*** RES Smart Cocktail Factory ***", SCROLL_LEFT);
      delayMs(500);
    }
    */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
    QS_OBJ_DICTIONARY(l_medPoolSto);
    QS_OBJ_DICTIONARY(l_lwIPMgrQueueSto);
    QS_OBJ_DICTIONARY(l_tableQueueSto);
    QS_OBJ_DICTIONARY(l_mgtProtocolHandlerSto);
    QS_OBJ_DICTIONARY(l_iceMgrSto);
    QS_OBJ_DICTIONARY(l_modIo2MgrSto);
    QS_OBJ_DICTIONARY(l_iceDetectionMgrSto);

    /* init publish-subscribe */
    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));

    /* initialize event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
    QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));

    /* start active objects */
    QActive_start(AO_LwIPMgr, 1,
                  l_lwIPMgrQueueSto, Q_DIM(l_lwIPMgrQueueSto),
                  (void *)0, 0, (QEvent *)0);

    QActive_start(AO_Table, 3,
                  l_tableQueueSto, Q_DIM(l_tableQueueSto),
                  (void *)0, 0, (QEvent *)0);

    QActive_start(AO_MgtProtocolHandler, 5,
                  l_mgtProtocolHandlerSto, Q_DIM(l_mgtProtocolHandlerSto),
                  (void *)0, 0, (QEvent *)0);

    QActive_start(AO_IceMgr, 7,
                  l_iceMgrSto, Q_DIM(l_iceMgrSto),
                  (void *)0, 0, (QEvent *)0);

    QActive_start(AO_ModIo2Mgr, 9,
                  l_modIo2MgrSto, Q_DIM(l_modIo2MgrSto),
                  (void *)0, 0, (QEvent *)0);

    QActive_start(AO_IceDetectionMgr, 11,
                  l_iceDetectionMgrSto, Q_DIM(l_iceDetectionMgrSto),
                  (void *)0, 0, (QEvent *)0);

    /* run the QF application */
    QF_run();

    return 1;
}
示例#14
0
文件: main.c 项目: KnightSch/qpc
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];

    static OS_STK philoStk[N_PHILO][128]; /* stacks for the Philosophers */
    static OS_STK tableStk[256];          /* stack for the Table */

    static QSubscrList subscrSto[MAX_PUB_SIG];
    static TableEvt smlPoolSto[2*N_PHILO]; /* storage for small event pool */
    uint8_t n;

    /* in C you need to explicitly instantiate all AOs...  */
    Philo_ctor();
    Table_ctor();

    QF_init();  /* initialize the framework and the underlying RT kernel */
    BSP_init(); /* initialize the Board Support Package */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    /* init publish-subscribe */
    QF_psInit(subscrSto, Q_DIM(subscrSto));

    /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    /* start the active objects... */
    /* CAUTION:
    * Make sure to configure **SUFFICIENT** number of uC/OS-II tasks and
    * message queues in "os_cfg.h" for all your active objects!!!
    */
    for (n = 0U; n < N_PHILO; ++n) {
        /* NOTE: provide uC/OS-II task attributes for the AO's task */
        QF_setUCosTaskAttr(AO_Philo[n], OS_TASK_OPT_STK_CHK);
        QACTIVE_START(AO_Philo[n],
                      (uint_fast8_t)(n + 1), /* QP priority */
                      philoQueueSto[n],      /* storage for the AO's queue */
                      Q_DIM(philoQueueSto[n]), /* queue's length [entries] */
                      philoStk[n],           /* stack storage */
                      sizeof(philoStk[n]),   /* sack size [bytes] */
                      (QEvt const *)0);      /* initialization event */
    }

    /* NOTE: provide uC/OS-II task attributes for the AO's task */
    QF_setUCosTaskAttr(AO_Table, OS_TASK_OPT_STK_CHK);
    QACTIVE_START(AO_Table,
                  (uint_fast8_t)(N_PHILO + 1), /* QP priority */
                  tableQueueSto,  /* storage for the AO's queue */
                  Q_DIM(tableQueueSto), /* queue's length [entries] */
                  tableStk,             /* stack storage */
                  sizeof(tableStk),     /* sack size [bytes] */
                  (QEvt const *)0);     /* initialization event */

    return QF_run(); /* run the QF application */
}
示例#15
0
文件: main.c 项目: KnightSch/qpc
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static uint64_t tableStackSto[64];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static uint64_t philoStackSto[N_PHILO][64];

    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO]; /* small pool */

    /* stack for the "naked" test thread */
    static void const *testQueueSto[5];
    static uint64_t testStackSto[64];

    /* stack for the QXK's idle thread */
    static uint64_t idleStackSto[32];

    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */
    Test_ctor();  /* instantiate the Test "naked" thread */

    QF_init();    /* initialize the framework */
    BSP_init();   /* initialize the Board Support Package */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    /* initialize QXK... */
    QXK_init(idleStackSto, sizeof(idleStackSto));

    /* initialize publish-subscribe... */
    QF_psInit(subscrSto, Q_DIM(subscrSto));

    /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0U; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n],           /* AO to start */
                  (uint_fast8_t)(n + 1),     /* QP priority of the AO */
                  philoQueueSto[n],          /* event queue storage */
                  Q_DIM(philoQueueSto[n]),   /* queue length [events] */
                  philoStackSto[n],          /* stack storage */
                  sizeof(philoStackSto[n]),  /* stack size [bytes] */
                  (QEvt *)0);                /* initialization event */
    }
    QACTIVE_START(AO_Table,                  /* AO to start */
                  (uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */
                  tableQueueSto,             /* event queue storage */
                  Q_DIM(tableQueueSto),      /* queue length [events] */
                  tableStackSto,             /* stack storage */
                  sizeof(tableStackSto),     /* stack size [bytes] */
                  (QEvt *)0);                /* initialization event */

    /* start the "naked" thread */
    QXTHREAD_START(&XT_Test->super,          /* Thread to start */
                  (uint_fast8_t)10U,         /* QP priority of the thread */
                  testQueueSto,              /* message queue storage */
                  Q_DIM(testQueueSto),       /* message length [events] */
                  testStackSto,              /* stack storage */
                  sizeof(testStackSto),      /* stack size [bytes] */
                  (QEvt *)0);                /* initialization event */

    return QF_run(); /* run the QF application */
}
示例#16
0
文件: main.c 项目: chalot/BWRecorder
/*..........................................................................*/
int main(void) {

	/**初始化BSP*/
	BSP_init();

//	/**载入系统参数,如失败系统停止运行*/
//	if(!Load_Parameters())
//	{
//		//系统参数初始化失败,程序终止
//		return -1;
//	}

	/**初始化QP框架*/
	QF_init();

	/** 初始化事件池,用了小尺寸事件池和中尺寸事件池,未用大尺寸事件池,因为并没有字节数特别多的事件 */
	QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
	QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));
//	QF_poolInit(l_largePoolSto, sizeof(l_largePoolSto), sizeof(l_largePoolSto[0]));

	/**初始化publish-subscribe缓区*/
	QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));

	/**创建内存池,预分配一个块。只能调用一次*/
	if (MP_Create() < 0) {
		/**内存池创建失败,程序终止*/
		return -1;
	}

#ifdef GPRS
	/**GPRS状态机初始化*/
	QGprs_ctor();

	/**启动GPRS状态机*/
	QActive_start(AO_Gprs, AO_PRIO_GPRS, l_GPRSQueueSto, Q_DIM(l_GPRSQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef GPS
	/**GPS状态机初始化*/
	QGps_ctor();

	/**启动状态机*/
	QActive_start(AO_Gps, AO_PRIO_GPS, l_GPSQueueSto, Q_DIM(l_GPSQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef ACCDET
	/**ACC检测状态机初始化*/
	QACCDetector_ctor();

	/**启动ACC检测状态机*/
	QActive_start(AO_ACCDetector, AO_PRIO_ACCDET, l_ACCQueueSto,
			Q_DIM(l_ACCQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef CAN
	/**CAN状态机初始化*/
	QCAN_ctor();

	/**启动CAN状态机*/
	QActive_start(AO_Can, AO_PRIO_CAN, l_CANQueueSto, Q_DIM(l_CANQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef LCD
	/**LCD屏状态机初始化 */
	QLCD_ctor();

	/**启动状态机*/
	QActive_start(AO_LCD, AO_PRIO_LCD, l_LCDQueueSto, Q_DIM(l_LCDQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef SENSOR
	/**LCD屏状态机初始化 */
	Q3DSensor_ctor();

	/**启动状态机*/
	QActive_start(AO_3DSensor, AO_PRIO_SENSOR, l_SENSORQueueSto,
			Q_DIM(l_SENSORQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef VIDEO
	/**摄像头状态机初始化 */
	QVideo_ctor();

	/**启动状态机*/
	QActive_start(AO_Video, AO_PRIO_VIDEO, l_VIDEOQueueSto,
			Q_DIM(l_VIDEOQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef TTS
	/**TTS状态机初始化 */
	QTTS_ctor();

	/**启动状态机*/
	QActive_start(AO_TTS, AO_PRIO_TTS, l_TTSQueueSto, Q_DIM(l_TTSQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef RECORDER
	/**TTS状态机初始化 */
	QRecorder_ctor();

	/**启动状态机*/
	QActive_start(AO_Recorder, AO_PRIO_RECORDER, l_RECORDQueueSto,
			Q_DIM(l_RECORDQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef ICCARD
	/**IC卡状态机初始化 */
	QICcard_ctor();

	/**启动状态机*/
	QActive_start(AO_ICCard, AO_PRIO_IC, l_ICCARDQueueSto,
			Q_DIM(l_ICCARDQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef PRINTER
	/**IC卡状态机初始化 */
	QPrinter_ctor();

	/**启动状态机*/
	QActive_start(AO_Printer, AO_PRIO_PRINTER, l_PRINTERQueueSto,
			Q_DIM(l_PRINTERQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef IR
	/**IC卡状态机初始化 */
	QIR_ctor();

	/**启动状态机*/
	QActive_start(AO_IR, AO_PRIO_IR, l_IRQueueSto, Q_DIM(l_IRQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef USB
	/**IC卡状态机初始化 */
	QUSB_ctor();

	/**启动状态机*/
	QActive_start(AO_USB, AO_PRIO_USB, l_USBQueueSto, Q_DIM(l_USBQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef AUDIO
	/**IC卡状态机初始化 */
	QAudio_ctor();

	/**启动状态机*/
	QActive_start(AO_Audio, AO_PRIO_AUDIO, l_AUDIOQueueSto,
			Q_DIM(l_AUDIOQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef UPGRADE
	/**SD卡升级状态机初始化*/
	QUpgrade_ctor();

	/**启动升级状态机*/
	QActive_start(AO_Upgrade, AO_PRIO_UPGRADE, l_UPGRADEQueueSto,
			Q_DIM(l_UPGRADEQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

	/**系统时间状态机初始化*/
	QSystick_ctor();

	/**启动系统时钟状态机*/
	QActive_start(AO_Systick, AO_PRIO_SYSTICK, l_SYSTICKQueueSto,
			Q_DIM(l_SYSTICKQueueSto), (void *) 0, 0U, (QEvt *) 0);

	/**载入系统参数,如失败系统停止运行*/
//	if (!Load_Parameters()) {
//		/**系统参数初始化失败,程序终止*/
//		return -1;
//	}

	/**嵌套中断向量初始化*/
	NVIC_Configuration();

	/**启动QP框架,程序开始运行*/
	return QF_run();
}
示例#17
0
文件: main.c 项目: JPLOpenSource/SCA
int main(int argc, char* argv[])
{
    char cmdBuf[SOCK_BUFF_SIZE];

    printf("Quantum Test\nQEP %s\nQF  %s, QF/Linux port %s\n",
           QEP_getVersion(),
           QF_getVersion(), QF_getPortVersion());

    QF_init();
	QF_psInit(subscrSto, Q_DIM(subscrSto));
	QF_poolInit(poolArray, sizeof(poolArray), sizeof(GenEvt));
	
    applicationStart(QSIZE);

    for (;;)
    {
      // Get the incoming string command from the dmsTerminal or the GUI
      receiveCmd(cmdBuf);


	  // Attempt to parse the command string for IMPL or ACTIVE calls
	   char tmpBuf[USER_ENTRY_SIZE];
	   char smName[USER_ENTRY_SIZE];
	   char attrName[USER_ENTRY_SIZE];
	   char valStr[USER_ENTRY_SIZE];
	   // scan for IMPL['SM'].set("attr", True/False), allowing blanks
	   // IMPL['trans'].set('guard', False)
	   int cnt = sscanf(strcpy(tmpBuf, cmdBuf),
			   "IMPL[%*['\"]%[^'\"]%*['\"]].set(%*['\"]%[^'\"]%*['\"],%[^)])",
			   smName, attrName, valStr);
	   if (cnt > 0) {  // found an IMPL attribute setter!
		   setGuardAttribute(smName, attrName, valStr);
		   continue;
	   }

      char *word;
      word = strtok(cmdBuf, " ");

      // We assume the first word contains the signal that is to be published,
      // and the remaining words are data to be used to populate the event.
      GenEvt *event;
      int signal = strtoul(word, NULL, 10);
      if (signal == DURING)
      {
        QF_tick();
        QF_publish( Q_NEW(QEvent, DURING) );
      }
      else
      {
        event = Q_NEW(GenEvt, signal);
        // Loop through the remaining words and populate the event
        int i = 0;
        do
        {
           word = strtok('\0', " ");
           if (word)
           {
             Q_ASSERT(i<EVENT_SIZE);
             event->data[i] = strtoul(word, NULL, 16);
           }
           i = i + 1;
        } while (word);
        QF_publish((QEvent *)event);
      }
      QF_run();
    }
}