созидания контроля

This commit is contained in:
2025-02-18 11:03:11 +03:00
parent dd6c9345f7
commit 45fe4816f6
5 changed files with 3155 additions and 43 deletions

1019
PRD20D3.tmp Normal file

File diff suppressed because it is too large Load Diff

1018
PRD250A.tmp Normal file

File diff suppressed because it is too large Load Diff

1018
PRDDB30.tmp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -478,6 +478,7 @@ theme_override_font_sizes/font_size = 22
text = "Прибор не исправен"
horizontal_alignment = 1
vertical_alignment = 1
metadata/_edit_lock_ = true
[node name="soc_y5" type="NinePatchRect" parent="TabContainer/ControlPanel"]
layout_mode = 0
@@ -490,6 +491,7 @@ patch_margin_left = 16
patch_margin_top = 16
patch_margin_right = 16
patch_margin_bottom = 16
metadata/_edit_lock_ = true
[node name="IP5_25" parent="TabContainer/ControlPanel/soc_y5" instance=ExtResource("11_fg7ul")]
offset_left = 9.0
@@ -499,7 +501,7 @@ offset_bottom = 184.0
fname = "ИП5-25"
rname = "A24"
[node name="ay07" parent="TabContainer/ControlPanel/soc_y5" instance=ExtResource("11_fg7ul")]
[node name="yau_07b" parent="TabContainer/ControlPanel/soc_y5" instance=ExtResource("11_fg7ul")]
offset_left = 59.0
offset_top = 34.0
offset_right = 109.0
@@ -557,6 +559,7 @@ offset_top = 201.0
offset_right = 518.0
offset_bottom = 420.0
script = null
metadata/_edit_lock_ = true
[node name="Kasseta" type="Label" parent="TabContainer/ControlPanel/Kasseta_FS"]
self_modulate = Color(1, 1, 1, 0.62)
@@ -634,6 +637,7 @@ patch_margin_left = 16
patch_margin_top = 16
patch_margin_right = 16
patch_margin_bottom = 16
metadata/_edit_lock_ = true
[node name="Kasseta" type="Label" parent="TabContainer/ControlPanel/soc_P1"]
self_modulate = Color(1, 1, 1, 0.62)
@@ -702,6 +706,7 @@ patch_margin_left = 16
patch_margin_top = 16
patch_margin_right = 16
patch_margin_bottom = 16
metadata/_edit_lock_ = true
[node name="Kasseta" type="Label" parent="TabContainer/ControlPanel/soc_DKM"]
self_modulate = Color(1, 1, 1, 0.62)
@@ -752,6 +757,7 @@ patch_margin_left = 16
patch_margin_top = 16
patch_margin_right = 16
patch_margin_bottom = 16
metadata/_edit_lock_ = true
[node name="Kasseta" type="Label" parent="TabContainer/ControlPanel/soc_P2"]
self_modulate = Color(1, 1, 1, 0.62)
@@ -790,12 +796,14 @@ offset_right = 695.0
offset_bottom = 235.0
metadata/_edit_lock_ = true
[node name="Power_array" type="Label" parent="TabContainer/ControlPanel"]
[node name="log_array" type="TextEdit" parent="TabContainer/ControlPanel"]
layout_mode = 0
offset_left = 913.0
offset_top = 433.0
offset_right = 1447.0
offset_bottom = 456.0
offset_left = 875.0
offset_top = 22.0
offset_right = 1515.0
offset_bottom = 664.0
placeholder_text = "Ожидание контроля ..."
metadata/_edit_lock_ = true
[node name="EMS_G" type="Panel" parent="TabContainer"]
visible = false

View File

