-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockRF.py
198 lines (167 loc) · 6.34 KB
/
blockRF.py
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import can
class BlockRF:
"""this class implements interaction with the control unit.
"""
"""id - the frame identifier used for arbitration on the bus.
"""
id_blockRF_command = 0x101E0030
def __init__(self, bus: object):
"""Variables are responsible for storing the pressure value, I and U.
Args:
bus (object): [USB-CAN object]
:range_power:
power seted for Rf magnetron sputtering
:block_rf_state:
state of block Rf
:block_rf_enable:
enable/disable block
:block_rf_sputtering:
enable/disable pre -sputtering
:block_rf_set_power:
enable/disable sputtering
:mes_rf_KBV:
Measurement of KBV
:mes_rf_Imagn:
Measurement of current's magnetron
:mes_rf_Umagn:
Measurement of voltage's magnetron
:mes_rf_Power:
Measurement of power
:mes_rf_Idriver:
Measurement of current's driver
:mes_rf_Ianod:
Measurement of currnet's anod
"""
self.range_power: int = 0
self.block_rf_state: bool = False
self.block_rf_enable: bool = False
self.block_rf_ready: bool = False
self.block_rf_sputtering: bool = False
self.block_rf_set_power: bool = False
self.rf_active_C1up: bool = False
self.rf_active_C2up: bool = False
self.rf_active_C1down: bool = False
self.rf_active_C2down: bool = False
self.error: bool = False
self.mes_rf_KBV: int = 0
self.mes_rf_Imagn: int = 0
self.mes_rf_Umagn: int = 0
self.mes_rf_Power: int = 0
self.mes_rf_Idriver: int = 0
self.mes_rf_Ianod: int = 0
self.bus = bus
self.msg_send_upr = can.Message(
arbitration_id=self.id_blockRF_command,
is_extended_id=True,
dlc=4,
data=bytearray(4),
)
def get_states(self):
"""call to get the actual states of the units.
"""
self.msg_send_upr.data[0] = b"\x0f"[0]
self.send_and_flush(self.msg_send_upr)
def get_measurements(self):
"""called to get values from sensors.
"""
self.msg_send_upr.data[0] = b"\xff"[0]
self.send_and_flush(self.msg_send_upr)
def state_block_rf(self, state: bool):
"""Enable/disable RF block
"""
if state:
self.msg_send_upr.data[0] = b"\x45"[0]
else:
self.msg_send_upr.data[0] = b"\x44"[0]
self.send_and_flush(self.msg_send_upr)
def check_rf(self, state):
"""Enable/disable cheking of RF sputtering
"""
if state:
self.msg_send_upr.data[0] = b"\x45"[0]
else:
self.msg_send_upr.data[0] = b"\x44"[0]
self.send_and_flush(self.msg_send_upr)
def power_rf(self, state: bool, value: int = 0):
"""Enable/disable sputtering
"""
if state:
self.msg_send_upr.data[0] = b"\x66"[0]
self.msg_send_upr.data[2:4] = value.to_bytes(2, "little")
else:
self.msg_send_upr.data[0] = b"\x67"[0]
self.send_and_flush(self.msg_send_upr)
def cap_state(self, name: str, direct: str, state: bool):
"""
Enable/disable capacity С1/2 increase/reduction
"""
if name == "C1":
if direct == "up":
if state:
self.msg_send_upr.data[0] = b"\x50"[0]
else:
self.msg_send_upr.data[0] = b"\x51"[0]
elif direct == "down":
if state:
self.msg_send_upr.data[0] = b"\x52"[0]
else:
self.msg_send_upr.data[0] = b"\x53"[0]
elif name == "C2":
if direct == "up":
if state:
self.msg_send_upr.data[0] = b"\x54"[0]
else:
self.msg_send_upr.data[0] = b"\x55"[0]
elif direct == "down":
if state:
self.msg_send_upr.data[0] = b"\x56"[0]
else:
self.msg_send_upr.data[0] = b"\x57"[0]
self.send_and_flush(self.msg_send_upr)
def send_and_flush(self, msg):
"""Send fun with callbcak Eror
"""
try:
self.bus.send(msg)
msg.data[:4] = bytearray(4)
# print("Message sent on {}".format(self.bus.channel_info))
except can.CanError:
print("Message NOT sent")
def return_states_mes(self):
return {
"range_power": self.range_power,
"block_rf_error": self.error,
"block_rf_ready": self.block_rf_ready,
"block_rf_state": self.block_rf_state,
"block_rf_enable": self.block_rf_enable,
"block_rf_sputtering": self.block_rf_sputtering,
"block_rf_set_power": self.block_rf_set_power,
"mes_rf_KBV": self.mes_rf_KBV,
"mes_rf_Imagn": self.mes_rf_Imagn,
"mes_rf_Umagn": self.mes_rf_Umagn,
"mes_rf_Power": self.mes_rf_Power,
"mes_rf_Idriver": self.mes_rf_Idriver,
"mes_rf_Ianod": self.mes_rf_Ianod,
}
def return_mes(self):
return {
"mes_rf_KBV": self.mes_rf_KBV,
"mes_rf_Imagn": self.mes_rf_Imagn,
"mes_rf_Umagn": self.mes_rf_Umagn,
"mes_rf_Power": self.mes_rf_Power,
"mes_rf_Idriver": self.mes_rf_Idriver,
"mes_rf_Ianod": self.mes_rf_Ianod,
"block_rf_state": self.block_rf_state,
"block_rf_enable": self.block_rf_enable,
"block_rf_sputtering": self.block_rf_sputtering,
"block_rf_set_power": self.block_rf_set_power,
"block_rf_error": self.error,
"block_rf_ready": self.block_rf_ready,
}
def return_states(self):
return {
"range_power": self.range_power,
"block_rf_enable": self.block_rf_enable,
"block_rf_sputtering": self.block_rf_sputtering,
"block_rf_set_power": self.block_rf_set_power,
}