101 lines
2.3 KiB
C++
101 lines
2.3 KiB
C++
#include "PowerControl3D.h"
|
|
|
|
using namespace MotorParams;
|
|
|
|
PowerControl3D::PowerControl3D(QWidget* parent)
|
|
: QDialog(parent)
|
|
{
|
|
ui.setupUi(this);
|
|
|
|
connect(ui.halogenLampPowerOn_btn, &QPushButton::clicked, this, &PowerControl3D::halogenLampPowerOn);
|
|
connect(ui.halogenLampPowerDown_btn, &QPushButton::clicked, this, &PowerControl3D::halogenLampPowerDown);
|
|
|
|
connect(ui.d65LampPowerOn_btn, &QPushButton::clicked, this, &PowerControl3D::d65LampPowerOn);
|
|
connect(ui.d65LampPowerDown_btn, &QPushButton::clicked, this, &PowerControl3D::d65LampPowerDown);
|
|
|
|
connect(ui.slrPowerOn_btn, &QPushButton::clicked, this, &PowerControl3D::slrPowerOn);
|
|
connect(ui.slrPowerDown_btn, &QPushButton::clicked, this, &PowerControl3D::slrPowerDown);
|
|
|
|
MotorParams::TCPConnectionParams tcpConnectionParams6003;
|
|
tcpConnectionParams6003.port = 6003;
|
|
tcpConnectionParams6003.serverIP = "192.168.1.2";
|
|
tcpServer6003 = new CommunicationViaTCP(tcpConnectionParams6003, this);
|
|
|
|
MotorParams::TCPConnectionParams tcpConnectionParams6004;
|
|
tcpConnectionParams6004.port = 6004;
|
|
tcpConnectionParams6004.serverIP = "192.168.1.2";
|
|
tcpServer6004 = new CommunicationViaTCP(tcpConnectionParams6004, this);
|
|
}
|
|
|
|
PowerControl3D::~PowerControl3D()
|
|
{
|
|
delete tcpServer6003;
|
|
delete tcpServer6004;
|
|
}
|
|
|
|
void PowerControl3D::halogenLampPowerOn()
|
|
{
|
|
tcpServer6003->sendCommand(R"({"key1":1,"type":"event"})");
|
|
}
|
|
|
|
void PowerControl3D::halogenLampPowerDown()
|
|
{
|
|
tcpServer6003->sendCommand(R"({"key1":0,"type":"event"})");
|
|
}
|
|
|
|
void PowerControl3D::switchHalogenLampPower(int state)
|
|
{
|
|
if (state==0)
|
|
{
|
|
halogenLampPowerDown();
|
|
}
|
|
else if(state == 1)
|
|
{
|
|
halogenLampPowerOn();
|
|
}
|
|
}
|
|
|
|
void PowerControl3D::d65LampPowerOn()
|
|
{
|
|
tcpServer6004->sendCommand(R"({"key1":1,"type":"event"})");
|
|
}
|
|
|
|
void PowerControl3D::d65LampPowerDown()
|
|
{
|
|
tcpServer6004->sendCommand(R"({"key1":0,"type":"event"})");
|
|
}
|
|
|
|
void PowerControl3D::switchD65LampPower(int state)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
d65LampPowerDown();
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
d65LampPowerOn();
|
|
}
|
|
}
|
|
|
|
void PowerControl3D::slrPowerOn()
|
|
{
|
|
tcpServer6003->sendCommand(R"({"key2":1,"type":"event"})");
|
|
}
|
|
|
|
void PowerControl3D::slrPowerDown()
|
|
{
|
|
tcpServer6003->sendCommand(R"({"key2":0,"type":"event"})");
|
|
}
|
|
|
|
void PowerControl3D::switchSlrPower(int state)
|
|
{
|
|
if (state == 0)
|
|
{
|
|
slrPowerDown();
|
|
}
|
|
else if (state == 1)
|
|
{
|
|
slrPowerOn();
|
|
}
|
|
}
|