@@ -392,7 +392,17 @@ async def create_and_start_device(req: CreateAndStartDeviceRequest, request: Req
392392 is_start = True ,
393393 )
394394 general_device .name = channel_name
395- general_device .data_update_thread .start ()
395+
396+ # 仅客户端设备启动数据更新线程(从远程服务器读取数据)
397+ # 服务端设备不需要,因为数据由用户手动设置或远程客户端写入
398+ is_client = channel_protocol_type in [
399+ ProtocolType .ModbusTcpClient ,
400+ ProtocolType .Iec104Client ,
401+ ProtocolType .Dlt645Client ,
402+ ProtocolType .Iec61850Client ,
403+ ]
404+ if is_client :
405+ general_device .data_update_thread .start ()
396406
397407 # 添加到设备控制器
398408 device_controller = request .app .state .device_controller
@@ -598,7 +608,14 @@ async def _reload_device_instance(device_controller, channel_id: int, is_start:
598608 )
599609 new_device .name = device_name
600610
601- if is_start :
611+ # 仅客户端设备启动数据更新线程
612+ is_client = channel_protocol_type in [
613+ ProtocolType .ModbusTcpClient ,
614+ ProtocolType .Iec104Client ,
615+ ProtocolType .Dlt645Client ,
616+ ProtocolType .Iec61850Client ,
617+ ]
618+ if is_start and is_client :
602619 new_device .data_update_thread .start ()
603620
604621 device_controller .device_list .append (new_device )
0 commit comments