Browse Source

master (#4)

程序启动切换到可执行文件所在目录

推送消息中没有倒计时不显示

添加轮播患者

2个api测试完成

添加按键检测

修改qtdebug->qtcore11

修改qtdebug->qtcore

pro文件中去除无用文件,以缩减目标平台编译时间

test device 1

test device

Co-authored-by: zhangsan <zezhao_wei@163.com>
Reviewed-on: https://dd.tall.wiki/gitea/ccsens_hardware/qt_qcp_show/pulls/4
master
ccsens_zhangsan 4 years ago
parent
commit
7f6fd9aa20
  1. 39
      QCPShow.pro
  2. 26
      QCPShow.pro.user
  3. 47
      api.http
  4. 93
      deviceservice.cpp
  5. 46
      deviceservice.h
  6. 14
      httpservice.cpp
  7. 1
      httpservice.h
  8. 20
      main.cpp
  9. 2
      mainconfig.cpp
  10. 65
      mainwidget.cpp
  11. 8
      mainwidget.h
  12. 2
      patientemergencyinfo.h
  13. 9
      resttest
  14. 27
      setting.ini
  15. 11
      websocketservice.cpp
  16. 2
      websocketservice.h

39
QCPShow.pro

@ -11,6 +11,13 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += C++11
win32{
# win32 libs
}else{
LIBS += -l wiringPi
}
TARGET = QCPShow
TEMPLATE = app
@ -28,28 +35,30 @@ DEFINES += QT_DEPRECATED_WARNINGS
SOURCES += main.cpp\
mainwidget.cpp \
serial/serialport.cpp \
ccwidgets/cqlineedit.cpp \
ccwidgets/cqspinbox.cpp \
ccwidgets/cqtextedit.cpp \
ccwidgets/cqwidgetspinbox.cpp \
util/commonutil.cpp \
# serial/serialport.cpp \
# ccwidgets/cqlineedit.cpp \
# ccwidgets/cqspinbox.cpp \
# ccwidgets/cqtextedit.cpp \
# ccwidgets/cqwidgetspinbox.cpp \
# util/commonutil.cpp \
httpservice.cpp \
mainconfig.cpp \
websocketservice.cpp \
patientemergencyinfo.cpp
patientemergencyinfo.cpp \
deviceservice.cpp
HEADERS += mainwidget.h \
serial/serialport.h \
ccwidgets/cqlineedit.h \
ccwidgets/cqspinbox.h \
ccwidgets/cqtextedit.h \
ccwidgets/cqwidgetspinbox.h \
util/commonutil.h \
# serial/serialport.h \
# ccwidgets/cqlineedit.h \
# ccwidgets/cqspinbox.h \
# ccwidgets/cqtextedit.h \
# ccwidgets/cqwidgetspinbox.h \
# util/commonutil.h \
httpservice.h \
mainconfig.h \
websocketservice.h \
patientemergencyinfo.h
patientemergencyinfo.h \
deviceservice.h
FORMS += mainwidget.ui
@ -59,4 +68,4 @@ RESOURCES += \
DISTFILES += \
.gitignore \
ReadMe.md \
resttest
api.http

26
QCPShow.pro.user

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.2.1, 2021-10-21T10:14:57. -->
<!-- Written by QtCreator 4.2.1, 2021-10-21T17:16:06. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{0d351c1e-abb6-427c-8d0b-30ca23826ed5}</value>
<value type="QByteArray">{fe03815e-74e2-457e-b60c-e66368cd4ce4}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -66,7 +66,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -90,7 +90,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -106,7 +106,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -144,7 +144,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -160,7 +160,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -198,7 +198,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">构建</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
@ -214,7 +214,7 @@
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">清理</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
@ -231,7 +231,7 @@
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
@ -285,14 +285,14 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">QCPShow</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">QCPShow2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:D:/Qt/QtSpace/qt_qcp_show/QCPShow.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/QtSpace/QCPShow/QCPShow.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">QCPShow.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">D:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">E:/Qt/QtSpace/build-QcpShow-Desktop_Qt_5_8_0_MinGW_32bit-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

47
api.http

@ -0,0 +1,47 @@
GET https://example.com/comments/1 HTTP/1.1
###
GET https://example.com/topics/1 HTTP/1.1
###
# @name signin
POST http://test.tall.wiki/gateway/tall3/v3.0/users/signin HTTP/1.1
content-type: application/json
{
"client": 1,
"data": {
"credential": "123456",
"identifier": "shoufeichu"
},
"scene": 0,
"type": 3
}
###
POST https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern HTTP/1.1
content-type: application/json
Authorization: Bearer {{signin.response.body.$.data.token}}
{
"param":{
"idcard":"142733198703123919",
"name":"彭于晏",
"sex":"1",
"nation":"汉族"
}
}
###
POST https://test.tall.wiki/gateway/qcp/v3.0/button/buttonStart HTTP/1.1
content-type: application/json
Authorization: Bearer {{signin.response.body.$.data.token}}
{
"param":{
"idcard":"142733198703123919"
}
}

93
deviceservice.cpp

@ -0,0 +1,93 @@
#include "deviceservice.h"
#include <QtCore>
#ifdef Q_OS_LINUX
#include <wiringPi.h>
#else
#endif
#define WIRING_PIN_LED 4 //GPIO.4
#define WIRING_PIN_KEY 3 //GPIO.3
#define Click_Overtime 50
DeviceService::DeviceService(QObject *parent) : QObject(parent)
{
key.flag = None;
key.lastState = KEY_Up;
m_ledStatus = 0;
m_keyStatus = 0;
#ifdef Q_OS_LINUX
wiringPiSetup();
pinMode(WIRING_PIN_LED,OUTPUT);//LED输出模式 可选值:INPUT、OUTPUT、PWM_OUTPUT,GPIO_CLOCK
pinMode(WIRING_PIN_KEY,INPUT); //KEY输入模式
pullUpDnControl(WIRING_PIN_KEY,PUD_UP); //KEY设置上拉
#else
qDebug() << "wiringPiSetup()";
qDebug() << "pinMode(WIRING_PIN_LED,OUTPUT)";
qDebug() << "pinMode(WIRING_PIN_BTN,INPUT)";
#endif
timer1.setInterval(1000);
timer1.start();
connect(&timer1,&QTimer::timeout,[=](){
m_ledStatus ^= 1;
ledSet(m_ledStatus);
});
timer2.setInterval(50);
timer2.start();
connect(&timer2,&QTimer::timeout,[=](){
// quint8 keyStatus = keyReadOnce();
// if(keyStatus != m_keyStatus){
// m_keyStatus = keyStatus;
// qDebug() << "m_keyStatus " << m_keyStatus;
// }
key.flag = (KeyFlag)keyDetection();
if(key.flag != None){
if(key.flag == Click){
emit keyClicked();
}
}
});
}
void DeviceService::ledSet(int status)
{
#ifdef Q_OS_LINUX
digitalWrite(WIRING_PIN_LED,status == 1 ? LOW : HIGH);//'HIGH'代表高电平,’LOW‘则为低电平
#else
qDebug() << "LED set: " << status;
#endif
}
/**
* @brief DeviceService::keyReadOnce
* 0,1
* @return
*/
quint8 DeviceService::keyReadOnce()
{
#ifdef Q_OS_LINUX
return digitalRead(WIRING_PIN_KEY);
#else
//qDebug() << "keyReadOnce()";
return KEY_Up;
#endif
}
quint8 DeviceService::keyDetection()
{
key.flag = None; //清空按键标志
quint8 status = keyReadOnce();
if ((status == KEY_Down) && (key.lastState == KEY_Up))
{
uint16_t i = Click_Overtime;
while(i--);
status = keyReadOnce();
if(status == KEY_Down){
key.flag = Click; //先确定按键标志为单击
}
}
key.lastState = status;
return key.flag;
}

46
deviceservice.h

@ -0,0 +1,46 @@
#ifndef DEVICESERVICE_H
#define DEVICESERVICE_H
#include <QObject>
#include <QTimer>
typedef enum{
GPIO_PIN_RESET = 0u,
GPIO_PIN_SET
} GPIO_PinState;
typedef enum{
None = (uint8_t)0,
Click = (uint8_t)1,
Dbl_Click = (uint8_t)2,
Tri_Click = (uint8_t)3,
Press = (uint8_t)4,
}KeyFlag;
#define KEY_Up 1
#define KEY_Down 0
typedef struct{
KeyFlag flag;
quint8 lastState;
}KeyType;
class DeviceService : public QObject
{
Q_OBJECT
public:
explicit DeviceService(QObject *parent = 0);
private:
KeyType key;
int m_ledStatus,m_keyStatus;
QTimer timer1,timer2;
signals:
void keyClicked();
public slots:
void ledSet(int status);
quint8 keyReadOnce();
quint8 keyDetection();
};
#endif // DEVICESERVICE_H

14
httpservice.cpp

@ -103,6 +103,7 @@ QByteArray HttpService::postJson(QUrl url,const QByteArray &json, quint32 timeou
result = reply->readAll();
}
}
qDebug() << result;
return result;
}
@ -114,7 +115,6 @@ void HttpService::login(QString username, QString password)
//发送请求
QByteArray result = postJson(MainConfig::loginUrl,json.toUtf8());
qDebug() << result;
//解析响应
QJsonParseError jerror;
@ -144,7 +144,6 @@ void HttpService::updateStatus(QString firstAidId, QString status)
//发送请求
QByteArray result = postJson(MainConfig::serviceStatusChangedUrl,json.toUtf8());
qDebug() << result;
//解析响应
QJsonParseError jerror;
@ -173,7 +172,6 @@ void HttpService::sendIdcardInfo(QString idcard,QString name, QString sex, QStri
//发送请求
QByteArray result = postJson(MainConfig::sendUserInfoUrl,json.toUtf8());
qDebug() << result;
//解析响应
QJsonParseError jerror;
@ -201,8 +199,7 @@ void HttpService::oneKeyStart(QString idcard)
QString json = rawJson.arg(idcard);
//发送请求
QByteArray result = postJson(MainConfig::sendUserInfoUrl,json.toUtf8());
qDebug() << result;
QByteArray result = postJson(MainConfig::oneKeyStartUrl,json.toUtf8());
//解析响应
QJsonParseError jerror;
@ -222,3 +219,10 @@ void HttpService::oneKeyStart(QString idcard)
qDebug() << "oneKeyStart失败:" << resCode;
}
}
void HttpService::onComplexOneKeyStart(QString idcard, QString name, QString sex, QString nation)
{
qDebug() << "onComplexOneKeyStart" << idcard << name << sex << nation;
sendIdcardInfo(idcard,name,sex,nation);
oneKeyStart(idcard);
}

