SDC C-Project CF Review 프로그램
kojingeun
2023-07-14 f77e8008cac062596058fca2aeddda62b80bedbf
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
#pragma once
 
#include "Serial.h"
#include "LightControl.h"
 
//HEADER
#define HEADER_DLE                0x10
#define HEADER_STX                0x02
 
//IDENTIFIER
#define IDENTIFIER_OPCODE        0x03
#define IDENTIFIER_LENGTH        0x02
 
//DATA
#define DATA_ACK                0x06
#define DATA_NACK                0x15
 
//DATA STATUS
#define DATA_STATUS_NORMAL        0x00
#define DATA_STATUS_81H            0x81
#define DATA_STATUS_82H            0x82
#define DATA_STATUS_83H            0x83
#define DATA_STATUS_86H            0x86
#define DATA_STATUS_FFH            0xFF
 
//CONTROL
#define CONTROL_DIMMING            0x03
#define CONTROL_POWER            0x04
#define CONTROL_RESET            0x05
 
//TAIL
#define TAIL_DLE                0x10
#define TAIL_ETX                0x03
 
//CONTROL_DATA
#define CONTROL_DATA_ON            0x01
#define CONTROL_DATA_OFF        0x00
#define CONTROL_DATA_RESET        0x01
 
//PACKET LENGTH
#define PACKET_DATA_LENGTH        10
 
//CURRENT_STATUS
#define  CURRENT_STATUS_ON        1;
#define  CURRENT_STATUS_OFF        0;
 
class AFX_EXT_CLASS CLightControl_LM6850GHM : public CLightControl, 
                                              public CSerial
{
public:
    CLightControl_LM6850GHM(int nIndex);
    virtual ~CLightControl_LM6850GHM(void);
 
    virtual BOOL Connect(const CLightControlInfo& controlInfo);
    virtual void Disconnect();
 
    virtual BOOL GetLightLevel(int &nValue, int nChannel = 0) const;
    virtual BOOL GetLightLevel(double &dValue, int nChannel = 0) const;
    virtual BOOL GetLightStatus(int &nValue, int nChannel = 0) const;
 
    virtual BOOL SetLightLevel(int nValue, int nChannel = 0);
    virtual BOOL SetLightLevel(double dValue, int nChannel = 0);
    virtual BOOL SetLightStatus(int nValue, int nChannel = 0);
 
    virtual BOOL SetLightOn();
    virtual BOOL SetLightOff();
 
    unsigned int CRC16(unsigned char* rdata, unsigned int len);
    static UINT  ReceiveThread(LPVOID pParam);
    BOOL CheckCRC(unsigned char* uOp1, unsigned char* uOp2);
    BOOL FactoryReset();
 
protected:
    int        m_nCurrentValue;
    int        m_nCurrentStatus;
};