Merge branch '测试2' of http://192.168.1.22:3000/zhangwen/front_linux into 测试2
This commit is contained in:
@@ -176,14 +176,24 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
ClientManager::instance().read_devversion_action_to_device(id);//主动触发,读取装置版本配置信息,仅在装置登录后执行一次,当前获取版本信息确认对时报文结构。
|
||||
|
||||
//std::vector<unsigned char> file_data = read_file_as_bytes("pqs_arm2.bin");
|
||||
//ClientManager::instance().send_upgrade_action_to_device(id, file_data,10240);//默认单帧最大10240
|
||||
//ClientManager::instance().send_file_action_to_device(id, file_data,10240,"/etc/test1.bin");//默认单帧最大10240 文件上送流程
|
||||
|
||||
//std::vector<unsigned char> file_data = read_file_as_bytes("pqs_arm2.bin");
|
||||
//ClientManager::instance().send_upgrade_action_to_device(id, file_data,10240);//默认单帧最大10240 程序升级流程
|
||||
|
||||
//ClientManager::instance().set_preupgrade_action_to_device(id, "");//装置升级预校验流程 校验文件自动生成 当前填空
|
||||
//ClientManager::instance().set_ctrl_action_to_device(id,0x01,0x00);//尝试装置重启指令!
|
||||
|
||||
//ClientManager::instance().add_menu_set_action_to_device(id,"/etc/tt1");//创建目录
|
||||
//ClientManager::instance().add_file_menu_action_to_device(id, "/etc");
|
||||
//ClientManager::instance().add_menu_del_action_to_device(id, "/etc/tt1");//删除目录
|
||||
//ClientManager::instance().add_file_menu_action_to_device(id, "/etc");
|
||||
|
||||
//ClientManager::instance().add_file_menu_action_to_device(id,"/etc");//测试文件目录读取
|
||||
//ClientManager::instance().add_file_delete_action_to_device(id, "/etc/test1.bin");//文件删除功能
|
||||
//ClientManager::instance().get_dev_status(id);//设备在线情况判断 ture在线 false离线
|
||||
//ClientManager::instance().set_real_state_count("D002", 1,1);//登录后测试实时
|
||||
//ClientManager::instance().add_file_menu_action_to_device(id,"/etc");//测试文件目录读取
|
||||
|
||||
//ClientManager::instance().add_file_download_action_to_device("D002", "/etc/NPQS570_VX_ZJ_2(V103).icd");//测试文件下载
|
||||
//ClientManager::instance().get_fixedvalue_action_to_device(id,1);//测试获取装置测点定值数据
|
||||
//ClientManager::instance().get_fixedvaluedes_action_to_device(id);//测试获取装置定值描述
|
||||
@@ -903,6 +913,124 @@ void process_received_message(string mac, string id,const char* data, size_t len
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceState::SEND_FILE:
|
||||
//文件上送
|
||||
if(udata[8] == static_cast<unsigned char>(MsgResponseType::Response_File_Send)){
|
||||
//文件应答最后一帧后,再回复的结束帧
|
||||
std::cout << "*** send file success ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewACK)) {
|
||||
uint32_t current_frame_index = 0; // 当前帧(下一次要发的帧号,0-based)
|
||||
uint32_t total_frames = 0; // 总帧数
|
||||
bool all_sent = false; // 是否所有帧都已发出
|
||||
std::vector<unsigned char> packet; // 下一帧报文
|
||||
|
||||
bool ok = ClientManager::instance().try_get_next_send_file_packet_to_device(
|
||||
id,
|
||||
current_frame_index,
|
||||
total_frames,
|
||||
all_sent,
|
||||
packet
|
||||
);
|
||||
|
||||
if (!ok) {
|
||||
// 组装后续文件上送报文失败
|
||||
std::cout << "*** send file get next packet fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (!packet.empty()) {
|
||||
// 成功拿到下一帧,立即发送
|
||||
std::cout << "已生成并发送下一帧文件上送报文,当前进度: "
|
||||
<< current_frame_index << "/" << total_frames << std::endl;
|
||||
|
||||
// 和升级一样,直接切状态发送,避免被其他动作打断
|
||||
ClientManager::instance().change_device_state(id, DeviceState::SEND_FILE, packet);
|
||||
|
||||
if (all_sent) {
|
||||
std::cout << "最后一帧已发出,等待装置最终文件应答\n";
|
||||
}
|
||||
}
|
||||
else if (all_sent) {
|
||||
// 所有数据帧都已经发送完毕,此时等待 Response_File_Send 最终应答
|
||||
std::cout << "所有文件帧都已发送完毕,等待装置最终文件应答\n";
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// 理论上不应出现
|
||||
std::cout << "*** send file invalid next packet ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewNACK)) {
|
||||
// 当前帧被拒收,文件上送失败
|
||||
std::cout << "*** send file 0x41 fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问
|
||||
std::cout << "*** send file ?? fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceState::DEL_FILE:
|
||||
//文件删除
|
||||
if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewACK)) {
|
||||
//文件删除完毕!
|
||||
std::cout << "*** del file success ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewNACK)) {
|
||||
// 当前帧被拒收,文件删除失败
|
||||
std::cout << "*** del file 0x41 fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问
|
||||
std::cout << "*** del file ?? fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceState::SEND_MENU:
|
||||
//创建目录
|
||||
if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewACK)) {
|
||||
//创建目录完毕!
|
||||
std::cout << "*** send menu success ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewNACK)) {
|
||||
// 当前帧被拒收,创建目录失败
|
||||
std::cout << "*** send menu 0x41 fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问
|
||||
std::cout << "*** send menu ?? fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceState::DEL_MENU:
|
||||
//删除目录
|
||||
if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewACK)) {
|
||||
//删除目录完毕!
|
||||
std::cout << "*** del menu success ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_NewNACK)) {
|
||||
// 当前帧被拒收,删除目录失败
|
||||
std::cout << "*** del menu 0x41 fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
else {
|
||||
// 装置答非所问
|
||||
std::cout << "*** del menu ?? fail ***! " << mac << std::endl;
|
||||
ClientManager::instance().change_device_state(id, DeviceState::IDLE);
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceState::READING_FILEDATA:
|
||||
//下载文件数据 和暂态文件下载共用同一功能码
|
||||
if (udata[8] == static_cast<unsigned char>(MsgResponseType::Response_File_Download))
|
||||
|
||||
Reference in New Issue
Block a user