Fotobot
Get data from your photovoltaic plant
fronius.h
Go to the documentation of this file.
1 
7 #ifndef _FRONIUS_H_
8 #define _FRONIUS_H_
9 #include <QList>
10 #include <QDateTime>
11 #include <QTimer>
12 #include <QVariant>
13 
14 #include "invertor.h"
15 #include "fronius_response.h"
16 #include "qextserialport.h"
17 
18 class DBT_DATA;
19 
26 class FRONIUS : public INVERTOR {
27  Q_OBJECT
28  public:
29  FRONIUS();
30  ~FRONIUS();
31 
32  public slots:
33  void open();
34 
35  public:
39  enum Command {
40  FRONIUS_CMD_GET_VERSION = 0x01,
41  FRONIUS_CMD_GET_DEVICE_TYPE = 0x02,
42  FRONIUS_CMD_GET_DATE_TIME = 0x03,
43  FRONIUS_CMD_GET_ACTIVE_INVERTOR_NUMBER = 0x04,
44  FRONIUS_CMD_GET_POWER_NOW = 0x10,
45  FRONIUS_CMD_GET_ENERGY_TOTAL = 0x11,
46  FRONIUS_CMD_GET_ENERGY_DAY = 0x12,
47  FRONIUS_CMD_GET_ENERGY_YEAR = 0x13,
48  FRONIUS_CMD_GET_AC_CURRENT_NOW = 0x14,
49  FRONIUS_CMD_GET_AC_VOLTAGE_NOW = 0x15,
50  FRONIUS_CMD_GET_AC_FREQUENCY_NOW = 0x16,
51  FRONIUS_CMD_GET_DC_CURRENT_NOW = 0x17,
52  FRONIUS_CMD_GET_DC_VOLTAGE_NOW = 0x18,
53  FRONIUS_CMD_GET_YIELD_DAY = 0x19,
54  FRONIUS_CMD_GET_MAXIMUM_POWER_DAY = 0x1a,
55  FRONIUS_CMD_GET_MAXIMUM_AC_VOLTAGE_DAY = 0x1b,
56  FRONIUS_CMD_GET_MINIMUM_AC_VOLTAGE_DAY = 0x1c,
57  FRONIUS_CMD_GET_MAXIMUM_DC_VOLTAGE_DAY = 0x1d,
58  FRONIUS_CMD_GET_OPERATING_HOURS_DAY = 0x1e,
59  FRONIUS_CMD_GET_YIELD_YEAR = 0x20,
60  FRONIUS_CMD_GET_MAXIMUM_POWER_TOTAL = 0x26,
61  FRONIUS_CMD_GET_MAXIMUM_AC_VOLTAGE_TOTAL = 0x27,
62  FRONIUS_CMD_GET_MINIMUM_AC_VOLTAGE_TOTAL = 0x28,
63  FRONIUS_CMD_GET_MAXIMUM_DC_VOLTAGE_TOTAL = 0x29,
64  FRONIUS_CMD_GET_OPERATING_HOURS_TOTAL = 0x2a,
65  FRONIUS_CMD_GET_INVERTOR_STATUS = 0x37,
66  FRONIUS_CMD_GET_TEMPERATURE_1 = 0xE0,
67  FRONIUS_CMD_GET_TEMPERATURE_2 = 0xE1,
68  FRONIUS_CMD_GET_IRRADIANCE = 0xE2
69  };
70 
71  private:
72 
76  enum Error {
77  FRONIUS_PROTOCOL_ERROR_UNKNOWN_COMMAND = 0x01,
78  FRONIUS_PROTOCOL_ERROR_TIMEOUT = 0x02,
79  FRONIUS_PROTOCOL_ERROR_INCORRECT_DATA_STRUCTURE =0x03,
80  FRONIUS_PROTOCOL_ERROR_COMMAND_QUEUE_FULL = 0x04,
81  FRONIUS_PROTOCOL_ERROR_DEVICE_OR_OPTION_NA = 0x05,
82  FRONIUS_PROTOCOL_ERROR_NO_RESPONSE = 0x06,
83  FRONIUS_PROTOCOL_ERROR_SENSOR_ERROR = 0x07,
84  FRONIUS_PROTOCOL_ERROR_SENSOR_NOT_ACTIVE = 0x08,
85  FRONIUS_PROTOCOL_ERROR_INCORRECT_COMMAND = 0x09,
86  FRONIUS_PROTOCOL_ERROR_DEVICE_ID_COLLISION = 0x0a
87  };
88 
89  enum Status {
90  FRONIUS_STATUS_STARTUP = 0x01,
91  FRONIUS_STATUS_OPERATION = 0x02,
92  FRONIUS_STATUS_MANUAL_STANDBY = 0x03,
93  FRONIUS_STATUS_FAILURE = 0x04
94  };
95 
96  private slots:
97  void slotInit();
98  void slotQuit();
99  void loop();
100 
101  private:
102 
103  static const int FRONIUS_ERROR = 0x0e;
104 
105  void readInvertor ();
106  QVariant readValue (FRONIUS::Command);
109  void checkData (const DBT_DATA&);
110 
111  QString decodeError (FRONIUS::Error);
113  QString decodeStatus (FRONIUS::Status);
114 
117  QextSerialPort *m_port;
118  QTimer *m_timer;
119 
120  int m_nr;
121  int m_retries;
122  int m_number_of_ok;
123  int m_number_of_err;
124 
125 };
126 
127 #endif
void loop()
Loops the invertors's list.
Definition: fronius.cpp:127
QString decodeError(FRONIUS::Error)
Converts fronius error code to text description.
Definition: fronius.cpp:534
void readInvertor()
Reads values from current invertor.
Definition: fronius.cpp:359
Response from fronius invertor.
void open()
Opens serial port.
Definition: fronius.cpp:66
void checkData(const DBT_DATA &)
Basic data check.
Definition: fronius.cpp:423
Error
List of all fronius error codes.
Definition: fronius.h:76
FRONIUS()
Constructor. The very basic initializations.
Definition: fronius.cpp:24
int m_current_invertor_index
Current index in INVERTOR::m_invertors list.
Definition: fronius.h:116
Class describing database table DATA.
QVariant readValue(FRONIUS::Command)
Reads one value from invertor.
Definition: fronius.cpp:237
QTimer * m_timer
Timer for main loop.
Definition: fronius.h:118
Communicates with invertors using serial port.
Definition: fronius.h:26
QextSerialPort * m_port
Serial port device.
Definition: fronius.h:117
void readResponse(FRONIUS_response &)
Reads and checks response read from invertor.
Definition: fronius.cpp:166
QVariant decodeResponse(FRONIUS_response &, FRONIUS::Command)
Decode response from invertor and returnsi retrieved value.
Definition: fronius.cpp:276
QString decodeStatus(FRONIUS::Status)
Converts fronius error code to text description.
Definition: fronius.cpp:580
Virtual class for invertor communication.
Definition: invertor.h:28
Command m_command
Current command processed.
Definition: fronius.h:115
QString decodeCommand(FRONIUS::Command)
Converts fronius command code to text description.
Definition: fronius.cpp:434
void slotInit()
Function called within running thread to initialize all needed child objects.
Definition: fronius.cpp:36
Command
List of all fronius commands.
Definition: fronius.h:39