1
httpservice.h

@ -21,6 +21,7 @@ public slots:
void updateStatus(QString firstAidId,QString status);
void sendIdcardInfo(QString idcard,QString name,QString sex,QString nation);
void oneKeyStart(QString idcard);
void onComplexOneKeyStart(QString idcard,QString name,QString sex,QString nation);
};
#endif // HTTPSERVICE_H

20
main.cpp

@ -4,11 +4,15 @@
#include "httpservice.h"
#include "websocketservice.h"
#include "patientemergencyinfo.h"
#include "deviceservice.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//切换当前工作目录
QDir::setCurrent(QCoreApplication::applicationDirPath());
//初始化配置文件
MainConfig::initConfig();
@ -20,21 +24,27 @@ int main(int argc, char *argv[])
WebsocketService websocketService;
websocketService.connectToServer(MainConfig::wsUrl);
//初始化DeviceInfo,并自动初始化IO配置
DeviceService deviceService;
//创建主窗体
MainWidget w;
//绑定信号与槽
QObject::connect(&websocketService,&WebsocketService::wsConnectedStatusChanged,
&w,&MainWidget::onWsConnectedStatusChanged);
&w,&MainWidget::onWsConnectedStatusChanged);
QObject::connect(&websocketService,&WebsocketService::newPatientMergencyInfo,
&w,&MainWidget::onNewPatientMergencyInfo);
&w,&MainWidget::onNewPatientMergencyInfo);
QObject::connect(&websocketService,&WebsocketService::patientMergencyStatusChanged,
&w,&MainWidget::onPatientMergencyStatusChanged);
&w,&MainWidget::onPatientMergencyStatusChanged);
QObject::connect(&deviceService,&DeviceService::keyClicked,
&w,&MainWidget::onKeyClicked);
QObject::connect(&w,&MainWidget::statusChanged,&httpService,&HttpService::updateStatus);
QObject::connect(&w,&MainWidget::complexOneKeyStart,&httpService,&HttpService::onComplexOneKeyStart);
// w.show();
w.showFullScreen();
w.show();
// w.showFullScreen();
return a.exec();
}

