Microcontroller firmware that uses a simple, yet powerful scripting language to control the timing of input and output events with high temporal resolution. Written by Mattias Karlsson

Dependencies:   SMARTWAV mbed

Committer:
mkarlsso
Date:
Tue Feb 07 18:45:25 2017 +0000
Revision:
7:5fe7329751d4
Parent:
4:abee20c0bf2a
Child:
8:872b843a3053
Fixed flip command for digital outputs

Who changed what in which revision?

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