-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainMotorsCam.py
More file actions
131 lines (116 loc) · 4.52 KB
/
Copy pathMainMotorsCam.py
File metadata and controls
131 lines (116 loc) · 4.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PyQt6 import QtCore
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWidgets import QWidget
from PyQt6.QtWidgets import QVBoxLayout,QHBoxLayout
from PyQt6.QtWidgets import QComboBox,QLabel
from PyQt6.QtGui import QIcon
import qdarkstyle
import sys
import moteurRSAIFDB
from oneMotorGuiFBCamera import ONEMOTORGUI
import time
import numpy as np
class MAINMOTOR(QWidget):
""" widget
list of ip adress and list of motors
"""
def __init__(self, parent=None):
super(MAINMOTOR, self).__init__()
self.isWinOpen = False
self.parent = parent
self.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt6'))
self.setWindowIcon(QIcon('./icons/LOA.png'))
self.setWindowTitle('Main Motors')
self.listRack = moteurRSAIFDB.rEquipmentList()
self.IPadress = self.listRack[0]
self.rackName = []
self.motorCreatedId = []
self.motorCreated = []
for IP in self.listRack:
self.rackName.append(moteurRSAIFDB.nameEquipment(IP))
rack =dict(zip(self.rackName,self.listRack)) # dictionnaire key name of the rack values IPadress
self.listMotor = moteurRSAIFDB.listMotorName(self.IPadress) # liste des nom des moteur i+1= numero de l'axe
self.SETUP()
#self.actionButton()
def SETUP(self):
self.vbox = QVBoxLayout()
hboxRack = QHBoxLayout()
LabelRack = QLabel('RACK NAME')
hboxRack.addWidget(LabelRack)
self.rackChoise = QComboBox()
hboxRack.addWidget(self.rackChoise)
i=0
for rack in self.listRack: #
self.rackChoise.addItem( str(moteurRSAIFDB.nameEquipment(rack))+ ' (' + rack +')')
i+=1
LabelMotor = QLabel('Motor NAME')
hboxRack.addWidget(LabelMotor)
self.motorChoise=QComboBox()
hboxRack.addWidget(self.motorChoise)
self.motorChoise.addItem('Choose a motor')
self.motorChoise.addItems(self.listMotor)
self.vbox.addLayout(hboxRack)
self.setLayout(self.vbox)
def actionButton(self):
self.motorChoise.currentIndexChanged.connect(self.createMotor)
self.rackChoise.currentIndexChanged.connect(self.ChangeIPRack)
def createMotor(self):
# print('create Motor')
if self.motorChoise.currentIndex() != 0 :
self.numMotor = self.motorChoise.currentIndex() # car indice 0 = 'choose o motor'
self.IPadress = self.listRack [self.rackChoise.currentIndex()]
motorID = str(self.IPadress)+'M'+str(self.numMotor)
if motorID in self.motorCreatedId:
# print('moteur already created')
index=self.motorCreatedId.index(motorID)
self.open_widget(self.motorCreated[index])
else :
self.motorWidget = ONEMOTORGUI(self.IPadress,self.numMotor,parent=self)
time.sleep(0.1)
self.open_widget(self.motorWidget)
self.motorCreatedId.append(motorID)
self.motorCreated.append(self.motorWidget)
def ChangeIPRack(self):
self.motorChoise.clear()
self.IPadress = str( self.listRack[self.rackChoise.currentIndex()])
#print('ip',self.IPadress)
self.listMotor = moteurRSAIFDB.listMotorName(self.IPadress)
self.rackName = moteurRSAIFDB.nameEquipment(self.IPadress)
self.motorChoise.addItem('Choose a motor')
self.motorChoise.addItems(self.listMotor)
#print('chage Ip')
def open_widget(self,fene):
""" open new widget
"""
if fene.isWinOpen is False:
#New widget"
fene.show()
fene.startThread2()
fene.isWinOpen = True
else:
#fene.activateWindow()
fene.raise_()
fene.showNormal()
def closeEvent(self, event):
"""
When closing the window
"""
self.fini()
time.sleep(0.1)
event.accept()
def fini(self):
'''
at the end we close all the thread
'''
self.isWinOpen = False
for mot in self.motorCreated:
mot.close()
time.sleep(0.1)
moteurRSAIFDB.closeConnection()
if __name__=='__main__':
appli=QApplication(sys.argv)
s = MAINMOTOR()
s.show()
appli.exec_()