tes

Dependencies:   NetServices mbed C027_Supports mbed-rpcx

Committer:
aldoao
Date:
Wed Sep 11 06:32:20 2019 +0000
Revision:
1:f7d9b0530b73
Parent:
0:64967b7043c2
tipe,1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
irsanjul 0:64967b7043c2 1 #ifndef DATAPROCESS_H
irsanjul 0:64967b7043c2 2 #define DATAPROCESS_H
irsanjul 0:64967b7043c2 3
irsanjul 0:64967b7043c2 4 #include <vector>
irsanjul 0:64967b7043c2 5 #include <queue>
irsanjul 0:64967b7043c2 6 #include <string>
irsanjul 0:64967b7043c2 7 #include "AruFraming.h"
irsanjul 0:64967b7043c2 8
irsanjul 0:64967b7043c2 9 class FtlMessage
irsanjul 0:64967b7043c2 10 {
irsanjul 0:64967b7043c2 11 public:
irsanjul 0:64967b7043c2 12 FtlMessage();
irsanjul 0:64967b7043c2 13 ~FtlMessage();
irsanjul 0:64967b7043c2 14
irsanjul 0:64967b7043c2 15 enum msg
irsanjul 0:64967b7043c2 16 {
irsanjul 0:64967b7043c2 17 OK = 0,
irsanjul 0:64967b7043c2 18 FAILED = -1,
irsanjul 0:64967b7043c2 19 PROERROR = -2,
irsanjul 0:64967b7043c2 20 NOTANSWER = -3
irsanjul 0:64967b7043c2 21 }ftl_msg;
irsanjul 0:64967b7043c2 22
irsanjul 0:64967b7043c2 23 msg checkMessage(const int &lastIdentifier, const int &identifier_);
irsanjul 0:64967b7043c2 24
irsanjul 0:64967b7043c2 25 private:
irsanjul 0:64967b7043c2 26
irsanjul 0:64967b7043c2 27 };
irsanjul 0:64967b7043c2 28
irsanjul 0:64967b7043c2 29 //-------------------------------------------------------------
irsanjul 0:64967b7043c2 30 class DataMessage
irsanjul 0:64967b7043c2 31 {
irsanjul 0:64967b7043c2 32 public:
irsanjul 0:64967b7043c2 33 DataMessage();
irsanjul 0:64967b7043c2 34 ~DataMessage();
irsanjul 0:64967b7043c2 35
irsanjul 0:64967b7043c2 36 enum msg
irsanjul 0:64967b7043c2 37 {
irsanjul 0:64967b7043c2 38 OK = 0,
irsanjul 0:64967b7043c2 39 FAILED = -1,
irsanjul 0:64967b7043c2 40 CHANGE = 1,
irsanjul 0:64967b7043c2 41
irsanjul 0:64967b7043c2 42 STATECHANGE = 2,
irsanjul 0:64967b7043c2 43
irsanjul 0:64967b7043c2 44 }data_msg;
irsanjul 0:64967b7043c2 45
irsanjul 0:64967b7043c2 46 typedef int (*_CALLBACKPTR)(const char* buf, int len, void* param);
irsanjul 0:64967b7043c2 47 msg processFromSlave(int identifier_=0, std::string buf="", _CALLBACKPTR cb = NULL, void* param = NULL);
irsanjul 0:64967b7043c2 48
irsanjul 0:64967b7043c2 49 template<class T>
irsanjul 0:64967b7043c2 50 inline msg processFromSlave(int identifier_, std::string buf, int (*cb)(const char* buf, int len, T* param),
irsanjul 0:64967b7043c2 51 T* param)
irsanjul 0:64967b7043c2 52 {
irsanjul 0:64967b7043c2 53 return processFromSlave(identifier_, buf, (_CALLBACKPTR)cb, (void*)param);
irsanjul 0:64967b7043c2 54 }
irsanjul 0:64967b7043c2 55
irsanjul 0:64967b7043c2 56 msg checkStateMessage(const int &identifier_, const std::string &stream, int *pStep);
irsanjul 0:64967b7043c2 57 msg checkOrderState(const int &identifier_, const std::string &stream, int *pStep);
irsanjul 0:64967b7043c2 58 msg checkInterlock(const int &identifier_, const std::string &stream, int *pStep);
irsanjul 0:64967b7043c2 59 //private:
irsanjul 0:64967b7043c2 60
irsanjul 0:64967b7043c2 61 protected:
irsanjul 0:64967b7043c2 62
irsanjul 0:64967b7043c2 63 typedef struct{ int *state;} MeterState;
irsanjul 0:64967b7043c2 64 static int _cbstate(const char* buf, int len, MeterState* param);
irsanjul 0:64967b7043c2 65
irsanjul 0:64967b7043c2 66 typedef struct{ int *state;} OrderState;
irsanjul 0:64967b7043c2 67 static int _cbOstate(const char* buf, int len, OrderState* param);
irsanjul 0:64967b7043c2 68
irsanjul 0:64967b7043c2 69 typedef struct{int *state;} InterlockState;
irsanjul 0:64967b7043c2 70 static int _cbInterlock(const char* buf, int len, InterlockState* param);
irsanjul 0:64967b7043c2 71 };
irsanjul 0:64967b7043c2 72
irsanjul 0:64967b7043c2 73 //-------------------------------------------------------------
irsanjul 0:64967b7043c2 74 class DataProcess : public FtlMessage, public DataMessage
irsanjul 0:64967b7043c2 75 {
irsanjul 0:64967b7043c2 76 public:
irsanjul 0:64967b7043c2 77 DataProcess();
irsanjul 0:64967b7043c2 78 ~DataProcess();
irsanjul 0:64967b7043c2 79
irsanjul 0:64967b7043c2 80 typedef enum state_
irsanjul 0:64967b7043c2 81 {
irsanjul 0:64967b7043c2 82 OK = 0,
irsanjul 0:64967b7043c2 83 ERROR = -1,
irsanjul 0:64967b7043c2 84
irsanjul 0:64967b7043c2 85 STAY = 0,
irsanjul 0:64967b7043c2 86 STEPUP = 1,
irsanjul 0:64967b7043c2 87 STEPDOWN = 2,
irsanjul 0:64967b7043c2 88 STEPJUMP = 3,
irsanjul 0:64967b7043c2 89 STEPEND = -1,
irsanjul 0:64967b7043c2 90 STAYNOL = -2,
irsanjul 0:64967b7043c2 91 FINISH = 4,
irsanjul 0:64967b7043c2 92
irsanjul 0:64967b7043c2 93 NOORDER = 0,
irsanjul 0:64967b7043c2 94 ORDERRCV = 2,
irsanjul 0:64967b7043c2 95 PLANORDERPROC = 3,
irsanjul 0:64967b7043c2 96 UNPLANORDERPROC = 4,
irsanjul 0:64967b7043c2 97 ORDERFINERROR = 9,
irsanjul 0:64967b7043c2 98 ORDERFINNOERROR = 10,
irsanjul 0:64967b7043c2 99
irsanjul 0:64967b7043c2 100 ACCCLOSED = 0,
irsanjul 0:64967b7043c2 101 ACCOPEN = 1
irsanjul 0:64967b7043c2 102 }STATE;
irsanjul 0:64967b7043c2 103
irsanjul 0:64967b7043c2 104 void CheckFtlMassage(const int &lastIdentifier, const AruFrm &frm);
irsanjul 0:64967b7043c2 105 FtlMessage::msg getFtlMessage();
irsanjul 0:64967b7043c2 106
irsanjul 0:64967b7043c2 107 void CheckDtMassage(const AruFrm &frm);
irsanjul 0:64967b7043c2 108 DataMessage::msg getDtMessage();
irsanjul 0:64967b7043c2 109 state_ checkState();
irsanjul 0:64967b7043c2 110 state_ checkOrderState();
irsanjul 0:64967b7043c2 111 state_ chackInterlock();
irsanjul 0:64967b7043c2 112
irsanjul 0:64967b7043c2 113 private:
irsanjul 0:64967b7043c2 114 FtlMessage::msg FtlMsg;
irsanjul 0:64967b7043c2 115
irsanjul 0:64967b7043c2 116 DataMessage::msg DataMsg;
irsanjul 0:64967b7043c2 117 int stateTmp;
irsanjul 0:64967b7043c2 118 int lastState;
irsanjul 0:64967b7043c2 119 int OrderStateTmp;
irsanjul 0:64967b7043c2 120 int LastOrderState;
irsanjul 0:64967b7043c2 121 int InterlockState;
irsanjul 0:64967b7043c2 122 };
irsanjul 0:64967b7043c2 123
irsanjul 0:64967b7043c2 124 //-------------------------------------------------------------
irsanjul 0:64967b7043c2 125 #endif // DATAPROCESS_H