74 lines
2.9 KiB
GDScript
74 lines
2.9 KiB
GDScript
extends Panel
|
||
|
||
var unit_yau07 = Yau07.YaU07.new('ЯУ07')
|
||
|
||
|
||
func _ready() -> void:
|
||
Network.connect('yau_receive', Callable(self, '_on_data_received'))
|
||
Network.connect('yau_status_line', Callable(self, '_on_yau_status'))
|
||
|
||
|
||
func lose_connect_yau():
|
||
for i in 4:
|
||
var sockets_ind = [$soc_y5/ref_A26/light_ind,
|
||
$soc_y5/ref_A27/light_ind,
|
||
$soc_y5/ref_A28/light_ind,
|
||
$soc_y5/ref_A29/light_ind]
|
||
sockets_ind[i].button_pressed = false
|
||
sockets_ind[i].disabled = true
|
||
|
||
for i in 8:
|
||
var node_power_ind = [$soc_P1/ref_A23/light_ind,
|
||
$soc_P1/ref_A24/light_ind,
|
||
$soc_P1/ref_A25/light_ind,
|
||
$soc_P1/ref_A26/light_ind,
|
||
$soc_P1/ref_A27/light_ind,
|
||
$soc_P1/ref_A28/light_ind,
|
||
$soc_P1/ref_A29/light_ind,
|
||
$soc_y5/ref_A24/light_ind]
|
||
node_power_ind[i].button_pressed = false
|
||
node_power_ind[i].disabled = true
|
||
|
||
|
||
func _on_data_received(data_from_yau_07):
|
||
var status_board = data_from_yau_07.decode_u8(Constants.DataIndices.STATUS_BOARD)
|
||
var dry_contact: int = data_from_yau_07.decode_u16(Constants.DataIndices.DRY_CONTACT) # Контроль сухих контактов (УГ)
|
||
|
||
## SOCKETS BOARDS
|
||
for i in 4:
|
||
var sockets_ind = [ $soc_y5/ref_A26/light_ind,
|
||
$soc_y5/ref_A27/light_ind,
|
||
$soc_y5/ref_A28/light_ind,
|
||
$soc_y5/ref_A29/light_ind]
|
||
var j = int(status_board & (1 << i) == 0)
|
||
if j == 0:
|
||
sockets_ind[i].button_pressed = true
|
||
sockets_ind[i].disabled = false
|
||
else:
|
||
sockets_ind[i].button_pressed = false
|
||
sockets_ind[i].disabled = true
|
||
|
||
## Блок ИП
|
||
for i in 8:
|
||
var node_power_ind = [$soc_P1/ref_A23/light_ind,
|
||
$soc_P1/ref_A24/light_ind,
|
||
$soc_P1/ref_A25/light_ind,
|
||
$soc_P1/ref_A26/light_ind,
|
||
$soc_P1/ref_A27/light_ind,
|
||
$soc_P1/ref_A28/light_ind,
|
||
$soc_P1/ref_A29/light_ind,
|
||
$soc_y5/ref_A24/light_ind]
|
||
var j = int(not(dry_contact & (1 << i) == 0))
|
||
if j == 0:
|
||
node_power_ind[i].button_pressed = true
|
||
node_power_ind[i].disabled = false
|
||
else:
|
||
node_power_ind[i].button_pressed = false
|
||
node_power_ind[i].disabled = true
|
||
|
||
|
||
## From Network status about yau-07
|
||
func _on_yau_status(yau_status:bool) -> void:
|
||
$soc_y5/ref_A30/light_ind.button_pressed = yau_status
|
||
$soc_y5/ref_A30/light_ind.disabled = not yau_status
|