Fotobot
Get data from your photovoltaic plant
Public Slots | Signals | Public Member Functions | Private Slots | Private Attributes | List of all members
INVERTORS Class Reference

Manages list of invertors and their threads. More...

#include <invertors.h>

Inheritance diagram for INVERTORS:

Public Slots

void openLines ()
 Opens all configured invertors. More...
 
void closeLines ()
 Closes all existing invertors and destoroy their instances.
 
void slotStoreData (DBT_DATA)
 Slot for handling of requests for storing of invertor data in database.
 

Signals

void quitInvertors ()
 Signal for invertors to quit. More...
 
void storeData (DBT_DATA)
 Signal for database to store invertor data.
 

Public Member Functions

 INVERTORS (QCoreApplication *)
 
QList< INVERTOR_statusstatus ()
 Returns list of current invertors status.
 

Private Slots

void databaseChanged ()
 Slot is called when configuration changed in database. More...
 
void slotCountWorking ()
 Count working invertors.
 
void slotQuitInvertors ()
 Slot is called a few seconds after configuration change. More...
 
void slotLoopFinished (int number_of_ok, int number_of_err)
 Slot is called when the line finished the reading cycle. More...
 
void data (DBT_DATA)
 For debugging only, writes read data to console.
 

Private Attributes

QList< INVERTOR * > m_invertors
 List of all invertors.
 
QTimer * m_timer
 Timer for database changes responses.
 
QTimer * m_timerWorking
 Timer for periodic status update.
 
QList< DBT_LINES_STATUSm_working
 List of working invertors.
 

Detailed Description

Manages list of invertors and their threads.

Containter for list of active lines. Every line is stored in it's own thread - virtual class INVERTOR.

Connects data sent from invertor's thread using signal INVERTORS::data(DBT_DATA) to database's slot insertData(DBT_DATA). Receives signal DATABASE::sigDatabaseChanged() in slot INVERTORS::databaseChanged() and after a short delay closes all open lines (class INVERTOR) and restart new instances based on new configuration stored in database.

Stores status of working lines in list of DBT_LINES_STATUS structures. The status is updated every 30 seconds independently of invertors functionality. This allows to update status in situations when no invertor connected to line worked and the INVERTOR class thread was blocked and not responding.

Definition at line 36 of file invertors.h.

Member Function Documentation

void INVERTORS::databaseChanged ( )
privateslot

Slot is called when configuration changed in database.

Registers changes made in database.

Response to changes in database is delayed since database tends to make changes in groups.

Definition at line 37 of file invertors.cpp.

37  {
38  m_timer->start();
39 }
QTimer * m_timer
Timer for database changes responses.
Definition: invertors.h:118
void INVERTORS::openLines ( )
slot

Opens all configured invertors.

Opens serial lines administered in database.

Every invertor is opened in it's own thread so more invertors can work at the same time.

Definition at line 93 of file invertors.cpp.

93  {
94  QList<DBT_LINES> lines = Static::db->lines();
95  for (int i=0; i<lines.size(); i++) {
96  QList<DBT_INVERTORS> invertors = Static::db->invertors(lines.at(i).line);
97  INVERTOR *f = INVERTOR::create(lines[i].type); // new FRONIUS();
98  f->setLine(lines.at(i));
99  f->setInvertors(invertors);
100  f->start();
101  connect (this, SIGNAL(quitInvertors()),
102  f, SLOT(quit()),
103  Qt::QueuedConnection);
104  connect (f, SIGNAL(data(DBT_DATA)),
105  this, SLOT(slotStoreData(DBT_DATA)),
106  Qt::QueuedConnection);
107  connect (this, SIGNAL(storeData(DBT_DATA)),
108  Static::db, SLOT(insertData(DBT_DATA)),
109  Qt::QueuedConnection);
110  connect (f, SIGNAL(loopFinished(int,int)),
111  Static::db, SLOT(commit()),
112  Qt::QueuedConnection);
113  connect (f, SIGNAL( loopFinished(int,int)),
114  this, SLOT(slotLoopFinished(int,int)),
115  Qt::QueuedConnection);
116  connect (f, SIGNAL(data(DBT_DATA)),
117  this, SLOT(data(DBT_DATA)),
118  Qt::QueuedConnection);
119  m_invertors << f;
120  }
121 }
QList< DBT_LINES > lines(int line=0)
Returns list of communications lines.
Definition: database.cpp:380
void data(DBT_DATA)
For debugging only, writes read data to console.
Definition: invertors.cpp:124
virtual void setLine(const DBT_LINES &)
Sets the parameters for the line.
Definition: invertor.cpp:42
QList< INVERTOR * > m_invertors
List of all invertors.
Definition: invertors.h:117
Class describing database table DATA.
QList< DBT_INVERTORS > invertors(int line=0)
Returns list of invertors filtered by line number.
Definition: database.cpp:411
void storeData(DBT_DATA)
Signal for database to store invertor data.
virtual void setInvertors(const QList< DBT_INVERTORS > &)
Sets the list of invertors connected to the line.
Definition: invertor.cpp:49
void slotLoopFinished(int number_of_ok, int number_of_err)
Slot is called when the line finished the reading cycle.
Definition: invertors.cpp:162
static INVERTOR * create(DBT_LINES::Type)
Factory makes instances depending on type.
Definition: invertor.cpp:17
Virtual class for invertor communication.
Definition: invertor.h:28
void quitInvertors()
Signal for invertors to quit.
void start(Priority priority=InheritPriority)
Starts the thread.
Definition: invertor.cpp:36
void slotStoreData(DBT_DATA)
Slot for handling of requests for storing of invertor data in database.
Definition: invertors.cpp:170
void INVERTORS::quitInvertors ( )
signal

Signal for invertors to quit.

When the signal is emitted then:

  • invertor's slot quit() was called
  • the object waited a few seconds and then destroy all invertors.
  • call openLines() to read new configuration and start new invertor's instances
void INVERTORS::slotLoopFinished ( int  number_of_ok,
int  number_of_err 
)
privateslot

Slot is called when the line finished the reading cycle.

Slot receives number of successfull data and error data. When all the invertors are in error, then the interfacebox is restarted

Definition at line 162 of file invertors.cpp.

162  {
163  if (number_of_ok > 0) return;
164  if (number_of_ok <= 0 || number_of_err <= 0) return;
165  if (Static::slunce == NULL || Static::slunce->alt() < 0.0) return;
166 
167  Static::interfacebox->restart();
168 }
void restart()
Restarts all connected interfaceboxes.
void INVERTORS::slotQuitInvertors ( )
privateslot

Slot is called a few seconds after configuration change.

Sends signal to invertors and wait a moment to close them.

It sends signal quitInvertors() and after a short pause (timer) calls closeLines() to destroy invertors.

Definition at line 45 of file invertors.cpp.

45  {
46  emit quitInvertors();
47  QTimer::singleShot(5000, this, SLOT(closeLines()));
48 }
void closeLines()
Closes all existing invertors and destoroy their instances.
Definition: invertors.cpp:51
void quitInvertors()
Signal for invertors to quit.

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