-
Notifications
You must be signed in to change notification settings - Fork 1
/
spinrun.cpp
63 lines (55 loc) · 1.51 KB
/
spinrun.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "spinrun.h"
#include "QObject"
//TODO add destructor
SpinRun::SpinRun(QString _spin, QString _path, QString _fileName, Type _type) {
spin = _spin;
path = QDir::toNativeSeparators(_path);
fileName = _fileName;
type = _type;
filePath = path + QDir::separator() + fileName;
}
void SpinRun::setStatus(QString status) {
if (currentStatus!="") currentStatus.append("\n");
currentStatus.append(status);
emit statusChanged(this);
}
QString SpinRun::readOutput(){
QString str = currentOutput.append("\n");
currentOutput="";
return str;
}
QString SpinRun::readStatus(){
QString status = currentStatus;
currentStatus = "";
return status;
}
void SpinRun::terminateProcess(){
if (process!=NULL) {
process->close();
setStatus("Process killed");
}
}
void SpinRun::error() {
QString errorMsg = "";
switch (process->error()) {
case QProcess::FailedToStart:
errorMsg = "Process failed to start, check SPIN and C compiler paths and try again";
break;
case QProcess::Crashed:
errorMsg = "Process crashed unexpected";
break;
case QProcess::Timedout:
errorMsg = "Process stopped due to a time out";
break;
default:
errorMsg = "Unexpected error while running process";
break;
}
emit processError(errorMsg);
terminateProcess();
}
QString SpinRun::listToString(QStringList list) {
QString s = "";
foreach(QString item , list) { s.append(item+" "); }
return s;
}