void changeAUXType(uint8_t num){ if(num != auxNumber && screenNumber == RACE_SCREEN){ fillRect(300, 140, 179, 135, backgroundColor); textMode(); textTransparent(foregroundColor); textEnlarge(1); textSetCursor(330, 140); switch(num) { // Battery Voltage case 0: textWrite("BAT V"); raceScreenItems[6].data = &pdmDataItems[VBAT_RAIL_IDX]; raceScreenItems[6].info.x += 30; break; // Lambda case 1: textWrite("LAMBDA"); raceScreenItems[6].data = &motecDataItems[LAMBDA_IDX]; break; // RPM case 2: textWrite("RPM"); raceScreenItems[6].data = &motecDataItems[ENG_RPM_IDX]; raceScreenItems[6].info.x -= 30; break; } textEnlarge(0); graphicsMode(); auxNumber = num; } }
/* * draws text on screen */ void text_draw(text *txt) { fillRect(txt->x,txt->y,txt->bgWidth,txt->bgHeight,txt->bgColor); textMode(); textEnlarge(txt->size); textSetCursor(txt->x,txt->y); textTransparent(txt->color); textWrite(txt->label); graphicsMode(); }
/* * draws the text on screen with a new value appended to the end */ void text_drawVal(text *txt, char *str) { fillRect(txt->x,txt->y,txt->bgWidth,txt->bgHeight,txt->bgColor); textMode(); textEnlarge(0); textSetCursor(txt->x,txt->y); textTransparent(txt->color); textWrite(str); graphicsMode(); }
// Error Handling Stuff void displayNoErrors(void){ // Reset error area fillRect(0,200,WIDTH,HEIGHT-200,backgroundColor); drawChevron(30, 210, 30, 50, foregroundColor, backgroundColor); textMode(); textSetCursor(100, 210); textTransparent(RA8875_BLACK); textEnlarge(1); textWrite("Illini Motorsports"); graphicsMode(); }
// Helper function for drawing labels and such on a new screen void initScreen(uint8_t num){ switch(num){ case RACE_SCREEN: textMode(); textEnlarge(1); textTransparent(foregroundColor); textSetCursor(7, 40); textWrite("OIL TEMP"); textSetCursor(0, 160); textWrite("OIL PRESS"); textSetCursor(360, 40); textWrite("WTR TMP"); textSetCursor(370,160); textWrite("BAT V"); textSetCursor(200,160); textWrite("LAMBDA"); textEnlarge(0); graphicsMode(); break; case PDM_DRAW_SCREEN: textMode(); textTransparent(foregroundColor); textSetCursor(10,10); textWrite("IGN DRW"); textSetCursor(85, 10); textWrite("INJ DRW"); textSetCursor(160, 10); textWrite("FUEL DRW"); textSetCursor(235, 10); textWrite("ECU DRW"); textSetCursor(310, 10); textWrite("WTR DRW"); textSetCursor(385, 10); textWrite("FAN DRW"); textSetCursor(10, 60); textWrite("AUX DRW"); textSetCursor(85, 60); textWrite("PDLU DRW"); textSetCursor(160,60); textWrite("PDLD DRW"); textSetCursor(235, 60); textWrite("ABS DRW"); textSetCursor(310, 60); textWrite("BAT DRW"); textSetCursor(385, 60); textWrite("STR DRW"); textSetCursor(10,110); textWrite("IGN CUT"); textSetCursor(85, 110); textWrite("INJ CUT"); textSetCursor(160, 110); textWrite("FUEL CUT"); textSetCursor(235, 110); textWrite("ECU CUT"); textSetCursor(310, 110); textWrite("WTR CUT"); textSetCursor(385, 110); textWrite("FAN CUT"); textSetCursor(10, 160); textWrite("AUX CUT"); textSetCursor(85, 160); textWrite("PDLU CUT"); textSetCursor(160,160); textWrite("PDLD CUT"); textSetCursor(235, 160); textWrite("ABS CUT"); textSetCursor(310, 160); textWrite("BAT CUT"); textSetCursor(160, 210); textWrite("FUEL PCT"); textSetCursor(235, 210); textWrite("FAN PCT"); textSetCursor(310, 210); textWrite("WTR PCT"); textSetCursor(385, 210); textWrite("ECU PCT"); textEnlarge(2); textSetCursor(10, 210); textWrite("PDM"); textEnlarge(0); graphicsMode(); break; case LAMBDA_SCREEN: textMode(); textTransparent(foregroundColor); textSetCursor(10,10); textEnlarge(0); graphicsMode(); break; case THROTTLE_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; /* case PDM_DRAW_SCREEN: textMode(); textTransparent(foregroundColor); textSetCursor(10,10); textWrite("IGN DRW"); textSetCursor(85, 10); textWrite("INJ DRW"); textSetCursor(160, 10); textWrite("FUEL DRW"); textSetCursor(235, 10); textWrite("ECU DRW"); textSetCursor(310, 10); textWrite("WTR DRW"); textSetCursor(385, 10); textWrite("FAN DRW"); graphicsMode(); //Horizontal Lines drawLine(80, 30, 0, 200, foregroundColor); drawLine(155, 30, 0, 200, foregroundColor); drawLine(230, 30, 0, 200, foregroundColor); drawLine(305, 30, 0, 200, foregroundColor); drawLine(380, 30, 0, 200, foregroundColor); //Vertical Lines drawLine(10, 30, 0, 200, foregroundColor); drawLine(10, 30, 0, 200, foregroundColor); drawLine(10, 30, 0, 200, foregroundColor); drawLine(10, 30, 0, 200, foregroundColor); drawLine(10, 30, 0, 200, foregroundColor); break; */ case PDM_CUT_SCREEN: textMode(); textTransparent(foregroundColor); textSetCursor(10,30); textWrite("PDM TEMP"); textSetCursor(85, 30); textWrite("IC TEMP"); textSetCursor(160, 30); textWrite("BAT VOLT"); textSetCursor(235, 30); textWrite("12V VOLT"); textSetCursor(310, 30); textWrite("5V5 VOLT"); textSetCursor(385, 30); textWrite("5V VOLT"); textSetCursor(10, 80); textWrite("3V3 VOLT"); textSetCursor(85, 80); textWrite("IGN CUT"); textSetCursor(160,80); textWrite("INJ CUT"); textSetCursor(235, 80); textWrite("FUEL NCUT"); textSetCursor(310, 80); textWrite("ECU NCUT"); textSetCursor(385, 80); textWrite("WTR NCUT"); textSetCursor(10, 130); textWrite("FAN NCUT"); textSetCursor(85, 130); textWrite("AUX CUT"); textSetCursor(160, 130); textWrite("PDLU CUT"); textSetCursor(235, 130); textWrite("PDLU CUT"); textSetCursor(310,130); textWrite("5V5 CUT"); textSetCursor(385, 130); textWrite("BAT CUT"); textSetCursor(10, 180); textWrite("STR0 CUT"); textSetCursor(85, 180); textWrite("BRK F"); textSetCursor(160, 180); textWrite("BRK R"); graphicsMode(); break; case MOTEC_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; case END_RACE_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; case CHASSIS_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; case BRAKE_SCREEN: textMode(); textTransparent(foregroundColor); textEnlarge(1); textSetCursor(20, 235); textWrite("BRK F"); textSetCursor(360, 235); textWrite("BRK R"); textSetCursor(20,60); textWrite("MIN F:"); textSetCursor(20,100); textWrite("MAX F:"); textSetCursor(300,60); textWrite("MIN R:"); textSetCursor(300,100); textWrite("MAX R:"); graphicsMode(); textEnlarge(0); break; case IMU_SCREEN: //to be determined textMode(); textTransparent(foregroundColor); textSetCursor(364, 85); textWrite("LATERAL"); textSetCursor(207, 213); textWrite("LONGITUDINAL"); textEnlarge(0); graphicsMode(); break; } }
bool Dymola::setVariablesToDsin(QString fileName, QString modelName,MOVector<Variable> *variables,MOParameters *parameters,QString & errMsg) { //Reading Preamble QFileInfo fileinfo = QFileInfo(fileName); QFile file(fileinfo.filePath()); if(!file.open(QIODevice::ReadOnly)) { errMsg = "Failed to open "+fileName; return false; } else { QTextStream textRead(&file); QString allText = textRead.readAll(); file.close(); // change preamble writeParameters(allText,parameters); // change variable values QRegExp rxLine; int index=0; QString newLine1,newLine2; QString varName; int iCurVar; Variable* curVar; QStringList fields; QString smallText; QStringList capLines; int index2; int prec=MOSettings::value("MaxDigitsDsin").toInt(); //number of decimals QString value; for(int iV=0;iV<variables->size();iV++) { InfoSender::instance()->debug("Setting variable "+ varName+" in "+fileName); curVar = variables->at(iV); varName = curVar->name(Variable::SHORT); //varName = varName.remove(modelName+"."); rxLine.setPattern(sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s*#\\s*("+varName+")\\s*"); // extracting only text around varname // to speed-up regexp research (too long without) index2 = allText.indexOf(varName); smallText.clear(); while(index2>-1) { smallText += allText.mid(index2-300,310+varName.size()); // must capture end of line chars -> 310>300 index2 = allText.indexOf(varName,index2+1); } index = rxLine.indexIn(smallText); if(index>-1) { char format = 'E'; value = QString::number(curVar->getFieldValue(Variable::VALUE).toDouble(),format,prec); fields = rxLine.capturedTexts(); capLines = rxLine.cap(0).split("\n",QString::SkipEmptyParts); newLine1 = fields.at(1)+"\t"+ value +"\t"; newLine1 += fields.at(3)+"\t"+fields.at(4); newLine2 = fields.at(5)+"\t"+fields.at(6)+"\t"+" # "+fields.at(7); // if variable def were on two lines if((capLines.size()>1)&& capLines.at(1).contains(QRegExp("\\S"))) { InfoSender::instance()->debug("found variable. 2 lines. Total text captured: "+rxLine.cap(0)); allText = allText.replace(rxLine.cap(0),newLine1+"\n"+newLine2+"\n"); InfoSender::instance()->debug("New Text : "+newLine1+"\n"+newLine2); } else { InfoSender::instance()->debug("found variable. 1 line. Total text captured: "+rxLine.cap(0)); // if variable def were on only one line allText = allText.replace(rxLine.cap(0),newLine1+"\t"+newLine2+"\n"); InfoSender::instance()->debug("New Text : "+newLine1+"\t"+newLine2); } } else { InfoSender::instance()->send(Info("Unable to set variable value (not found in init file):"+varName,ListInfo::ERROR2)); } } fileinfo.setFile(fileName); file.setFileName(fileinfo.filePath()); bool ok = file.open(QIODevice::WriteOnly); if(!ok) { errMsg = "Unable to open file for writing :" + fileinfo.absoluteFilePath(); return false; } QTextStream textWrite(&file); textWrite<<allText; file.close(); } }
void OpenModelica::setInputVariablesTxt(QString fileName, MOVector<Variable> *variables,QString modModelName,MOParameters *parameters) { QFileInfo fileinfo = QFileInfo(fileName); if (fileinfo.exists()) { QFile file(fileinfo.filePath()); file.open(QIODevice::ReadOnly); QTextStream textRead(&file); QString allText = textRead.readAll(); file.close(); // change variable values QRegExp rxLine; int index=0; QString newLine; QString varName; int iCurVar; Variable* curVar; QStringList fields; for(int iV=0;iV<variables->size();iV++) { curVar = variables->at(iV); varName = curVar->name(Variable::SHORT); //varName = varName.remove(modModelName+"."); rxLine.setPattern(sciNumRx()+"\\s*(//[\\w*|\\s*]*//|//)\\s*"+varName); index = rxLine.indexIn(allText); if(index>-1) { fields = rxLine.capturedTexts(); newLine = curVar->getFieldValue(Variable::VALUE).toString() +"\t"; newLine += fields.at(2)+varName; allText = allText.replace(rxLine.cap(0),newLine); } else { InfoSender::instance()->send(Info("Warning : unable to set variable value (not found in init file):"+varName,ListInfo::ERROR2)); } } // Parameters to write in init file /// @deprecated Now OM uses xml input. if(parameters) { QList<OpenModelicaParameters::Parameters> initParameters; // parameters to specify in init file initParameters << OpenModelicaParameters::STOPTIME; QStringList paramIndicators; paramIndicators << "stop value"; QVariant paramValue; QString paramName; MOParameter * curParam; int iP; for(int i=0;i<initParameters.size();i++) { curParam = parameters->findItem(OpenModelicaParameters::str(initParameters.at(i))); if(curParam) { paramName = paramIndicators.at(i); paramValue = curParam->getFieldValue(MOParameter::VALUE); rxLine.setPattern(sciNumRx()+"\\s*(//[\\w*|\\s*]*//|//)\\s*"+paramName); index = rxLine.indexIn(allText); if(index>-1) { fields = rxLine.capturedTexts(); newLine = paramValue.toString() +"\t"; newLine += fields.at(2)+paramName; allText = allText.replace(rxLine.cap(0),newLine); } else { InfoSender::instance()->send(Info("Warning : unable to set parameter value (not found in init file):"+paramName,ListInfo::ERROR2)); } } } } fileinfo.setFile(fileName); file.setFileName(fileinfo.filePath()); bool ok = file.open(QIODevice::WriteOnly); QTextStream textWrite(&file); textWrite<<allText; file.close(); } }
// Helper function for drawing labels and such on a new screen void initScreen(uint8_t num){ switch(num){ case RACE_SCREEN: textMode(); textEnlarge(1); textTransparent(foregroundColor); textSetCursor(0, 40); textWrite("OIL TEMP"); textSetCursor(0, 140); textWrite("OIL PRESS"); textSetCursor(330, 40); textWrite("WTR TMP"); textSetCursor(330,140); textWrite("BAT V"); textEnlarge(0); graphicsMode(); break; case PDM_DRAW_SCREEN: textMode(); textTransparent(foregroundColor); textSetCursor(10,30); textWrite("IGN DRW"); textSetCursor(85, 30); textWrite("INJ DRW"); textSetCursor(160, 30); textWrite("FUEL DRW"); textSetCursor(235, 30); textWrite("ECU DRW"); textSetCursor(310, 30); textWrite("WTR DRW"); textSetCursor(385, 30); textWrite("FAN DRW"); textSetCursor(10, 80); textWrite("AUX DRW"); textSetCursor(85, 80); textWrite("PDLU DRW"); textSetCursor(160,80); textWrite("PDLD DRW"); textSetCursor(235, 80); textWrite("5V5 DRW"); textSetCursor(310, 80); textWrite("BAT DRW"); textSetCursor(385, 80); textWrite("FUEL P CUT"); textSetCursor(10, 130); textWrite("ECU PCUT"); textSetCursor(85, 130); textWrite("WTR PCUT"); textSetCursor(160, 130); textWrite("FAN PCUT"); textSetCursor(10, 180); textWrite("STR0 DRW"); textSetCursor(100, 180); textWrite("STR1 DRW"); textSetCursor(190, 180); textWrite("STR2 DRW"); textSetCursor(280, 180); textWrite("STR DRW"); textSetCursor(370, 180); textWrite("TOT DRW"); graphicsMode(); break; case PDM_CUT_SCREEN: textMode(); textTransparent(foregroundColor); textSetCursor(10,30); textWrite("PDM TEMP"); textSetCursor(85, 30); textWrite("IC TEMP"); textSetCursor(160, 30); textWrite("BAT VOLT"); textSetCursor(235, 30); textWrite("12V VOLT"); textSetCursor(310, 30); textWrite("5V5 VOLT"); textSetCursor(385, 30); textWrite("5V VOLT"); textSetCursor(10, 80); textWrite("3V3 VOLT"); textSetCursor(85, 80); textWrite("IGN CUT"); textSetCursor(160,80); textWrite("INJ CUT"); textSetCursor(235, 80); textWrite("FUEL NCUT"); textSetCursor(310, 80); textWrite("ECU NCUT"); textSetCursor(385, 80); textWrite("WTR NCUT"); textSetCursor(10, 130); textWrite("FAN NCUT"); textSetCursor(85, 130); textWrite("AUX CUT"); textSetCursor(160, 130); textWrite("PDLU CUT"); textSetCursor(235, 130); textWrite("PDLU CUT"); textSetCursor(310,130); textWrite("5V5 CUT"); textSetCursor(385, 130); textWrite("BAT CUT"); textSetCursor(10, 180); textWrite("STR0 CUT"); textSetCursor(85, 180); textWrite("BRK F"); textSetCursor(160, 180); textWrite("BRK R"); graphicsMode(); break; case MOTEC_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; case END_RACE_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; case CHASSIS_SCREEN: textMode(); textTransparent(foregroundColor); graphicsMode(); break; case BRAKE_SCREEN: textMode(); textTransparent(foregroundColor); textEnlarge(1); textSetCursor(20, 235); textWrite("BRK F"); textSetCursor(360, 235); textWrite("BRK R"); textSetCursor(20,60); textWrite("MIN F:"); textSetCursor(20,100); textWrite("MAX F:"); textSetCursor(300,60); textWrite("MIN R:"); textSetCursor(300,100); textWrite("MAX R:"); graphicsMode(); textEnlarge(0); break; } }