Initial commit: 上传完整代码

This commit is contained in:
2026-06-19 20:47:06 +08:00
commit 78b5898da2
71 changed files with 8767 additions and 0 deletions
+107
View File
@@ -0,0 +1,107 @@
from PySide6.QtCore import *
class DataCenter(QObject):
plcAlive = Signal(bool)
dataReady = Signal(int, dict)
readFinished = Signal()
def __init__(self, parent=None):
super().__init__(parent)
self.settings = QSettings("TGZZ", "TGX") # 设置存储位置
self.device_object = {
"scanner1":{
"motor":{
"online": False,
"position": 0,
"direction": 0,
"duration": 0,
"location": 0,
"velocity": 0,
"setting_velocity": 0,
"usage_duration": 15,
"useful_life": 365,
"failure_status": 1,
"failure_info": ""
}
},
"scanner2":{
"motor":{
"online": False,
"position": 0,
"direction": 0,
"duration": 0,
"location": 0,
"velocity": 0,
"setting_velocity": 0,
"usage_duration": 15,
"useful_life": 365,
"failure_status": 1,
"failure_info": ""
}
},
"global_dev":{
"device":{
"sports_mode": "fast"
}
}
}
@Slot(str)
def update_motor_sports_mode(self, sports_mode):
self.device_object["global_dev"]["device"]["sports_mode"] = sports_mode
print("self.device_object global_dev=",self.device_object["global_dev"])
self.dataReady.emit(3, self.device_object["global_dev"]["device"]) # 更新全局设备数据
@Slot(int, int)
def update_online_status(self, motor_index, status):
result = False
if status == 1:
result = True
else:
result = False
self.device_object[f"scanner{motor_index}"]["motor"]["online"] = result
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])
@Slot(int, float, float)
def update_motor_estimates(self, node_index, position, velocity):
motor_index = node_index
self.device_object[f"scanner{motor_index}"]["motor"]["position"] = position
self.device_object[f"scanner{motor_index}"]["motor"]["velocity"] = velocity
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])
# print(f"motor{motor_index}, position:{position}, velocity:{velocity}")
@Slot(int, int)
def update_motor_location(self, motor_index, location):
self.device_object[f"scanner{motor_index}"]["motor"]["location"] = location
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])
# print(f"motor{motor_index}, location:{location}")
@Slot(int, str)
def update_motor_direction(self, motor_index, direction):
print(f"motor{motor_index}, direction:{direction}")
self.device_object[f"scanner{motor_index}"]["motor"]["direction"] = direction
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])
@Slot(int, float)
def update_motor_duration(self, motor_index, duration):
self.device_object[f"scanner{motor_index}"]["motor"]["duration"] = duration
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])
@Slot(int,float)
def update_motor_setting_velocity(self, motor_index, setting_velocity):
if motor_index == 0:
self.device_object["scanner1"]["motor"]["setting_velocity"] = setting_velocity
self.device_object["scanner2"]["motor"]["setting_velocity"] = setting_velocity
else:
self.device_object[f"scanner{motor_index}"]["motor"]["setting_velocity"] = setting_velocity
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])
@Slot(int,int)
def update_motor_state(self, motor_index, state):
self.device_object[f"scanner{motor_index}"]["motor"]["state"] = state
self.dataReady.emit(motor_index, self.device_object[f"scanner{motor_index}"]["motor"])