|
|
@@ -1,6 +1,7 @@
|
|
|
import sys
|
|
|
from itertools import product
|
|
|
|
|
|
+from PyQt5 import sip
|
|
|
from PyQt5.QtWidgets import QApplication, QSizePolicy, QLabel, QWidget
|
|
|
|
|
|
import json
|
|
|
@@ -56,16 +57,16 @@ statu_ex_keys = [
|
|
|
mcpu_keys = [
|
|
|
["in", 1, "192.168.2.25", 40000],
|
|
|
["in", 2, "192.168.2.25", 40001],
|
|
|
- ["in", 3, "192.168.1.132", 40005],
|
|
|
- ["in", 4, "192.168.1.133", 40005],
|
|
|
- ["in", 5, "192.168.1.134", 40005],
|
|
|
- ["in", 6, "192.168.2.25", 40002],
|
|
|
- ["out", 1, "192.168.1.130", 40005],
|
|
|
- ["out", 2, "192.168.1.130", 40005],
|
|
|
- ["out", 3, "192.168.1.130", 40005],
|
|
|
- ["out", 4, "192.168.1.130", 40005],
|
|
|
- ["out", 5, "192.168.1.130", 40005],
|
|
|
- ["out", 6, "192.168.1.130", 40005]
|
|
|
+ # ["in", 3, "192.168.1.132", 40005],
|
|
|
+ # ["in", 4, "192.168.1.133", 40005],
|
|
|
+ # ["in", 5, "192.168.1.134", 40005],
|
|
|
+ # ["in", 6, "192.168.2.25", 40002],
|
|
|
+ ["out", 1, "192.168.2.25", 40005]
|
|
|
+ # ["out", 2, "192.168.1.130", 40005],
|
|
|
+ # ["out", 3, "192.168.1.130", 40005],
|
|
|
+ # ["out", 4, "192.168.1.130", 40005],
|
|
|
+ # ["out", 5, "192.168.1.130", 40005],
|
|
|
+ # ["out", 6, "192.168.1.130", 40005]
|
|
|
]
|
|
|
|
|
|
|
|
|
@@ -94,8 +95,7 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
QMainWindow.__init__(self)
|
|
|
self.rmq_statu = {}
|
|
|
self.rmq_timeout = {}
|
|
|
- self.mcpu_iomsg = {}
|
|
|
- self.mcpu_connect_statu = {}
|
|
|
+ self.command_queue_dict = {}
|
|
|
|
|
|
self.ui = sui.Ui_MainWindow()
|
|
|
self.ui.setupUi(self)
|
|
|
@@ -108,6 +108,21 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
|
|
|
self.btn_positions = [(i, j) for i in range(13, -1, -1) for j in range(6)]
|
|
|
|
|
|
+ # self.ui.in_mcpu_1_statu_btn = QPBtn(self.ui.in_mcpu_1_statu_btn)
|
|
|
+ self.ui.in_mcpu_1_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.in_mcpu_2_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.in_mcpu_3_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.in_mcpu_4_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.in_mcpu_5_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.in_mcpu_6_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+
|
|
|
+ self.ui.out_mcpu_1_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.out_mcpu_2_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.out_mcpu_3_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.out_mcpu_4_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.out_mcpu_5_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+ self.ui.out_mcpu_6_statu_btn.clicked.connect(self.mcpu_btn_click)
|
|
|
+
|
|
|
def getBackGroundColor(self, color):
|
|
|
if color == "red":
|
|
|
return "background-color:rgb(255,70,70)"
|
|
|
@@ -118,10 +133,10 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
elif color == "yellow":
|
|
|
return "background-color:rgb(248,239,71)"
|
|
|
|
|
|
- def drawMcpuBtn(self,key):
|
|
|
+ def drawMcpuBtn(self, key):
|
|
|
mouth = key.split(':')[0]
|
|
|
id = key.split(':')[1]
|
|
|
- btn_name = mouth+'_'+id+'_statu_btn'
|
|
|
+ btn_name = mouth + '_' + id + '_statu_btn'
|
|
|
btn = self.findChild(QPushButton, btn_name)
|
|
|
iomsg = g_mcpu.GetMcpuIoMsg(key)
|
|
|
if g_mcpu.GetMcpuConnectStatus(key) is True or iomsg.timeout() is False:
|
|
|
@@ -133,20 +148,25 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
btn.setToolTip("None")
|
|
|
btn.setStyleSheet(self.getBackGroundColor("gray"))
|
|
|
|
|
|
-
|
|
|
def drawUnitProcess(self):
|
|
|
if g_space.command_queue_dict is not False and g_space.command_queue_dict is not None:
|
|
|
- for i, j, k in zip(range(self.ui.A_verticalLayout.count()), range(self.ui.B_verticalLayout.count()),
|
|
|
- range(self.ui.B_verticalLayout.count())):
|
|
|
- Aitem = self.ui.A_verticalLayout.itemAt(i)
|
|
|
- Bitem = self.ui.B_verticalLayout.itemAt(i)
|
|
|
- Citem = self.ui.C_verticalLayout.itemAt(i)
|
|
|
- if Aitem.widget():
|
|
|
- Aitem.widget().deleteLater()
|
|
|
- if Bitem.widget():
|
|
|
- Bitem.widget().deleteLater()
|
|
|
- if Citem.widget():
|
|
|
- Citem.widget().deleteLater()
|
|
|
+ # if self.command_queue_dict != g_space.command_queue_dict
|
|
|
+
|
|
|
+ # for Aindex in range(self.ui.A_verticalLayout.count()):
|
|
|
+ # item = self.ui.A_verticalLayout.itemAt(Aindex)
|
|
|
+ # self.ui.A_verticalLayout.removeItem(item)
|
|
|
+ # sip.delete(item.widget())
|
|
|
+ #
|
|
|
+ # for Bindex in range(self.ui.B_verticalLayout.count()):
|
|
|
+ # wid = self.ui.B_verticalLayout.itemAt(Bindex).widget()
|
|
|
+ # self.ui.B_verticalLayout.removeWidget(wid)
|
|
|
+ # sip.delete(wid)
|
|
|
+ #
|
|
|
+ # for Cindex in range(self.ui.C_verticalLayout.count()):
|
|
|
+ # wid = self.ui.C_verticalLayout.itemAt(Cindex).widget()
|
|
|
+ # self.ui.C_verticalLayout.removeWidget(wid)
|
|
|
+ # sip.delete(wid)
|
|
|
+
|
|
|
for dict in g_space.command_queue_dict:
|
|
|
btn = QPBtn()
|
|
|
measure = message.measure_info()
|
|
|
@@ -168,12 +188,12 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
"None" if dict["space_info"] is None else dict["space_info"],
|
|
|
"None" if dict["measure_info"] is None else dict["measure_info"],
|
|
|
-1 if dict["export_id"] is None else dict["export_id"])
|
|
|
- if self.findChild(QPBtn, dict["car_number"]) is not None:
|
|
|
- self.findChild(QPBtn, dict["car_number"]).setText(str)
|
|
|
- self.findChild(QPBtn, dict["car_number"]).setToolTip(tool_tip)
|
|
|
- self.findChild(QPBtn, dict["car_number"]).setStyleSheet(
|
|
|
- 'border:3px groove orange;border-radius:10px;padding:2px 4px;' + color)
|
|
|
- continue
|
|
|
+ # if self.findChild(QPBtn, dict["car_number"]) is not None:
|
|
|
+ # self.findChild(QPBtn, dict["car_number"]).setText(str)
|
|
|
+ # self.findChild(QPBtn, dict["car_number"]).setToolTip(tool_tip)
|
|
|
+ # self.findChild(QPBtn, dict["car_number"]).setStyleSheet('border:3px groove %s;border-radius:10px;padding:2px 4px;' % (
|
|
|
+ # "orange" if dict["type"] is 1 else "blue") + color)
|
|
|
+ # continue
|
|
|
btn.setStyleSheet('border:3px groove %s;border-radius:10px;padding:2px 4px;' % (
|
|
|
"orange" if dict["type"] is 1 else "blue") + color)
|
|
|
btn.setObjectName(dict["car_number"])
|
|
|
@@ -331,7 +351,62 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
btn.setToolTip("None")
|
|
|
btn.setStyleSheet(self.getBackGroundColor("gray"))
|
|
|
btn.setText(btn.text()[:9] + "断连")
|
|
|
-
|
|
|
+ def mcpu_btn_click(self):
|
|
|
+ sender = self.sender()
|
|
|
+ mcpu_key_list = sender.objectName().split('_')
|
|
|
+ menu = QMenu(self)
|
|
|
+ action = menu.addAction('手动开门')
|
|
|
+ action.triggered.connect(partial(self.manual_open_door, mcpu_key_list))
|
|
|
+ action = menu.addAction('手动关门')
|
|
|
+ action.triggered.connect(partial(self.manual_close_door, mcpu_key_list))
|
|
|
+ if mcpu_key_list[0] == 'in':
|
|
|
+ action = menu.addAction('半自动开门')
|
|
|
+ action.triggered.connect(partial(self.automatic_open_door, mcpu_key_list))
|
|
|
+ elif mcpu_key_list[0] == 'out':
|
|
|
+ action = menu.addAction('半自动关门')
|
|
|
+ action.triggered.connect(partial(self.automatic_close_door, mcpu_key_list))
|
|
|
+ menu.exec_(QCursor.pos())
|
|
|
+
|
|
|
+ def manual_open_door(self,mcpu_key_list):
|
|
|
+ dispatch_direction = 0
|
|
|
+ if mcpu_key_list[0] == 'in':
|
|
|
+ dispatch_direction = 1
|
|
|
+ elif mcpu_key_list[0] == 'out':
|
|
|
+ dispatch_direction = 2
|
|
|
+ msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 2, "OutPutDo": { "Do0": 1, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
|
|
|
+ int(mcpu_key_list[2]) - 1,dispatch_direction)
|
|
|
+ key = mcpu_key_list[0]+":mcpu_"+mcpu_key_list[2]
|
|
|
+ g_mcpu.publish(key,msg)
|
|
|
+ def manual_close_door(self,mcpu_key_list):
|
|
|
+ dispatch_direction = 0
|
|
|
+ if mcpu_key_list[0] == 'in':
|
|
|
+ dispatch_direction = 1
|
|
|
+ elif mcpu_key_list[0] == 'out':
|
|
|
+ dispatch_direction = 2
|
|
|
+ msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 2, "OutPutDo": { "Do0": 0, "Do1": 1, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
|
|
|
+ int(mcpu_key_list[2]) - 1, dispatch_direction)
|
|
|
+ key = mcpu_key_list[0] + ":mcpu_" + mcpu_key_list[2]
|
|
|
+ g_mcpu.publish(key, msg)
|
|
|
+ def automatic_open_door(self,mcpu_key_list):
|
|
|
+ dispatch_direction = 0
|
|
|
+ if mcpu_key_list[0] == 'in':
|
|
|
+ dispatch_direction = 1
|
|
|
+ elif mcpu_key_list[0] == 'out':
|
|
|
+ dispatch_direction = 2
|
|
|
+ msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 4, "OutPutDo": { "Do0": 0, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
|
|
|
+ int(mcpu_key_list[2]) - 1, dispatch_direction)
|
|
|
+ key = mcpu_key_list[0] + ":mcpu_" + mcpu_key_list[2]
|
|
|
+ g_mcpu.publish(key, msg)
|
|
|
+ def automatic_close_door(self,mcpu_key_list):
|
|
|
+ dispatch_direction = 0
|
|
|
+ if mcpu_key_list[0] == 'in':
|
|
|
+ dispatch_direction = 1
|
|
|
+ elif mcpu_key_list[0] == 'out':
|
|
|
+ dispatch_direction = 2
|
|
|
+ msg = b'{ "TerminalID": %d, "DispatchDirection": %d, "ProcessControl": 3, "OutPutDo": { "Do0": 0, "Do1": 0, "Do2": 0, "Do3": 0, "Do4": 0, "Do5": 0, "Do6": 0, "Do7": 0 }}' % (
|
|
|
+ int(mcpu_key_list[2]) - 1, dispatch_direction)
|
|
|
+ key = mcpu_key_list[0] + ":mcpu_" + mcpu_key_list[2]
|
|
|
+ g_mcpu.publish(key, msg)
|
|
|
def drawSpaceBtn(self, parkspace_dict, unit):
|
|
|
|
|
|
for park, position in zip(parkspace_dict.values(), self.btn_positions):
|
|
|
@@ -363,7 +438,7 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
dict = json.loads(tool_tip)
|
|
|
menu = QMenu(self)
|
|
|
action = menu.addAction('清除')
|
|
|
- action.triggered.connect(partial(self.process_delete,dict))
|
|
|
+ action.triggered.connect(partial(self.process_delete, dict))
|
|
|
menu.exec_(QCursor.pos())
|
|
|
|
|
|
def park_btn_click(self, flag):
|
|
|
@@ -410,12 +485,14 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
QMessageBox.Ok) # "退出"代表的是弹出框的标题,"你确认退出.."表示弹出框的内容
|
|
|
else:
|
|
|
g_space.pickUpPark(dict)
|
|
|
- def process_delete(self,dict):
|
|
|
+
|
|
|
+ def process_delete(self, dict):
|
|
|
if g_space.statu is False:
|
|
|
QMessageBox.warning(self, '错误', '数据库连接错误,请检查网络状态!',
|
|
|
QMessageBox.Ok) # "退出"代表的是弹出框的标题,"你确认退出.."表示弹出框的内容
|
|
|
else:
|
|
|
g_space.processDelete(dict)
|
|
|
+
|
|
|
def run(self):
|
|
|
while self.isClose is not True:
|
|
|
if g_space.statu is False:
|
|
|
@@ -450,17 +527,9 @@ class MainWindow(QMainWindow, threading.Thread):
|
|
|
self.drawLedSignal.emit()
|
|
|
self.drawUnitProcessSignal.emit()
|
|
|
g_space.commandIsUpdate = False
|
|
|
- # print(g_mcpu.GetMcpuIoMsg("in:mcpu_1").timeout())
|
|
|
for key, statu in g_mcpu.GetAllMcpuConnectStatus().items():
|
|
|
self.drawMcpuBtnSignal.emit(key)
|
|
|
time.sleep(0.01)
|
|
|
- # if key in self.mcpu_connect_statu.keys():
|
|
|
- # print( "key = {} self.mcpu_connect_statu[key] = {} g_mcpu.GetMcpuConnectStatus()[key] = {} ".format(key,self.mcpu_connect_statu[key],g_mcpu.GetMcpuConnectStatus()[key]))
|
|
|
- # if (key in self.mcpu_connect_statu.keys()) is False or self.mcpu_connect_statu[key] != g_mcpu.GetMcpuConnectStatus()[key]:
|
|
|
- # self.mcpu_connect_statu[key] = g_mcpu.GetMcpuConnectStatus()[key]
|
|
|
- # if (key in self.mcpu_connect_statu.keys() is False) or (self.mcpu_connect_statu[key] != g_mcpu.GetMcpuConnectStatus()[key]):
|
|
|
- # self.mcpu_connect_statu[key] = g_mcpu.GetMcpuConnectStatus()[key]
|
|
|
- # self.drawMcpuBtnSignal.emit(key)
|
|
|
time.sleep(0.5)
|
|
|
|
|
|
def closeEvent(self, event):
|