-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSAVC.cpp
78 lines (62 loc) · 1.76 KB
/
SAVC.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "SAVC.h"
//Params
const float SAVC::bandaMorta = 2.0;
const float SAVC::tensaoBaixaAceitavel = 220.0 - SAVC::bandaMorta;
const float SAVC::tensaoAltaAceitavel = 220.0 + SAVC::bandaMorta;
SAVC::SAVC()
{
this->speATCC = new ATCC;
this->mmxu1 = new MMXU;
this->mmxu2 = new MMXU;
this->sender = new Sender;
this->tensaoBarra220kv = -1;
this->tensaoBarra500kv = -1;
}
SAVC::~SAVC() {
delete this->speATCC;
delete this->mmxu1;
delete this->mmxu2;
delete this->sender;
}
void SAVC::verificaTensao() {
qDebug() << "Verificando Tensao";
qDebug() << "=========================";
qDebug() << this->tensaoBarra220kv;
if (this->tensaoBarra220kv < this->tensaoBaixaAceitavel) {
//Sobe Tap
qDebug() << "Sobe tap +1";
this->mudaTap(1);
}
else if (this->tensaoBarra220kv > this->tensaoAltaAceitavel) {
//baixa Tap
qDebug() << "Baixa tap -1";
this->mudaTap(-1);
}
}
//Envia comando para subir tap na rede
void SAVC::mudaTap(short int tapPos) {
QJsonObject comando;
if (tapPos == 1) {
comando["mudarTap"] = "up";
}
else if (tapPos == -1) {
comando["mudarTap"] = "down";
}
//envia comando pela rede
this->sender->sendDatagram(comando);
}
void SAVC::atualizaTensao(QJsonObject receivedData) {
qDebug() << "Atualizando Tensao";
QJsonObject tensaoTPs = receivedData["buses"].toObject();
for(QJsonObject::iterator it = tensaoTPs.begin(); it != tensaoTPs.end(); it++) {
//tp1
if(it.key().endsWith("220kV")) {
this->tensaoBarra220kv = it.value().toDouble();
}
//tp2
else {
this->tensaoBarra500kv = it.value().toDouble();
}
}
this->verificaTensao();
}