Files
HPPA/HPPA/PowerControl.cpp
2025-01-05 18:34:23 +08:00

56 lines
1.5 KiB
C++

#include "PowerControl.h"
PowerControl::PowerControl(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.lamp_power_open_btn, SIGNAL(clicked()), this, SLOT(onLampPowerOpen_btn()));
connect(ui.lamp_power_close_btn, SIGNAL(clicked()), this, SLOT(onLampPowerClose_btn()));
connect(ui.motor_power_open_btn, SIGNAL(clicked()), this, SLOT(onMotorPowerOpen_btn()));
connect(ui.motor_power_close_btn, SIGNAL(clicked()), this, SLOT(onMotorPowerClose_btn()));
}
PowerControl::~PowerControl()
{}
void PowerControl::getRequest(QString str)
{
QNetworkRequest request;
QNetworkAccessManager* naManager = new QNetworkAccessManager(this);
QMetaObject::Connection connRet = QObject::connect(naManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(requestFinished(QNetworkReply*)));
Q_ASSERT(connRet);
request.setUrl(QUrl(str));
QNetworkReply* reply = naManager->get(request);
}
void PowerControl::onLampPowerOpen_btn()//onLampPowerOpen_btn
{
QString xx = "http://192.168.1.3/setshutter?Portname=3&Value=1";
getRequest(xx);
}
void PowerControl::onLampPowerClose_btn()//onLampPowerClose_btn
{
QString xx = "http://192.168.1.3/setshutter?Portname=3&Value=0";
getRequest(xx);
}
void PowerControl::onMotorPowerOpen_btn()
{
QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=1";
getRequest(xx);
emit powerOpened();
}
void PowerControl::onMotorPowerClose_btn()
{
QString xx = "http://192.168.1.3/setshutter?Portname=1&Value=0";
getRequest(xx);
emit powerClosed();
}