Merge remote-tracking branch 'origin/master'
# Conflicts: # project.godot
This commit is contained in:
@@ -17,7 +17,7 @@ extends 'res://scenes/контроль/элемент-я.gd'
|
||||
var regs_input: = {} ## Регистры входные
|
||||
var regs_holding: = {} ## Регистры хранения
|
||||
var switches_sync: = false ## Флаг. Если установлен, то можно переключать
|
||||
|
||||
var external_ctl: = false ## Флаг внешнего управления
|
||||
|
||||
func on_error(msg, unit_sch3):
|
||||
if unit_sch3.online:
|
||||
@@ -42,7 +42,7 @@ func on_line_changed_sch3(unit_sch3):
|
||||
|
||||
|
||||
func on_settings_changed():
|
||||
var external_ctl = ProjectSettings.get_setting('application/config/Внешнее управление', false)
|
||||
external_ctl = ProjectSettings.get_setting('application/config/Внешнее управление', false)
|
||||
if not external_ctl:
|
||||
return
|
||||
var items = get_tree().get_nodes_in_group('bits_items_switch')
|
||||
@@ -77,8 +77,7 @@ func _enter_tree() -> void:
|
||||
unit_sch3.regs_input_count = regs_input_count
|
||||
unit_sch3.request_period = request_period
|
||||
unit_sch3.reconnect_period = reconnect_period
|
||||
unit_sch3.connect('read', on_read.bind(unit_sch3))
|
||||
unit_sch3.connect('read_input', on_input)
|
||||
unit_sch3.connect('read_input', on_input.bind(unit_sch3))
|
||||
unit_sch3.connect('error', on_error.bind(unit_sch3))
|
||||
unit_sch3.connect('line_changed', on_line_changed_sch3)
|
||||
|
||||
@@ -98,40 +97,16 @@ func _exit_tree() -> void:
|
||||
if Engine.is_editor_hint(): return
|
||||
var unit_key = settings.get_unit_key(unit_name)
|
||||
var unit_sch3 = network.units[unit_key]
|
||||
unit_sch3.disconnect('read', on_read.bind(unit_sch3))
|
||||
unit_sch3.disconnect('read_input', on_input.bind(unit_sch3))
|
||||
external_ctl = ProjectSettings.get_setting('application/config/Внешнее управление', false)
|
||||
unit_sch3.disconnect('error', on_error)
|
||||
unit_sch3.disconnect('line_changed', on_line_changed_sch3)
|
||||
|
||||
|
||||
## Вызывается по сигналу "приняты данные чтения регистров хранения"[br]
|
||||
## [param base_addr] - Начальный адрес регистров.[br]
|
||||
## [param data] - Массив значений прочитанных из регистров.
|
||||
func on_read(base_addr: int, data: Array, unit_sch3):
|
||||
if (base_addr != base_holding_address) or (data.size() < regs_holding_count):
|
||||
return
|
||||
for i in data.size():
|
||||
regs_holding[base_addr + i] = data[i]
|
||||
# Разрешить работу выключателей только когда прочитано их реальное состояние
|
||||
if not switches_sync:
|
||||
switches_sync = true
|
||||
for item in get_tree().get_nodes_in_group('bits_items_switch'):
|
||||
var bits = item.get_meta('bits')
|
||||
var byte0: int = bits[0] # Адрес регистра
|
||||
var bit0: int = bits[1] # Индекс бита
|
||||
var byte1: int = bits[2] # Адрес регистра
|
||||
var bit1: int = bits[3] # Индекс бита
|
||||
var val0: bool = regs_holding[byte0] & (1 << bit0) > 0
|
||||
item.button_pressed = val0
|
||||
item.disabled = false
|
||||
regs_holding[byte1] = tools.set_bit(regs_holding[byte1], bit1, not val0)
|
||||
unit_sch3.push_write_holding(regs_holding)
|
||||
|
||||
|
||||
## Вызывается по сигналу "приняты данные чтения регистров входов".[br]
|
||||
## [param base_addr] - Начальный адрес регистров.[br]
|
||||
## [param data] - Массив значений прочитанных из регистров.[br]
|
||||
func on_input(base_addr: int, data: Array):
|
||||
func on_input(base_addr: int, data: Array, unit_sch3):
|
||||
if !is_inside_tree():
|
||||
return
|
||||
if (base_addr != base_input_address) or (data.size() < regs_input_count):
|
||||
@@ -143,6 +118,29 @@ func on_input(base_addr: int, data: Array):
|
||||
var items = get_tree().get_nodes_in_group('bits_items_good')
|
||||
for i in data.size():
|
||||
regs_input[base_addr + i] = data[i]
|
||||
# Разрешить работу выключателей только когда прочитано их реальное состояние
|
||||
if not switches_sync:
|
||||
regs_holding[0] = regs_input[0]
|
||||
regs_holding[1] = regs_input[1]
|
||||
for i in 16:
|
||||
regs_holding[2] = tools.set_bit(regs_holding[0], i, not ((regs_holding[0] >> i) & 1))
|
||||
regs_holding[3] = tools.set_bit(regs_holding[1], i, not ((regs_holding[1] >> i) & 1))
|
||||
if not external_ctl:
|
||||
if regs_holding.has(0) and regs_holding.has(2):
|
||||
regs_holding[0] = regs_holding[0] | 1
|
||||
regs_holding[2] = regs_holding[2] & 0xffe
|
||||
switches_sync = true
|
||||
for item in get_tree().get_nodes_in_group('bits_items_switch'):
|
||||
var bits = item.get_meta('bits')
|
||||
var byte0: int = bits[0] # Адрес регистра
|
||||
var bit0: int = bits[1] # Индекс бита
|
||||
var byte1: int = bits[2] # Адрес регистра
|
||||
var bit1: int = bits[3] # Индекс бита
|
||||
var val0: bool = regs_holding[byte0] & (1 << bit0) > 0
|
||||
item.set_pressed_no_signal(val0)
|
||||
item.disabled = false
|
||||
regs_holding[byte1] = tools.set_bit(regs_holding[byte1], bit1, not val0)
|
||||
unit_sch3.push_write_holding(regs_holding)
|
||||
# Таблица 3.15, Регистр PowerState
|
||||
$margin/vbox/grid1/lbl_freq.text = '%d' % (regs_input[4] & 0x1ff)
|
||||
$margin/vbox/grid1/lbl_freq.self_modulate = Color.WHITE
|
||||
|
||||
@@ -142,6 +142,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания УФ"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 0, 2, 0]
|
||||
@@ -171,6 +172,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания РТР"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 1, 2, 1]
|
||||
@@ -199,6 +201,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания ПРД-Н.1"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 2, 2, 2]
|
||||
@@ -228,6 +231,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания ПРД-Н.2"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 3, 2, 3]
|
||||
@@ -257,6 +261,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания ПРД-Н.3"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 4, 2, 4]
|
||||
@@ -286,6 +291,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания ПРД-Н.4"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 5, 2, 5]
|
||||
@@ -315,6 +321,7 @@ material = SubResource("ShaderMaterial_vdwfd")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания ПРД-В.1"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 6, 2, 6]
|
||||
@@ -344,6 +351,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания ПРД-В.2"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 7, 2, 7]
|
||||
@@ -373,6 +381,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания ПРД-В.3"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 8, 2, 8]
|
||||
@@ -402,6 +411,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания ПРД-В.4"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 9, 2, 9]
|
||||
@@ -431,6 +441,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания ПРД-К.1"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 10, 2, 10]
|
||||
@@ -460,6 +471,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания ПРД-К.2"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [0, 11, 2, 11]
|
||||
@@ -489,6 +501,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 2
|
||||
tooltip_text = "Выключатель питания ПРД-К.3"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [1, 0, 3, 0]
|
||||
@@ -518,6 +531,7 @@ material = SubResource("ShaderMaterial_c1mqk")
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
tooltip_text = "Выключатель питания ПРД-К.4"
|
||||
button_pressed = true
|
||||
action_mode = 0
|
||||
script = ExtResource("7_l6esm")
|
||||
metadata/bits = [1, 1, 3, 1]
|
||||
|
||||
Reference in New Issue
Block a user