diff --git a/ems_g.gd b/ems_g.gd index dec9433..7ff3296 100644 --- a/ems_g.gd +++ b/ems_g.gd @@ -97,54 +97,57 @@ func _on_data_received(data_from_yau_07): var out_imp: int = data_from_yau_07.decode_u16(Constants.DataIndices.OUT_IMPULS_PRD) var parent_node2 = get_parent().get_parent() + process_sockets_vert(in_blank, in_imp, 16, 1, parent_node2) + process_sockets_horizon(out_blank, out_imp, 16, 2, parent_node2) - for i_in in 16: - var socket_status = node_select1.get_node2(1, i_in+shift+1).get_child(0, false) - if (in_blank & (1 << i_in) != 0): - if i_in == 1: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(1).get_child(3), Constants.Frame.CONSTANT) - if i_in == 9: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(2).get_child(3), Constants.Frame.CONSTANT) - set_frame(socket_status, Constants.Frame.CONSTANT) - elif (in_imp & (1 << i_in) != 0): - if i_in == 1: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(1).get_child(3), Constants.Frame.VARIABLE) - if i_in == 9: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(2).get_child(3), Constants.Frame.VARIABLE) - set_frame(socket_status, Constants.Frame.VARIABLE) - else: - if i_in == 1: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(1).get_child(3), Constants.Frame.WORK) - if i_in == 9: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(2).get_child(3), Constants.Frame.WORK) - set_frame(socket_status, Constants.Frame.WORK) - # - for i_out in 16: - var socket_status = node_select1.get_node2(i_out+shift, 2).get_child(0, false) - if (out_blank & (1 << i_out) != 0): - if i_out == 1: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(3).get_child(3), Constants.Frame.CONSTANT) - if i_out == 4: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(4).get_child(3), Constants.Frame.CONSTANT) - if i_out == 9: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(5).get_child(3), Constants.Frame.CONSTANT) - set_frame(socket_status, Constants.Frame.CONSTANT) - elif (out_imp & (1 << i_out) != 0): - if i_out == 1: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(3).get_child(3), Constants.Frame.VARIABLE) - if i_out == 4: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(4).get_child(3), Constants.Frame.VARIABLE) - if i_out == 9: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(5).get_child(3), Constants.Frame.VARIABLE) - set_frame(socket_status, Constants.Frame.VARIABLE) - else: - if i_out == 1: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(3).get_child(3), Constants.Frame.WORK) - if i_out == 4: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(4).get_child(3), Constants.Frame.WORK) - if i_out == 9: - set_frame(parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(5).get_child(3), Constants.Frame.WORK) - set_frame(socket_status, Constants.Frame.WORK) +func process_sockets_horizon(blank: int, imp: int, count: int, col: int, parent_node2: Node): + for i in count: + var socket_status = node_select1.get_node2(col+i, shift).get_child(0, false) + var frame_type = Constants.Frame.WORK + + if (blank & (1 << i)) != 0: + frame_type = Constants.Frame.CONSTANT + elif (imp & (1 << i)) != 0: + frame_type = Constants.Frame.VARIABLE + + set_frame(socket_status, frame_type) + + if i == 1: + set_frame(get_specific_node(parent_node2, 5), frame_type) + if i == 2: + set_frame(get_specific_node(parent_node2, 6), frame_type) + if i == 4: + set_frame(get_specific_node(parent_node2, 7), frame_type) + if i == 5: + set_frame(get_specific_node(parent_node2, 8), frame_type) + if i == 9: + set_frame(get_specific_node(parent_node2, 9), frame_type) + + +func process_sockets_vert(blank: int, imp: int, count: int, col: int, parent_node2: Node): + for i in count: + var socket_status = node_select1.get_node2(col, i + shift+1).get_child(0, false) + var frame_type = Constants.Frame.WORK + + if (blank & (1 << i)) != 0: + frame_type = Constants.Frame.CONSTANT + elif (imp & (1 << i)) != 0: + frame_type = Constants.Frame.VARIABLE + + set_frame(socket_status, frame_type) + + if i == 1: + set_frame(get_specific_node(parent_node2, 1), frame_type) + if i == 2: + set_frame(get_specific_node(parent_node2, 2), frame_type) + if i == 9: + set_frame(get_specific_node(parent_node2, 3), frame_type) + if i == 10: + set_frame(get_specific_node(parent_node2, 4), frame_type) + + +func get_specific_node(parent_node2: Node, child_index: int)-> Node: + return parent_node2.get_child(3, false).get_child(1).get_child(5).get_child(child_index).get_child(3) func _process(_delta: float) -> void: diff --git a/scripts/PRD.gd b/scripts/PRD.gd index c0e1dc3..8b23e5a 100644 --- a/scripts/PRD.gd +++ b/scripts/PRD.gd @@ -159,26 +159,26 @@ func set_frame(node: Node, val: int): node.set_frame(val) func _on_prd_select() -> void: - $TabContainer.current_tab = 0 - $Background/side_panel/select_prd.button_pressed = true - $Background/side_panel/select_control.button_pressed = false - $Background/side_panel/select_ems_g.button_pressed = false + set_tab_and_buttons(0, 'select_prd') func _on_control_button() -> void: - $TabContainer.current_tab = 1 - $Background/side_panel/select_control.button_pressed = true - $Background/side_panel/select_prd.button_pressed = false - $Background/side_panel/select_ems_g.button_pressed = false + set_tab_and_buttons(1, 'select_control') func _on_emsg_select() -> void: emit_signal('read_ems_g_start') - $TabContainer.current_tab = 2 - $Background/side_panel/select_ems_g.button_pressed = true - $Background/side_panel/select_control.button_pressed = false - $Background/side_panel/select_prd.button_pressed = false + set_tab_and_buttons(2, 'select_ems_g') + + +func set_tab_and_buttons(tab_index: int, button_name: String) -> void: + $TabContainer.current_tab = tab_index + var side_panel = $Background/side_panel + for button in side_panel.get_children(): + if button is Button: + button.button_pressed = (button.name == button_name) + func on_btn_select(intem_from_sector): var node_select_device = $TabContainer/PRD/select_dev/select_dev diff --git a/scripts/constants.gd b/scripts/constants.gd index 253692f..76da37e 100644 --- a/scripts/constants.gd +++ b/scripts/constants.gd @@ -56,31 +56,31 @@ const INPUT_EMS_G: Array = [ '06 :39', '07 :40', '08 :41', - '18 :42', - '19 :43', - '20 :44', - '21 :45', - '22 :46', - '23 :47', - '24 :48', - '25 :49',] + '18 :34', + '19 :35', + '20 :36', + '21 :37', + '22 :38', + '23 :39', + '24 :40', + '25 :41',] const OUT_EMS_G: Array = [ - [47, '10 :34'], - [48, '11 :35'], - [49, '12 :36'], - [50, '13 :37'], - [51, '14 :38'], - [52, '15 :39'], - [53, '16 :40'], - [54, '17 :41'], - [55, '26 :42'], - [56, '27 :43'], - [57, '28 :44'], - [58, '29 :45'], - [59, '30 :46'], - [60, '31 :47'], - [61, '32 :48'], - [62, '33 :49']] + [47, '10 :43'], + [48, '11 :44'], + [49, '12 :45'], + [50, '13 :46'], + [51, '14 :47'], + [52, '15 :48'], + [53, '16 :49'], + [54, '17 :50'], + [55, '26 :43'], + [56, '27 :44'], + [57, '28 :45'], + [58, '29 :46'], + [59, '30 :47'], + [60, '31 :48'], + [61, '32 :49'], + [62, '33 :50']] const OUT_x128: Array = [ 'Р', 'К',