装置运行信息报文与装置版本配置信息报文读取
This commit is contained in:
@@ -377,6 +377,7 @@ void on_timer(uv_timer_t* handle) {
|
||||
ctx->add_action(DeviceState::READING_STATS_TIME, sendbuff);//将该状态以及待发送报文存入队列
|
||||
}
|
||||
//一秒一次 执行实时数据询问 仅执行指定次数
|
||||
now = uv_now(ctx->loop);
|
||||
if (ctx->current_state_ == DeviceState::IDLE && now - ctx->real_state_query_time_ >= 1000 && ctx->real_state_count > 0) {
|
||||
// 更新实时数据执行时间和实时收发计数
|
||||
ctx->real_state_query_time_ = now;
|
||||
@@ -385,6 +386,16 @@ void on_timer(uv_timer_t* handle) {
|
||||
auto sendbuff = generate_realstat_message(static_cast<unsigned char>(ctx->real_point_id_), static_cast<unsigned char>(0x01), static_cast<unsigned char>(0x01));//组装询问实时数据报文
|
||||
ctx->add_action(DeviceState::READING_REALSTAT, sendbuff);//将该状态以及待发送报文存入队列
|
||||
}
|
||||
//30分钟一次 读取装置运行信息
|
||||
now = uv_now(ctx->loop);
|
||||
if (ctx->current_state_ == DeviceState::IDLE && now - ctx->read_runninginformationMsg >= 60000 * 30)
|
||||
{
|
||||
// 更新运行信息最后读取时间
|
||||
ctx->read_runninginformationMsg = now;
|
||||
|
||||
auto sendbuff = generate_machinestatus_message();//组装读取装置运行信息报文
|
||||
ctx->add_action(DeviceState::READING_RUNNINGINFORMATION_2, sendbuff);//将该状态以及待发送报文存入队列
|
||||
}
|
||||
//处理后续工作队列的工作 取出一个并执行
|
||||
if (ctx->current_state_ == DeviceState::IDLE) {
|
||||
ctx->process_next_action();
|
||||
@@ -530,6 +541,7 @@ void on_connect(uv_connect_t* req, int status) {
|
||||
// 新增:初始化各个计时时间戳
|
||||
ctx->last_state_query_time_ = uv_now(ctx->loop);//初始化统计数据时间戳
|
||||
ctx->real_state_query_time_ = uv_now(ctx->loop);//初始化实时数据时间戳
|
||||
ctx->read_runninginformationMsg = uv_now(ctx->loop);//初始化读取装置运行信息时间戳
|
||||
ctx->real_state_count = 0;//实时数据收发计数
|
||||
//客户端连接完毕后,发送装置登陆消息
|
||||
std::cout << "connected: " << ctx->device_info.mac << " send login msg!" << std::endl;
|
||||
@@ -1250,6 +1262,59 @@ bool ClientManager::set_interfixedvalue_action_to_device(const std::string& iden
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
//读取装置运行信息
|
||||
bool ClientManager::read_runninginformation_action_to_device(const std::string& identifier) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
// 查找匹配的设备
|
||||
for (auto& pair : clients_) {
|
||||
auto& ctx = pair.second;
|
||||
if (ctx->device_info.device_id == identifier ||
|
||||
ctx->device_info.mac == identifier)
|
||||
{
|
||||
// 生成定值描述报文
|
||||
auto packet = generate_machinestatus_message();
|
||||
|
||||
// 添加动作到队列 (状态: 读取文件目录)
|
||||
ctx->add_action(DeviceState::READING_RUNNINGINFORMATION_1, packet);
|
||||
|
||||
// 如果当前空闲则立即执行
|
||||
if (ctx->current_state_ == DeviceState::IDLE) {
|
||||
ctx->process_next_action();
|
||||
}
|
||||
|
||||
return true; // 成功添加
|
||||
}
|
||||
}
|
||||
return false; // 设备未找到
|
||||
}
|
||||
|
||||
//读取装置版本配置信息
|
||||
bool ClientManager::read_devversion_action_to_device(const std::string& identifier) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
// 查找匹配的设备
|
||||
for (auto& pair : clients_) {
|
||||
auto& ctx = pair.second;
|
||||
if (ctx->device_info.device_id == identifier ||
|
||||
ctx->device_info.mac == identifier)
|
||||
{
|
||||
// 生成定值描述报文
|
||||
auto packet = generate_machineversion_message();
|
||||
|
||||
// 添加动作到队列 (状态: 读取文件目录)
|
||||
ctx->add_action(DeviceState::READING_DEVVERSION, packet);
|
||||
|
||||
// 如果当前空闲则立即执行
|
||||
if (ctx->current_state_ == DeviceState::IDLE) {
|
||||
ctx->process_next_action();
|
||||
}
|
||||
|
||||
return true; // 成功添加
|
||||
}
|
||||
}
|
||||
return false; // 设备未找到
|
||||
}
|
||||
//获取指定装置测点的电压等级与接线方式
|
||||
bool ClientManager::get_point_scale_and_pttype(const std::string& identifier,
|
||||
ushort nCpuNo,
|
||||
|
||||
Reference in New Issue
Block a user