Andy Lustig
/
Nucleo_statescript
stateScript for Nucleo-F401RE board
behave.h@0:ecf80f0172d0, 2016-02-08 (annotated)
- Committer:
- alustig3
- Date:
- Mon Feb 08 18:56:09 2016 +0000
- Revision:
- 0:ecf80f0172d0
initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alustig3 | 0:ecf80f0172d0 | 1 | //#include "mbed.h" |
alustig3 | 0:ecf80f0172d0 | 2 | #include <stdint.h> |
alustig3 | 0:ecf80f0172d0 | 3 | #include <string.h> |
alustig3 | 0:ecf80f0172d0 | 4 | #include <string> |
alustig3 | 0:ecf80f0172d0 | 5 | #include <vector> |
alustig3 | 0:ecf80f0172d0 | 6 | #include <list> |
alustig3 | 0:ecf80f0172d0 | 7 | #include <deque> |
alustig3 | 0:ecf80f0172d0 | 8 | #include <queue> |
alustig3 | 0:ecf80f0172d0 | 9 | #include "hardwareInterface.h" |
alustig3 | 0:ecf80f0172d0 | 10 | |
alustig3 | 0:ecf80f0172d0 | 11 | |
alustig3 | 0:ecf80f0172d0 | 12 | //#define MBEDHARDWARE //here is where we define which platform we are compiling for |
alustig3 | 0:ecf80f0172d0 | 13 | //#define FPGAHARDWARE |
alustig3 | 0:ecf80f0172d0 | 14 | #define NUCLEOHARDWARE |
alustig3 | 0:ecf80f0172d0 | 15 | |
alustig3 | 0:ecf80f0172d0 | 16 | #define MAXVARNAMESIZE 30 //The maximum number of characters of a variable name |
alustig3 | 0:ecf80f0172d0 | 17 | |
alustig3 | 0:ecf80f0172d0 | 18 | #ifdef MBEDHARDWARE |
alustig3 | 0:ecf80f0172d0 | 19 | #include "mbedInterface.h" |
alustig3 | 0:ecf80f0172d0 | 20 | #endif |
alustig3 | 0:ecf80f0172d0 | 21 | #ifdef FPGAHARDWARE |
alustig3 | 0:ecf80f0172d0 | 22 | #include "fpgaInterface.h" |
alustig3 | 0:ecf80f0172d0 | 23 | #endif |
alustig3 | 0:ecf80f0172d0 | 24 | #ifdef NUCLEOHARDWARE |
alustig3 | 0:ecf80f0172d0 | 25 | #include "nucleoInterface.h" |
alustig3 | 0:ecf80f0172d0 | 26 | #endif |
alustig3 | 0:ecf80f0172d0 | 27 | |
alustig3 | 0:ecf80f0172d0 | 28 | #define BLOCKMEMORYTYPES 1 |
alustig3 | 0:ecf80f0172d0 | 29 | #define VARIABLEMEMORYTYPES 2 |
alustig3 | 0:ecf80f0172d0 | 30 | #define ENVSETTINGSMEMORYTYPES 4 |
alustig3 | 0:ecf80f0172d0 | 31 | |
alustig3 | 0:ecf80f0172d0 | 32 | |
alustig3 | 0:ecf80f0172d0 | 33 | /* |
alustig3 | 0:ecf80f0172d0 | 34 | #define NUMEVENTS 50 |
alustig3 | 0:ecf80f0172d0 | 35 | #define NUMCONDITIONS 150 |
alustig3 | 0:ecf80f0172d0 | 36 | #define NUMINTCOMPARE 150 |
alustig3 | 0:ecf80f0172d0 | 37 | #define NUMACTIONS 150 |
alustig3 | 0:ecf80f0172d0 | 38 | #define NUMPORTMESSAGES 150 |
alustig3 | 0:ecf80f0172d0 | 39 | #define NUMINTOPERATIONS 150 |
alustig3 | 0:ecf80f0172d0 | 40 | #define NUMDISPLAYACTIONS 30 |
alustig3 | 0:ecf80f0172d0 | 41 | #define NUMTRIGGERACTIONS 30 |
alustig3 | 0:ecf80f0172d0 | 42 | #define NUMFUNCTIONS 50 |
alustig3 | 0:ecf80f0172d0 | 43 | #define INPUTCHARBUFFERSIZE 3072 |
alustig3 | 0:ecf80f0172d0 | 44 | */ |
alustig3 | 0:ecf80f0172d0 | 45 | |
alustig3 | 0:ecf80f0172d0 | 46 | #define ARITHMATIC_CONDITION 0 |
alustig3 | 0:ecf80f0172d0 | 47 | #define OR_CONDITION 1 |
alustig3 | 0:ecf80f0172d0 | 48 | #define AND_CONDITION 2 |
alustig3 | 0:ecf80f0172d0 | 49 | |
alustig3 | 0:ecf80f0172d0 | 50 | extern "C" void mbed_reset();//reset mbed through software |
alustig3 | 0:ecf80f0172d0 | 51 | |
alustig3 | 0:ecf80f0172d0 | 52 | |
alustig3 | 0:ecf80f0172d0 | 53 | |
alustig3 | 0:ecf80f0172d0 | 54 | using namespace std; |
alustig3 | 0:ecf80f0172d0 | 55 | |
alustig3 | 0:ecf80f0172d0 | 56 | class event; //we foreward declare this because of class interdependencies |
alustig3 | 0:ecf80f0172d0 | 57 | |
alustig3 | 0:ecf80f0172d0 | 58 | //used in the digital port class to organize digital change events |
alustig3 | 0:ecf80f0172d0 | 59 | /* |
alustig3 | 0:ecf80f0172d0 | 60 | struct changeEvent { |
alustig3 | 0:ecf80f0172d0 | 61 | uint32_t timeStamp; |
alustig3 | 0:ecf80f0172d0 | 62 | bool triggered; |
alustig3 | 0:ecf80f0172d0 | 63 | };*/ |
alustig3 | 0:ecf80f0172d0 | 64 | |
alustig3 | 0:ecf80f0172d0 | 65 | |
alustig3 | 0:ecf80f0172d0 | 66 | //The digitalPort object directly controls and keeps data about the port. Each port has |
alustig3 | 0:ecf80f0172d0 | 67 | //one digital out and one digital in. |
alustig3 | 0:ecf80f0172d0 | 68 | class digitalPort { |
alustig3 | 0:ecf80f0172d0 | 69 | public: |
alustig3 | 0:ecf80f0172d0 | 70 | digitalPort(); |
alustig3 | 0:ecf80f0172d0 | 71 | //digitalPort(sDigitalOut* DOP, sDigitalIn* DIP); |
alustig3 | 0:ecf80f0172d0 | 72 | void init(sDigitalOut* DOP, sDigitalIn* DIP); |
alustig3 | 0:ecf80f0172d0 | 73 | void setDigitalOut(int outVal); |
alustig3 | 0:ecf80f0172d0 | 74 | //int getDigitalOut(); |
alustig3 | 0:ecf80f0172d0 | 75 | int getDigitalIn(); |
alustig3 | 0:ecf80f0172d0 | 76 | int getLastChangeState(); |
alustig3 | 0:ecf80f0172d0 | 77 | uint32_t getTimeSinceLastChange(); |
alustig3 | 0:ecf80f0172d0 | 78 | uint32_t lastChangeTime; |
alustig3 | 0:ecf80f0172d0 | 79 | uint32_t lastOutChangeTime; |
alustig3 | 0:ecf80f0172d0 | 80 | |
alustig3 | 0:ecf80f0172d0 | 81 | void setTriggerUpEvent(event* eventInput); //attahces a routine to an upward change |
alustig3 | 0:ecf80f0172d0 | 82 | void setTriggerDownEvent(event* eventInput); //attahces a routine to a downward change |
alustig3 | 0:ecf80f0172d0 | 83 | //void addStateChange(int newState, uint32_t timeStamp); |
alustig3 | 0:ecf80f0172d0 | 84 | |
alustig3 | 0:ecf80f0172d0 | 85 | bool update(); //called from the main loop |
alustig3 | 0:ecf80f0172d0 | 86 | |
alustig3 | 0:ecf80f0172d0 | 87 | int inState; |
alustig3 | 0:ecf80f0172d0 | 88 | int outState; |
alustig3 | 0:ecf80f0172d0 | 89 | |
alustig3 | 0:ecf80f0172d0 | 90 | bool outStateChanged; |
alustig3 | 0:ecf80f0172d0 | 91 | |
alustig3 | 0:ecf80f0172d0 | 92 | event* triggerUpEventPtr; |
alustig3 | 0:ecf80f0172d0 | 93 | event* triggerDownEventPtr; |
alustig3 | 0:ecf80f0172d0 | 94 | |
alustig3 | 0:ecf80f0172d0 | 95 | private: |
alustig3 | 0:ecf80f0172d0 | 96 | |
alustig3 | 0:ecf80f0172d0 | 97 | sDigitalOut* outPin; |
alustig3 | 0:ecf80f0172d0 | 98 | sDigitalIn* inPin; |
alustig3 | 0:ecf80f0172d0 | 99 | int lastInState; |
alustig3 | 0:ecf80f0172d0 | 100 | uint32_t lastChangeInterval; |
alustig3 | 0:ecf80f0172d0 | 101 | |
alustig3 | 0:ecf80f0172d0 | 102 | //changeEvent lastUpEvent; |
alustig3 | 0:ecf80f0172d0 | 103 | //changeEvent lastDownEvent; |
alustig3 | 0:ecf80f0172d0 | 104 | }; |
alustig3 | 0:ecf80f0172d0 | 105 | |
alustig3 | 0:ecf80f0172d0 | 106 | |
alustig3 | 0:ecf80f0172d0 | 107 | //an intVariable contains an integer value and the name of that variable within the script |
alustig3 | 0:ecf80f0172d0 | 108 | class intVariable { |
alustig3 | 0:ecf80f0172d0 | 109 | |
alustig3 | 0:ecf80f0172d0 | 110 | public: |
alustig3 | 0:ecf80f0172d0 | 111 | intVariable(); |
alustig3 | 0:ecf80f0172d0 | 112 | intVariable(std::string& tagInput, int initialValue); |
alustig3 | 0:ecf80f0172d0 | 113 | void set(std::string& tagInput, int initialValue); |
alustig3 | 0:ecf80f0172d0 | 114 | int value; |
alustig3 | 0:ecf80f0172d0 | 115 | //string tag; |
alustig3 | 0:ecf80f0172d0 | 116 | char tag[MAXVARNAMESIZE+1]; |
alustig3 | 0:ecf80f0172d0 | 117 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 118 | |
alustig3 | 0:ecf80f0172d0 | 119 | }; |
alustig3 | 0:ecf80f0172d0 | 120 | |
alustig3 | 0:ecf80f0172d0 | 121 | |
alustig3 | 0:ecf80f0172d0 | 122 | //ACTION SECTION-- an 'action' is a command in the script. It can be a single command, |
alustig3 | 0:ecf80f0172d0 | 123 | //or a block containing a set of actions |
alustig3 | 0:ecf80f0172d0 | 124 | //------------------------------------------------------------------------------------ |
alustig3 | 0:ecf80f0172d0 | 125 | |
alustig3 | 0:ecf80f0172d0 | 126 | //display actions are used to output text messages via the serial port. The user can display |
alustig3 | 0:ecf80f0172d0 | 127 | //either a static text string or the value of a single variable. |
alustig3 | 0:ecf80f0172d0 | 128 | class displayAction { |
alustig3 | 0:ecf80f0172d0 | 129 | |
alustig3 | 0:ecf80f0172d0 | 130 | public: |
alustig3 | 0:ecf80f0172d0 | 131 | displayAction(); |
alustig3 | 0:ecf80f0172d0 | 132 | void set(int* variable, string varNameInput); |
alustig3 | 0:ecf80f0172d0 | 133 | void set(string text); |
alustig3 | 0:ecf80f0172d0 | 134 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 135 | void execute(); |
alustig3 | 0:ecf80f0172d0 | 136 | void release(); |
alustig3 | 0:ecf80f0172d0 | 137 | |
alustig3 | 0:ecf80f0172d0 | 138 | private: |
alustig3 | 0:ecf80f0172d0 | 139 | int* dVariable; |
alustig3 | 0:ecf80f0172d0 | 140 | string dText; |
alustig3 | 0:ecf80f0172d0 | 141 | |
alustig3 | 0:ecf80f0172d0 | 142 | }; |
alustig3 | 0:ecf80f0172d0 | 143 | |
alustig3 | 0:ecf80f0172d0 | 144 | class triggerFunctionAction { |
alustig3 | 0:ecf80f0172d0 | 145 | |
alustig3 | 0:ecf80f0172d0 | 146 | public: |
alustig3 | 0:ecf80f0172d0 | 147 | triggerFunctionAction(); |
alustig3 | 0:ecf80f0172d0 | 148 | triggerFunctionAction(int functionNum); |
alustig3 | 0:ecf80f0172d0 | 149 | void set(int functionNum); |
alustig3 | 0:ecf80f0172d0 | 150 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 151 | void execute(); |
alustig3 | 0:ecf80f0172d0 | 152 | void release(); |
alustig3 | 0:ecf80f0172d0 | 153 | private: |
alustig3 | 0:ecf80f0172d0 | 154 | int functionNum; |
alustig3 | 0:ecf80f0172d0 | 155 | |
alustig3 | 0:ecf80f0172d0 | 156 | |
alustig3 | 0:ecf80f0172d0 | 157 | }; |
alustig3 | 0:ecf80f0172d0 | 158 | |
alustig3 | 0:ecf80f0172d0 | 159 | //intOpertaion is an action that does addition or subtraction of integers and returns/stores the result |
alustig3 | 0:ecf80f0172d0 | 160 | //these operation are very limited so far (only + or - allowed, and only one operation per object, |
alustig3 | 0:ecf80f0172d0 | 161 | //for example a = b + b works but a = b + c + d does not. The output value can also be set to a random number. |
alustig3 | 0:ecf80f0172d0 | 162 | class intOperation { |
alustig3 | 0:ecf80f0172d0 | 163 | |
alustig3 | 0:ecf80f0172d0 | 164 | public: |
alustig3 | 0:ecf80f0172d0 | 165 | intOperation(); |
alustig3 | 0:ecf80f0172d0 | 166 | |
alustig3 | 0:ecf80f0172d0 | 167 | /* |
alustig3 | 0:ecf80f0172d0 | 168 | intOperation(int randParam, const char* cmpString, int cmpValInput); |
alustig3 | 0:ecf80f0172d0 | 169 | intOperation(int randParam, const char* cmpString, int* cmpIntVarInput); |
alustig3 | 0:ecf80f0172d0 | 170 | intOperation(int* intVarInput, const char* cmpString, int cmpValInput); |
alustig3 | 0:ecf80f0172d0 | 171 | intOperation(int* intVarInput, const char* cmpString, int* cmpIntVarInput); |
alustig3 | 0:ecf80f0172d0 | 172 | intOperation(int* intVarInput, intOperation* operationInput); |
alustig3 | 0:ecf80f0172d0 | 173 | */ |
alustig3 | 0:ecf80f0172d0 | 174 | |
alustig3 | 0:ecf80f0172d0 | 175 | ~intOperation(); |
alustig3 | 0:ecf80f0172d0 | 176 | |
alustig3 | 0:ecf80f0172d0 | 177 | //Supported operations with rand: |
alustig3 | 0:ecf80f0172d0 | 178 | //a = rand(x) |
alustig3 | 0:ecf80f0172d0 | 179 | //a = rand(x) + 3 |
alustig3 | 0:ecf80f0172d0 | 180 | //a = rand(x) + b |
alustig3 | 0:ecf80f0172d0 | 181 | void setRandOp(int randParam, const char* cmpString, int cmpValInput, bool flipped); |
alustig3 | 0:ecf80f0172d0 | 182 | void setRandOp(int randParam, const char* cmpString, int* cmpIntVarInput, bool flipped); |
alustig3 | 0:ecf80f0172d0 | 183 | |
alustig3 | 0:ecf80f0172d0 | 184 | //Supported regular operations |
alustig3 | 0:ecf80f0172d0 | 185 | //a = 5 |
alustig3 | 0:ecf80f0172d0 | 186 | //a = b |
alustig3 | 0:ecf80f0172d0 | 187 | //a = b + 6 |
alustig3 | 0:ecf80f0172d0 | 188 | //a = b + c |
alustig3 | 0:ecf80f0172d0 | 189 | void set(int* intVarInput, const char* cmpString, int cmpValInput); |
alustig3 | 0:ecf80f0172d0 | 190 | void set(int* intVarInput, const char* cmpString, int* cmpIntVarInput); |
alustig3 | 0:ecf80f0172d0 | 191 | void set(int* intVarInput, intOperation* operationInput); |
alustig3 | 0:ecf80f0172d0 | 192 | |
alustig3 | 0:ecf80f0172d0 | 193 | |
alustig3 | 0:ecf80f0172d0 | 194 | //Supported operations with clock() |
alustig3 | 0:ecf80f0172d0 | 195 | //a = clock() |
alustig3 | 0:ecf80f0172d0 | 196 | //a = clock() + 5 |
alustig3 | 0:ecf80f0172d0 | 197 | //a = clock() + b |
alustig3 | 0:ecf80f0172d0 | 198 | void setClockOp(int* intVarInput); |
alustig3 | 0:ecf80f0172d0 | 199 | void setClockOp(const char* cmpString, int cmpValInput, bool flip); |
alustig3 | 0:ecf80f0172d0 | 200 | void setClockOp(const char* cmpString, int* cmpIntVarInput, bool flip); |
alustig3 | 0:ecf80f0172d0 | 201 | |
alustig3 | 0:ecf80f0172d0 | 202 | void release(); |
alustig3 | 0:ecf80f0172d0 | 203 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 204 | int execute(); |
alustig3 | 0:ecf80f0172d0 | 205 | |
alustig3 | 0:ecf80f0172d0 | 206 | private: |
alustig3 | 0:ecf80f0172d0 | 207 | int randHigh; |
alustig3 | 0:ecf80f0172d0 | 208 | int* cmpVal; |
alustig3 | 0:ecf80f0172d0 | 209 | int* intVal; |
alustig3 | 0:ecf80f0172d0 | 210 | intOperation* opPtr; |
alustig3 | 0:ecf80f0172d0 | 211 | bool cmpValGlobal; |
alustig3 | 0:ecf80f0172d0 | 212 | bool isClockAssign; //if the current clock value is part of the operation |
alustig3 | 0:ecf80f0172d0 | 213 | bool inputsFlipped; |
alustig3 | 0:ecf80f0172d0 | 214 | int (intOperation::*executePtr)(); |
alustig3 | 0:ecf80f0172d0 | 215 | int addAndStore(); |
alustig3 | 0:ecf80f0172d0 | 216 | int subtractAndStore(); |
alustig3 | 0:ecf80f0172d0 | 217 | int add(); |
alustig3 | 0:ecf80f0172d0 | 218 | int subtract(); |
alustig3 | 0:ecf80f0172d0 | 219 | int equals(); |
alustig3 | 0:ecf80f0172d0 | 220 | |
alustig3 | 0:ecf80f0172d0 | 221 | }; |
alustig3 | 0:ecf80f0172d0 | 222 | |
alustig3 | 0:ecf80f0172d0 | 223 | //portMessage is an action to change a digital port. So far, You can only change the digital out (0 or 1) |
alustig3 | 0:ecf80f0172d0 | 224 | class portMessage { |
alustig3 | 0:ecf80f0172d0 | 225 | public: |
alustig3 | 0:ecf80f0172d0 | 226 | |
alustig3 | 0:ecf80f0172d0 | 227 | portMessage(); |
alustig3 | 0:ecf80f0172d0 | 228 | //portMessage(digitalPort* portIn, int whichToSet, int value); //whichToSet: 1 DigitalOut; 2 State |
alustig3 | 0:ecf80f0172d0 | 229 | //void setMessage(digitalPort* portIn, int whichToSet, int value); //whichToSet: 1 DigitalOut; 2 State |
alustig3 | 0:ecf80f0172d0 | 230 | //portMessage(int* portIn, int whichToSet, int value); //whichToSet: |
alustig3 | 0:ecf80f0172d0 | 231 | void setMessage(int* portIn, int whichToSet, int value, digitalPort* portVector); //whichToSet: |
alustig3 | 0:ecf80f0172d0 | 232 | |
alustig3 | 0:ecf80f0172d0 | 233 | void execute(); |
alustig3 | 0:ecf80f0172d0 | 234 | void release(); |
alustig3 | 0:ecf80f0172d0 | 235 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 236 | |
alustig3 | 0:ecf80f0172d0 | 237 | private: |
alustig3 | 0:ecf80f0172d0 | 238 | int whichToSet; //hard coded port number |
alustig3 | 0:ecf80f0172d0 | 239 | int* port; //alternative variable port number |
alustig3 | 0:ecf80f0172d0 | 240 | int value; |
alustig3 | 0:ecf80f0172d0 | 241 | |
alustig3 | 0:ecf80f0172d0 | 242 | digitalPort* portVector; |
alustig3 | 0:ecf80f0172d0 | 243 | |
alustig3 | 0:ecf80f0172d0 | 244 | }; |
alustig3 | 0:ecf80f0172d0 | 245 | |
alustig3 | 0:ecf80f0172d0 | 246 | //holder class for all possible actions. This include general system commands. |
alustig3 | 0:ecf80f0172d0 | 247 | class action { |
alustig3 | 0:ecf80f0172d0 | 248 | public: |
alustig3 | 0:ecf80f0172d0 | 249 | |
alustig3 | 0:ecf80f0172d0 | 250 | action(); |
alustig3 | 0:ecf80f0172d0 | 251 | ~action(); |
alustig3 | 0:ecf80f0172d0 | 252 | action(intOperation* opInput); |
alustig3 | 0:ecf80f0172d0 | 253 | action(portMessage* messageInput); |
alustig3 | 0:ecf80f0172d0 | 254 | action(event* eventInput); |
alustig3 | 0:ecf80f0172d0 | 255 | //action(event* eventInput, uint32_t delay); |
alustig3 | 0:ecf80f0172d0 | 256 | action(displayAction* displayInput); |
alustig3 | 0:ecf80f0172d0 | 257 | action(sSound* soundInput); |
alustig3 | 0:ecf80f0172d0 | 258 | action(triggerFunctionAction* triggerFuncInput); |
alustig3 | 0:ecf80f0172d0 | 259 | action(int8_t sysCommandInput); //for general system commands |
alustig3 | 0:ecf80f0172d0 | 260 | |
alustig3 | 0:ecf80f0172d0 | 261 | void set(intOperation* opInput); |
alustig3 | 0:ecf80f0172d0 | 262 | void set(portMessage* messageInput); |
alustig3 | 0:ecf80f0172d0 | 263 | void set(event* eventInput); |
alustig3 | 0:ecf80f0172d0 | 264 | //void set(event* eventInput, uint32_t delay); |
alustig3 | 0:ecf80f0172d0 | 265 | |
alustig3 | 0:ecf80f0172d0 | 266 | void set(displayAction* displayInput); |
alustig3 | 0:ecf80f0172d0 | 267 | void set(sSound* soundInput); |
alustig3 | 0:ecf80f0172d0 | 268 | void set(triggerFunctionAction* triggerFuncInput); |
alustig3 | 0:ecf80f0172d0 | 269 | void set(int8_t sysCommandInput); |
alustig3 | 0:ecf80f0172d0 | 270 | void execute(); |
alustig3 | 0:ecf80f0172d0 | 271 | void execute(uint32_t blockExecTime); |
alustig3 | 0:ecf80f0172d0 | 272 | void release(); |
alustig3 | 0:ecf80f0172d0 | 273 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 274 | |
alustig3 | 0:ecf80f0172d0 | 275 | private: |
alustig3 | 0:ecf80f0172d0 | 276 | intOperation* op; |
alustig3 | 0:ecf80f0172d0 | 277 | portMessage* message; |
alustig3 | 0:ecf80f0172d0 | 278 | event* eventToCreate; |
alustig3 | 0:ecf80f0172d0 | 279 | displayAction* displayActionPtr; |
alustig3 | 0:ecf80f0172d0 | 280 | sSound* sound; |
alustig3 | 0:ecf80f0172d0 | 281 | triggerFunctionAction* triggerFunc; |
alustig3 | 0:ecf80f0172d0 | 282 | //uint32_t eventDelay; |
alustig3 | 0:ecf80f0172d0 | 283 | int8_t sysCommand; |
alustig3 | 0:ecf80f0172d0 | 284 | char actionType; |
alustig3 | 0:ecf80f0172d0 | 285 | |
alustig3 | 0:ecf80f0172d0 | 286 | }; |
alustig3 | 0:ecf80f0172d0 | 287 | //----------------------------------------------------- |
alustig3 | 0:ecf80f0172d0 | 288 | |
alustig3 | 0:ecf80f0172d0 | 289 | //CONDITION SECTION-- a 'condition' is used in the beginning of a block (if-else blocks or while blocks) |
alustig3 | 0:ecf80f0172d0 | 290 | //If the condition is true, the block is exectuted during a callback |
alustig3 | 0:ecf80f0172d0 | 291 | //------------------------------------------------------------------------------------ |
alustig3 | 0:ecf80f0172d0 | 292 | |
alustig3 | 0:ecf80f0172d0 | 293 | |
alustig3 | 0:ecf80f0172d0 | 294 | //intCompare is a condition class that compares the state value of a port or |
alustig3 | 0:ecf80f0172d0 | 295 | //an integer variable to another integer variable or operation output |
alustig3 | 0:ecf80f0172d0 | 296 | class intCompare { |
alustig3 | 0:ecf80f0172d0 | 297 | |
alustig3 | 0:ecf80f0172d0 | 298 | public: |
alustig3 | 0:ecf80f0172d0 | 299 | intCompare(); |
alustig3 | 0:ecf80f0172d0 | 300 | intCompare(digitalPort* portInput, const char* cmpString, int cmpValInput, int whichToUse); |
alustig3 | 0:ecf80f0172d0 | 301 | intCompare(digitalPort* portInput, const char* cmpString, int* cmpIntVarInput, int whichToUse); |
alustig3 | 0:ecf80f0172d0 | 302 | intCompare(int* intVarInput, const char* cmpString, int cmpValInput); |
alustig3 | 0:ecf80f0172d0 | 303 | intCompare(int* intVarInput, const char* cmpString, int* cmpIntVarInput); |
alustig3 | 0:ecf80f0172d0 | 304 | intCompare(int* intVarInput, const char* cmpString, intOperation* cmpIntOpInput); |
alustig3 | 0:ecf80f0172d0 | 305 | intCompare(digitalPort* portInput, const char* cmpString, intOperation* cmpIntOpInput, int whichToUse); |
alustig3 | 0:ecf80f0172d0 | 306 | |
alustig3 | 0:ecf80f0172d0 | 307 | void set(digitalPort* portInput, const char* cmpString, int cmpValInput, int whichToUse); |
alustig3 | 0:ecf80f0172d0 | 308 | void set(digitalPort* portInput, const char* cmpString, int* cmpIntVarInput, int whichToUse); |
alustig3 | 0:ecf80f0172d0 | 309 | void set(int* intVarInput, const char* cmpString, int cmpValInput); |
alustig3 | 0:ecf80f0172d0 | 310 | void set(int* intVarInput, const char* cmpString, int* cmpIntVarInput); |
alustig3 | 0:ecf80f0172d0 | 311 | void set(int* intVarInput, const char* cmpString, intOperation* cmpIntOpInput); |
alustig3 | 0:ecf80f0172d0 | 312 | void set(digitalPort* portInput, const char* cmpString, intOperation* cmpIntOpInput, int whichToUse); |
alustig3 | 0:ecf80f0172d0 | 313 | |
alustig3 | 0:ecf80f0172d0 | 314 | void release(); |
alustig3 | 0:ecf80f0172d0 | 315 | |
alustig3 | 0:ecf80f0172d0 | 316 | ~intCompare(); |
alustig3 | 0:ecf80f0172d0 | 317 | bool isTrue(); |
alustig3 | 0:ecf80f0172d0 | 318 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 319 | |
alustig3 | 0:ecf80f0172d0 | 320 | private: |
alustig3 | 0:ecf80f0172d0 | 321 | digitalPort* port; |
alustig3 | 0:ecf80f0172d0 | 322 | int* portValPtr; |
alustig3 | 0:ecf80f0172d0 | 323 | int* cmpVal; |
alustig3 | 0:ecf80f0172d0 | 324 | int* intVal; |
alustig3 | 0:ecf80f0172d0 | 325 | intOperation* intOp; |
alustig3 | 0:ecf80f0172d0 | 326 | void setPointer(const char* cmpString); |
alustig3 | 0:ecf80f0172d0 | 327 | void setPointer_operation(const char* cmpString); |
alustig3 | 0:ecf80f0172d0 | 328 | bool (intCompare::*isTruePtr)(); |
alustig3 | 0:ecf80f0172d0 | 329 | bool cmpValGlobal; |
alustig3 | 0:ecf80f0172d0 | 330 | bool greaterThan(); |
alustig3 | 0:ecf80f0172d0 | 331 | bool greaterOrEqual(); |
alustig3 | 0:ecf80f0172d0 | 332 | bool lessThan(); |
alustig3 | 0:ecf80f0172d0 | 333 | bool lessOrEqual(); |
alustig3 | 0:ecf80f0172d0 | 334 | bool equal(); |
alustig3 | 0:ecf80f0172d0 | 335 | bool notEqual(); |
alustig3 | 0:ecf80f0172d0 | 336 | bool greaterThan_op(); |
alustig3 | 0:ecf80f0172d0 | 337 | bool greaterOrEqual_op(); |
alustig3 | 0:ecf80f0172d0 | 338 | bool lessThan_op(); |
alustig3 | 0:ecf80f0172d0 | 339 | bool lessOrEqual_op(); |
alustig3 | 0:ecf80f0172d0 | 340 | bool equal_op(); |
alustig3 | 0:ecf80f0172d0 | 341 | bool notEqual_op(); |
alustig3 | 0:ecf80f0172d0 | 342 | }; |
alustig3 | 0:ecf80f0172d0 | 343 | |
alustig3 | 0:ecf80f0172d0 | 344 | |
alustig3 | 0:ecf80f0172d0 | 345 | //holder class for all possible conditions (so far only intCompare) |
alustig3 | 0:ecf80f0172d0 | 346 | class condition { |
alustig3 | 0:ecf80f0172d0 | 347 | public: |
alustig3 | 0:ecf80f0172d0 | 348 | |
alustig3 | 0:ecf80f0172d0 | 349 | condition(); |
alustig3 | 0:ecf80f0172d0 | 350 | condition(intCompare* compareInput); |
alustig3 | 0:ecf80f0172d0 | 351 | condition(condition* condition1, char condType, condition* condition2); |
alustig3 | 0:ecf80f0172d0 | 352 | ~condition(); |
alustig3 | 0:ecf80f0172d0 | 353 | void set(intCompare* compareInput); |
alustig3 | 0:ecf80f0172d0 | 354 | void set(condition* condition1, char condType, condition* condition2); |
alustig3 | 0:ecf80f0172d0 | 355 | bool isTrue(); |
alustig3 | 0:ecf80f0172d0 | 356 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 357 | void release(); //called when the event is no longer being used; |
alustig3 | 0:ecf80f0172d0 | 358 | private: |
alustig3 | 0:ecf80f0172d0 | 359 | |
alustig3 | 0:ecf80f0172d0 | 360 | //char conditionType; //1 for intCompare |
alustig3 | 0:ecf80f0172d0 | 361 | intCompare* intCmp; |
alustig3 | 0:ecf80f0172d0 | 362 | condition* conditionPtrs[2]; |
alustig3 | 0:ecf80f0172d0 | 363 | char conditionType; |
alustig3 | 0:ecf80f0172d0 | 364 | |
alustig3 | 0:ecf80f0172d0 | 365 | |
alustig3 | 0:ecf80f0172d0 | 366 | }; |
alustig3 | 0:ecf80f0172d0 | 367 | //-------------------------------------------- |
alustig3 | 0:ecf80f0172d0 | 368 | |
alustig3 | 0:ecf80f0172d0 | 369 | |
alustig3 | 0:ecf80f0172d0 | 370 | //queueItem connects a pre-defined event with an exectution time. |
alustig3 | 0:ecf80f0172d0 | 371 | //They are placed in the eventQueue |
alustig3 | 0:ecf80f0172d0 | 372 | struct queueItem { |
alustig3 | 0:ecf80f0172d0 | 373 | uint32_t timeToExecute; |
alustig3 | 0:ecf80f0172d0 | 374 | event* eventPtr; |
alustig3 | 0:ecf80f0172d0 | 375 | }; |
alustig3 | 0:ecf80f0172d0 | 376 | |
alustig3 | 0:ecf80f0172d0 | 377 | |
alustig3 | 0:ecf80f0172d0 | 378 | //Organizes events in a temporal queue. check() is called from the main loop. |
alustig3 | 0:ecf80f0172d0 | 379 | //If the execution time of the event has passed, then the event is exectuted. |
alustig3 | 0:ecf80f0172d0 | 380 | class eventQueue { |
alustig3 | 0:ecf80f0172d0 | 381 | public: |
alustig3 | 0:ecf80f0172d0 | 382 | eventQueue(); |
alustig3 | 0:ecf80f0172d0 | 383 | void addEventToQueue(event* eventInput, uint32_t delay); |
alustig3 | 0:ecf80f0172d0 | 384 | void eraseQueue(); //clear all future events |
alustig3 | 0:ecf80f0172d0 | 385 | void check(void); |
alustig3 | 0:ecf80f0172d0 | 386 | |
alustig3 | 0:ecf80f0172d0 | 387 | private: |
alustig3 | 0:ecf80f0172d0 | 388 | std::vector<queueItem> events; |
alustig3 | 0:ecf80f0172d0 | 389 | int queueSize; |
alustig3 | 0:ecf80f0172d0 | 390 | |
alustig3 | 0:ecf80f0172d0 | 391 | }; |
alustig3 | 0:ecf80f0172d0 | 392 | |
alustig3 | 0:ecf80f0172d0 | 393 | //An 'event' is a block of 'actions' that can be gated with a boolean 'condition' set. All |
alustig3 | 0:ecf80f0172d0 | 394 | //conditions in the set must be true for the block of actions to be executed. Right now, |
alustig3 | 0:ecf80f0172d0 | 395 | //there is no OR logic (||), only AND (&&). |
alustig3 | 0:ecf80f0172d0 | 396 | //The entire event is placed on the event queue to be executed at a given delay. |
alustig3 | 0:ecf80f0172d0 | 397 | //At that future time, the condition is checked and if true, the block of actions |
alustig3 | 0:ecf80f0172d0 | 398 | //is exectuted. Note: an 'action' can be another event (or even the parent event), allowing |
alustig3 | 0:ecf80f0172d0 | 399 | //nested 'if' and 'while' statements. |
alustig3 | 0:ecf80f0172d0 | 400 | class event { |
alustig3 | 0:ecf80f0172d0 | 401 | public: |
alustig3 | 0:ecf80f0172d0 | 402 | |
alustig3 | 0:ecf80f0172d0 | 403 | event(); |
alustig3 | 0:ecf80f0172d0 | 404 | event(eventQueue* queueInput); |
alustig3 | 0:ecf80f0172d0 | 405 | ~event(); |
alustig3 | 0:ecf80f0172d0 | 406 | void setTimeLag(uint32_t timeLagInput); //the event will be exectuted at this time from now |
alustig3 | 0:ecf80f0172d0 | 407 | void setTimeLag(int* timeLagInput); //the event will be exectuted at this time from now |
alustig3 | 0:ecf80f0172d0 | 408 | void setWhileLoopPeriod(uint32_t period); |
alustig3 | 0:ecf80f0172d0 | 409 | void setWhileLoopPeriod(int* period); |
alustig3 | 0:ecf80f0172d0 | 410 | void addCondition(condition* conditionInput); //contains a set of conditions to check and a truth table |
alustig3 | 0:ecf80f0172d0 | 411 | bool isConditionTrue(void); //checks if the condition is true |
alustig3 | 0:ecf80f0172d0 | 412 | void addAction(action* actionInput); //called during script parsing, when the block is being defined |
alustig3 | 0:ecf80f0172d0 | 413 | void addToQueue(void); //places the event on the event queue with default time lag. When the time |
alustig3 | 0:ecf80f0172d0 | 414 | //lag has expired, the the block is executed |
alustig3 | 0:ecf80f0172d0 | 415 | void addToQueue(uint32_t delay); |
alustig3 | 0:ecf80f0172d0 | 416 | void execute(void); //Execute without checking the condition. Called only from the event queue |
alustig3 | 0:ecf80f0172d0 | 417 | void setNextElseEvent(event* eventInput); //allows for else event block |
alustig3 | 0:ecf80f0172d0 | 418 | uint32_t timeLag; //default time from now when the event will be executed (this is ignored once placed in event queue) |
alustig3 | 0:ecf80f0172d0 | 419 | int* timeLagVar; //exectution time lab defined by a variable |
alustig3 | 0:ecf80f0172d0 | 420 | eventQueue* queuePtr; |
alustig3 | 0:ecf80f0172d0 | 421 | void release(); //called when the event is no longer being used; |
alustig3 | 0:ecf80f0172d0 | 422 | |
alustig3 | 0:ecf80f0172d0 | 423 | char blockType; //0 callback |
alustig3 | 0:ecf80f0172d0 | 424 | //1 if ... do block (with conditions) |
alustig3 | 0:ecf80f0172d0 | 425 | //2 do block (no conditions) |
alustig3 | 0:ecf80f0172d0 | 426 | //3 else if ... do block |
alustig3 | 0:ecf80f0172d0 | 427 | //4 else do (no conditions) |
alustig3 | 0:ecf80f0172d0 | 428 | //5 while ... do every ... block |
alustig3 | 0:ecf80f0172d0 | 429 | //6 else while ... do every ... block |
alustig3 | 0:ecf80f0172d0 | 430 | //7 then if ... do block |
alustig3 | 0:ecf80f0172d0 | 431 | //8 then do (no conditions) |
alustig3 | 0:ecf80f0172d0 | 432 | |
alustig3 | 0:ecf80f0172d0 | 433 | uint32_t whileLoopPeriod; //if non-zero, the block is a while loop (executed at regular intervals) |
alustig3 | 0:ecf80f0172d0 | 434 | int* whileLoopPeriodVar; |
alustig3 | 0:ecf80f0172d0 | 435 | event* nextElseEventPtr; |
alustig3 | 0:ecf80f0172d0 | 436 | bool isUsed; |
alustig3 | 0:ecf80f0172d0 | 437 | bool timeLagIsConstant; |
alustig3 | 0:ecf80f0172d0 | 438 | bool whileLoopPeriodIsConstant; |
alustig3 | 0:ecf80f0172d0 | 439 | bool hasWhileLoop; |
alustig3 | 0:ecf80f0172d0 | 440 | |
alustig3 | 0:ecf80f0172d0 | 441 | private: |
alustig3 | 0:ecf80f0172d0 | 442 | int numConditions; |
alustig3 | 0:ecf80f0172d0 | 443 | int numActions; |
alustig3 | 0:ecf80f0172d0 | 444 | condition* conditionToCheck; |
alustig3 | 0:ecf80f0172d0 | 445 | action* actionArray[20]; |
alustig3 | 0:ecf80f0172d0 | 446 | |
alustig3 | 0:ecf80f0172d0 | 447 | //if statement (can be left empty, which is interpreted as 'true') |
alustig3 | 0:ecf80f0172d0 | 448 | //std::vector<condition*> conditionArray; |
alustig3 | 0:ecf80f0172d0 | 449 | //std::deque<action*> actionArray; |
alustig3 | 0:ecf80f0172d0 | 450 | |
alustig3 | 0:ecf80f0172d0 | 451 | }; |
alustig3 | 0:ecf80f0172d0 | 452 | |
alustig3 | 0:ecf80f0172d0 | 453 | //each functionItem help a poiter to an action, and the name of the function. Not currently in use. |
alustig3 | 0:ecf80f0172d0 | 454 | class functionItem { |
alustig3 | 0:ecf80f0172d0 | 455 | public: |
alustig3 | 0:ecf80f0172d0 | 456 | functionItem(action* actionInput, string tagInput); |
alustig3 | 0:ecf80f0172d0 | 457 | ~functionItem(); |
alustig3 | 0:ecf80f0172d0 | 458 | string tag; |
alustig3 | 0:ecf80f0172d0 | 459 | action* actionPtr; |
alustig3 | 0:ecf80f0172d0 | 460 | }; |
alustig3 | 0:ecf80f0172d0 | 461 | |
alustig3 | 0:ecf80f0172d0 | 462 | class blockBuffer { |
alustig3 | 0:ecf80f0172d0 | 463 | |
alustig3 | 0:ecf80f0172d0 | 464 | public: |
alustig3 | 0:ecf80f0172d0 | 465 | blockBuffer(); |
alustig3 | 0:ecf80f0172d0 | 466 | bool addLine(char* input, int numChars); |
alustig3 | 0:ecf80f0172d0 | 467 | string getNextLine(); |
alustig3 | 0:ecf80f0172d0 | 468 | int16_t linesAvailable(); |
alustig3 | 0:ecf80f0172d0 | 469 | bool empty(); |
alustig3 | 0:ecf80f0172d0 | 470 | void resetBuffer(); |
alustig3 | 0:ecf80f0172d0 | 471 | |
alustig3 | 0:ecf80f0172d0 | 472 | private: |
alustig3 | 0:ecf80f0172d0 | 473 | #ifdef MBEDHARDWARE |
alustig3 | 0:ecf80f0172d0 | 474 | //On the MBED, we need to put this on a different memory bank |
alustig3 | 0:ecf80f0172d0 | 475 | __attribute((section("AHBSRAM1"),aligned)) char charBuffer[INPUTCHARBUFFERSIZE]; |
alustig3 | 0:ecf80f0172d0 | 476 | #else |
alustig3 | 0:ecf80f0172d0 | 477 | char charBuffer[INPUTCHARBUFFERSIZE]; |
alustig3 | 0:ecf80f0172d0 | 478 | #endif |
alustig3 | 0:ecf80f0172d0 | 479 | int16_t bufferWritePos; |
alustig3 | 0:ecf80f0172d0 | 480 | int16_t bufferReadPos; |
alustig3 | 0:ecf80f0172d0 | 481 | int16_t _linesAvailable; |
alustig3 | 0:ecf80f0172d0 | 482 | |
alustig3 | 0:ecf80f0172d0 | 483 | }; |
alustig3 | 0:ecf80f0172d0 | 484 | |
alustig3 | 0:ecf80f0172d0 | 485 | //Parser for the incoming text. The parser is called when a line terminates with a semicolon (;). |
alustig3 | 0:ecf80f0172d0 | 486 | //Only the final line in a callback block should have a semicolon. |
alustig3 | 0:ecf80f0172d0 | 487 | class scriptStream { |
alustig3 | 0:ecf80f0172d0 | 488 | public: |
alustig3 | 0:ecf80f0172d0 | 489 | scriptStream(digitalPort* portVectorInput, int numPortsInput, eventQueue* queueInput, sSystem* system); |
alustig3 | 0:ecf80f0172d0 | 490 | void parseBlock(); //Parses everything since the last semicolon was found |
alustig3 | 0:ecf80f0172d0 | 491 | void addLineToCurrentBlock(char* lineInput); // if the line did not end with a semicolon, add it to the current block |
alustig3 | 0:ecf80f0172d0 | 492 | |
alustig3 | 0:ecf80f0172d0 | 493 | private: |
alustig3 | 0:ecf80f0172d0 | 494 | |
alustig3 | 0:ecf80f0172d0 | 495 | int* findIntVariable(string nameInput); //used to retrieve the pointer to the designated variable if it exists |
alustig3 | 0:ecf80f0172d0 | 496 | int* findIntVariable(const char* nameInput); //used to retrieve the pointer to the designated variable if it exists |
alustig3 | 0:ecf80f0172d0 | 497 | int* findIntVariable(const char* nameInput, int start, int end); //used to retrieve the pointer to the designated variable if it exists |
alustig3 | 0:ecf80f0172d0 | 498 | bool createIntVariable(string nameInput); // creates a new interger variable |
alustig3 | 0:ecf80f0172d0 | 499 | action* evaluateAssignmentForAction(string expression); //parses a numerical assignment or operation (a = b - c) |
alustig3 | 0:ecf80f0172d0 | 500 | action* evaluateAssignmentForAction(const char* expression); //parses a numerical assignment or operation (a = b - c) |
alustig3 | 0:ecf80f0172d0 | 501 | bool evaluateConditions(string& expression, event* currentEvent); //parses a condition statement (a == b && c > d) |
alustig3 | 0:ecf80f0172d0 | 502 | condition* parseConditions(const char* expression,int start, int end); //parses a condition statement (a == b && c > d) |
alustig3 | 0:ecf80f0172d0 | 503 | int findFirstOrOutsideParenth(const char* expression, int start, int end); |
alustig3 | 0:ecf80f0172d0 | 504 | int findFirstAndOutsideParenth(const char* expression, int start, int end); |
alustig3 | 0:ecf80f0172d0 | 505 | bool isOutsideParenth(const char* expression,int foundItem, int start, int end); |
alustig3 | 0:ecf80f0172d0 | 506 | bool isNum(const char* expression, int start, int end); |
alustig3 | 0:ecf80f0172d0 | 507 | bool areStringsSame(const char* str1, const char* str2, int start, int end); |
alustig3 | 0:ecf80f0172d0 | 508 | int getRandomParam(string expression); |
alustig3 | 0:ecf80f0172d0 | 509 | int getRandomParam(const char* expression,int start,int end); |
alustig3 | 0:ecf80f0172d0 | 510 | int findStringLoc(const char* refString,const char* findString,int start, int end); |
alustig3 | 0:ecf80f0172d0 | 511 | void clearEnvironmentVariables(int mode); |
alustig3 | 0:ecf80f0172d0 | 512 | |
alustig3 | 0:ecf80f0172d0 | 513 | int currentTriggerPort; |
alustig3 | 0:ecf80f0172d0 | 514 | int currentTriggerDir; |
alustig3 | 0:ecf80f0172d0 | 515 | int currentPort; |
alustig3 | 0:ecf80f0172d0 | 516 | int currentFunction; |
alustig3 | 0:ecf80f0172d0 | 517 | |
alustig3 | 0:ecf80f0172d0 | 518 | string tmpLine; |
alustig3 | 0:ecf80f0172d0 | 519 | vector<string> tokens; |
alustig3 | 0:ecf80f0172d0 | 520 | |
alustig3 | 0:ecf80f0172d0 | 521 | bool lineError; |
alustig3 | 0:ecf80f0172d0 | 522 | int blockDepth; |
alustig3 | 0:ecf80f0172d0 | 523 | bool ifBlockInit; |
alustig3 | 0:ecf80f0172d0 | 524 | bool whileBlockInit; |
alustig3 | 0:ecf80f0172d0 | 525 | bool elseFlag; |
alustig3 | 0:ecf80f0172d0 | 526 | bool thenFlag; |
alustig3 | 0:ecf80f0172d0 | 527 | bool expectingDoStatement; |
alustig3 | 0:ecf80f0172d0 | 528 | int currentDelay; |
alustig3 | 0:ecf80f0172d0 | 529 | event* tmpEvent; |
alustig3 | 0:ecf80f0172d0 | 530 | string tmpString; |
alustig3 | 0:ecf80f0172d0 | 531 | |
alustig3 | 0:ecf80f0172d0 | 532 | vector<intVariable*> globalVariables; |
alustig3 | 0:ecf80f0172d0 | 533 | vector<event*> tmpEventPtrArray; |
alustig3 | 0:ecf80f0172d0 | 534 | //event* functionEventArray[NUMFUNCTIONS]; |
alustig3 | 0:ecf80f0172d0 | 535 | //bool functionSpotTaken[NUMFUNCTIONS]; |
alustig3 | 0:ecf80f0172d0 | 536 | |
alustig3 | 0:ecf80f0172d0 | 537 | //vector<functionItem*> functionArray; //any blocks declared outsite callback blocks are stored here |
alustig3 | 0:ecf80f0172d0 | 538 | //list<string> currentBlock; |
alustig3 | 0:ecf80f0172d0 | 539 | blockBuffer currentBlock; |
alustig3 | 0:ecf80f0172d0 | 540 | digitalPort* portVector; |
alustig3 | 0:ecf80f0172d0 | 541 | sSystem* system; |
alustig3 | 0:ecf80f0172d0 | 542 | |
alustig3 | 0:ecf80f0172d0 | 543 | |
alustig3 | 0:ecf80f0172d0 | 544 | |
alustig3 | 0:ecf80f0172d0 | 545 | int numPorts; |
alustig3 | 0:ecf80f0172d0 | 546 | eventQueue* queuePtr; |
alustig3 | 0:ecf80f0172d0 | 547 | |
alustig3 | 0:ecf80f0172d0 | 548 | }; |
alustig3 | 0:ecf80f0172d0 | 549 | |
alustig3 | 0:ecf80f0172d0 | 550 | |
alustig3 | 0:ecf80f0172d0 | 551 | class mainLoop |
alustig3 | 0:ecf80f0172d0 | 552 | |
alustig3 | 0:ecf80f0172d0 | 553 | { |
alustig3 | 0:ecf80f0172d0 | 554 | public: |
alustig3 | 0:ecf80f0172d0 | 555 | mainLoop(); |
alustig3 | 0:ecf80f0172d0 | 556 | void init(); |
alustig3 | 0:ecf80f0172d0 | 557 | void exec(); |
alustig3 | 0:ecf80f0172d0 | 558 | private: |
alustig3 | 0:ecf80f0172d0 | 559 | void eraseBuffer(); |
alustig3 | 0:ecf80f0172d0 | 560 | uint32_t currentDIOstate[2]; |
alustig3 | 0:ecf80f0172d0 | 561 | bool digitalInChanged; |
alustig3 | 0:ecf80f0172d0 | 562 | bool digitalOutChanged; |
alustig3 | 0:ecf80f0172d0 | 563 | scriptStream *parser; |
alustig3 | 0:ecf80f0172d0 | 564 | sSystem *hardware; //hardware interface |
alustig3 | 0:ecf80f0172d0 | 565 | sSerialPort *pc; //communication to computer |
alustig3 | 0:ecf80f0172d0 | 566 | char buffer[256]; |
alustig3 | 0:ecf80f0172d0 | 567 | digitalPort ports[NUMPORTS]; |
alustig3 | 0:ecf80f0172d0 | 568 | |
alustig3 | 0:ecf80f0172d0 | 569 | |
alustig3 | 0:ecf80f0172d0 | 570 | |
alustig3 | 0:ecf80f0172d0 | 571 | }; |