bool DesignerApp::initApplication(QString cmdLine) { QLocale::setDefault(QLocale(QLocale::English)); QTextCodec::setCodecForTr(QTextCodec::codecForLocale()); QPixmap pixmap(":/designer/splash.png"); QSplashScreen *splash = new QSplashScreen(pixmap); splash->show(); splash->showMessage(tr("Loading...")); processEvents(); writeConfigValue("", "apppath", QtSingleApplication::applicationFilePath()); dbIgame = QSqlDatabase::addDatabase("QMYSQL","igame"); dbIgame.setDatabaseName("MoDeL"); dbIgame.setHostName("localhost"); dbIgame.setUserName("root"); dbIgame.setPassword("lovewin"); dbIgame.open(); DesignerViewMgr::initializeIfNotYet(); DesignerDocMgr::initializeIfNotYet(); DesignerModelMgr::initializeIfNotYet(); DesignerExtensionMgr::initializeIfNotYet(); DesignerMainWnd* mainWnd = DesignerMainWnd::globalCreateNewMainWnd(); setActivationWindow(mainWnd); QObject::connect(this, SIGNAL(messageReceived(const QString&)), mainWnd, SLOT(instanceMessageReceived(const QString&))); splash->setWindowFlags(Qt::WindowStaysOnTopHint); splash->setParent(mainWnd); splash->show(); QTimer::singleShot(1500, splash, SLOT(close())); if(cmdLine!="/new") mainWnd->instanceMessageReceived(cmdLine); while(splash->isVisible()) { processEvents(); } return true; }
QVariant DesignerApp::readConfigValue(QString group, QString name, QVariant defaultValue) { QString fullGroupName = "designer"; if(group.length()) fullGroupName+="."; fullGroupName+=group; QVariant retValue; settings.beginGroup(fullGroupName); retValue = settings.value(name); settings.endGroup(); if(!retValue.isValid()) { writeConfigValue(group, name, defaultValue); return defaultValue; } return retValue; }
int main() { //Enable custom ISR's initAllISR(); //Enable Globals CyGlobalIntEnable; //INITIALIZE 12C, XBEE, Veg Veg_Start(); Veg_StartConvert(); Xbee_UART_Start(); I2C_1_Start(); CyDelay(250); //read EEPROM, config, and oscillator trimming value readEEPROM(); writeOscTrimValue(); writeConfigValue(); //Initialize PSOC state state = WAKE; //Start Sleep Timer SleepTimer_Start(); for(;;) { /* Place your application code here. */ if (state == WAKE){ //change state state = GETDATA; } // end WAKE else if (state == GETDATA){ //MLX READ------------------------------------------ //Temperature, compensation, and whole frame read uint16 ptat = readPTAT(); uint16 comp = readCompensation(); readFrame(); //END MLX READ-------------------------------------- //VEG READ------------------------------------------ //Get and scale ADC int depth; for (depth = 0; depth < NUM_LEVELS; depth++) { voltage[depth] = Veg_GetResult16(0)*(3.3/4096); temperature[depth] = 22.3; } //END VEG READ-------------------------------------- //change state state = TXDATA; } // end GETDATA else if (state == TXDATA){ //TX MLX //tx whole frame, PTAT, and compensation XBeeTxFrame(); XBeeTxPTAT(); XBeeTxCompensation(); //END TX MLX---------------------------------------- //TX VEG-------------------------------------------- char level[4]; int depth; //string for calculating Checksum char toCksm[56]; Xbee_UART_PutString("V,"); for (depth = 0; depth < NUM_LEVELS; depth++) { sprintf(level, "%d:", depth); sprintf(Veg_out, "%1.4f:", voltage[depth]); //Add hard coded temperature value sprintf(temp_out, "%2.1f,", temperature[depth]); //if first level, copy string, otherwise concatenate if (depth == 0) { strcpy(toCksm, level); } else { strcat(toCksm, level); } strcat(toCksm, Veg_out); strcat(toCksm, temp_out); //Transmit level string Xbee_UART_PutString(level); Xbee_UART_PutString(Veg_out); Xbee_UART_PutString(temp_out); } //end for //Transmit Checksum for Vegetronix Xbee_UART_PutChar(calculateCheckSum(toCksm, strlen(toCksm))); //END TX VEG---------------------------------------- //Change State state = SLEEPMODE; } // end TXDATA else if (state == SLEEPMODE){ //put her to sleep //CyDelay(2000); if (wake_count % wakeCycles == 0) { //Change State state = WAKE; continue; } else { sleepPsoc(); } } // END SLEEPM0DE else{ // Error in state machine, to be filled out. Likely a reset will occur here. //Change State state = WAKE; } // End Error Catch } }