whyclwt
2022-05-18 ab72c6e114d7c4e83564194367ba623ca23bf09d
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
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef REMOTE_CTRL_H
#define REMOTE_CTRL_H
 
#include "Common/app_define.h"
#include "work_thread.h"
 
class Remote_Ctrl
{
 
public:
    Remote_Ctrl(Work_Thread *wt);
 
    Work_Thread *workThread;
 
    static quint8 devAddr;
 
    static const quint16 Heartbeat = 0x0A01;
    static const quint16 ExitSlave = 0x0A02;
    static const quint16 EnterSlave = 0x0A03;
    static const quint16 GetDischargeParam = 0x0A04;
    static const quint16 SetDischargeParam = 0x0A05;
    static const quint16 GetCellData = 0x0A06;
    static const quint16 GetFileInfo = 0x0A07;
    static const quint16 GetFile = 0x0A08;
    static const quint16 SetChargeParam = 0x0A09;
    static const quint16 GetChargeParam = 0x0A0A;
    static const quint16 StartDischarge = 0x0A0B;
    static const quint16 PausetDischarge = 0x0A0C;
    static const quint16 GetDischargeData = 0x0A0D;
    static const quint16 StartCharge = 0x0A0E;
    static const quint16 PauseCharge = 0x0A0F;
    static const quint16 GetChargeData = 0x0A10;
    static const quint16 StopDischarge = 0x0A1C;
    static const quint16 StopCharge = 0x0A1D;
    static const quint16 GetVersion = 0x0A2A;
 
    static const quint16 EnterPackPassthrough = 0x0A2B;
    static const quint16 GetPackData = 0x0A2C;
    static const quint16 GetPackParam = 0x0A2D;
    static const quint16 SetPackParam = 0x0A2E;
    static const quint16 SetPackClock = 0x0A2F;
    static const quint16 ExitPackPassthrough = 0x0A30;
    static const quint16 GetPackBarcode = 0x0A31;
    static const quint16 SetPackBarcode = 0x0A32;
    static const quint16 ActivePack = 0x0A33;
    static const quint16 EasyPackPassthrough = 0x0A34;
 
    enum RTN_TYPE {
        SUCCEED = 0,
        LEN_ERR,
        CRC_ERR,
        SLAVEMODE_ERR,
        FILE_DATA_ERR,
        START_ERR,
 
        SYSTEM_WORKING, //透传模式,不响应其它命令
        PASSTHROUGH_ERR, //仪表测试中,无法进行透传
        PACK_COMM_ERR,
 
        OTHER_ERR = 0xFF
    };
 
 
public:
    bool processRxData(FRAME_DATA *recv, FRAME_DATA *sent, const quint8 contype);
 
    static void setRemoteDevAddr(const quint8 addr);
 
private:
    REMOTE_STATE remote_state;
    PASSTHROUGH_ST passthrough_Stat;
 
private:
    bool CheckLen(FRAME_DATA *recv);
    bool CheckSYNCode(FRAME_DATA *recv);
    bool CheckCRC(FRAME_DATA *recv);
    bool ReadFrameHead(FRAME_DATA *recv, FRAME_DATA *sent);
    bool ReadFrameData(FRAME_DATA *recv, FRAME_DATA *sent);
 
    void prepareSendData(FRAME_DATA *recv,FRAME_DATA *sent);
 
    quint16 getVersion(FRAME_DATA *recv,FRAME_DATA *sent);
 
    quint16 getMonData(FRAME_DATA *sent);
    quint16 getTestData(FRAME_DATA *sent);
    quint16 getCommTestParam(FRAME_DATA *sent);
    quint16 getCommPackParam(FRAME_DATA *sent);
    quint16 getPackBarcode(FRAME_DATA *sent);
    quint16 exePassthroughData(FRAME_DATA *recv,FRAME_DATA *sent);
    quint16 getPackDataModbus(FRAME_DATA *recv,FRAME_DATA *sent);
    void setCommTestParam(FRAME_DATA *recv);
    void setCommPackParam(FRAME_DATA *recv);
    void setPackBarcode(FRAME_DATA *recv);
 
};
 
#endif // REMOTE_CTRL_H