2
mainconfig.cpp

@ -5,7 +5,7 @@
#define D_CONFIG_FILE_PATH "./setting.ini"
QString MainConfig::token = "";
QString MainConfig::username = "shoufeichu";
QString MainConfig::username = "fenzhentai";
QString MainConfig::password = "123456";
QString MainConfig::loginUrl = "http://test.tall.wiki/gateway/tall3/v3.0/users/signin";
QString MainConfig::sendUserInfoUrl = "https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern";

65
mainwidget.cpp

@ -3,6 +3,10 @@
#include <QtCore>
#include "mainconfig.h"
#define NAMELIST_LENGTH 4
QString namelist[] = {"传立春","传立夏","传立秋","传立冬"};
qint8 gindex = 0;
MainWidget::MainWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MainWidget)
@ -48,9 +52,9 @@ MainWidget::MainWidget(QWidget *parent) :
ui->textLabel->setStyleSheet("QLabel {color: rgb(255,0,0);}");//设置文本红色
ui->countdownLabel->setStyleSheet("QLabel {color: rgb(255,0,0);}");//设置文本红色
ui->statusLabel->setStyleSheet("QLabel {color: rgb(85,255,0);}");//设置文本绿色
// ui->textLabel->setAlignment(Qt::AlignHCenter);
// ui->countdownLabel->setAlignment(Qt::AlignHCenter);
// ui->statusLabel->setAlignment(Qt::AlignRight);
// ui->textLabel->setAlignment(Qt::AlignHCenter);
// ui->countdownLabel->setAlignment(Qt::AlignHCenter);
// ui->statusLabel->setAlignment(Qt::AlignRight);
m_curX = 0;
connect(&m_lableScrollTimer,SIGNAL(timeout()),this,SLOT(lableScrollDisplay()));
@ -67,10 +71,10 @@ void MainWidget::updateUi()
m_curX = 0;//内容超出显示区域时,更新患者信息显示从头开始滚动
//更新statusLabel
// ui->statusLabel->setText(QString("%1 | %2")
// .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接")
// .arg(m_patientEmergencyInfos.length())
// );
// ui->statusLabel->setText(QString("%1 | %2")
// .arg(m_wsConnectedStatus == 0 ? "未连接" : "已连接")
// .arg(m_patientEmergencyInfos.length())
// );
if(m_wsConnectedStatus){
ui->LEDLabel->setStyleSheet("border-image: url(:/image/1LED_green.png);");
}else{
@ -95,13 +99,18 @@ void MainWidget::updateUi()
ui->textLabel->setText(pInfo->text);
//显示倒计时
int hour,min,sec,nTotalSecs;
nTotalSecs = pInfo->realCountDownInSeconds;
sec = nTotalSecs % 60;
// min = nTotalSecs / 60 % 60;
min = nTotalSecs / 60 ; //min显示大于60
hour = nTotalSecs / 3600;
QString str = QString("%1:%2").arg(min,2,10,QLatin1Char('0')).arg(sec,2,10,QLatin1Char('0'));
QString str = "";
if(pInfo->realCountDownInSeconds < 0){
str = "";
}else{
int hour,min,sec,nTotalSecs;
nTotalSecs = pInfo->realCountDownInSeconds;
sec = nTotalSecs % 60;
// min = nTotalSecs / 60 % 60;
min = nTotalSecs / 60 ; //min显示大于60
hour = nTotalSecs / 3600;
str = QString("%1:%2").arg(min,2,10,QLatin1Char('0')).arg(sec,2,10,QLatin1Char('0'));
}
ui->countdownLabel->setText(str);
}
@ -110,7 +119,7 @@ void MainWidget::paintEvent(QPaintEvent *event)
//设置背景图片
QPainter p(this);
p.drawPixmap(0,0,this->width(),this->height(),QPixmap(":/image/black_bg.jpg"));
// qDebug() << "MainWidget::paintEvent";
// qDebug() << "MainWidget::paintEvent";
//重新调整label字体大小
//TODO
@ -121,7 +130,7 @@ void MainWidget::resizeEvent(QResizeEvent *event)
QWidget::resizeEvent(event);
//标题
// ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2);
// ui->textLabel->setGeometry(0,0,this->width(),(this->height()-30)/2);
ui->countdownLabel->setGeometry(0,(this->height()-30)/2,this->width(),(this->height()-30)/2);
ui->LEDLabel->setGeometry(this->width()-120,this->height()-30,20,30);
ui->statusLabel->setGeometry(this->width()-80,this->height()-30,20,30);
@ -137,7 +146,7 @@ void MainWidget::lableScrollDisplay()
else{
m_curX ++;
ui->textLabel->setGeometry(20-m_curX,0,m_width,(this->height()-30)/2);
// qDebug()<<"move" <<m_curX;
// qDebug()<<"move" <<m_curX;
}
if(m_curX > (m_width - this->width())){
m_curX = 0;
@ -152,7 +161,7 @@ void MainWidget::onWsConnectedStatusChanged(int status)
updateUi();
}
void MainWidget::onNewPatientMergencyInfo(QString firstAidId, QString name, QString content, quint64 realCountDownInSeconds)
void MainWidget::onNewPatientMergencyInfo(QString firstAidId, QString name, QString content, qint64 realCountDownInSeconds)
{
//TODO 此处是否需要加锁处理
PatientEmergencyInfo *pInfo = new PatientEmergencyInfo(firstAidId,name,content,realCountDownInSeconds);
@ -181,6 +190,16 @@ void MainWidget::onPatientMergencyStatusChanged(QString firstAidId,QString time,
}
}
void MainWidget::onKeyClicked()
{
emit complexOneKeyStart("142733198703123918",::namelist[::gindex],"1","汉族");
qDebug() << "Key Clicked";
if(++::gindex >= NAMELIST_LENGTH){
::gindex = 0;
}
}
void MainWidget::addPatientToList(PatientEmergencyInfo *info)
{
//1.如果有就删除,以保证同一个病人按两次应该重新开始计时
@ -206,3 +225,13 @@ void MainWidget::deletePatientFromList(QString firstAidId)
}
}
}
void MainWidget::mouseDoubleClickEvent(QMouseEvent *event)
{
if(event->button()==Qt::LeftButton){
//TODO
}
else if(event->button()==Qt::RightButton){
onKeyClicked();
}
}

