Ejemplo n.º 1
0
/* timer interrupt function executes every millisecond ************************/
void CO_TIMER_ISR() {
    static ttimer tprof;
    saveTime(&tprof);
    CO_timer1ms++;

    CO_process_RPDO(CO);
    /*  TODO: zpracovani RPDO dat */

    /*  TODO: priprava dat pro TPDO */
    CO_process_TPDO(CO);

    /* calculate cycle time for performance measurement */
    uint32_t t = getTime_us(&tprof);
    OD_performance[ODA_performance_timerCycleTime] = t;
    if (t > OD_performance[ODA_performance_timerCycleMaxTime])
        OD_performance[ODA_performance_timerCycleMaxTime] = t;
}
Ejemplo n.º 2
0
void MainWindow::is_started(bool started)
{
    if(!started)
    {
        if(internalServer!=NULL)
        {
            delete internalServer;
            internalServer=NULL;
        }
        saveTime();
        if(!isVisible())
            QCoreApplication::quit();
    }
    else
    {
        CatchChallenger::BaseWindow::baseWindow->serverIsReady();
        socket->connectToHost("localhost",9999);
    }
}
Ejemplo n.º 3
0
void MainWindow::play(const QString &savegamesPath)
{
    QSettings metaData(savegamesPath+"metadata.conf",QSettings::IniFormat);
    if(!metaData.contains("pass"))
    {
        QMessageBox::critical(NULL,tr("Error"),tr("Unable to load internal value"));
        return;
    }
    launchedGamePath=savegamesPath;
    haveLaunchedGame=true;
    pass=metaData.value("pass").toString();
    if(internalServer!=NULL)
    {
        delete internalServer;
        saveTime();
    }
    internalServer=new CatchChallenger::InternalServer();
    sendSettings(internalServer,savegamesPath);
    connect(internalServer,SIGNAL(is_started(bool)),this,SLOT(is_started(bool)),Qt::QueuedConnection);

    ui->stackedWidget->setCurrentIndex(1);
    CatchChallenger::BaseWindow::baseWindow->serverIsLoading();
}
Ejemplo n.º 4
0
/* main ***********************************************************************/
int main(void) {
    CO_NMT_reset_cmd_t reset = CO_RESET_NOT;

    InitCanLeds();
    DBGU_Configure(115200);
    TRACE_INFO_WP("\n\rCanOpenNode %s (%s %s)\n\r", cVer, __DATE__, __TIME__);
    /* Configure Timer interrupt function for execution every 1 millisecond */
    if (SysTick_Config(SysTick_1ms))
        TRACE_FATAL("SysTick_Config\n\r");
    initTimer(getTimer_us);

    /* Todo: initialize EEPROM */

    /*  Todo: Loading COD */
    TRACE_INFO("Loading COD\n\r");

    /* Verify, if OD structures have proper alignment of initial values */
    TRACE_DEBUG("Checking COD in RAM (size=%d)\n\r", &CO_OD_RAM.LastWord - &CO_OD_RAM.FirstWord);
    if (CO_OD_RAM.FirstWord != CO_OD_RAM.LastWord)
        TRACE_FATAL("Err COD in RAM\n\r");
    TRACE_DEBUG("Checking COD in EEPROM (size=%d)\n\r", &CO_OD_EEPROM.LastWord - &CO_OD_EEPROM.FirstWord);
    if (CO_OD_EEPROM.FirstWord != CO_OD_EEPROM.LastWord)
        TRACE_FATAL("Err COD in EEPROM\n\r");
    TRACE_DEBUG("Checking COD in ROM (size=%d)\n\r", &CO_OD_ROM.LastWord - &CO_OD_ROM.FirstWord);
    if (CO_OD_ROM.FirstWord != CO_OD_ROM.LastWord)
        TRACE_FATAL("Err COD in ROM\n\r");

    /* increase variable each startup. Variable is stored in eeprom. */
    OD_powerOnCounter++;

    TRACE_INFO("CO power-on (BTR=%dk Node=0x%x)\n\r", CO_OD_ROM.CANBitRate, CO_OD_ROM.CANNodeID);
    ttimer tprof;
    while (reset != CO_RESET_APP) {
        /* CANopen communication reset - initialize CANopen objects *******************/
        static uint32_t timer1msPrevious;
        CO_ReturnError_t err;

        /* disable timer interrupts, turn on red LED */
        canTimerOff = 1;
        CanLedsSet(eCoLed_Red);

        /* initialize CANopen */
        err = CO_init();
        if (err) {
            TRACE_FATAL("CO_init\n\r");
            /* CO_errorReport(CO->em, CO_EM_MEMORY_ALLOCATION_ERROR, CO_EMC_SOFTWARE_INTERNAL, err); */
        }

        /* start Timer */
        canTimerOff = 0;

        reset = CO_RESET_NOT;
        timer1msPrevious = CO_timer1ms;

        TRACE_INFO("CO (re)start\n\r");
        while (reset == CO_RESET_NOT) {
            saveTime(&tprof);
            /* loop for normal program execution ******************************************/
            uint32_t timer1msDiff;

            timer1msDiff = CO_timer1ms - timer1msPrevious;
            timer1msPrevious = CO_timer1ms;

            ClearWDT();

            /* CANopen process */
            reset = CO_process(CO, timer1msDiff);

            CanLedsSet((LED_GREEN_RUN(CO->NMT)>0 ? eCoLed_Green : 0) | (LED_RED_ERROR(CO->NMT)>0 ? eCoLed_Red : 0));

            ClearWDT();

            /* (not implemented) eeprom_process(&eeprom); */
            uint32_t t = getTime_us(&tprof);
            OD_performance[ODA_performance_mainCycleTime] = t;
            if (t > OD_performance[ODA_performance_mainCycleMaxTime])
                OD_performance[ODA_performance_mainCycleMaxTime] = t;

        } /*  while (reset != 0) */
    } /*  while (reset != 2) */
    /* program exit ***************************************************************/
    /* save variables to eeprom */
    CO_DISABLE_INTERRUPTS();

    CanLedsSet(eCoLed_None);
    /* (not implemented) eeprom_saveAll(&eeprom); */
    CanLedsSet(eCoLed_Red);
    /* delete CANopen object from memory */
    CO_delete();

    /* reset - by WD */
    return 0;
}