enum TypeInfo{
|
DEVICESELECT_REQ, //查看设备请求
|
DEVICESELECT_RES, //查看设备响应
|
|
DEVICEADD_REQ, //增加设备请求
|
DEVICEADD_RES, //增加设备响应
|
|
DEVICEDELETE_REQ, //删除设备请求
|
DEVICEDELETE_RES, //删除设备响应
|
|
DEVICEUPDATE_REQ, //修改设备请求
|
DEVICEUPDATE_RES, //修改设备响应
|
|
DEVICESELECTALL_REQ,//查看全部设备请求
|
DEVICESELECTALL_RES//查看全部设备响应
|
};
|
|
struct Head
|
{
|
int type;//区分不同功能结构体
|
int lenth;//表示当前封包长度,主要解决年粘包、拆包的操作
|
// int flag;
|
};
|
|
//设备信息
|
struct DeviceData {
|
int id; // 设备编号
|
char name[32]; // 设备名称
|
double longitude; // 设备所在位置(经度)
|
double latitude; //设备所在位置(纬度)
|
int status; // 设备状态 0:设备正常 1:设备异常 2:设备损坏
|
double currentEnvironment_humidity;//当前生产环境湿度
|
double currentEnvironment_temperature;//当前生产环境温度
|
};
|
|
//全部设备查询请求结构体
|
struct DeviceSelectAllReq
|
{
|
Head head;
|
DeviceData dev;
|
DeviceSelectAllReq() {//构造函数
|
head.type = DEVICESELECTALL_REQ;
|
head.lenth = sizeof(DeviceSelectAllReq);
|
}
|
};
|
|
|
//全部设备查询响应结构体
|
struct DeviceSelectAllRes
|
{
|
Head head;
|
int state;//0:查询成功 1:查询失败
|
DeviceData dev[0]; // 柔性数组
|
DeviceSelectAllRes() {
|
head.type = DEVICESELECTALL_RES;
|
head.lenth = sizeof(DeviceSelectAllRes);
|
}
|
};
|
//设备查询请求结构体
|
struct DeviceSelectReq
|
{
|
Head head;
|
DeviceData dev;
|
DeviceSelectReq() {//构造函数
|
head.type = DEVICESELECT_REQ;
|
head.lenth = sizeof(DeviceSelectReq);
|
}
|
};
|
|
|
//设备查询响应结构体
|
struct DeviceSelectRes
|
{
|
Head head;
|
int state;//0:查询成功 1:查询失败
|
DeviceData dev[0]; // 柔性数组
|
DeviceSelectRes() {
|
head.type = DEVICESELECT_RES;
|
head.lenth = sizeof(DeviceSelectRes);
|
}
|
};
|
|
//设备增加请求结构体
|
struct DeviceAddReq
|
{
|
Head head;
|
DeviceData dev;
|
DeviceAddReq() {
|
head.type = DEVICEADD_REQ;
|
head.lenth = sizeof(DeviceAddReq);
|
}
|
};
|
|
//设备增加响应结构体
|
struct DeviceAddRes
|
{
|
Head head;
|
int state;//0:添加成功 1:失败
|
DeviceAddRes() {
|
head.type = DEVICEADD_RES;
|
head.lenth = sizeof(DeviceAddRes);
|
}
|
};
|
|
//设备删除请求结构体
|
struct DeviceDeleteReq
|
{
|
Head head;
|
DeviceData dev;
|
DeviceDeleteReq() {
|
head.type = DEVICEDELETE_REQ;
|
head.lenth = sizeof(DeviceDeleteReq);
|
}
|
};
|
|
//设备删除响应结构体
|
struct DeviceDeleteRes
|
{
|
Head head;
|
int state;//0:删除成功 1:删除失败
|
DeviceDeleteRes() {
|
head.type = DEVICEDELETE_RES;
|
head.lenth = sizeof(DeviceDeleteRes);
|
}
|
};
|
|
|
//设备修改更新请求结构体
|
struct DeviceUpdateReq
|
{
|
Head head;
|
DeviceData dev;
|
DeviceUpdateReq() {
|
head.type = DEVICEUPDATE_REQ;
|
head.lenth = sizeof(DeviceUpdateReq);
|
}
|
};
|
|
|
//设备修改更新响应结构体
|
struct DeviceUpdateRes
|
{
|
Head head;
|
DeviceData dev;
|
int state;//0:修改成功 1:修改失败
|
DeviceUpdateRes() {
|
head.type = DEVICEUPDATE_RES;
|
head.lenth = sizeof(DeviceUpdateRes);
|
}
|
};
|