8
mainwidget.h

@ -19,6 +19,7 @@ public:
~MainWidget();
void paintEvent(QPaintEvent *event);
void resizeEvent(QResizeEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
private:
Ui::MainWidget *ui;
@ -35,14 +36,19 @@ private:
public slots:
void updateUi();
void onWsConnectedStatusChanged(int);
void onNewPatientMergencyInfo(QString firstAidId,QString name,QString content,quint64 realCountDownInSeconds);
void onNewPatientMergencyInfo(QString firstAidId,QString name,QString content,qint64 realCountDownInSeconds);
void onPatientMergencyStatusChanged(QString firstAidId,QString time,QString status);
void addPatientToList(PatientEmergencyInfo *);
void deletePatientFromList(QString firstAidId);
void lableScrollDisplay();
void onKeyClicked();
signals:
void statusChanged(QString firstAidId,QString status);
void complexOneKeyStart(QString idcard,QString name,QString sex,QString nation);
void sendCardInfo(QString idcard,QString name,QString sex,QString nation);
void oneKeyStart(QString idcard);
};
#endif // MAINWIDGET_H

2
patientemergencyinfo.h

@ -13,7 +13,7 @@ public:
QString id;
QString name;
QString text;
quint64 realCountDownInSeconds;
qint64 realCountDownInSeconds;
signals:

