Fotobot
Get data from your photovoltaic plant
fronius_request.h
Go to the documentation of this file.
1 
7 #ifndef _FRONIUS_request_H_
8 #define _FRONIUS_request_H_
9 
10 #include "fronius.h"
11 
16  public:
17  unsigned char startByte0;
18  unsigned char startByte1;
19  unsigned char startByte2;
20  unsigned char length;
21  unsigned char deviceOption;
22  unsigned char deviceNumber;
23  unsigned char command;
24  unsigned char checksum;
25 
26  const unsigned char static FRONIUS_START_VALUE;
27  const unsigned char static FRONIUS_INTERFACE_CARD;
28  const unsigned char static FRONIUS_SENSORBOX;
29  const unsigned char static FRONIUS_INVERTOR;
30 
34  FRONIUS_request(unsigned char invertor, unsigned char cmd) {
35  startByte0 = FRONIUS_START_VALUE;
36  startByte1 = FRONIUS_START_VALUE;
37  startByte2 = FRONIUS_START_VALUE;
38  length = 0;
39  command = cmd;
40  deviceOption = (command==FRONIUS::FRONIUS_CMD_GET_ACTIVE_INVERTOR_NUMBER ||
41  command==FRONIUS::FRONIUS_CMD_GET_VERSION)
42  ? FRONIUS_INTERFACE_CARD
43  : (command==FRONIUS::FRONIUS_CMD_GET_TEMPERATURE_1 ||
44  command==FRONIUS::FRONIUS_CMD_GET_TEMPERATURE_2 ||
45  command==FRONIUS::FRONIUS_CMD_GET_IRRADIANCE)
46  ? FRONIUS_SENSORBOX
47  : FRONIUS_INVERTOR
48  ;
49  deviceNumber = (command==FRONIUS::FRONIUS_CMD_GET_ACTIVE_INVERTOR_NUMBER ||
50  command==FRONIUS::FRONIUS_CMD_GET_VERSION)
51  ? 0
52  : invertor
53  ;
54  checksum = calculateChecksum();
55  }
56 
57  unsigned char calculateChecksum() {
58  unsigned char checksum = 0;
59  checksum += length;
60  checksum += deviceOption;
61  checksum += deviceNumber;
62  checksum += command;
63  return checksum;
64  }
65 
66 };
67 
68 #endif
FRONIUS_request(unsigned char invertor, unsigned char cmd)
Initialize request with constant values;.
Structure of fronius request sent to invertor over serial line.