@@ -1,25 +1,55 @@
extends Panel
var timer = Timer.new()
var timer: Timer = Timer.new()
var node_cell_ind: Array
var count_cell: int
var past_pribor: int
var logger: Node
class Logger extends Node:
var log_counter: int = 0
var log_level = "INFO"
var log_array
func _init(log_node):
log_array = log_node
log_array.clear()
func get_current_datetime_string() -> String:
var time = Time.get_datetime_dict_from_system()
return ' [%02d-%02d-%04d %02d:%02d] ' % [time['day'], time['month'], time['year'], time['hour'], time['minute']]
func info(message):
if log_level == "INFO" or log_level == "DEBUG":
var datetime_string = get_current_datetime_string()
log_array.insert_line_at(log_counter, "[INFO]" + datetime_string + message)
log_counter += 1
func warning(message):
if log_level == "WARNING" or log_level == "INFO" or log_level == "DEBUG":
var datetime_string = get_current_datetime_string()
log_array.insert_line_at(log_counter, "[WARNING]" + datetime_string + message)
log_counter += 1
func error(message):
var datetime_string = get_current_datetime_string()
log_array.insert_line_at(log_counter, "[ERROR]" + datetime_string + message)
log_counter += 1
func _ready() -> void:
Network.connect('port_fs_opened_1', _on_fs_status_1.bind(Constants.STATE_VAL.GOOD))
Network.connect('port_fs_closed_1', _on_fs_status_1.bind(Constants.STATE_VAL.NONE))
Network.connect('port_fs_opened_2', _on_fs_status_2.bind(Constants.STATE_VAL.GOOD))
Network.connect('port_fs_closed_2', _on_fs_status_2.bind(Constants.STATE_VAL.NONE))
self.add_child(timer)
timer.connect('timeout', Callable(self, '_on_timer').bind(Network.unit))
timer.start(1)
timer.connect('timeout', Callable(self, '_on_timer'))
node_cell_ind = [
$soc_y5/ay07,
$soc_y5/yau_07b,
$soc_y5/ems_g,
$soc_y5/ug,
$soc_y5/ukp_2,
@@ -46,31 +76,20 @@ func _ready() -> void:
_draw_control_panel_prd(Constants.CURRENT_MODE)
func _on_timer(pribor_prd):
if (past_pribor != Constants.CURRENT_MODE):
_draw_control_panel_prd(Constants.CURRENT_MODE)
if (pribor_prd.online):
$soc_y5/ay07.state = Constants.STATE_VAL.GOOD
_status_cell(pribor_prd.status)
else:
$soc_y5/ay07.state = Constants.STATE_VAL.ERROR
for i in range(1,count_cell):
node_cell_ind[i].state = Constants.STATE_VAL.NONE
_status_prd()
past_pribor = Constants.CURRENT_MODE
func _status_cell(status):
var status_board: int = status.decode_u8(Constants.DataIndices.STATUS_BOARD)
var dry_contact: int = status.decode_u8(Constants.DataIndices.DRY_CONTACT)
var dkm: int = status.decode_u8(Constants.DataIndices.DKM)
$DKM.text = str(dkm)
# status_board
for i in range(1, 5):
if ((status_board >> (i-1)) & 0x1) == 1:
node_cell_ind[i].state = Constants.STATE_VAL.GOOD
logger.info("%s : Есть связь ✅" % node_cell_ind[i].get('fname'))
else:
node_cell_ind[i].state = Constants.STATE_VAL.ERROR
logger.error("%s : Нет связи ❌" % node_cell_ind[i].get('fname'))
#dkm
if Constants.CURRENT_MODE == Constants.MODE.PRD_H:
@@ -96,11 +115,15 @@ func _status_cell(status):
for i in range(5, 13):
if ((dry_contact >> (i-5)) & 0x1) == 0:
node_cell_ind[i].state = Constants.STATE_VAL.GOOD
logger.info("%s : Есть связь ✅" % node_cell_ind[i].get('fname'))
else:
node_cell_ind[i].state = Constants.STATE_VAL.ERROR
logger.error("%s : Нет связи ❌" % node_cell_ind[i].get('fname'))
else:
for i in range(5, 13):
node_cell_ind[i].state = Constants.STATE_VAL.NONE
func _status_prd():
@@ -116,26 +139,20 @@ func _status_prd():
status += 1 if (node_cell_ind[12].state == Constants.STATE_VAL.GOOD) else 0
status += 1 if (node_cell_ind[17].state == Constants.STATE_VAL.GOOD) else 0
status += 1 if (node_cell_ind[18].state == Constants.STATE_VAL.GOOD) else 0
if (status == count_cell):
$lbl_control.text = 'Прибор исправен'
$lbl_control.modulate = Color.AQUAMARINE
else:
$lbl_control.text = 'Прибор неисправен'
$lbl_control.modulate = Color.CRIMSON
if (status == count_cell-5):
$lbl_control.text = 'Прибор исправен'
$lbl_control.modulate = Color.AQUAMARINE
else:
if (status == count_cell-5):
$lbl_control.text = 'Прибор исправен'
$lbl_control.modulate = Color.AQUAMARINE
else:
$lbl_control.text = 'Прибор неисправен'
$lbl_control.modulate = Color.CRIMSON
$lbl_control.text = 'Прибор неисправен'
$lbl_control.modulate = Color.CRIMSON
func _draw_control_panel_prd(pribor):
if pribor == Constants.MODE.PRD_H:
# Кассета У5
$soc_y5/IP5_25.rname = 'А24'
$soc_y5/ay07.rname = 'А30'
$soc_y5/yau_07b.rname = 'А30'
$soc_y5/ems_g.rname = 'А26'
$soc_y5/ug.rname = 'А27'
$soc_y5/ukp_1.rname = 'А28'
@@ -169,7 +186,7 @@ func _draw_control_panel_prd(pribor):
elif pribor == Constants.MODE.PRD_B:
# Кассета У5
$soc_y5/IP5_25.rname = 'А24'
$soc_y5/ay07.rname = 'А30'
$soc_y5/yau_07b.rname = 'А30'
$soc_y5/ems_g.rname = 'А26'
$soc_y5/ug.rname = 'А27'
$soc_y5/ukp_1.rname = 'А28'
@@ -202,7 +219,7 @@ func _draw_control_panel_prd(pribor):
elif pribor == Constants.MODE.PRD_K:
# Кассета У5
$soc_y5/IP5_25.rname = 'А31'
$soc_y5/ay07.rname = 'А37'
$soc_y5/yau_07b.rname = 'А37'
$soc_y5/ems_g.rname = 'А33'
$soc_y5/ug.rname = 'А34'
$soc_y5/ukp_1.rname = 'А35'
@@ -246,4 +263,36 @@ func _on_fs_status_2(_name_port, status_fs_2):
func _on_start_super_control():
$Power_array.text = 'Hello'
logger = Logger.new(get_node('log_array'))
timer.start(5)
if (past_pribor != Constants.CURRENT_MODE):
_draw_control_panel_prd(Constants.CURRENT_MODE)
if (Network.unit.online):
$soc_y5/yau_07b.state = Constants.STATE_VAL.GOOD
logger.info("Яу-07б: Есть связь ✅")
_status_cell(Network.unit.status)
else:
for i in range(1, count_cell):
node_cell_ind[i].state = Constants.STATE_VAL.NONE
$soc_y5/yau_07b.state = Constants.STATE_VAL.ERROR
logger.error("Яу-07б: Нет связи ❌")
_status_prd()
past_pribor = Constants.CURRENT_MODE
func _on_timer():
if (Network.unit.online):
logger = Logger.new(get_node('log_array'))
logger.info("Яу-07б: Есть связь ✅")
$soc_y5/yau_07b.state = Constants.STATE_VAL.GOOD
_status_cell(Network.unit.status)
else:
for i in range(1, count_cell):
node_cell_ind[i].state = Constants.STATE_VAL.NONE
$soc_y5/yau_07b.state = Constants.STATE_VAL.ERROR
logger.error("Яу-07б: Нет связи ❌")