![]() |
Fotobot
Get data from your photovoltaic plant
|
Communicates with invertors using serial port. More...
#include <fronius.h>
Public Types | |
enum | Command { FRONIUS_CMD_GET_VERSION = 0x01, FRONIUS_CMD_GET_DEVICE_TYPE = 0x02, FRONIUS_CMD_GET_DATE_TIME = 0x03, FRONIUS_CMD_GET_ACTIVE_INVERTOR_NUMBER = 0x04, FRONIUS_CMD_GET_POWER_NOW = 0x10, FRONIUS_CMD_GET_ENERGY_TOTAL = 0x11, FRONIUS_CMD_GET_ENERGY_DAY = 0x12, FRONIUS_CMD_GET_ENERGY_YEAR = 0x13, FRONIUS_CMD_GET_AC_CURRENT_NOW = 0x14, FRONIUS_CMD_GET_AC_VOLTAGE_NOW = 0x15, FRONIUS_CMD_GET_AC_FREQUENCY_NOW = 0x16, FRONIUS_CMD_GET_DC_CURRENT_NOW = 0x17, FRONIUS_CMD_GET_DC_VOLTAGE_NOW = 0x18, FRONIUS_CMD_GET_YIELD_DAY = 0x19, FRONIUS_CMD_GET_MAXIMUM_POWER_DAY = 0x1a, FRONIUS_CMD_GET_MAXIMUM_AC_VOLTAGE_DAY = 0x1b, FRONIUS_CMD_GET_MINIMUM_AC_VOLTAGE_DAY = 0x1c, FRONIUS_CMD_GET_MAXIMUM_DC_VOLTAGE_DAY = 0x1d, FRONIUS_CMD_GET_OPERATING_HOURS_DAY = 0x1e, FRONIUS_CMD_GET_YIELD_YEAR = 0x20, FRONIUS_CMD_GET_MAXIMUM_POWER_TOTAL = 0x26, FRONIUS_CMD_GET_MAXIMUM_AC_VOLTAGE_TOTAL = 0x27, FRONIUS_CMD_GET_MINIMUM_AC_VOLTAGE_TOTAL = 0x28, FRONIUS_CMD_GET_MAXIMUM_DC_VOLTAGE_TOTAL = 0x29, FRONIUS_CMD_GET_OPERATING_HOURS_TOTAL = 0x2a, FRONIUS_CMD_GET_INVERTOR_STATUS = 0x37, FRONIUS_CMD_GET_TEMPERATURE_1 = 0xE0, FRONIUS_CMD_GET_TEMPERATURE_2 = 0xE1, FRONIUS_CMD_GET_IRRADIANCE = 0xE2 } |
List of all fronius commands. | |
Public Slots | |
void | open () |
Opens serial port. More... | |
![]() | |
void | quit () |
Quits the running thread. More... | |
Public Member Functions | |
FRONIUS () | |
Constructor. The very basic initializations. More... | |
![]() | |
INVERTOR_status | status () |
Returns current status of the line. | |
virtual void | setLine (const DBT_LINES &) |
Sets the parameters for the line. More... | |
virtual void | setInvertors (const QList< DBT_INVERTORS > &) |
Sets the list of invertors connected to the line. More... | |
void | start (Priority priority=InheritPriority) |
Starts the thread. More... | |
Private Types | |
enum | Error { FRONIUS_PROTOCOL_ERROR_UNKNOWN_COMMAND = 0x01, FRONIUS_PROTOCOL_ERROR_TIMEOUT = 0x02, FRONIUS_PROTOCOL_ERROR_INCORRECT_DATA_STRUCTURE =0x03, FRONIUS_PROTOCOL_ERROR_COMMAND_QUEUE_FULL = 0x04, FRONIUS_PROTOCOL_ERROR_DEVICE_OR_OPTION_NA = 0x05, FRONIUS_PROTOCOL_ERROR_NO_RESPONSE = 0x06, FRONIUS_PROTOCOL_ERROR_SENSOR_ERROR = 0x07, FRONIUS_PROTOCOL_ERROR_SENSOR_NOT_ACTIVE = 0x08, FRONIUS_PROTOCOL_ERROR_INCORRECT_COMMAND = 0x09, FRONIUS_PROTOCOL_ERROR_DEVICE_ID_COLLISION = 0x0a } |
List of all fronius error codes. | |
enum | Status { FRONIUS_STATUS_STARTUP = 0x01, FRONIUS_STATUS_OPERATION = 0x02, FRONIUS_STATUS_MANUAL_STANDBY = 0x03, FRONIUS_STATUS_FAILURE = 0x04 } |
Private Slots | |
void | slotInit () |
Function called within running thread to initialize all needed child objects. More... | |
void | slotQuit () |
void | loop () |
Loops the invertors's list. More... | |
Private Member Functions | |
void | readInvertor () |
Reads values from current invertor. More... | |
QVariant | readValue (FRONIUS::Command) |
Reads one value from invertor. More... | |
void | readResponse (FRONIUS_response &) |
Reads and checks response read from invertor. More... | |
QVariant | decodeResponse (FRONIUS_response &, FRONIUS::Command) |
Decode response from invertor and returnsi retrieved value. | |
void | checkData (const DBT_DATA &) |
Basic data check. | |
QString | decodeError (FRONIUS::Error) |
Converts fronius error code to text description. More... | |
QString | decodeCommand (FRONIUS::Command) |
Converts fronius command code to text description. More... | |
QString | decodeStatus (FRONIUS::Status) |
Converts fronius error code to text description. More... | |
Private Attributes | |
Command | m_command |
Current command processed. | |
int | m_current_invertor_index |
Current index in INVERTOR::m_invertors list. | |
QextSerialPort * | m_port |
Serial port device. | |
QTimer * | m_timer |
Timer for main loop. | |
int | m_nr |
int | m_retries |
int | m_number_of_ok |
int | m_number_of_err |
Static Private Attributes | |
static const int | FRONIUS_ERROR = 0x0e |
Additional Inherited Members | |
![]() | |
void | data (DBT_DATA) |
Signal to send retrieved data to other objects. More... | |
void | loopFinished (int number_of_ok, int number_of_err) |
Signal is sent when reading cycle was finished and all invertors were read. More... | |
![]() | |
static INVERTOR * | create (DBT_LINES::Type) |
Factory makes instances depending on type. | |
![]() | |
virtual void | slotInit ()=0 |
Initializes ancestors. More... | |
virtual void | slotQuit ()=0 |
Quits ancestors. More... | |
![]() | |
void | setStatus (int address, int retries, const QString &command, const QString &status) |
Set status of line. | |
![]() | |
DBT_LINES | m_line |
Stores information about line. | |
QList< DBT_INVERTORS > | m_invertors |
Stores information about all invertors connected to the line. | |
Communicates with invertors using serial port.
The class opens one serial port. If you have more ports, you have to have more instances of the FRONIUS class;
FRONIUS::FRONIUS | ( | ) |
Constructor. The very basic initializations.
Only basic initializations can be made here. All needed objects must be created in slotInit() function. Constructor runs in different thread than the rest of the class!
Definition at line 24 of file fronius.cpp.
|
private |
Converts fronius command code to text description.
Definition at line 434 of file fronius.cpp.
|
private |
Converts fronius error code to text description.
Definition at line 534 of file fronius.cpp.
|
private |
Converts fronius error code to text description.
Definition at line 580 of file fronius.cpp.
|
privateslot |
Loops the invertors's list.
Slot is called from timer's signal. Loops throw the invertors's list and call readInvertor() function for every invertor in the list, one invertor per call.
Current invertor index in m_invertors list is stored in m_current_invertor_index member variable.
At the end starts timer again so the event loop calls this function again when the inverval passes.
Definition at line 127 of file fronius.cpp.
|
slot |
Opens serial port.
Opens serial port and set all communication parameters. Starts timer for main loop when successfull.
Sends the data signal with error message set when an error occured.
Definition at line 66 of file fronius.cpp.
|
private |
Reads values from current invertor.
Retrieved data are stored in DBT_DATA class and sent to other object using signal data(DBT_DATA);
When an error occured then the DBT_DATA::error variable is set and all other data stored id DBT_DATA should be ignored in receiver object.
Current invertor's parameters are read from m_invetors list. Reads only data required by parameters set in DBT_INVERTORS when communicating with invertors so you can read very quickly only needed values (the actual power for example).
Definition at line 359 of file fronius.cpp.
|
private |
Reads and checks response read from invertor.
When an error occured then throws an exception with error description. Data read are stored in response object.
Definition at line 166 of file fronius.cpp.
|
private |
Reads one value from invertor.
command - requested parameter to read from fronius invertor
The function complete the request datagram to set to invertor and write it to serial port. All data are the flushed to serial line. Then the function reads and checks the response from invertor. When successfull, the read value is decoded and returned in QVariant.
The exception is thrown when an error occured.
Definition at line 237 of file fronius.cpp.
|
privateslot |
Function called within running thread to initialize all needed child objects.
This is the first function called when the object is created and new thread event loop is started. All needed objects must be created in this function.
Definition at line 36 of file fronius.cpp.