-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockDC.py
120 lines (97 loc) · 3.54 KB
/
blockDC.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
import can
class BlockDC:
"""this class implements interaction with the control unit.
"""
"""id - the frame identifier used for arbitration on the bus.
"""
id_blockDC_command = 0x101E0010
def __init__(self, bus: object):
"""Variables are responsible for storing the pressure value, I and U.
Args:
bus (object): [USB-CAN object]
:range_current:
current seted for Dc magnetron sputtering
:block_dc_state:
state of block DC
:block_enable:
enable/disable block
:current_state:
state process of sputtering material
:mes_current:
effective current flow throught magnetron
:mes_voltage:
effective voltage applayed to magnetron
"""
self.range_current: int = 0
self.block_dc_state: bool = False
self.block_dc_enable: bool = False
self.current_state: bool = False
self.mes_current_dc: int = 0
self.mes_voltage_dc: int = 0
self.mes_seted_cur_dc: int = 0
self.bus = bus
self.msg_send_upr = can.Message(
arbitration_id=self.id_blockDC_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_dc(self, state: bool):
"""Enable/disable DC block
"""
if state:
self.msg_send_upr.data[0] = b"\x32"[0]
else:
self.msg_send_upr.data[0] = b"\x30"[0]
self.send_and_flush(self.msg_send_upr)
def current_dc(self, state: bool, value: int = 0):
"""Enable/disable sputtering
"""
if state:
self.msg_send_upr.data[0] = b"\x48"[0]
self.msg_send_upr.data[2] = value
else:
self.msg_send_upr.data[0] = b"\x50"[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_current": self.range_current,
"block_dc_state": self.block_dc_state,
"block_dc_enable": self.block_dc_enable,
"current_state": self.current_state,
"mes_current_dc": self.mes_current_dc,
"mes_voltage_dc": self.mes_voltage_dc,
}
def return_mes(self):
return {
"block_dc_state": self.block_dc_state,
"block_dc_enable": self.block_dc_enable,
"current_state": self.current_state,
"mes_current_dc": self.mes_current_dc,
"mes_voltage_dc": self.mes_voltage_dc,
}
def return_states(self):
return {
"range_current": self.range_current,
"block_dc_enable": self.block_dc_enable,
"current_state": self.current_state,
}