11/25
This commit is contained in:
29
ZBD_IIIDL_S_Project/Src/DataFormate/dataformate.cpp
Normal file
29
ZBD_IIIDL_S_Project/Src/DataFormate/dataformate.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "dataformate.h"
|
||||
#include <QTime>
|
||||
#include <QCoreApplication>
|
||||
void Pressure_CheckCRC(uint8_t*buf,int len,uint8_t* CRC_H,uint8_t* CRC_L)
|
||||
{
|
||||
uint16_t i,j,tmp,CRC16;
|
||||
CRC16=0xffff;
|
||||
for (i=0;i<len;i++)
|
||||
{
|
||||
CRC16=*buf^CRC16;
|
||||
for (j=0;j< 8;j++)
|
||||
{
|
||||
tmp=CRC16 & 0x0001;
|
||||
CRC16 =CRC16 >>1;
|
||||
if (tmp)
|
||||
CRC16=CRC16 ^ 0xA001;
|
||||
}
|
||||
*buf++;
|
||||
}
|
||||
CRC_H[0]=CRC16>>8;
|
||||
CRC_L[0]=CRC16&0xff;
|
||||
}
|
||||
|
||||
void Sleep(int msec)
|
||||
{
|
||||
QTime dieTime = QTime::currentTime().addMSecs(msec);
|
||||
while( QTime::currentTime() < dieTime )
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
|
||||
}
|
||||
386
ZBD_IIIDL_S_Project/Src/DataFormate/dataformate.h
Normal file
386
ZBD_IIIDL_S_Project/Src/DataFormate/dataformate.h
Normal file
@@ -0,0 +1,386 @@
|
||||
#ifndef DATAFORMATE_H
|
||||
#define DATAFORMATE_H
|
||||
#include <QWidget>
|
||||
#define PAGENUM 8 //每页显示数量
|
||||
#define MAXSHOWNUM 1000 //最大显示数量
|
||||
#define PERCOUNT 8 //用户每页显示数量
|
||||
//上位机发送使用
|
||||
#define PACKHEAD 0xAB //帧头
|
||||
#define PACKTAIL 0xCD //帧尾
|
||||
//下位机发送使用
|
||||
#define SLAVEPACKHEAD 0xBA
|
||||
#define SLAVEPACKTAIL 0xDC
|
||||
|
||||
#define FRAME_HEAD 0xAA
|
||||
#define FRAME_END 0x55
|
||||
typedef enum
|
||||
{
|
||||
E_NEW_USER = 0,
|
||||
E_EDIT_USER
|
||||
}USER_ENUM;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ONLY_FES_E = 0,
|
||||
BICYCLE_FES_E
|
||||
}E_FES_PAGE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
Chinese_E,
|
||||
English_E
|
||||
}E_LANGUAGE;
|
||||
|
||||
//通信状态
|
||||
typedef enum
|
||||
{
|
||||
UnconnectedState_E = 0,
|
||||
HostLookupState_E,
|
||||
ConnectingState_E,
|
||||
ConnectedState_E,
|
||||
BoundState_E,
|
||||
ClosingState_E,
|
||||
ListeningState_E
|
||||
|
||||
}E_DeviceState;
|
||||
|
||||
//页面切换
|
||||
typedef enum
|
||||
{
|
||||
MainPage_E = 0, //主界面
|
||||
TrainingPage_E, //训练界面
|
||||
UserPage_E, //用户界面
|
||||
SettingPage_E, //设置界面
|
||||
BicycleParamSet_E, //踏车参数设置界面
|
||||
FesParamSet_E, //fes设置界面
|
||||
FesBicycleParamSet_E, //FesT踏车设置界面
|
||||
BicycleToFes_E, //从踏车界面到FES界面
|
||||
TrainingParamSetting_E, //从肢体训练界面,进入参数设置
|
||||
BrainTraining, //脑电训练
|
||||
visionTrain //视觉训练
|
||||
//LoginPage_E //切换到登录页面
|
||||
}E_PAGENAME;
|
||||
|
||||
//上位机发送指令
|
||||
typedef enum
|
||||
{
|
||||
BICYCLE_PARAM_CMD = 0x01, //启动前参数
|
||||
REALTIME_PARAM_CMD = 0x02, //实时调节参数
|
||||
SEND_HEARTBEAT_CMD = 0X05, //发送心跳(启用)
|
||||
GET_VERSION_CMD = 0X08 //获取版本号
|
||||
}E_SENDCMDID;
|
||||
|
||||
//游戏训练状态
|
||||
typedef enum
|
||||
{
|
||||
START = 0x01, //运行
|
||||
PAUSE = 0x02, //暂停
|
||||
STOP = 0x03 //停止
|
||||
}E_TRAINSTATE;
|
||||
|
||||
//接收下位机指令
|
||||
typedef enum
|
||||
{
|
||||
BRFORE_START_CMD = 0x00, //启动前
|
||||
AFTER_START_CMD = 0x01, //启动后
|
||||
RECE_HEARTBEAT_CMD = 0x02 //接收心跳(启用)
|
||||
}E_RECECMDID;
|
||||
|
||||
//实时调节参数子指令
|
||||
typedef enum
|
||||
{
|
||||
RESISTANCE_CMD = 0x01, //阻力
|
||||
PASSIVE_SPEED = 0x02, //被动转速
|
||||
SPASM_LEVEL = 0x03, //痉挛等级
|
||||
SWITCH_DIRECTION = 0x04,//手动换向
|
||||
EQUAL_SPEED = 0x08, //等速转速
|
||||
SYNERGY_SPEED = 0x09, //协同限速
|
||||
SPASM_CONFIRM = 0x10, //确认痉挛
|
||||
TUIGAN_UPDOWN = 0x11, //推杆响应 1-up 2-down
|
||||
YIJIAN_SHANGJI = 0x12 //一键上机
|
||||
|
||||
}E_REALTIMECMD;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CMD_PARAM_SET_E = 0x71, //单独电刺激参数设置
|
||||
CMD_CHANNEL_CONTROL =0x72, //电刺激控制0-关闭 1-开启 2-暂停 3-继续
|
||||
PreCurrentSet_E = 0x73, //预设电流设置
|
||||
PreCurrentSwitch = 0x76, //预设电流控制开关
|
||||
CMD_QUERY_STATE_E = 0x78, //查询各个电刺激模块状态
|
||||
CMD_TURNOFF_E = 0x7A, //关机(断开)
|
||||
CMD_SEARCH_DEVICE_E = 0x7B, //设备搜索
|
||||
CMD_DEVICE_REPORT_E = 0x7C, //新设备上报
|
||||
CMD_DEVICE_CONNECT_E = 0x7D, //连接设备
|
||||
CMD_DEVICE_DISCONNECT_E = 0X7E, //设备断开,蓝牙断开(下->上)
|
||||
RealTimeParam_E = 0x80, //实时参数
|
||||
FESParamSet_E = 0x81, //fes参数
|
||||
//CMD_BATTERY_LEVAL = 0x82 //接收显示电量
|
||||
FES_PRE_FREQUENCY = 0x7F, //预设频率
|
||||
FES_PRE_BINDWIDTH = 0x70 //预设脉宽
|
||||
|
||||
}E_FESCMD;
|
||||
|
||||
|
||||
//串口配置
|
||||
typedef struct ST_SerialPortConfig
|
||||
{
|
||||
QString portName; //端口名
|
||||
int32_t baud; //波特率
|
||||
int8_t dataBits; //数据位
|
||||
int8_t parity; //奇偶校验
|
||||
int8_t stopBit; //停止位
|
||||
int8_t flowControl; //流控
|
||||
ST_SerialPortConfig()
|
||||
{
|
||||
portName = "";
|
||||
baud = 0;
|
||||
dataBits = 0;
|
||||
parity = 0;
|
||||
stopBit = 0;
|
||||
flowControl = 0;
|
||||
}
|
||||
|
||||
}ST_SerialPortConfig;
|
||||
|
||||
//数据库配置
|
||||
typedef struct ST_DataBaseConfig
|
||||
{
|
||||
QString IP;
|
||||
int16_t port;
|
||||
QString userName; //用户名
|
||||
QString password; //密码
|
||||
ST_DataBaseConfig()
|
||||
{
|
||||
IP = "";
|
||||
port = 0;
|
||||
userName = "";
|
||||
password = "";
|
||||
}
|
||||
|
||||
}ST_DataBaseConfig;
|
||||
|
||||
|
||||
//FES参数中按钮显示
|
||||
typedef struct
|
||||
{
|
||||
QString muscleName; //肌肉名
|
||||
int muscleId; //肌肉下标(根据下标可判断左右)
|
||||
bool connectState; //连接状态
|
||||
int frequency; //频率
|
||||
int plus; //脉宽
|
||||
int minCurrent; //最小电流
|
||||
int maxCurrent; //最小电流
|
||||
}ST_MuscleParam;
|
||||
|
||||
//高级设置参数
|
||||
typedef struct
|
||||
{
|
||||
//预热阶段
|
||||
int preheatContinueTime; //预热期持续时间 0~60min step-1
|
||||
int preheatAContinueTime; //加速持续时间 0~60min step-1
|
||||
int preheatCompensate; //转速补偿 -30~30 step-1
|
||||
bool isFesOn; //是否开启电刺激
|
||||
int preheatMaxPower; //预热期最大电量 0~50% step-1%
|
||||
int transitionalFesRise; //电刺激上升幅度 1~100% step-1%
|
||||
//积极阶段
|
||||
int positiveFChiXuTime; //向前(持续时间)0~120min step-1
|
||||
int positiveFControlSpeed; //向前(控制速度) 5~60r/min step-1
|
||||
int positiveBChiXuTime; //(向后)持续时间 0~120min step-1
|
||||
int positiveBSpeedCompensate;//(向后)转速补偿 -30~30r/min step-1
|
||||
int positiveBresistance; //(向后)阻力扭矩补偿 -20~20Nm step-1
|
||||
int timeLimit; //时间阈值 0~240s step-1s
|
||||
int speedLimit; //转速阈值 -1~-50r/min step-1
|
||||
//消极阶段
|
||||
bool isSkipPassive; //跳过此阶段
|
||||
int negativeSpeedCompensate; //(向前)转速补偿 -30~30r/min step-1
|
||||
int tiredContinueTime; //持续时间(疲劳侦测) 0~30min
|
||||
int tiredSpeedCompensate; //转速补偿(疲劳侦测) -30~0 step-1
|
||||
}ST_AdvancedParam;
|
||||
|
||||
/**********与下位机通信--start**********/
|
||||
//踏车参数
|
||||
#pragma pack(push) // 保存原来的字节对齐方式
|
||||
#pragma pack(1)
|
||||
|
||||
//启动前参数
|
||||
typedef struct
|
||||
{
|
||||
int8_t controlState;//状态控制 0-停止 1启动 2-暂停 3-继续
|
||||
int8_t bodyPart; //训练部位 0-上肢 1-下肢 2-四肢 3-垂直上肢
|
||||
int8_t trainMode; //训练模式 0-被动 1-主动 2-助力 3-等速 4-上下肢协同被动 7-四肢主被动 9-单独主动 10-被动可切主动(主被动)
|
||||
int8_t spasmSwitch; //痉挛开关 0-关 1-开
|
||||
int8_t spasmLevel; //痉挛等级1~3挡
|
||||
int8_t configPower; //配置功率0~2 低中高
|
||||
int8_t switchDirectonTime;//换向时间
|
||||
int8_t phaseValue; //协同相位值
|
||||
int8_t direction; //方向 0-逆向 1-正向
|
||||
int8_t speed; //速度 2~60r/min
|
||||
int8_t resistance; //阻力 Nm 0~20挡
|
||||
int8_t spasmType; //痉挛后方向 1-正向 0-逆向,默认逆向,没有了
|
||||
uint8_t trainTime; //训练时间 0~120min
|
||||
|
||||
}ST_BicycleParam;
|
||||
|
||||
//下位机上传参数
|
||||
typedef struct
|
||||
{
|
||||
int8_t currentMode; //当前模式
|
||||
int8_t direction; //方向 0-反向 1-正向
|
||||
uint8_t downLimpSpeed; //下肢速度
|
||||
uint8_t upLimpSpeed; //上肢速度
|
||||
uint16_t leftHandPosition; //左手位置
|
||||
uint16_t leftFootPosition; //左脚位置
|
||||
uint16_t rightHandPosition; //右手位置
|
||||
uint16_t rightFootPosition; //右脚位置
|
||||
int8_t upBalance; //上肢平衡度
|
||||
int8_t downBalance; //下肢平衡度
|
||||
uint16_t upLimpCircle; //上肢圈数
|
||||
uint16_t downLimpCircle; //下肢圈数
|
||||
int8_t emergencyState; //急停 1-触发 0-未触发
|
||||
int8_t spasmState; //痉挛 1-触发 0-未触发
|
||||
int8_t error; //系统故障
|
||||
int8_t oxygen; //血氧数据
|
||||
int8_t overSpeedProtect; //过速保护 0-正常 1-触发
|
||||
uint16_t upPower; //上肢功率
|
||||
uint16_t downPower; //下肢功率
|
||||
uint32_t energy; //能量
|
||||
}ST_DeviceParam;
|
||||
|
||||
#pragma pack(pop) // 恢复字节对齐方式
|
||||
/**********与下位机通信--end**********/
|
||||
|
||||
//脉搏血氧
|
||||
typedef struct
|
||||
{
|
||||
int pulse;//脉搏
|
||||
int oxygen;//血氧
|
||||
}ST_PulseOxygen;
|
||||
|
||||
//游戏界面显示参数
|
||||
typedef struct
|
||||
{
|
||||
int type; //0-上肢 1-下肢
|
||||
int updown; //方向1-正向 0-逆向
|
||||
int power; //阻力
|
||||
int speed; //速度
|
||||
}ST_SetBicycleParam;
|
||||
|
||||
#pragma pack(push) //保存对齐状态
|
||||
#pragma pack(1)//设定为1字节对齐
|
||||
//设置参数
|
||||
typedef struct
|
||||
{
|
||||
uint8_t mode; //模式 1-采集 2-刺激 3-触发
|
||||
uint8_t sampleRate; //采样率 1-4K 2-8K
|
||||
uint8_t waveStyle; //波形 01-双向对称方波
|
||||
uint16_t frequency; //频率
|
||||
uint16_t pulseWidth; //脉宽
|
||||
uint16_t startAngle; //开始角度(正)
|
||||
uint16_t stopAgnle; //结束角度(正)
|
||||
|
||||
uint16_t startAngleReverse; //开始角度(反)
|
||||
uint16_t stopAgnleReverse; //结束角度(反)
|
||||
|
||||
uint8_t minCurrent; //最小电流
|
||||
uint16_t maxCurrent; //最大电流
|
||||
uint8_t upDownLimp; // 1-上 2-下
|
||||
uint8_t leftRightLimp;//1-左 2-右
|
||||
}ST_FESSetParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t mode;//模式 1-采集 2-刺激 3-触发
|
||||
uint8_t sampleRate; //采样率 1-4K 2-8K
|
||||
uint8_t waveStyle; //波形 01-双向对称方波
|
||||
uint16_t frequency; //频率
|
||||
uint16_t pulseWidth;//脉宽
|
||||
uint16_t waveRise; //波升
|
||||
uint16_t keepTime; //保持
|
||||
uint16_t waveFall; //波降
|
||||
uint16_t sleepTime; //休息
|
||||
}ST_OnlyFESParam;
|
||||
//实时参数
|
||||
typedef struct
|
||||
{
|
||||
uint8_t upSpeed; //1~60rmp/min
|
||||
uint8_t downSpeed; //1~60rmp/min
|
||||
uint16_t currentUpAngle;//实时角度0~360
|
||||
uint16_t currentDownAngle;
|
||||
uint8_t direction; //方向 0-逆 1-正
|
||||
}ST_FESRealTimeParam;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int muscleId; //肌肉ID
|
||||
QString muscleName; //肌肉名称
|
||||
int startAngle; //起始角度
|
||||
int stopAngle; //停止角度
|
||||
}ST_RecipeParam;
|
||||
|
||||
//电刺激盒状态
|
||||
typedef struct
|
||||
{
|
||||
uint8_t channle1State; //通道1状态 0-脱落 1-连接
|
||||
uint8_t channle2State;
|
||||
uint8_t power;
|
||||
|
||||
}ST_FESDeviceState;
|
||||
|
||||
#pragma pack(pop)//恢复对齐状态
|
||||
|
||||
//游戏相关参数
|
||||
//更改游戏配置文件的参数(通信文件)
|
||||
typedef struct ST_GameParam
|
||||
{
|
||||
int hardLevel; //难度等级 1-3(此处的难度等级对应范围大小)
|
||||
int gameTime; //游戏运行时间 单位/s
|
||||
int speed; //运行速度 1-5
|
||||
int trainingMode; //训练类型
|
||||
QString trainTrackFilePath; //路径文件
|
||||
bool readPosTable; //是否去读轨迹
|
||||
int angleValue; //分段运动角度
|
||||
int trainType; //被动训练类型1-圆周 2-分段
|
||||
int waitTime; //等待时间
|
||||
int maxCircle; //最大圈数
|
||||
ST_GameParam()
|
||||
{
|
||||
hardLevel = 1;
|
||||
gameTime = 0;
|
||||
speed = 3;
|
||||
trainingMode = 0;
|
||||
trainTrackFilePath = "";
|
||||
readPosTable = false;
|
||||
}
|
||||
}ST_GameParam;
|
||||
|
||||
//该结构体用于读取游戏列表
|
||||
typedef struct
|
||||
{
|
||||
int gameID; //游戏ID
|
||||
QString gamePath; //游戏路径
|
||||
QString iconPath; //游戏图标路径
|
||||
QString gameName; //游戏可执行文件名
|
||||
QString className; //窗口类名
|
||||
QString windownName; //窗口名
|
||||
}ST_GameMsg;
|
||||
|
||||
//游戏控制参数
|
||||
typedef struct
|
||||
{
|
||||
int MsgId; //消息ID
|
||||
int ID; //用户ID
|
||||
QString userName;//用户名
|
||||
float speed; //速度
|
||||
int forceLeft; //左平衡
|
||||
int forceRight; //右平衡
|
||||
int angle; //角度
|
||||
}ST_GameControlParam;
|
||||
|
||||
|
||||
|
||||
extern void Pressure_CheckCRC(uint8_t*buf,int len,uint8_t* CRC_H,uint8_t* CRC_L);
|
||||
extern void Sleep(int msec);
|
||||
|
||||
#endif // DATAFORMATE_H
|
||||
224
ZBD_IIIDL_S_Project/Src/DataFormate/dbforrmate.cpp
Normal file
224
ZBD_IIIDL_S_Project/Src/DataFormate/dbforrmate.cpp
Normal file
@@ -0,0 +1,224 @@
|
||||
#include "dbforrmate.h"
|
||||
#include <QUuid>
|
||||
|
||||
ST_PatientMsg variantMapToPatientMsg(QVariantMap vMap)
|
||||
{
|
||||
ST_PatientMsg st_PatientMsg;
|
||||
if(vMap.contains("ID"))
|
||||
st_PatientMsg.ID = vMap.value("ID").toUInt();
|
||||
if(vMap.contains("name"))
|
||||
st_PatientMsg.name = vMap.value("name").toString();
|
||||
if(vMap.contains("phone"))
|
||||
st_PatientMsg.phone = vMap.value("phone").toString();
|
||||
if(vMap.contains("sex"))
|
||||
st_PatientMsg.sex = vMap.value("sex").toUInt();
|
||||
if(vMap.contains("birthday"))
|
||||
st_PatientMsg.birthday = vMap.value("birthday").toDate();
|
||||
if(vMap.contains("bodyIndex"))
|
||||
st_PatientMsg.bodyIndex = vMap.value("bodyIndex").toInt();
|
||||
if(vMap.contains("markMsg"))
|
||||
st_PatientMsg.markMsg = vMap.value("markMsg").toString();
|
||||
if(vMap.contains("age"))
|
||||
st_PatientMsg.age = vMap.value("age").toUInt();
|
||||
return st_PatientMsg;
|
||||
}
|
||||
|
||||
ST_TrainReport variantMapToTrainReport(QVariantMap vMap)
|
||||
{
|
||||
ST_TrainReport st_TrainReport;
|
||||
if(vMap.contains("UUID"))
|
||||
st_TrainReport.UUID = vMap.value("UUID").toString();
|
||||
if(vMap.contains("ID"))
|
||||
st_TrainReport.ID = vMap.value("ID").toInt();
|
||||
if(vMap.contains("name"))
|
||||
st_TrainReport.name = vMap.value("name").toString();
|
||||
if(vMap.contains("sex"))
|
||||
st_TrainReport.sex = vMap.value("sex").toInt();
|
||||
if(vMap.contains("phone"))
|
||||
st_TrainReport.phone = vMap.value("phone").toString();
|
||||
if(vMap.contains("age"))
|
||||
st_TrainReport.age = vMap.value("age").toUInt();
|
||||
if(vMap.contains("trainMode"))
|
||||
st_TrainReport.trainMode = vMap.value("trainMode").toInt();
|
||||
if(vMap.contains("bodyIndex"))
|
||||
st_TrainReport.bodyIndex = vMap.value("bodyIndex").toInt();
|
||||
if(vMap.contains("markMsg"))
|
||||
st_TrainReport.markMsg = vMap.value("markMsg").toString();
|
||||
if(vMap.contains("trainTime"))
|
||||
st_TrainReport.trainTime = vMap.value("trainTime").toInt();
|
||||
if(vMap.contains("leftBalance"))
|
||||
st_TrainReport.leftBalance = vMap.value("leftBalance").toInt();
|
||||
if(vMap.contains("rightBalance"))
|
||||
st_TrainReport.rightBalance = vMap.value("rightBalance").toInt();
|
||||
if(vMap.contains("upLimpLength"))
|
||||
st_TrainReport.upLimpLength = vMap.value("upLimpLength").toFloat();
|
||||
if(vMap.contains("downLimpLength"))
|
||||
st_TrainReport.downLimpLength = vMap.value("downLimpLength").toFloat();
|
||||
if(vMap.contains("passiveTime"))
|
||||
st_TrainReport.passiveTime = vMap.value("passiveTime").toInt();
|
||||
if(vMap.contains("activeTime"))
|
||||
st_TrainReport.activeTime = vMap.value("activeTime").toInt();
|
||||
if(vMap.contains("spasmTimes"))
|
||||
st_TrainReport.spasmTimes = vMap.value("spasmTimes").toInt();
|
||||
if(vMap.contains("maxResistance"))
|
||||
st_TrainReport.maxResistance = vMap.value("maxResistance").toFloat();
|
||||
if(vMap.contains("minResistance"))
|
||||
st_TrainReport.minResistance = vMap.value("minResistance").toFloat();
|
||||
if(vMap.contains("averangeResistance"))
|
||||
st_TrainReport.averangeResistance = vMap.value("averangeResistance").toFloat();
|
||||
if(vMap.contains("startTimeStr"))
|
||||
st_TrainReport.startTimeStr = vMap.value("startTimeStr").toString();
|
||||
if(vMap.contains("averageSpeed"))
|
||||
st_TrainReport.averageSpeed = vMap.value("averageSpeed").toInt();
|
||||
if(vMap.contains("maxSpeed"))
|
||||
st_TrainReport.maxSpeed = vMap.value("maxSpeed").toInt();
|
||||
return st_TrainReport;
|
||||
}
|
||||
|
||||
ST_TrainRecord variantMapToTrainRecord(QVariantMap vMap)
|
||||
{
|
||||
ST_TrainRecord st_trainRecord;
|
||||
if(vMap.contains("ID"))
|
||||
st_trainRecord.ID = vMap.value("ID").toUInt();
|
||||
if(vMap.contains("startTime"))
|
||||
st_trainRecord.startTime = vMap.value("startTime").toDateTime();
|
||||
if(vMap.contains("startTimeStr"))
|
||||
st_trainRecord.startTimeStr = vMap.value("startTimeStr").toString();
|
||||
if(vMap.contains("trainTime"))
|
||||
st_trainRecord.trainTime = vMap.value("trainTime").toInt();
|
||||
if(vMap.contains("score"))
|
||||
st_trainRecord.score = vMap.value("score").toInt();
|
||||
if(vMap.contains("bodyPart"))
|
||||
st_trainRecord.bodyPart = vMap.value("bodyPart").toString();
|
||||
if(vMap.contains("trainMode"))
|
||||
st_trainRecord.trainMode = vMap.value("trainMode").toString();
|
||||
return st_trainRecord;
|
||||
}
|
||||
|
||||
ST_BLEDevice variantMapToBLEDevice(QVariantMap vMap)
|
||||
{
|
||||
ST_BLEDevice st_deviceMsg;
|
||||
if(vMap.contains("deviceNo"))
|
||||
st_deviceMsg.deviceNo = vMap.value("deviceNo").toInt();
|
||||
if(vMap.contains("deviceMac"))
|
||||
st_deviceMsg.deviceMac = vMap.value("deviceMac").toString();
|
||||
return st_deviceMsg;
|
||||
}
|
||||
|
||||
ST_TrainParam variantMapToTrainParam(QVariantMap vMap)
|
||||
{
|
||||
ST_TrainParam st_trainParam;
|
||||
if(vMap.contains("ID"))
|
||||
st_trainParam.ID = vMap.value("ID").toInt();
|
||||
if(vMap.contains("trainLimp"))
|
||||
st_trainParam.trainLimp = vMap.value("trainLimp").toInt();
|
||||
if(vMap.contains("trainMode"))
|
||||
st_trainParam.trainMode = vMap.value("trainMode").toInt();
|
||||
if(vMap.contains("trainTime"))
|
||||
st_trainParam.trainTime = vMap.value("trainTime").toInt();
|
||||
|
||||
if(vMap.contains("trainResistance"))
|
||||
st_trainParam.trainResistance = vMap.value("trainResistance").toInt();
|
||||
if(vMap.contains("trainSpeed"))
|
||||
st_trainParam.trainSpeed = vMap.value("trainSpeed").toInt();
|
||||
if(vMap.contains("trainDirection"))
|
||||
st_trainParam.trainDirection = vMap.value("trainDirection").toInt();
|
||||
if(vMap.contains("spasmProtect"))
|
||||
st_trainParam.spasmProtect = vMap.value("spasmProtect").toInt();
|
||||
|
||||
if(vMap.contains("spasmLevel"))
|
||||
st_trainParam.spasmLevel = vMap.value("spasmLevel").toInt();
|
||||
if(vMap.contains("gameID"))
|
||||
st_trainParam.gameID = vMap.value("gameID").toInt();
|
||||
return st_trainParam;
|
||||
}
|
||||
|
||||
QVariantMap patientMsgToVariantMap(const ST_PatientMsg& st_PatientMsg)
|
||||
{
|
||||
QVariantMap vMap;
|
||||
vMap.insert("ID",st_PatientMsg.ID);
|
||||
vMap.insert("name",st_PatientMsg.name);
|
||||
vMap.insert("phone",st_PatientMsg.phone);
|
||||
vMap.insert("birthday",st_PatientMsg.birthday);
|
||||
vMap.insert("sex",st_PatientMsg.sex);
|
||||
vMap.insert("bodyIndex",st_PatientMsg.bodyIndex);
|
||||
vMap.insert("markMsg",st_PatientMsg.markMsg);
|
||||
vMap.insert("age",st_PatientMsg.age);
|
||||
return vMap;
|
||||
}
|
||||
|
||||
QVariantMap trainReportToVariantMap(const ST_TrainReport& st_TrainReport)
|
||||
{
|
||||
QVariantMap vMap;
|
||||
//添加UUID
|
||||
QUuid id = QUuid::createUuid();
|
||||
QString strId = id.toString(QUuid::Id128);
|
||||
vMap.insert("UUID",strId);
|
||||
vMap.insert("ID",st_TrainReport.ID);
|
||||
vMap.insert("name",st_TrainReport.name);
|
||||
vMap.insert("sex",st_TrainReport.sex);
|
||||
vMap.insert("phone",st_TrainReport.phone);
|
||||
vMap.insert("age",st_TrainReport.age);
|
||||
vMap.insert("trainMode",st_TrainReport.trainMode);
|
||||
vMap.insert("bodyIndex",st_TrainReport.bodyIndex);
|
||||
vMap.insert("markMsg",st_TrainReport.markMsg);
|
||||
vMap.insert("trainTime",st_TrainReport.trainTime);
|
||||
vMap.insert("leftBalance",st_TrainReport.leftBalance);
|
||||
vMap.insert("rightBalance",st_TrainReport.rightBalance);
|
||||
vMap.insert("upLimpLength",st_TrainReport.upLimpLength);
|
||||
vMap.insert("downLimpLength",st_TrainReport.downLimpLength);
|
||||
vMap.insert("activeTime",st_TrainReport.activeTime);
|
||||
vMap.insert("passiveTime",(int)st_TrainReport.passiveTime);
|
||||
vMap.insert("spasmTimes",st_TrainReport.spasmTimes);
|
||||
vMap.insert("maxResistance",st_TrainReport.maxResistance);
|
||||
vMap.insert("averangeResistance",st_TrainReport.averangeResistance);
|
||||
vMap.insert("minResistance",st_TrainReport.minResistance);
|
||||
vMap.insert("startTimeStr",st_TrainReport.startTimeStr);
|
||||
vMap.insert("averageSpeed",st_TrainReport.averageSpeed);
|
||||
vMap.insert("maxSpeed",st_TrainReport.maxSpeed);
|
||||
return vMap;
|
||||
}
|
||||
|
||||
QVariantMap trainRecordToVariantMap(const ST_TrainRecord& st_trainRecord)
|
||||
{
|
||||
QVariantMap vMap;
|
||||
//添加UUID
|
||||
QUuid id = QUuid::createUuid();
|
||||
QString strId = id.toString(QUuid::Id128);
|
||||
vMap.insert("UUID",strId);
|
||||
vMap.insert("ID",st_trainRecord.ID);
|
||||
vMap.insert("startTime",st_trainRecord.startTime);
|
||||
vMap.insert("startTimeStr",st_trainRecord.startTimeStr);
|
||||
vMap.insert("trainTime",st_trainRecord.trainTime);
|
||||
vMap.insert("score",st_trainRecord.score);
|
||||
vMap.insert("bodyPart",st_trainRecord.bodyPart);
|
||||
vMap.insert("trainMode",st_trainRecord.trainMode);
|
||||
return vMap;
|
||||
}
|
||||
|
||||
QVariantMap BLEDeviceToVariantMap(const ST_BLEDevice& st_bleDevice)
|
||||
{
|
||||
QVariantMap vMap;
|
||||
vMap.insert("deviceNo",st_bleDevice.deviceNo);
|
||||
vMap.insert("deviceMac",st_bleDevice.deviceMac);
|
||||
return vMap;
|
||||
}
|
||||
|
||||
|
||||
QVariantMap TrainParamToVariantMap(const ST_TrainParam &st_trainParam)
|
||||
{
|
||||
QVariantMap vMap;
|
||||
vMap.insert("ID",st_trainParam.ID);
|
||||
vMap.insert("trainLimp",st_trainParam.trainLimp);
|
||||
vMap.insert("trainMode",st_trainParam.trainMode);
|
||||
vMap.insert("trainTime",st_trainParam.trainTime);
|
||||
vMap.insert("trainResistance",st_trainParam.trainResistance);
|
||||
vMap.insert("trainSpeed",st_trainParam.trainSpeed);
|
||||
vMap.insert("trainDirection",st_trainParam.trainDirection);
|
||||
vMap.insert("spasmProtect",st_trainParam.spasmProtect);
|
||||
vMap.insert("spasmLevel",st_trainParam.spasmLevel);
|
||||
vMap.insert("gameID",st_trainParam.gameID);
|
||||
return vMap;
|
||||
}
|
||||
|
||||
|
||||
93
ZBD_IIIDL_S_Project/Src/DataFormate/dbforrmate.h
Normal file
93
ZBD_IIIDL_S_Project/Src/DataFormate/dbforrmate.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef DBFORRMATE_H
|
||||
#define DBFORRMATE_H
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QVariantMap>
|
||||
//用户信息
|
||||
typedef struct
|
||||
{
|
||||
uint32_t ID; //自增性ID,由系统分配控制
|
||||
QString name; //患者姓名 必填
|
||||
QString phone; //患者电话
|
||||
int sex; //0-男性 1-女性
|
||||
QDate birthday; //生日
|
||||
int bodyIndex; //训练部位选择 0-下肢 1-上肢 2-上下肢
|
||||
QString markMsg; //备注信息
|
||||
int age; //患者年龄
|
||||
}ST_PatientMsg;
|
||||
|
||||
//训练记录,
|
||||
typedef struct
|
||||
{
|
||||
QString UUID;
|
||||
int ID; //用户ID
|
||||
QDateTime startTime; //开始训练时间-用于排序
|
||||
QString startTimeStr; //训练时间字符串版-用于显示
|
||||
int trainTime; //训练时长 (min)
|
||||
int score; //游戏得分 距离*3
|
||||
QString bodyPart; //训练部位
|
||||
QString trainMode; //训练模式
|
||||
}ST_TrainRecord;
|
||||
|
||||
|
||||
//训练报告
|
||||
typedef struct
|
||||
{
|
||||
QString UUID;
|
||||
int ID; //系统ID
|
||||
QString name; //患者姓名
|
||||
int sex; //0-male 1-female
|
||||
QString phone; //手机
|
||||
int age; //年龄
|
||||
int trainMode; //训练模式
|
||||
int bodyIndex; //训练部位
|
||||
QString markMsg; //备注
|
||||
int trainTime; //本次训练时长(分钟)
|
||||
int leftBalance; //左平衡
|
||||
int rightBalance; //右平衡
|
||||
float upLimpLength; //上肢距离
|
||||
float downLimpLength; //下肢距离
|
||||
int activeTime; //主动时间 /s
|
||||
int passiveTime; //被动时间 /s
|
||||
int spasmTimes; //痉挛次数
|
||||
float maxResistance; //最大阻力
|
||||
float averangeResistance;//平均阻力
|
||||
float minResistance; //最小阻力
|
||||
QString startTimeStr; //训练时间 字符串版-查看检索
|
||||
int averageSpeed; //平均速度
|
||||
int maxSpeed; //最大速度
|
||||
}ST_TrainReport;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ID; //训练用户的ID
|
||||
int trainLimp; //训练肢体,0代表上肢、1代表下肢、2代表四肢
|
||||
int trainMode; //训练模式
|
||||
int trainTime; //训练时间
|
||||
int trainResistance; //训练阻力
|
||||
int trainSpeed; //训练速度
|
||||
int trainDirection; //训练方向,0正向,1逆向
|
||||
int spasmProtect; //痉挛保护
|
||||
int spasmLevel; //痉挛等级
|
||||
int gameID; //游戏的ID
|
||||
}ST_TrainParam;
|
||||
|
||||
//电刺激数据
|
||||
typedef struct
|
||||
{
|
||||
int deviceNo; //设备号
|
||||
QString deviceMac;//设备Mac地址
|
||||
}ST_BLEDevice;
|
||||
|
||||
extern ST_PatientMsg variantMapToPatientMsg(QVariantMap vMap);
|
||||
extern ST_TrainReport variantMapToTrainReport(QVariantMap vMap);
|
||||
extern ST_TrainRecord variantMapToTrainRecord(QVariantMap vMap);
|
||||
extern ST_BLEDevice variantMapToBLEDevice(QVariantMap vMap);
|
||||
extern ST_TrainParam variantMapToTrainParam(QVariantMap vMap);
|
||||
|
||||
extern QVariantMap patientMsgToVariantMap(const ST_PatientMsg&);
|
||||
extern QVariantMap trainReportToVariantMap(const ST_TrainReport&);
|
||||
extern QVariantMap trainRecordToVariantMap(const ST_TrainRecord&);
|
||||
extern QVariantMap BLEDeviceToVariantMap(const ST_BLEDevice&);
|
||||
extern QVariantMap TrainParamToVariantMap(const ST_TrainParam&);
|
||||
#endif // DBFORRMATE_H
|
||||
Reference in New Issue
Block a user