/*..........................................................................*/
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 */
}
示例#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 */
}
示例#4
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;
}
示例#5
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;
}
示例#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
文件: 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();
}
示例#8
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;
}