9
resttest

@ -1,9 +0,0 @@
https://example.com/comments/1
POST https://example.com/comments HTTP/1.1
content-type: application/json
{
"name": "sample",
"time": "Wed, 21 Oct 2015 18:27:50 GMT"
}

27
setting.ini

@ -0,0 +1,27 @@
[MAIN]
;最大患者数量
maxPatientNum = 5
;切换病人时间(s)
switchPatientInterval = 5
[USER]
;登录用户名
username = shoufeichu
;登录密码
password = 123456
[HTTP]
;登录请求URL
loginUrl = http://test.tall.wiki/gateway/tall3/v3.0/users/signin
;发送身份证信息URL
sendUserInfoUrl = https://test.tall.wiki/gateway/qcp/v3.0/button/idCardDiscern
;一键启动URL
oneKeyStartUrl = https://test.tall.wiki/gateway/qcp/v3.0/button/buttonStart
;服务状态改变URL(rgb)
serviceStatusChangedUrl = https://test.tall.wiki/gateway/qcp/v3.0/button/updateStatus
[WEBSOCKET]
;Websocket URL
wsUrl = wss://test.tall.wiki/websocket/message/v4.0/ws
;Websocket心跳间隔(s)
wsHeartInterval = 10

11
websocketservice.cpp

