12 INVERTORS::INVERTORS(QCoreApplication *p) : QObject(p) {
14 m_timer =
new QTimer(
this);
15 m_timer->setSingleShot(
true);
16 m_timer->setInterval(7000);
17 connect(m_timer, SIGNAL(timeout()),
18 this, SLOT(slotQuitInvertors()));
19 connect(Static::db, SIGNAL(databaseChanged()),
20 this, SLOT(databaseChanged()));
22 m_timerWorking =
new QTimer(
this);
23 m_timerWorking->setSingleShot(
true);
24 m_timerWorking->setInterval(1000);
25 connect(m_timerWorking, SIGNAL(timeout()),
26 this, SLOT(slotCountWorking()));
27 m_timerWorking->start();
47 QTimer::singleShot(5000,
this, SLOT(
closeLines()));
54 QCoreApplication::processEvents();
63 qWarning() <<
"INVERTORS::closeLines(): configuration reloaded";
68 QList<INVERTOR_status> list;
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);
103 Qt::QueuedConnection);
106 Qt::QueuedConnection);
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)),
115 Qt::QueuedConnection);
118 Qt::QueuedConnection);
125 qDebug() << QString(
"%1 sun=%2 pwr=%3 err=%4")
127 .arg(Static::slunce->alt())
128 .arg(x.now_power.toInt())
132 if (x.error.isEmpty()) {
133 qDebug() <<
"invertor=" << x.invertor
134 <<
"power=" << x.now_power
135 <<
"dc current=" << x.now_dc_current
136 <<
"dc voltage=" << x.now_dc_voltage
137 <<
"ac current=" << x.now_ac_current
138 <<
"ac voltage=" << x.now_ac_voltage
139 <<
"ac frequency=" << x.now_ac_frequency
141 <<
"ac voltage max=" << x.day_ac_voltage_maximum
142 <<
"ac voltage min=" << x.day_ac_voltage_minimum
143 <<
"dc voltage max=" << x.day_dc_voltage_maximum
144 <<
"powr max=" << x.day_power_maximum
145 <<
"hours=" << x.day_operating_hours
146 <<
"energy=" << x.day_energy
148 <<
"ac voltage max=" << x.total_ac_voltage_maximum
149 <<
"ac voltage min=" << x.total_ac_voltage_minimum
150 <<
"dc voltage max=" << x.total_dc_voltage_maximum
151 <<
"powr max=" << x.total_power_maximum
152 <<
"hours=" << x.total_operating_hours
153 <<
"energy=" << x.total_energy
156 qDebug() <<
"invertor=" << x.invertor
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;
167 Static::interfacebox->
restart();
171 if (Static::slunce == NULL || Static::slunce->alt() > -18.0) {
QTimer * m_timerWorking
Timer for periodic status update.
QList< DBT_LINES > lines(int line=0)
Returns list of communications lines.
QTimer * m_timer
Timer for database changes responses.
void data(DBT_DATA)
For debugging only, writes read data to console.
virtual void setLine(const DBT_LINES &)
Sets the parameters for the line.
void slotQuitInvertors()
Slot is called a few seconds after configuration change.
QList< INVERTOR * > m_invertors
List of all invertors.
void restart()
Restarts all connected interfaceboxes.
int invertors
Number of invertors.
Class describing database table DATA.
void databaseChanged()
Slot is called when configuration changed in database.
int line
line number (database id)
QList< DBT_INVERTORS > invertors(int line=0)
Returns list of invertors filtered by line number.
void storeData(DBT_DATA)
Signal for database to store invertor data.
QList< DBT_LINES_STATUS > m_working
List of working invertors.
int working
Number of working invertors.
void openLines()
Opens all configured invertors.
virtual void setInvertors(const QList< DBT_INVERTORS > &)
Sets the list of invertors connected to the line.
void slotLoopFinished(int number_of_ok, int number_of_err)
Slot is called when the line finished the reading cycle.
Stores the invertors status.
static INVERTOR * create(DBT_LINES::Type)
Factory makes instances depending on type.
Virtual class for invertor communication.
QList< INVERTOR_status > status()
Returns list of current invertors status.
void closeLines()
Closes all existing invertors and destoroy their instances.
void slotCountWorking()
Count working invertors.
QList< DBT_LINES_STATUS > linesStatus()
Returns status of lines.
void quitInvertors()
Signal for invertors to quit.
void start(Priority priority=InheritPriority)
Starts the thread.
void slotStoreData(DBT_DATA)
Slot for handling of requests for storing of invertor data in database.