-
Notifications
You must be signed in to change notification settings - Fork 4
/
FsmOraVisitor.cpp
executable file
·84 lines (61 loc) · 1.93 KB
/
FsmOraVisitor.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//
// FsmOraVisitor.cpp
// fsm
//
// Created by Jan Peleska on 2017-02-12.
//
//
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "fsm/Fsm.h"
#include "fsm/FsmNode.h"
#include "fsm/FsmTransition.h"
#include "fsm/FsmLabel.h"
#include "fsm/FsmOraVisitor.h"
using namespace std;
void FsmOraVisitor::visit(Fsm& f) {
if ( finalRun ) {
cout << endl
<< "default: break;" << endl
<< "} // switch (rttIOPost->event ) " << endl
<< "default: break;" << endl
<< "} // switch (thisState) " << endl
<< "@rttYield();" << endl
<< "}" << endl << "}";
}
else {
cout << "@func void ora_" << f.getName() << "() {" << endl << endl;
cout << "int thisState = " << f.getInitStateIdx() << ";" << endl;
cout << endl << "while ( @rttIsRunning ) {" << endl << endl;
cout << "rttIOPost->fsmAction = -1;" << endl << endl;
cout << "switch ( thisState ) {" << endl;
}
}
void FsmOraVisitor::visit(FsmNode& n) {
if ( finalRun ) return;
if ( getNew() ) {
if ( not n.isInitial() ) {
cout << endl << "default: break;" << endl << "}"
<< endl << "break;" << endl;
}
cout << endl << "case " << n.getId() << ": "
<< "// State " << n.getName() << endl;
cout << "switch ( rttIOPost->fsmEvent ) {" << endl;
setNew(false);
}
else {
}
}
void FsmOraVisitor::visit(FsmTransition& t) {
if ( finalRun ) return;
cout << "case " << t.getLabel()->getInput() << ": " << endl;
cout << "// Transition -> " << t.getTarget()->getName() << endl;
cout << "@rttAssert(rttIOPost->fsmAction == " << t.getLabel()->getOutput()
<< ");";
cout << "thisState = " << t.getTarget()->getId() << ";" << endl;
cout << "break;";
}
void FsmOraVisitor::visit(FsmLabel& /* x */) {
}