@ -43,7 +43,7 @@ void WebsocketService::wsSendAuthMsg()
QString rawJson = "{\"toDomain\":\"Server\",\"data\":\"{\\\"type\\\":\\\"Auth\\\",\\\"data\\\":{\\\"token\\\":\\\"%1\\\"}}\"}";
QString json = rawJson.arg(MainConfig::token);
m_webSocket.sendTextMessage(json);
qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "wsSendAuthMsg: " << json;
//qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "wsSendAuthMsg: " << json;
}
void WebsocketService::wsSendPingMsg()
@ -56,7 +56,7 @@ void WebsocketService::wsSendPingMsg()
QString rawJson = "{\"toDomain\":\"Server\",\"data\":\"{\\\"type\\\":\\\"Ping\\\"}\"}";
QString json = rawJson;
m_webSocket.sendTextMessage(json);
qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "wsSendPingMsg: " << json;
//qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "wsSendPingMsg: " << json;
}
void WebsocketService::sendWsAckMessage(QString ackId)
@ -65,12 +65,13 @@ void WebsocketService::sendWsAckMessage(QString ackId)
QString rawJson = "{\"toDomain\":\"Server\",\"data\":\"{\\\"type\\\":\\\"Ack\\\",\\\"data\\\":{\\\"ackId\\\":\\\"%1\\\"}}\"}";
QString json = rawJson.arg(ackId);
m_webSocket.sendTextMessage(json);
//qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "sendWsAckMessage: " << json;
}
void WebsocketService::onTextMessageReceived(const QString &message)
{
qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "wsRecvMsg: " << message.toUtf8();
//qDebug() << QDateTime::currentDateTime().toString("hh:mm:ss") << "wsRecvMsg: " << message.toUtf8();
//解析响应中的data字段,data又是一个json字符串
QJsonParseError jerror;
QJsonDocument jdoc;
@ -109,7 +110,7 @@ void WebsocketService::onTextMessageReceived(const QString &message)
}else if(notifyType == "Pong"){
qDebug() << "Pong Message";
}else if(notifyType == "ChannelStatus"){
qDebug() << "Auth Message";
//qDebug() << "Auth Message";
}
}
@ -119,7 +120,7 @@ void WebsocketService::handleWsButtonStartMsg(QJsonObject jobj)
QString firstAidId = jobj.take("firstAidId").toString();
QString name = jobj.take("name").toString();
QString content = jobj.take("content").toString();
quint64 realCountdown = jobj.take("realCountdown").toString().toInt(0) / 1000;
qint64 realCountdown = jobj.take("realCountdown").toString("-1000").toInt(0) / 1000;
emit newPatientMergencyInfo(firstAidId,name,content,realCountdown);
}

2
websocketservice.h

@ -25,7 +25,7 @@ private:
signals:
void wsConnectedStatusChanged(int);
//void newPatientMergencyInfo(PatientEmergencyInfo *);
void newPatientMergencyInfo(QString firstAidId,QString name,QString content,quint64 realCountDownInSeconds);
void newPatientMergencyInfo(QString firstAidId,QString name,QString content,qint64 realCountDownInSeconds);
void patientMergencyStatusChanged(QString firstAidId,QString time,QString status);
public slots:
void onConnected();

Loading…
Cancel
Save