Fotobot
Get data from your photovoltaic plant
Public Member Functions | Private Member Functions | List of all members
StatusController Class Reference

status controller More...

#include <statuscontroller.h>

Inheritance diagram for StatusController:

Public Member Functions

 StatusController ()
 
void service (HttpRequest &request, HttpResponse &response)
 

Private Member Functions

 Q_DISABLE_COPY (StatusController)
 

Detailed Description

status controller

This is a controller for interface to status information of the power station.

The return format is JSON.

Definition at line 22 of file statuscontroller.h.

Constructor & Destructor Documentation

StatusController::StatusController ( )

Constructor

Definition at line 9 of file statuscontroller.cpp.

9 {}

Member Function Documentation

void StatusController::service ( HttpRequest &  request,
HttpResponse &  response 
)

Generates the response

Definition at line 11 of file statuscontroller.cpp.

11  {
12  Q_UNUSED(request);
13  response.setHeader("Content-Type", "application/json; charset=utf-8");
14  QString body ("{\n"
15  "\"status\" : [\n");
16 
17  QList<INVERTOR_status> sdata = Static::invertors->status();
18 
19  QList<INVERTOR_status>::const_iterator i;
20  for(i = sdata.constBegin(); i != sdata.constEnd(); ++i) {
21  const INVERTOR_status& is = *i;
22  if(i != sdata.constBegin())
23  body.append(",\n");
24  body.append("\t{\n");
25 
26  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.line).arg("line"));
27  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.line_description).arg("line_description"));
28  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.address).arg("address"));
29  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.retries).arg("retries"));
30  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.command).arg("command"));
31  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.working).arg("working"));
32  body.append(QString("\t\t\"%2\" : \"%1\",\n").arg(is.invertors).arg("invertors"));
33  body.append(QString("\t\t\"%2\" : \"%1\"\n").arg(is.status).arg("status"));
34 
35  body.append("\t}\n");
36  }
37  body.append("]\n"
38  "}\n");
39  response.write(body.toUtf8());
40 }
int retries
Number of retries.
QString status
Status string.
int invertors
Number of invertors.
QString command
Current command pending.
int line
line number (database id)
QString line_description
Line description.
int working
Number of working invertors.
Stores the invertors status.
QList< INVERTOR_status > status()
Returns list of current invertors status.
Definition: invertors.cpp:67
int address
address of invertor

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