qt/LedOK/wDevicesManager/controlverifyclockwidget.cpp

823 lines
37 KiB
C++
Raw Normal View History

2022-01-04 18:11:48 +08:00
#include "controlverifyclockwidget.h"
#include "ui_controlverifyclockwidget.h"
#include "LoUIClass/x_uimsgboxok.h"
#include <globaldefine.h>
2022-01-20 10:08:17 +08:00
ControlVerifyClockWidget::ControlVerifyClockWidget(QWidget *parent, QList<LedCard*> *list) : QWidget(parent), ui(new Ui::ControlVerifyClockWidget) {
2022-01-04 18:11:48 +08:00
m_pLedlist=list;
ui->setupUi(this);
refreshLable();
ui->pushButtonSetNtp->setProperty("ssType", "progManageTool");
ui->pushButtonSetNtp->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonSetSync->setProperty("ssType", "progManageTool");
ui->pushButtonSetSync->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonSetToCptTime->setProperty("ssType", "progManageTool");
ui->pushButtonSetToCptTime->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonReadBackSync->setProperty("ssType", "progManageTool");
ui->pushButtonReadBackSync->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButton_ReadbackNtp->setProperty("ssType", "progManageTool");
ui->pushButton_ReadbackNtp->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonSetLoraMaster->setProperty("ssType", "progManageTool");
ui->pushButtonSetLoraMaster->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonReadbackLoraMaster->setProperty("ssType", "progManageTool");
ui->pushButtonReadbackLoraMaster->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonCurTimeOfController->setProperty("ssType", "progManageTool");
ui->pushButtonCurTimeOfController->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonSetTimeZone->setProperty("ssType", "progManageTool");
ui->pushButtonSetTimeZone->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
2022-01-20 10:08:17 +08:00
ui->pushButtonSetLang->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
ui->pushButtonGetLang->setStyleSheet("QPushButton{background:rgba(28,154,210,1);}");
2022-01-04 18:11:48 +08:00
ui->buttonGroup_2->setId(ui->radioButton_4, 0);
ui->buttonGroup_2->setId(ui->radioButton_5, 1);
ui->radioButton_2->setChecked(true);
ui->labelIdCode->setVisible(true);
ui->lineEditIdCode->setVisible(true);
ui->labelTimeOffset->setVisible(true);
ui->lineEditTimeOffset->setVisible(true);
ui->lineEdit_3->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->labelTimeZone->setVisible(false);
ui->lineEdit_TimeZone->setVisible(false);
ui->labelmintime->setVisible(false);
//按钮事件绑定
connect(ui->pushButtonSetNtp,SIGNAL(clicked()),this,SLOT(OnSetNtp()));
connect(ui->pushButtonSetToCptTime,SIGNAL(clicked()),this,SLOT(OnSetSyncToCpt()));
connect(ui->pushButton_ReadbackNtp,SIGNAL(clicked()),this,SLOT(OnReadbackNtp()));
connect(ui->pushButtonReadBackSync,SIGNAL(clicked()),this,SLOT(OnReadbackSyncInfo()));
connect(ui->pushButtonSetSync,SIGNAL(clicked()),this,SLOT(OnSetSync()));
connect(ui->radioButton,SIGNAL(clicked()),this,SLOT(OnRadioButton()));
connect(ui->radioButton_2,SIGNAL(clicked()),this,SLOT(OnRadioButton2()));
connect(ui->radioButton_3,SIGNAL(clicked()),this,SLOT(OnRadioButton3()));
connect(ui->radioButton_6,SIGNAL(clicked()),this,SLOT(OnRadioButton6()));
connect(ui->pushButtonSetLoraMaster,SIGNAL(clicked()),this,SLOT(OnSetLoraMaster()));
connect(ui->pushButtonReadbackLoraMaster,SIGNAL(clicked()),this,SLOT(OnReadbackLoraMaster()));
connect(ui->pushButtonCurTimeOfController,SIGNAL(clicked()),this,SLOT(OnReadbackCurTimeOfController()));
connect(ui->pushButtonSetTimeZone, SIGNAL(clicked()), this, SLOT(OnSetTimeZone()));
2022-01-20 10:08:17 +08:00
connect(ui->pushButtonSetLang, SIGNAL(clicked()), this, SLOT(OnSetLang()));
connect(ui->pushButtonGetLang, SIGNAL(clicked()), this, SLOT(OnGetLang()));
2022-01-04 18:11:48 +08:00
initTimezone();
MARCO_DEFINE_CONTROL_FUNC2(parent->parent(),parent)
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::refreshLable(){
2022-01-04 18:11:48 +08:00
ui->labelTimeZone->setText(tr("Time zone"));
ui->labelNtpServerAddress->setText(tr("NTP Server address"));
ui->labelTimeOffset->setText(tr("Time offset(msec)"));
ui->labelVerifyClockConfiguration->setText(tr("Verify clock configuration"));
ui->pushButtonSetNtp->setText(tr("Set"));
ui->pushButtonSetSync->setText(tr("Set"));
ui->groupBox_2->setTitle(tr("NTP Server"));
ui->groupBox->setTitle(tr("Enable Synchronous playing"));
ui->radioButton_4->setText(tr("Master"));
ui->radioButton_5->setText(tr("Slave"));
ui->pushButtonSetLoraMaster->setText(tr("Set"));
ui->pushButtonReadbackLoraMaster->setText(tr("Readback"));
ui->pushButton_ReadbackNtp->setText(tr("Readback"));
ui->pushButtonReadBackSync->setText(tr("Readback"));
ui->groupBox_3->setTitle(tr("Sync clock to computer time"));
ui->pushButtonSetToCptTime->setText(tr("Set"));
ui->labelSyncTimeInterval->setText(tr("Sync time interval"));
ui->labelIdCode->setText(tr("Identification Code"));
ui->checkBoxBrightness->setText(tr("Brightness"));
ui->checkBoxVolume->setText(tr("Volume"));
ui->checkBoxScreenSwitch->setText(tr("Screen on/off"));
ui->groupBox_5->setTitle(tr("Cur time of controller"));
ui->pushButtonCurTimeOfController->setText(tr("Readback"));
ui->lineEditNtpServer->setPlaceholderText(tr("NTP Server address"));
ui->lineEdit_3->setPlaceholderText(tr("Sync time interval"));
ui->lineEditIdCode->setPlaceholderText(tr("identification code"));
ui->label->setText(tr("TimeZone"));
ui->pushButtonSetTimeZone->setText(tr("Set"));
}
ControlVerifyClockWidget::~ControlVerifyClockWidget()
{
delete ui;
if(pHpptClient != nullptr)
{
qDebug() <<"delete pHpptClient in ~NetComm";
delete pHpptClient;
pHpptClient=nullptr;
}
if(pHpptClientAll != nullptr)
{
qDebug() <<"delete pHpptClientAll in ~NetComm";
delete pHpptClientAll;
pHpptClientAll=nullptr;
}
}
void ControlVerifyClockWidget::OnRadioButton()//gps
{
ui->labelIdCode->setVisible(false);
ui->lineEditIdCode->setVisible(false);
ui->labelTimeOffset->setVisible(false);
ui->lineEditTimeOffset->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->lineEdit_3->setVisible(false);
ui->labelmintime->setVisible(false);
ui->groupBox_4->setVisible(false);
ui->radioButton_4->setVisible(false);
ui->radioButton_5->setVisible(false);
ui->pushButtonSetLoraMaster->setVisible(false);
ui->pushButtonReadbackLoraMaster->setVisible(false);
ui->checkBoxScreenSwitch->setVisible(false);
ui->checkBoxVolume->setVisible(false);
ui->checkBoxBrightness->setVisible(false);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
void ControlVerifyClockWidget::OnRadioButton2()//lora
{
ui->labelIdCode->setVisible(true);
ui->lineEditIdCode->setVisible(true);
ui->labelTimeOffset->setVisible(true);
ui->lineEditTimeOffset->setVisible(true);
ui->lineEdit_3->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->labelmintime->setVisible(false);
ui->groupBox_4->setVisible(true);
ui->radioButton_4->setVisible(true);
ui->radioButton_5->setVisible(true);
ui->pushButtonSetLoraMaster->setVisible(true);
ui->pushButtonReadbackLoraMaster->setVisible(true);
ui->checkBoxScreenSwitch->setVisible(true);
ui->checkBoxVolume->setVisible(true);
ui->checkBoxBrightness->setVisible(true);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
void ControlVerifyClockWidget::OnRadioButton3()//ntp
{
ui->labelIdCode->setVisible(false);
ui->lineEditIdCode->setVisible(false);
ui->labelTimeOffset->setVisible(false);
ui->lineEditTimeOffset->setVisible(false);
ui->lineEdit_3->setVisible(true);
ui->labelSyncTimeInterval->setVisible(true);
ui->labelmintime->setVisible(true);
ui->groupBox_4->setVisible(false);
ui->radioButton_4->setVisible(false);
ui->radioButton_5->setVisible(false);
ui->pushButtonSetLoraMaster->setVisible(false);
ui->pushButtonReadbackLoraMaster->setVisible(false);
ui->checkBoxScreenSwitch->setVisible(false);
ui->checkBoxVolume->setVisible(false);
ui->checkBoxBrightness->setVisible(false);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnRadioButton6() {
2022-01-04 18:11:48 +08:00
ui->labelIdCode->setVisible(true);
ui->lineEditIdCode->setVisible(true);
ui->labelTimeOffset->setVisible(true);
ui->lineEditTimeOffset->setVisible(true);
ui->lineEdit_3->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->labelmintime->setVisible(false);
ui->groupBox_4->setVisible(true);
ui->radioButton_4->setVisible(true);
ui->radioButton_5->setVisible(true);
ui->pushButtonSetLoraMaster->setVisible(true);
ui->pushButtonReadbackLoraMaster->setVisible(true);
ui->checkBoxScreenSwitch->setVisible(true);
ui->checkBoxVolume->setVisible(true);
ui->checkBoxBrightness->setVisible(true);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
void ControlVerifyClockWidget::OnSetNtp()
{
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "SetNtpServer");
json.insert("ntpServer", ui->lineEditNtpServer->text());
MACRO_DEFINE_TIPDLG_FUCN(tr("SetNtpServer"),tr("Success"),tr("failed"))
}
void ControlVerifyClockWidget::OnSetLoraMaster()
{
// if(ui->radioButton_6->isChecked())//局域网同步设置主从
// {
// QJsonObject json;
// json.insert("_id", getRandomString(10));
// json.insert("_type", "SetingSyncMethod");
// json.insert("ntpServer", ui->labelNtpServerAddress->text());
// json.insert("time", "Lan");
// if(ui->checkBoxBrightness->isChecked())
// json.insert("brightness", "serial");
// else
// json.insert("brightness", "none");
// //
// if(ui->checkBoxVolume->isChecked())
// json.insert("volume", "serial");
// else
// json.insert("volume", "none");
// if(ui->checkBoxScreenSwitch->isChecked())
// json.insert("screenSwitch", "serial");
// else
// json.insert("screenSwitch", "none");
// MACRO_DEFINE_TIPDLG_FUCN(tr("SetingSyncMethod"),tr("Success"),tr("failed"))
// }
// else if(ui->radioButton_2->isChecked())//Lora同步设置主从
// {
// }
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "MasterSlaveSwitch");
if(ui->buttonGroup_2->checkedId()==0)
{
json.insert("master", true);
qDebug()<<"master";
MACRO_DEFINE_TIPDLG_FUCN(tr("MasterSwitch "),tr("Success"),tr("failed"))
}
else
{
json.insert("master", false);
qDebug()<<"slave";
MACRO_DEFINE_TIPDLG_FUCN(tr("SlaveSwitch "),tr("Success"),tr("failed"))
}
}
void ControlVerifyClockWidget::OnReadbackLoraMaster()
{
// if(ui->radioButton_6->isChecked())//局域网同步设置主从
// {
// QJsonObject json;
// json.insert("_id", getRandomString(10));
// json.insert("_type", "IsOpenNetSyncTime");
// MACRO_DEFINE_TIPDLG_FUCN(tr("IsMasterSlave"),tr("Success"),tr("failed"))
// }
// else if(ui->radioButton_2->isChecked())//Lora同步设置主从
// {
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "IsMasterSlave");
MACRO_DEFINE_TIPDLG_FUCN(tr("IsMasterSlave"),tr("Success"),tr("failed"))
// }
}
void ControlVerifyClockWidget::OnReadbackCurTimeOfController()
{
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "GetControllerDate");
MACRO_DEFINE_TIPDLG_FUCN(tr("GetControllerDate"),tr("Success"),tr("failed"))
}
void ControlVerifyClockWidget::OnSetSync()
{
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "SetingSyncMethod");
json.insert("ntpServer", ui->labelNtpServerAddress->text());
if(ui->radioButton_2->isChecked())
{
json.insert("time", "serial");
json.insert("delaySync", ui->lineEditTimeOffset->text().toInt());
json.insert("identificationCode",ui->lineEditIdCode->text());
}
else if(ui->radioButton_3->isChecked())
{
json.insert("time", "ntp");
json.insert("checkNtpTime", ui->lineEdit_3->text().toInt());
json.insert("delaySync", ui->lineEditTimeOffset->text().toInt());
json.insert("identificationCode",ui->lineEditIdCode->text());
}
else if(ui->radioButton->isChecked())
{
json.insert("time", "gps");
json.insert("delaySync", ui->lineEditTimeOffset->text().toInt());
json.insert("identificationCode",ui->lineEditIdCode->text());
}
else if(ui->radioButton_6->isChecked())
{
json.insert("time", "Lan");
json.insert("delaySync", ui->lineEditTimeOffset->text().toInt());
json.insert("identificationCode",ui->lineEditIdCode->text());
}
if(ui->checkBoxBrightness->isChecked())
json.insert("brightness", "serial");
else
json.insert("brightness", "none");
//
if(ui->checkBoxVolume->isChecked())
json.insert("volume", "serial");
else
json.insert("volume", "none");
if(ui->checkBoxScreenSwitch->isChecked())
json.insert("screenSwitch", "serial");
else
json.insert("screenSwitch", "none");
MACRO_DEFINE_TIPDLG_FUCN(tr("SetingSyncMethod"),tr("Success"),tr("failed"))
}
void ControlVerifyClockWidget::OnSetSyncToCpt()
{
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "SyncTime");
QDateTime *datatime=new QDateTime(QDateTime::currentDateTime());
// qint64 iSecs22=datatime->toSecsSinceEpoch();
qint64 iSecs11=datatime->toMSecsSinceEpoch();
// qDebug()<<iSecs22<<","<<iSecs11;
// json.insert("time", iSecs22);
json.insert("time", iSecs11);
MACRO_DEFINE_TIPDLG_FUCN(tr("SyncTime"),tr("Success"),tr("failed"))
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnReadbackNtp(){
2022-01-04 18:11:48 +08:00
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "GetNtpServer");
MACRO_DEFINE_TIPDLG_FUCN(tr("GetNtpServer"),tr("Success"),tr("failed"))
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnReadbackSyncInfo() {
qDebug()<<" OnReadbackSyncInfo";
2022-01-04 18:11:48 +08:00
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "GetingSyncMethod");
MACRO_DEFINE_TIPDLG_FUCN(tr("GetingSyncMethod"),tr("Success"),tr("failed"))
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::onSelectedDeviceList(QList<LedCard*> *list){
2022-01-04 18:11:48 +08:00
m_pLedlist=list;
MACRO_DEFINE_CONTROL_FUNC3
}
void ControlVerifyClockWidget::OnControlTypeSwitchIndexChanged(int index)
{
if(index==ENUM_CONTRL_WIDGET_VERIFYCLOCK)
{
m_bSelected=true;
if(m_pLedCard!=nullptr)
onReadbackAllThisPage();
}
else {
m_bSelected=false;
}
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::onReadbackAllThisPage() {
if(m_pLedlist==nullptr) return;
if(m_pLedlist->count()!=1) return;
2022-01-04 18:11:48 +08:00
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "GetingSyncMethod");
2022-01-20 10:08:17 +08:00
HttpPostByTypeJsonObject(pHpptClientAll, m_strUrl, json);
2022-01-04 18:11:48 +08:00
2022-01-20 10:08:17 +08:00
json = QJsonObject();
json.insert("_id", getRandomString(10));
json.insert("_type", "GetTimezone");
HttpPostByTypeJsonObject(pHpptClientAll, m_strUrl, json);
json = QJsonObject();
json.insert("_id", getRandomString(10));
json.insert("_type", "GetLanguage");
HttpPostByTypeJsonObject(pHpptClientAll, m_strUrl, json);
MACRO_DEFINE_TIPDLG_ALL_FUCN(tr("Readback"),tr("Success"),tr("failed"))
2022-01-04 18:11:48 +08:00
}
QString ControlVerifyClockWidget::formatTime(int ms)
{
int ss = 1000;
int mi = ss * 60;
int hh = mi * 60;
int dd = hh * 24;
long day = ms / dd;
long hour = (ms - day * dd) / hh;
long minute = (ms - day * dd - hour * hh) / mi;
long second = (ms - day * dd - hour * hh - minute * mi) / ss;
long milliSecond = ms - day * dd - hour * hh - minute * mi - second * ss;
QString hou = QString::number(hour,10);
QString min = QString::number(minute,10);
QString sec = QString::number(second,10);
QString msec = QString::number(milliSecond,10);
//qDebug() << "minute:" << min << "second" << sec << "ms" << msec <<endl;
return hou + ":" + min + ":" + sec ;
}
//获取到httpPost的应答如果参数变化需要出发修改控件item的内容
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnProHttpResponse(QString url, QString, QByteArray data){
if(url == m_strUrl){
2022-01-04 18:11:48 +08:00
QJsonParseError parseJsonErr;
QJsonDocument document = QJsonDocument::fromJson(data,&parseJsonErr);
2022-01-20 10:08:17 +08:00
if(parseJsonErr.error != QJsonParseError::NoError) {
if(data.size()==0) qDebug()<<"json is empty";
else qDebug()<<tr("wDevicesItem OnProHttpResponse 解析json文件错误");
2022-01-04 18:11:48 +08:00
return;
}
QJsonObject jsonObject = document.object();
2022-01-20 10:08:17 +08:00
QString strType = jsonObject["_type"].toString();
if(jsonObject["success"].toBool()==true) {
2022-01-04 18:11:48 +08:00
qDebug()<<m_pLedCard->m_strCardId +"---------"+ strType;
2022-01-20 10:08:17 +08:00
if(strType == "GetLanguage") {
if(jsonObject["language"].toInt()==1) ui->radioButtonCn->setChecked(true);
else ui->radioButtonEn->setChecked(true);
2022-01-04 18:11:48 +08:00
}
2022-01-20 10:08:17 +08:00
else if(strType == "SetNtpServer") ;//alahover 新增协议类型
else if(strType == "GetNtpServer") ui->lineEditNtpServer->setText(jsonObject["ntpServer"].toString());
else if(strType == "GetNtpAndTimezone") ui->lineEditNtpServer->setText(jsonObject["ntpServer"].toString());
else if(strType == "SyncTime") qDebug()<<jsonObject["date"].toString();
else if(strType == "MasterSlaveSwitch") ;
else if(strType == "IsMasterSlave") {
if(jsonObject["result"].toBool()) {
2022-01-04 18:11:48 +08:00
ui->radioButton_4->setChecked(true);
ui->radioButton_5->setChecked(false);
2022-01-20 10:08:17 +08:00
} else {
2022-01-04 18:11:48 +08:00
ui->radioButton_4->setChecked(false);
ui->radioButton_5->setChecked(true);
}
}
2022-01-20 10:08:17 +08:00
else if(strType == "SetingSyncMethod") ;
2022-01-04 18:11:48 +08:00
else if(strType == "GetTimezone"){
QString strtemp=jsonObject["timezone"].toString();
ui->comboBox_Timezone->setCurrentText(strtemp);
}
2022-01-20 10:08:17 +08:00
else if(strType == "SetTimezone");
else if(strType == "GetControllerDate") {
2022-01-04 18:11:48 +08:00
QString strDate=jsonObject["date"].toString();
//int millis=jsonObject["millis"].toInt();
//strDate+=":"+QString::number(millis);
ui->labelCurTime->setText(strDate);
}
2022-01-20 10:08:17 +08:00
else if(strType == "GetingSyncMethod") {
2022-01-04 18:11:48 +08:00
//jsonObject["brightness"].toString();
QString strType=jsonObject["time"].toString();
strType=strType.toLower();
2022-01-20 10:08:17 +08:00
if(strType=="serial"||strType=="lan"){
if(strType=="serial") ui->radioButton_2->setChecked(true);
else if(strType=="lan") ui->radioButton_6->setChecked(true);
2022-01-04 18:11:48 +08:00
ui->lineEditIdCode->setText(jsonObject["identificationCode"].toString());
QString strtempdelaySync=QString::number(jsonObject["delaySync"].toInt());
ui->lineEditTimeOffset->setText(strtempdelaySync);
ui->labelIdCode->setVisible(true);
ui->lineEditIdCode->setVisible(true);
ui->labelTimeOffset->setVisible(true);
ui->lineEditTimeOffset->setVisible(true);
ui->lineEdit_3->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->labelmintime->setVisible(false);
if(jsonObject["screenSwitch"].toString()=="NONE")
{
ui->checkBoxScreenSwitch->setChecked(false);
}
else {
ui->checkBoxScreenSwitch->setChecked(true);
}
if(jsonObject["volume"].toString()=="NONE")
{
ui->checkBoxVolume->setChecked(false);
}
else {
ui->checkBoxVolume->setChecked(true);
}
if(jsonObject["brightness"].toString()=="NONE")
{
ui->checkBoxBrightness->setChecked(false);
}
else {
ui->checkBoxBrightness->setChecked(true);
}
ui->checkBoxScreenSwitch->setVisible(true);
ui->checkBoxVolume->setVisible(true);
ui->checkBoxBrightness->setVisible(true);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
else if(strType=="ntp"){
ui->radioButton_3->setChecked(true);
QString strtempdelaySync=QString::number(jsonObject["checkNtpTime"].toInt());
ui->lineEdit_3->setText(strtempdelaySync);
ui->labelIdCode->setVisible(false);
ui->lineEditIdCode->setVisible(false);
ui->labelTimeOffset->setVisible(false);
ui->lineEditTimeOffset->setVisible(false);
ui->lineEdit_3->setVisible(true);
ui->labelSyncTimeInterval->setVisible(true);
ui->labelmintime->setVisible(true);
ui->groupBox_4->setVisible(false);
ui->radioButton_4->setVisible(false);
ui->radioButton_5->setVisible(false);
ui->pushButtonSetLoraMaster->setVisible(false);
ui->pushButtonReadbackLoraMaster->setVisible(false);
ui->checkBoxScreenSwitch->setVisible(false);
ui->checkBoxVolume->setVisible(false);
ui->checkBoxBrightness->setVisible(false);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
else if(strType=="gps"){
ui->radioButton->setChecked(true);
ui->labelIdCode->setVisible(false);
ui->lineEditIdCode->setVisible(false);
ui->labelTimeOffset->setVisible(false);
ui->lineEditTimeOffset->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->lineEdit_3->setVisible(false);
ui->labelmintime->setVisible(false);
ui->groupBox_4->setVisible(false);
ui->radioButton_4->setVisible(false);
ui->radioButton_5->setVisible(false);
ui->pushButtonSetLoraMaster->setVisible(false);
ui->pushButtonReadbackLoraMaster->setVisible(false);
ui->checkBoxScreenSwitch->setVisible(false);
ui->checkBoxVolume->setVisible(false);
ui->checkBoxBrightness->setVisible(false);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
//jsonObject["screenSwitch"].toString();
//jsonObject["lastSynchronousTime"].toInt();
//jsonObject["volume"].toString();
jsonObject["checkNtpTime"].toInt();
}
MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK
}
}
}
//获取到httpPost的应答如果参数变化需要出发修改控件item的内容
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnProHttpResponseAll(QString url, QString, QByteArray data){
if(url == m_strUrl) {
2022-01-04 18:11:48 +08:00
QJsonParseError parseJsonErr;
QJsonDocument document = QJsonDocument::fromJson(data,&parseJsonErr);
2022-01-20 10:08:17 +08:00
if(!(parseJsonErr.error == QJsonParseError::NoError)) {
if(data.size()==0) qDebug()<<"json is empty";
else qDebug()<<tr("wDevicesItem OnProHttpResponse 解析json文件错误");
2022-01-04 18:11:48 +08:00
return;
}
QJsonObject jsonObject = document.object();
QString strType=jsonObject["_type"].toString();
2022-01-20 10:08:17 +08:00
if(jsonObject["success"].toBool()) {
qDebug()<<m_pLedCard->m_strCardId +"----All----"+ strType;
if(strType == "GetLanguage") {
if(jsonObject["language"].toInt()==1) ui->radioButtonCn->setChecked(true);
else ui->radioButtonEn->setChecked(true);
2022-01-04 18:11:48 +08:00
}
else if(strType == "GetTimezone"){
QString strtemp=jsonObject["timezone"].toString();
ui->comboBox_Timezone->setCurrentText(strtemp);
MACRO_ASKTIME_STOP
MACRO_POSTING_DLG_UNLOCK
}
2022-01-20 10:08:17 +08:00
else if(strType == "GetingSyncMethod") {
2022-01-04 18:11:48 +08:00
//jsonObject["brightness"].toString();
QString strType=jsonObject["time"].toString();
strType=strType.toLower();
if(strType=="serial"||strType=="lan")
{
if(strType=="serial")
ui->radioButton_2->setChecked(true);
else if(strType=="lan")
ui->radioButton_6->setChecked(true);
ui->lineEditIdCode->setText(jsonObject["identificationCode"].toString());
QString strtempdelaySync=QString::number(jsonObject["delaySync"].toInt());
ui->lineEditTimeOffset->setText(strtempdelaySync);
ui->labelIdCode->setVisible(true);
ui->lineEditIdCode->setVisible(true);
ui->labelTimeOffset->setVisible(true);
ui->lineEditTimeOffset->setVisible(true);
ui->lineEdit_3->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->labelmintime->setVisible(false);
if(jsonObject["screenSwitch"].toString()=="NONE")
{
ui->checkBoxScreenSwitch->setChecked(false);
}
else {
ui->checkBoxScreenSwitch->setChecked(true);
}
if(jsonObject["volume"].toString()=="NONE")
{
ui->checkBoxVolume->setChecked(false);
}
else {
ui->checkBoxVolume->setChecked(true);
}
if(jsonObject["brightness"].toString()=="NONE")
{
ui->checkBoxBrightness->setChecked(false);
}
else {
ui->checkBoxBrightness->setChecked(true);
}
ui->checkBoxScreenSwitch->setVisible(true);
ui->checkBoxVolume->setVisible(true);
ui->checkBoxBrightness->setVisible(true);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
else if(strType=="ntp"){
ui->radioButton_3->setChecked(true);
QString strtempdelaySync=QString::number(jsonObject["checkNtpTime"].toInt());
ui->lineEdit_3->setText(strtempdelaySync);
ui->labelIdCode->setVisible(false);
ui->lineEditIdCode->setVisible(false);
ui->labelTimeOffset->setVisible(false);
ui->lineEditTimeOffset->setVisible(false);
ui->lineEdit_3->setVisible(true);
ui->labelSyncTimeInterval->setVisible(true);
ui->labelmintime->setVisible(true);
ui->groupBox_4->setVisible(false);
ui->radioButton_4->setVisible(false);
ui->radioButton_5->setVisible(false);
ui->pushButtonSetLoraMaster->setVisible(false);
ui->pushButtonReadbackLoraMaster->setVisible(false);
ui->checkBoxScreenSwitch->setVisible(false);
ui->checkBoxVolume->setVisible(false);
ui->checkBoxBrightness->setVisible(false);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
else if(strType=="gps"){
ui->radioButton->setChecked(true);
ui->labelIdCode->setVisible(false);
ui->lineEditIdCode->setVisible(false);
ui->labelTimeOffset->setVisible(false);
ui->lineEditTimeOffset->setVisible(false);
ui->labelSyncTimeInterval->setVisible(false);
ui->lineEdit_3->setVisible(false);
ui->labelmintime->setVisible(false);
ui->groupBox_4->setVisible(false);
ui->radioButton_4->setVisible(false);
ui->radioButton_5->setVisible(false);
ui->pushButtonSetLoraMaster->setVisible(false);
ui->pushButtonReadbackLoraMaster->setVisible(false);
ui->checkBoxScreenSwitch->setVisible(false);
ui->checkBoxVolume->setVisible(false);
ui->checkBoxBrightness->setVisible(false);
ui->pushButtonSetSync->setVisible(true);
ui->pushButtonReadBackSync->setVisible(true);
}
//jsonObject["screenSwitch"].toString();
//jsonObject["lastSynchronousTime"].toInt();
//jsonObject["volume"].toString();
jsonObject["checkNtpTime"].toInt();
}
}
}
}
void ControlVerifyClockWidget::DeletePostingDlg()
{
if(m_PostingDlg!=nullptr)
{
delete m_PostingDlg;
m_PostingDlg=nullptr;
}
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::initTimezone(){
2022-01-04 18:11:48 +08:00
QStringList listTimezone;
listTimezone.append("Pacific/Majuro");
listTimezone.append("Pacific/Midway");
listTimezone.append("Pacific/Honolulu");
listTimezone.append("America/Anchorage");//>安克雷奇</timezone>
listTimezone.append("America/Los_Angeles");//>美国太平洋时间 (洛杉矶)</timezone>
listTimezone.append("America/Tijuana");//>美国太平洋时间 (提华纳)</timezone>
listTimezone.append("America/Phoenix");//>美国山区时间 (凤凰城)</timezone>
listTimezone.append("America/Chihuahua");//>奇瓦瓦</timezone>
listTimezone.append("America/Denver");//>美国山区时间 (丹佛)</timezone>
listTimezone.append("America/Costa_Rica");//>美国中部时间 (哥斯达黎加)</timezone>
listTimezone.append("America/Chicago");//>美国中部时间 (芝加哥)</timezone>
listTimezone.append("America/Mexico_City");//>美国中部时间 (墨西哥城)</timezone>
listTimezone.append("America/Regina");//>美国中部时间 (里贾纳)</timezone>
listTimezone.append("America/Bogota");//>哥伦比亚时间 (波哥大)</timezone>
listTimezone.append("America/New_York");//>美国东部时间 (纽约)</timezone>
listTimezone.append("America/Caracas");//>委内瑞拉时间 (加拉加斯)</timezone>
listTimezone.append("America/Barbados");//>大西洋时间 (巴巴多斯)</timezone>
listTimezone.append("America/Manaus");//亚马逊标准时间 (马瑙斯)</timezone>
listTimezone.append("America/Santiago");//圣地亚哥</timezone>
listTimezone.append("America/St_Johns");//纽芬兰时间 (圣约翰)</timezone>
listTimezone.append("America/Sao_Paulo");//圣保罗</timezone>
listTimezone.append("America/Argentina/Buenos_Aires");//布宜诺斯艾利斯</timezone>
listTimezone.append("America/Godthab");//戈特霍布</timezone>
listTimezone.append("America/Montevideo");//乌拉圭时间 (蒙得维的亚)</timezone>
listTimezone.append("Atlantic/South_Georgia");//南乔治亚</timezone>
listTimezone.append("Atlantic/Azores");//亚述尔群岛</timezone>
listTimezone.append("Atlantic/Cape_Verde");//佛得角</timezone>
listTimezone.append("Africa/Casablanca");//卡萨布兰卡</timezone>
listTimezone.append("Europe/London");//格林尼治标准时间 (伦敦)</timezone>
listTimezone.append("Europe/Amsterdam");//中欧标准时间 (阿姆斯特丹)</timezone>
listTimezone.append("Europe/Belgrade");//中欧标准时间 (贝尔格莱德)</timezone>
listTimezone.append("Europe/Brussels");//中欧标准时间 (布鲁塞尔)</timezone>
listTimezone.append("Europe/Sarajevo");//中欧标准时间 (萨拉热窝)</timezone>
listTimezone.append("Africa/Windhoek");//温得和克</timezone>
listTimezone.append("Africa/Brazzaville");//西部非洲标准时间 (布拉扎维)</timezone>
listTimezone.append("Asia/Amman");//东欧标准时间 (安曼)</timezone>
listTimezone.append("Europe/Athens");//东欧标准时间 (雅典)</timezone>
listTimezone.append("Asia/Beirut");//东欧标准时间 (贝鲁特)</timezone>
listTimezone.append("Africa/Cairo");//东欧标准时间 (开罗)</timezone>
listTimezone.append("Europe/Helsinki");//东欧标准时间 (赫尔辛基)</timezone>
listTimezone.append("Asia/Jerusalem");//以色列时间 (耶路撒冷)</timezone>
listTimezone.append("Europe/Minsk");//明斯克</timezone>
listTimezone.append("Africa/Harare");//中部非洲标准时间 (哈拉雷)</timezone>
listTimezone.append("Asia/Baghdad");//巴格达</timezone>
listTimezone.append("Europe/Moscow");//莫斯科</timezone>
listTimezone.append("Asia/Kuwait");//科威特</timezone>
listTimezone.append("Africa/Nairobi");//东部非洲标准时间 (内罗毕)</timezone>
listTimezone.append("Asia/Tehran");//伊朗标准时间 (德黑兰)</timezone>
listTimezone.append("Asia/Baku");//巴库</timezone>
listTimezone.append("Asia/Tbilisi");//第比利斯</timezone>
listTimezone.append("Asia/Yerevan");//埃里温</timezone>
listTimezone.append("Asia/Dubai");//迪拜</timezone>
listTimezone.append("Asia/Kabul");//阿富汗时间 (喀布尔)</timezone>
listTimezone.append("Asia/Karachi");//卡拉奇</timezone>
listTimezone.append("Asia/Oral");//乌拉尔</timezone>
listTimezone.append("Asia/Yekaterinburg");//叶卡捷林堡</timezone>
listTimezone.append("Asia/Calcutta");//加尔各答</timezone>
listTimezone.append("Asia/Colombo");//科伦坡</timezone>
listTimezone.append("Asia/Katmandu");//尼泊尔时间 (加德满都)</timezone>
listTimezone.append("Asia/Almaty");//阿拉木图</timezone>
listTimezone.append("Asia/Rangoon");//缅甸时间 (仰光)</timezone>
listTimezone.append("Asia/Krasnoyarsk");//克拉斯诺亚尔斯克</timezone>
listTimezone.append("Asia/Bangkok");//曼谷</timezone>
listTimezone.append("Asia/Shanghai");//中国标准时间 (北京)</timezone>
listTimezone.append("Asia/Hong_Kong");//香港时间 (香港)</timezone>
listTimezone.append("Asia/Irkutsk");//伊尔库茨克时间 (伊尔库茨克)</timezone>
listTimezone.append("Asia/Kuala_Lumpur");//吉隆坡</timezone>
listTimezone.append("Australia/Perth");//佩思</timezone>
listTimezone.append("Asia/Taipei");//台北时间 (台北)</timezone>
listTimezone.append("Asia/Seoul");//首尔</timezone>
listTimezone.append("Asia/Tokyo");//日本时间 (东京)</timezone>
listTimezone.append("Asia/Yakutsk");//雅库茨克时间 (雅库茨克)</timezone>
listTimezone.append("Australia/Adelaide");//阿德莱德</timezone>
listTimezone.append("Australia/Darwin");//达尔文</timezone>
listTimezone.append("Australia/Brisbane");//布里斯班</timezone>
listTimezone.append("Australia/Hobart");//霍巴特</timezone>
listTimezone.append("Australia/Sydney");//悉尼</timezone>
listTimezone.append("Asia/Vladivostok");//海参崴时间 (符拉迪沃斯托克)</timezone>
listTimezone.append("Pacific/Guam");//关岛</timezone>
listTimezone.append("Asia/Magadan");//马加丹时间 (马加丹)</timezone>
listTimezone.append("Pacific/Auckland");//奥克兰</timezone>
listTimezone.append("Pacific/Fiji");//斐济</timezone>
listTimezone.append("Pacific/Tongatapu");//东加塔布</timezone>
ui->comboBox_Timezone->addItems(listTimezone);
}
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnSetTimeZone(){
QString strTimeZone=ui->comboBox_Timezone->currentText();
MACRO_DEFINE_NO_SELECTED_CARD_TIP
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "SetTimezone");
json.insert("timezone", strTimeZone);
MACRO_DEFINE_TIPDLG_FUCN(tr("SetTimezone"),tr("Success"),tr("failed"))
}
2022-01-04 18:11:48 +08:00
2022-01-20 10:08:17 +08:00
void ControlVerifyClockWidget::OnSetLang(){
MACRO_DEFINE_NO_SELECTED_CARD_TIP
int lang = ui->radioButtonCn->isChecked() ? 1 : 0;
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "SetLanguage");
json.insert("language", lang);
MACRO_DEFINE_TIPDLG_FUCN("设置语言", "成功", "失败")
}
void ControlVerifyClockWidget::OnGetLang() {
QJsonObject json;
json.insert("_id", getRandomString(10));
json.insert("_type", "GetLanguage");
MACRO_DEFINE_TIPDLG_FUCN("回读语言", "成功", "失败")
2022-01-04 18:11:48 +08:00
}