Fotobot
Get data from your photovoltaic plant
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
INVERTOR Class Referenceabstract

Virtual class for invertor communication. More...

#include <invertor.h>

Inheritance diagram for INVERTOR:
FRONIUS MODBUSTCP

Public Slots

void quit ()
 Quits the running thread. More...
 

Signals

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...
 

Public Member Functions

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...
 

Static Public Member Functions

static INVERTORcreate (DBT_LINES::Type)
 Factory makes instances depending on type.
 

Protected Slots

virtual void slotInit ()=0
 Initializes ancestors. More...
 
virtual void slotQuit ()=0
 Quits ancestors. More...
 

Protected Member Functions

void setStatus (int address, int retries, const QString &command, const QString &status)
 Set status of line.
 

Protected Attributes

DBT_LINES m_line
 Stores information about line.
 
QList< DBT_INVERTORSm_invertors
 Stores information about all invertors connected to the line.
 

Private Attributes

INVERTOR_status m_status
 Line status.
 
QMutex m_status_mutex
 

Detailed Description

Virtual class for invertor communication.

Every derived class must implement slotInit() nd slotQuit() methods.

As parameters the object gets the line specification in DBT_LINES object and list of invertors connected to this line in DBT_INVERTORS's list. One independent thread is started for every line.

When all needed parameters are set the start() function must be called.

Data are sent to other object using signal data(DBT_DATA);

Definition at line 28 of file invertor.h.

Member Function Documentation

void INVERTOR::data ( DBT_DATA  )
signal

Signal to send retrieved data to other objects.

In main thread this signal is connected to DATABASE object and saves the stored data to database file.

All retrieved data should be stored in the DBT_DATA class. When an error occured, the error member variable must be set. Then the other values stored in class are ignored.

void INVERTOR::loopFinished ( int  number_of_ok,
int  number_of_err 
)
signal

Signal is sent when reading cycle was finished and all invertors were read.

As a response to this signal the database commit should be requested.

void INVERTOR::quit ( )
slot

Quits the running thread.

From this slot the virtual method slotQuit() is called so the child class can stop its work and close all opened file descriptors.

Definition at line 69 of file invertor.cpp.

69  {
70  if (!isRunning()) return;
71  slotQuit();
72  QThread::quit();
73 }
virtual void slotQuit()=0
Quits ancestors.
void INVERTOR::setInvertors ( const QList< DBT_INVERTORS > &  invertors)
virtual

Sets the list of invertors connected to the line.

The DBT_INVERTORS corresonds to database table INVERTORS.

Definition at line 49 of file invertor.cpp.

49  {
50  m_invertors = invertors;
51 }
QList< DBT_INVERTORS > m_invertors
Stores information about all invertors connected to the line.
Definition: invertor.h:127
void INVERTOR::setLine ( const DBT_LINES line)
virtual

Sets the parameters for the line.

The DBT_LINES corresponds to database table LINES - all needed parameters should be set in the database using webserver part.

Definition at line 42 of file invertor.cpp.

42  {
43  m_line = line;
44  m_status.line = m_line.line;
45  m_status.line_description = m_line.description;
46 }
DBT_LINES m_line
Stores information about line.
Definition: invertor.h:122
int line
line number (database id)
QString line_description
Line description.
INVERTOR_status m_status
Line status.
Definition: invertor.h:138
virtual void INVERTOR::slotInit ( )
protectedpure virtualslot

Initializes ancestors.

This function is called as a first event from event loop when new thread is started.

Important: Do not create any Qt object in derived class's constructor. Make new objects (timers, serial lines and so on) in the slotInit() implementation. Constructor and slotInit() function are called within different threads so all objects created in constructor makes problem later.

virtual void INVERTOR::slotQuit ( )
protectedpure virtualslot

Quits ancestors.

This function is called when the quit signal was received. You should close your serial lines and make other necessary jobs to end the invertor. Do not call QThread::quit() from this function since it is called after your action automatically in INVERTOR::quit() method.

void INVERTOR::start ( Priority  priority = InheritPriority)

Starts the thread.

Starts the thread's event loop, moves the object to that thread and calls from the event loop ancestor's slotInit() function.

Definition at line 36 of file invertor.cpp.

36  {
37  QTimer::singleShot(10, this, SLOT(slotInit()));
38  QThread::start(priority);
39 }
virtual void slotInit()=0
Initializes ancestors.

The documentation for this class was generated from the following files: