Bug Summary

File:OMOptim/OMOptim/build/../Core/Dymola/Dymola.cpp
Warning:line 390, column 5
Value stored to 'nbv' is never read

Annotated Source Code

[?] Use j/k keys for keyboard navigation

1// $Id$
2/**
3@file Dymola.cpp
4@brief Comments for file documentation.
5@author Hubert Thieriot, hubert.thieriot@mines-paristech.fr
6Company : CEP - ARMINES (France)
7http://www-cep.ensmp.fr/english/
8@version
9
10
11*/
12
13
14#include <stdio.h>
15#ifdef WIN32
16#include <windows.h>
17#endif
18#include <iostream>
19
20
21#include "Dymola.h"
22#include "MOSettings.h"
23#include "Variable.h"
24#include "Variables.h"
25#include "InfoSender.h"
26#include "LowTools.h"
27#include "DymolaParameters.h"
28
29Dymola::Dymola(void)
30{
31}
32
33Dymola::~Dymola(void)
34{
35}
36
37void Dymola::verifyInstallation()
38{
39
40 // check EI.mo exists
41 char * folder = getenv("MOLIBRARIES");
42
43 if (!folder)
44 {
45 }
46 else
47 {
48 }
49
50}
51
52
53bool Dymola::compile(QFileInfo moPath,QString modelToConsider,QDir storeFolder,QFileInfo logFile,
54 const QFileInfoList & moDeps, QFileInfoList neededFiles)
55{
56 // Create Dymola script
57 QString filePath = storeFolder.absoluteFilePath("MOFirstRun.mos");
58 QFile file(filePath);
59 if(file.exists())
60 {
61 file.remove();
62 }
63 file.open(QIODevice::WriteOnly);
64
65 QString scriptText;
66 QString curPath;
67
68 // load dependencies and model
69 QFileInfoList moToLoad;
70 moToLoad.append(moDeps);
71 moToLoad.push_back(moPath);
72 LowTools::removeDuplicates(moToLoad);
73
74 for(int i=0;i<moToLoad.size();i++)
75 {
76 curPath = QDir::fromNativeSeparators(moToLoad.at(i).absoluteFilePath());
77 scriptText.append("openModel(\""+curPath+"\",false)\n");
78 }
79
80
81 QString strFolder = QDir::fromNativeSeparators(storeFolder.absolutePath());
82 QString logFilePath = QDir::fromNativeSeparators(logFile.absoluteFilePath());
83
84 scriptText.append("cd "+strFolder+"\n");
85 scriptText.append("experimentSetupOutput(textual=true)\n");
86 scriptText.append("Advanced.StoreProtectedVariables:=true;\n");
87 //scriptText.append("checkModel(\""+modelToConsider+"\",simulate=true)\n");
88 scriptText.append("translateModel(\""+modelToConsider+"\")\n");
89 scriptText.append("compile()\n");
90 scriptText.append("savelog(\""+logFilePath+"\")\n");
91 scriptText.append("exit\n");
92
93 QTextStream ts( &file );
94 ts << scriptText;
95 file.close();
96
97 // Copy needed files
98 LowTools::copyFilesInFolder(neededFiles,storeFolder);
99
100 // Run script
101 QString dymolaPath = MOSettings::value("dymolaExe").toString();
102 QFileInfo dymolaBin(dymolaPath);
103 if(!dymolaBin.exists())
104 {
105 InfoSender::instance()->send(Info("Dymola executable not found. Please verify path in Settings",ListInfo::ERROR2));
106 return false;
107 }
108 else
109 {
110 // delete previous dymosim.exe
111 QFile dymoFile(storeFolder.absoluteFilePath("dymosim.exe"));
112 if(dymoFile.exists())
113 dymoFile.remove();
114
115 // delete previous dsin file
116 QFile dsinFile(storeFolder.absoluteFilePath("dsin.txt"));
117 if(dsinFile.exists())
118 dsinFile.remove();
119
120 // launch script
121 QProcess scriptProcess;
122 QStringList args;
123 args.push_back(filePath);
124
125 //start process
126 InfoSender::sendCurrentTask("Launching Dymola...");
127 scriptProcess.start(dymolaPath,args);
128 bool ok = scriptProcess.waitForFinished(-1);
129 if(!ok)
130 {
131 QString msg("CreateProcess failed");
132 InfoSender::instance()->debug(msg);
133 return false;
134 }
135
136 //look if it succeed
137 bool success = dymoFile.exists();
138 InfoSender::eraseCurrentTask();
139 return success;
140 }
141}
142
143bool Dymola::createDsin(QFileInfo moFile,QString modelToConsider,QDir folder,
144 const QFileInfoList & moDeps,QFileInfoList neededFiles)
145{
146 // Create Dymola script
147 QFile file(folder.absoluteFilePath("MOFirstRun.mos"));
148 if(file.exists())
149 {
150 file.remove();
151 }
152 file.open(QIODevice::WriteOnly);
153
154 QString strFolder = QDir::fromNativeSeparators(folder.absolutePath());
155
156 QString scriptText;
157 QString curPath;
158
159 // load dependencies and model
160 QFileInfoList moToLoad;
161 moToLoad.append(moDeps);
162 moToLoad.push_back(moFile);
163 LowTools::removeDuplicates(moToLoad);
164
165 for(int i=0;i<moToLoad.size();i++)
166 {
167 curPath = QDir::fromNativeSeparators(moToLoad.at(i).absoluteFilePath());
168 scriptText.append("openModel(\""+curPath+"\")\n");
169 }
170
171
172 scriptText.append("cd "+strFolder+"\n");
173 scriptText.append("translateModel(\""+modelToConsider+"\")\n");
174 scriptText.append("exportInitialDsin(\"dsin.txt\")\n");
175 scriptText.append("savelog(\"buildlog.txt\")\n");
176 scriptText.append("exit\n");
177
178 QTextStream ts( &file );
179 ts << scriptText;
180 file.close();
181
182 // Copy needed files
183 LowTools::copyFilesInFolder(neededFiles,folder);
184
185 // Run script
186 QString dymolaPath = MOSettings::value("dymolaExe").toString();
187
188
189 QProcess simProcess;
190 QStringList args;
191 args.push_back(QFileInfo(file).absoluteFilePath());
192
193
194 // delete previous dsin file
195 QFile dsinFile(folder.absoluteFilePath("dsin.txt"));
196 if(dsinFile.exists())
197 dsinFile.remove();
198
199 // launch script
200 InfoSender::instance()->send(Info("Launching Dymola..."));
201 simProcess.start(dymolaPath, args);
202 bool ok = simProcess.waitForFinished(-1);
203 if(!ok)
204 {
205 QString msg("CreateProcess failed");
206 InfoSender::instance()->debug(msg);
207 return false;
208 }
209
210 //look if it succeed
211 bool success = dsinFile.exists();
212 return success;
213}
214
215
216QString Dymola::getExecutablePath()
217{
218 QString path;
219#ifdef WIN32
220 HKEY hKey = 0;
221 char buf[255] = {0};
222 DWORD dwType = 0;
223 DWORD dwBufSize = sizeof(buf);
224
225
226 QString subkey("SOFTWARE\\Classes\\Applications\\Dymola.exe\\shell\\Run\\command");
227
228 if( RegOpenKey(HKEY_LOCAL_MACHINE,VQTConvert::QString_To_LPCTSTR(subkey),&hKey) == ERROR_SUCCESS)
229 {
230 dwType = REG_SZ;
231 if( RegQueryValueEx(hKey,NULL__null,NULL__null, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS)
232 {
233 path = QString(buf);
234 }
235 RegCloseKey(hKey);
236 }
237
238 path.remove("\"");
239 path.remove("%1");
240 //path.remove(" ");
241#endif
242 return path;
243}
244
245
246bool Dymola::start(QDir folder,QProcess &simProcess,QString & errMsg,int maxNSec)
247{
248#ifdef WIN32
249 simProcess.setWorkingDirectory(folder.absolutePath());
250
251 QString appPath = folder.absoluteFilePath("Dymosim.exe");
252 if(!QFile::exists(appPath))
253 {
254 errMsg = "Cannot find Dymosim.exe in folder " + folder.absolutePath();
255 return false;
256 }
257 simProcess.start(appPath, QStringList());
258
259 int nmsec;
260 if(maxNSec==-1)
261 nmsec = -1;
262 else
263 nmsec = maxNSec*1000;
264
265 bool ok = simProcess.waitForFinished(nmsec);
266 if(!ok)
267 {
268 errMsg = "Simulation process failed or time limit reached";
269 simProcess.close();
270 }
271
272 return ok;
273#else
274 return false;
275#endif
276}
277
278void Dymola::writeParameters(QString &allDsinText,MOParameters *parameters)
279{
280 QString newLine;
281
282 QStringList lines = allDsinText.split("\n");
283 int iLForm = lines.indexOf(QRegExp(".* # lform .*"));
284 if(iLForm>-1)
285 {
286 newLine = " 0 # lform 0/1 ASCII/Matlab-binary storage format of results";
287 lines.replace(iLForm,newLine);
288 }
289
290
291 MOParameter* pStopTime = parameters->findItem(DymolaParameters::str(DymolaParameters::STOPTIME));
292 int iLStopTime = lines.indexOf(QRegExp(".* # StopTime .*"));
293 if((iLStopTime>-1) && pStopTime)
294 {
295 newLine = " "
296 +pStopTime->getFieldValue(MOParameter::VALUE).toString()
297 +" # StopTime Time at which integration stops";
298 lines.replace(iLStopTime,newLine);
299 }
300
301 MOParameter* pTolerance = parameters->findItem(DymolaParameters::str(DymolaParameters::TOLERANCE));
302 int iLTolerance = lines.indexOf(QRegExp(".* # Tolerance .*"));
303 if((iLTolerance>-1) && pTolerance)
304 {
305 newLine = " "
306 +pTolerance->getFieldValue(MOParameter::VALUE).toString()
307 +" # nInterval Relative precision of signals for \n # simulation, linearization and trimming";
308 lines.replace(iLTolerance,newLine);
309 }
310
311 MOParameter* pnInterval = parameters->findItem(DymolaParameters::str(DymolaParameters::NINTERVAL));
312 int iLnInterval = lines.indexOf(QRegExp(".* # nInterval .*"));
313 if((iLnInterval>-1) && pnInterval)
314 {
315 newLine = " "
316 +pnInterval->getFieldValue(MOParameter::VALUE).toString()
317 +" # nInterval Number of communication intervals, if > 0";
318 lines.replace(iLnInterval,newLine);
319 }
320
321 MOParameter* pSolver = parameters->findItem(DymolaParameters::str(DymolaParameters::SOLVER));
322 int iLSolver = lines.indexOf(QRegExp(".* # Algorithm .*"));
323 if((iLSolver>-1) && pSolver)
324 {
325 newLine = " "
326 +pSolver->getFieldValue(MOParameter::VALUE).toString()
327 +" # Algorithm Integration algorithm as integer";
328 lines.replace(iLSolver,newLine);
329 }
330
331 MOParameter* pFinalFile = parameters->findItem(DymolaParameters::str(DymolaParameters::FINALFILE));
332 int iLineLRes = lines.indexOf(QRegExp(".* # lres 0/1 do not/store results .*"));
333 if((iLineLRes>-1) && pFinalFile)
334 {
335 int lRes;
336 switch(pFinalFile->value().toInt())
337 {
338 case DymolaParameters::DSFINAL :
339 lRes = 0;
340 break;
341 case DymolaParameters::DSRES :
342 default :
343 lRes = 1;
344 break;
345 }
346
347 newLine = " "
348 +QString::number(lRes)
349 +" # lres 0/1 do not/store results on result file";
350 lines.replace(iLineLRes,newLine);
351 }
352
353
354 allDsinText = lines.join("\n");
355}
356
357bool Dymola::getVariablesFromDsFile(QTextStream *text, MOVector<Variable> *variables,QString modelName)
358
359{
360 variables->clear();
361 QString line;
362 QStringList linefields;
363
364 Variable *newVariable;
365 text->seek(0);
366 QString str = text->readAll();
367
368 int indStartVariables;
369 int indStartDesc;
370 int nv; //current variable
371 int nbv; //number of variables
372
373
374 indStartVariables = str.indexOf("# Names of initial variables");
375 text->seek(indStartVariables);
376 text->readLine(); //go to next line
377 text->readLine(); //pass through char() line
378
379 // Get variables' names
380 line = text->readLine();
381 while (!line.isEmpty()){
382 newVariable = new Variable();
383 newVariable->setName(line);
384 newVariable->setModel(modelName);
385 variables->addItem(newVariable);
386 line=text->readLine();
387 }
388
389
390 nbv=variables->size();
Value stored to 'nbv' is never read
391
392 // Get variable's value, type, min, max, nature
393 text->readLine(); // pass through double() line
394 nv=0;
395 line = text->readLine();
396 while (!line.isEmpty())
397 {
398 linefields = line.split(" ", QString::SkipEmptyParts);
399 if(linefields.size()<8)
400 {
401 // data has been stored on two lines
402 line = text->readLine();
403 linefields << line.split(" ", QString::SkipEmptyParts);
404 }
405 if(nv>=variables->size())
406 {
407 InfoSender::instance()->sendError("Corrupted dsin file. Unable to read variables. Try to regenerate dsin file.");
408 variables->clear();
409 return false;
410 }
411 if(linefields.size()<8)
412 {
413 InfoSender::instance()->sendWarning("Cannot read variable information ["+variables->at(nv)->name()+"]. It will not be considered");
414 variables->removeRow(nv);
415 }
416 else
417 {
418 variables->at(nv)->setValue(linefields[1].toDouble());
419 int dymDataType = linefields[5].toInt();
420 variables->at(nv)->setDataType(convertVariableType(dymDataType));
421 int dymValueType = linefields[0].toInt();
422 int dymCategory = linefields[4].toInt();
423 variables->at(nv)->setCausality(convertToCausality(dymValueType,dymCategory));
424 nv++;
425 }
426 line = text->readLine();
427 }
428
429 // Get variables' description
430 indStartDesc = str.indexOf("initialDescription");
431 text->seek(indStartDesc);
432 text->readLine(); //pass through end of line
433
434 line = text->readLine();
435 nv=0;
436 nbv=variables->size();
437 while (!text->atEnd() && nv<nbv)
438 {
439 variables->at(nv)->setDescription(line);
440 line = text->readLine();
441 nv++;
442 }
443 return true;
444}
445
446bool Dymola::getVariablesFromDsFile(QString fileName_, MOVector<Variable> *variables,QString _modelName)
447{
448 variables->clear();
449 QFileInfo fileinfo = QFileInfo(fileName_);
450 bool result = false;
451 if (fileinfo.exists())
452 {
453 QFile file(fileinfo.filePath());
454 file.open(QIODevice::ReadOnly);
455 QTextStream* in = new QTextStream(&file);
456 result = getVariablesFromDsFile(in, variables,_modelName);
457 file.close();
458 }
459 return result;
460}
461
462bool Dymola::getFinalVariablesFromDsFile(QString fileName_, MOVector<Variable> *variables,QString modelName)
463{
464 variables->clear();
465 QFileInfo fileinfo = QFileInfo(fileName_);
466 bool result = false;
467 if (fileinfo.exists())
468 {
469 QFile file(fileinfo.filePath());
470 file.open(QIODevice::ReadOnly);
471 QTextStream* in = new QTextStream(&file);
472 result = getFinalVariablesFromDsFile(in, variables,modelName);
473 file.close();
474 delete in;
475 }
476 return result;
477}
478
479bool Dymola::getFinalVariablesFromDsFile(QTextStream *text, MOVector<Variable> *variables,QString _modelName)
480{
481
482 variables->clear();
483 QString line,data;
484 QStringList linefields;
485
486 Variable *newVariable;
487 text->seek(0);
488 QString str = text->readAll();
489
490 int indStartVariables;
491 int indStartDesc;
492 int indStartDataInfo, indStartData;
493 int nv; //current variable
494 int nbv; //number of variables
495 int nbCols1,nbRows1,nbCols2,nbRows2;
496
497 QList<int> dataInfo1;
498 QList<int> dataInfo2;
499 QList<int> dataInfo3;
500 QList<int> dataInfo4;
501
502 double **data1, **data2;
503
504
505
506 // **************************
507 // Names
508 // **************************
509 indStartVariables = str.indexOf("char name(");
510 text->seek(indStartVariables);
511 line = text->readLine(); //go to next line
512 line = text->readLine(); //read line
513 while (!line.isEmpty()){
514 newVariable = new Variable();
515 newVariable->setName(line);
516 newVariable->setModel(_modelName);
517 variables->addItem(newVariable);
518 line=text->readLine();
519 }
520 nbv=variables->size();
521
522 // **************************
523 // Description
524 // **************************
525 indStartDesc = str.indexOf("char description(");
526 text->seek(indStartDesc);
527 line = text->readLine(); //go to next line
528 line = text->readLine(); //read line
529
530 nv=0;
531 while (!line.isEmpty() && nv<nbv){
532 variables->at(nv)->setDescription(line);
533 line = text->readLine();
534 nv++;
535 }
536
537
538 // **************************
539 // Matrix informations
540 // **************************
541 indStartDataInfo = str.indexOf("int dataInfo(");
542 text->seek(indStartDataInfo);
543 line = text->readLine(); //go to next line
544 line = text->readLine(); //read line
545
546 QStringList curDataInfos;
547 nv=0;
548 while (!line.isEmpty() && nv<nbv){
549 curDataInfos = line.split(" ",QString::SkipEmptyParts);
550 dataInfo1.push_back(curDataInfos.at(0).toInt());
551 dataInfo2.push_back(curDataInfos.at(1).toInt());
552 dataInfo3.push_back(curDataInfos.at(2).toInt());
553 dataInfo4.push_back(curDataInfos.at(3).toInt());
554 line = text->readLine();
555 nv++;
556 }
557
558
559 // **************************
560 // Matrix Values
561 // **************************
562 // DATA1
563 indStartData = str.indexOf("float data_1(");
564 text->seek(indStartData);
565 line = text->readLine();
566 line=line.right(line.size()-line.indexOf("("));
567 line.remove("(");
568 line.remove(")");
569 curDataInfos = line.split(",");
570 nbRows1 = curDataInfos.at(0).toInt();
571 nbCols1 = curDataInfos.at(1).toInt();
572
573 data.clear();
574 line = text->readLine(); //read line
575 while (!line.isEmpty()){
576 data.append(line);
577 line = text->readLine();
578 }
579 curDataInfos = data.split(" ",QString::SkipEmptyParts);
580
581
582 // fill data1 matrix
583 data1 = new double* [nbRows1];
584 for (int row = 0; row < nbRows1; row++)
585 {
586 data1[row] = new double[nbCols1];
587
588 for(int col = 0; col < nbCols1; col++)
589 {
590 data1[row][col] = curDataInfos.at(row*nbCols1+col).toDouble();
591 }
592 }
593
594 // DATA2
595 indStartData = str.indexOf("float data_2(");
596 text->seek(indStartData);
597 line = text->readLine();
598 line=line.right(line.size()-line.indexOf("("));
599 line.remove("(");
600 line.remove(")");
601 curDataInfos = line.split(",");
602 nbRows2 = curDataInfos.at(0).toInt();
603 nbCols2 = curDataInfos.at(1).toInt();
604
605 data.clear();
606 line = text->readLine(); //read line
607 while (!line.isEmpty()){
608 data.append(line);
609 line = text->readLine();
610 }
611 curDataInfos = data.split(" ",QString::SkipEmptyParts);
612
613
614 // fill data2 matrix
615 data2 = new double* [nbRows2];
616 for (int row = 0; row < nbRows2; row++)
617 {
618 data2[row] = new double[nbCols2];
619
620 for(int col = 0; col < nbCols2; col++)
621 {
622 data2[row][col] = curDataInfos.at(row*nbCols2+col).toDouble();
623 }
624 }
625
626
627
628
629 // **************************
630 // Variable Values
631 // **************************
632 for(int iV=0;iV<nbv;iV++)
633 {
634 if(dataInfo1.at(iV) ==0 || dataInfo1.at(iV) ==1)
635 {
636 if(dataInfo2.at(iV)<0)
637 variables->at(iV)->setValue(data1[nbRows1-1][-dataInfo2.at(iV)-1]);
638 else
639 variables->at(iV)->setValue(data1[nbRows1-1][dataInfo2.at(iV)-1]);
640 }
641 else
642 {
643 if(dataInfo2.at(iV)<0)
644 variables->at(iV)->setValue(data2[nbRows2-1][-dataInfo2.at(iV)-1]);
645 else
646 variables->at(iV)->setValue(data2[nbRows2-1][dataInfo2.at(iV)-1]);
647 }
648 }
649
650
651 for (int i = 0; i < nbRows1; i++)
652 delete [] data1[i];
653 delete [] data1;
654
655 for (int i = 0; i < nbRows2; i++)
656 delete [] data2[i];
657 delete [] data2;
658
659 return true;
660
661}
662
663
664bool Dymola::setVariablesToDsin(QString fileName, QString modelName,MOVector<Variable> *variables,MOParameters *parameters,QString & errMsg)
665{
666
667 //Reading Preamble
668 QFileInfo fileinfo = QFileInfo(fileName);
669 QFile file(fileinfo.filePath());
670 if(!file.open(QIODevice::ReadOnly))
671 {
672 errMsg = "Failed to open "+fileName;
673 return false;
674 }
675 else
676 {
677 QTextStream textRead(&file);
678 QString allText = textRead.readAll();
679 file.close();
680
681 // change preamble
682 writeParameters(allText,parameters);
683
684 // change variable values
685 QRegExp rxLine;
686 int index=0;
687 QString newLine1,newLine2;
688 QString varName;
689 int iCurVar;
690 Variable* curVar;
691 QStringList fields;
692 QString smallText;
693 QStringList capLines;
694 int index2;
695 int prec=MOSettings::value("MaxDigitsDsin").toInt(); //number of decimals
696 QString value;
697 for(int iV=0;iV<variables->size();iV++)
698 {
699 InfoSender::instance()->debug("Setting variable "+ varName+" in "+fileName);
700
701 curVar = variables->at(iV);
702 varName = curVar->name(Variable::SHORT);
703 //varName = varName.remove(modelName+".");
704 rxLine.setPattern(sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s+"+sciNumRx()+"\\s*#\\s*("+varName+")\\s*");
705
706 // extracting only text around varname
707 // to speed-up regexp research (too long without)
708 index2 = allText.indexOf(varName);
709 smallText.clear();
710 while(index2>-1)
711 {
712 smallText += allText.mid(index2-300,310+varName.size()); // must capture end of line chars -> 310>300
713 index2 = allText.indexOf(varName,index2+1);
714 }
715
716 index = rxLine.indexIn(smallText);
717 if(index>-1)
718 {
719
720
721 char format = 'E';
722
723 value = QString::number(curVar->getFieldValue(Variable::VALUE).toDouble(),format,prec);
724 fields = rxLine.capturedTexts();
725 capLines = rxLine.cap(0).split("\n",QString::SkipEmptyParts);
726 newLine1 = fields.at(1)+"\t"+ value +"\t";
727 newLine1 += fields.at(3)+"\t"+fields.at(4);
728 newLine2 = fields.at(5)+"\t"+fields.at(6)+"\t"+" # "+fields.at(7);
729 // if variable def were on two lines
730 if((capLines.size()>1)&& capLines.at(1).contains(QRegExp("\\S")))
731 {
732 InfoSender::instance()->debug("found variable. 2 lines. Total text captured: "+rxLine.cap(0));
733 allText = allText.replace(rxLine.cap(0),newLine1+"\n"+newLine2+"\n");
734 InfoSender::instance()->debug("New Text : "+newLine1+"\n"+newLine2);
735 }
736 else
737 {
738 InfoSender::instance()->debug("found variable. 1 line. Total text captured: "+rxLine.cap(0));
739 // if variable def were on only one line
740 allText = allText.replace(rxLine.cap(0),newLine1+"\t"+newLine2+"\n");
741 InfoSender::instance()->debug("New Text : "+newLine1+"\t"+newLine2);
742 }
743 }
744 else
745 {
746 InfoSender::instance()->send(Info("Unable to set variable value (not found in init file):"+varName,ListInfo::ERROR2));
747 }
748 }
749
750 fileinfo.setFile(fileName);
751 file.setFileName(fileinfo.filePath());
752 bool ok = file.open(QIODevice::WriteOnly);
753 if(!ok)
754 {
755 errMsg = "Unable to open file for writing :" + fileinfo.absoluteFilePath();
756 return false;
757 }
758
759 QTextStream textWrite(&file);
760 textWrite<<allText;
761 file.close();
762 }
763}
764
765QString Dymola::sciNumRx()
766{
767 QString rx = "([+-]?[0-9]*\\.?[0-9]+|[+-]?[0-9]+\\.?[0-9]*[eE][+-]?[0-9]+)";
768 return rx;
769}
770
771VariableType Dymola::convertVariableType(int dymDataType)
772{
773 dymDataType = dymDataType % 4; // use %4 to avoid Dymola variable definition 'bug'
774 //# column 6: Data type of variable.
775 //# = 0: real.
776 //# = 1: boolean.
777 //# = 2: integer.
778 switch(dymDataType)
779 {
780 case 0 :
781 return OMREAL;
782 case 1 :
783 return OMBOOLEAN;
784 case 2 :
785 return OMINTEGER;
786 default :
787 return OMREAL;
788 }
789}
790
791VariableCausality Dymola::convertToCausality(int dymValueType, int dymCategory)
792{
793 if((dymValueType==-1)||(dymCategory==1)||(dymCategory==5))
794 return OMINPUT;
795
796 if((dymValueType==-2)||(dymValueType==-0))
797 return OMOUTPUT;
798
799 return OMUNKNOWN;
800}