-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathABBAurora.h
197 lines (144 loc) · 3.86 KB
/
ABBAurora.h
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef ABBAurora_h
#define ABBAurora_h
#include <Arduino.h>
#include <ABBAuroraEnums.h>
#include <Wire.h>
//RS485 control
#define RS485Transmit HIGH
#define RS485Receive LOW
class ABBAurora
{
private:
int MaxAttempt = 1;
static byte TXPinControl;
static HardwareSerial *serial;
void clearData(byte *data, byte len);
int Crc16(byte *data, int offset, int count);
bool Send(byte address, byte param0, byte param1, byte param2, byte param3, byte param4, byte param5, byte param6);
union {
byte asBytes[4];
float asFloat;
} foo;
union {
byte asBytes[4];
unsigned long asUlong;
} ulo;
public:
bool SendStatus = false;
bool ReceiveStatus = false;
byte Address = 0;
byte ReceiveData[8];
static void setup(HardwareSerial &serial, byte RXGpioPin, byte TXGpioPin, byte TXControllPin);
ABBAurora(byte address);
void clearReceiveData();
typedef struct
{
byte TransmissionState;
byte GlobalState;
byte InverterState;
byte Channel1State;
byte Channel2State;
byte AlarmState;
bool ReadState;
} DataState;
DataState State;
bool ReadState();
typedef struct
{
byte TransmissionState;
byte GlobalState;
String Par1;
String Par2;
String Par3;
String Par4;
bool ReadState;
} DataVersion;
DataVersion Version;
bool ReadVersion();
typedef struct
{
byte TransmissionState;
byte GlobalState;
float Value;
bool ReadState;
} DataDSP;
DataDSP DSP;
bool ReadDSPValue(DSP_VALUE_TYPE type, DSP_GLOBAL global);
typedef struct
{
byte TransmissionState;
byte GlobalState;
unsigned long Seconds;
bool ReadState;
} DataTimeDate;
DataTimeDate TimeDate;
bool ReadTimeDate();
typedef struct
{
byte TransmissionState;
byte GlobalState;
byte Alarms1;
byte Alarms2;
byte Alarms3;
byte Alarms4;
bool ReadState;
} DataLastFourAlarms;
DataLastFourAlarms LastFourAlarms;
bool ReadLastFourAlarms();
bool ReadJunctionBoxState(byte nj);
bool ReadJunctionBoxVal(byte nj, byte par);
// Inverters
typedef struct
{
String PN;
bool ReadState;
} DataSystemPN;
DataSystemPN SystemPN;
bool ReadSystemPN();
typedef struct
{
String SerialNumber;
bool ReadState;
} DataSystemSerialNumber;
DataSystemSerialNumber SystemSerialNumber;
bool ReadSystemSerialNumber();
typedef struct
{
byte TransmissionState;
byte GlobalState;
String Week;
String Year;
bool ReadState;
} DataManufacturingWeekYear;
DataManufacturingWeekYear ManufacturingWeekYear;
bool ReadManufacturingWeekYear();
typedef struct
{
byte TransmissionState;
byte GlobalState;
String Release;
bool ReadState;
} DataFirmwareRelease;
DataFirmwareRelease FirmwareRelease;
bool ReadFirmwareRelease();
typedef struct
{
byte TransmissionState;
byte GlobalState;
unsigned long Energy;
bool ReadState;
} DataCumulatedEnergy;
DataCumulatedEnergy CumulatedEnergy;
bool ReadCumulatedEnergy(CUMULATED_ENERGY_TYPE par);
bool WriteBaudRateSetting(byte baudcode);
// Central
bool ReadFlagsSwitchCentral();
bool ReadCumulatedEnergyCentral(byte var, byte ndays_h, byte ndays_l, byte global);
bool ReadFirmwareReleaseCentral(byte var);
bool ReadBaudRateSettingCentral(byte baudcode, byte serialline);
bool ReadSystemInfoCentral(byte var);
bool ReadJunctionBoxMonitoringCentral(byte cf, byte rn, byte njt, byte jal, byte jah);
bool ReadSystemPNCentral();
bool ReadSystemSerialNumberCentral();
};
#endif