Merge remote-tracking branch 'origin/master' into master-prd
BIN
data/load1.png
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 6.0 KiB |
BIN
data/save1.png
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 8.9 KiB |
@@ -80,6 +80,7 @@ gdscript/warnings/integer_division=0
|
||||
|
||||
window/size/viewport_width=1600
|
||||
window/size/viewport_height=1200
|
||||
window/size/window_width_override=1024
|
||||
window/size/window_height_override=768
|
||||
window/subwindows/embed_subwindows=false
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@tool
|
||||
class_name pribor_rtr extends 'res://scenes/контроль/прибор.gd'
|
||||
|
||||
@export var prefix_path: String = 'DeviceDescripton[DeviceName]'
|
||||
|
||||
@@ -131,48 +131,56 @@ layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 1"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[0]['TestPassed']"
|
||||
|
||||
[node name="kanal2" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 2"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[1]['TestPassed']"
|
||||
|
||||
[node name="kanal3" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 3"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[2]['TestPassed']"
|
||||
|
||||
[node name="kanal4" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 4"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[3]['TestPassed']"
|
||||
|
||||
[node name="kanal5" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 5"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[4]['TestPassed']"
|
||||
|
||||
[node name="kanal6" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 6"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[5]['TestPassed']"
|
||||
|
||||
[node name="kanal7" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 7"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[6]['TestPassed']"
|
||||
|
||||
[node name="kanal8" parent="grid_bpo_a2" instance=ExtResource("2_jp6m0")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 7
|
||||
size_flags_vertical = 7
|
||||
fname = "Канал 8"
|
||||
metadata/state = "SelfTest[0].SystemList[0].DevList[7]['TestPassed']"
|
||||
|
||||
[node name="yas_bpo_a2" parent="." instance=ExtResource("3_jcpjs")]
|
||||
offset_left = 500.0
|
||||
|
||||
@@ -36,7 +36,7 @@ func on_line_changed_sch3(unit_sch3):
|
||||
regs_input.clear()
|
||||
switches_sync = false
|
||||
$margin/vbox/grid1/lbl_freq.text = '<нет данных>'
|
||||
$margin/vbox/grid1/lbl_freq.self_modulate = Color(settings.C_BLUE)
|
||||
$margin/vbox/grid1/lbl_freq.self_modulate = Color.CADET_BLUE
|
||||
$margin/vbox/grid1/state_freq.texture = textures[STATE_VAL.NONE]
|
||||
$margin/vbox/grid/state.texture = textures[STATE_VAL.NONE]
|
||||
|
||||
|
||||
BIN
scenes/tilemap/23900.png
Normal file
|
After Width: | Height: | Size: 122 KiB |
@@ -2,16 +2,16 @@
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b3i0dm4vk3fvu"
|
||||
path="res://.godot/imported/ship2.png-dfba13504c314fdc4446dacd0ce91bc5.ctex"
|
||||
uid="uid://cj1f2uy6qfvki"
|
||||
path="res://.godot/imported/23900.png-aba6c607cdfb6350afef981f7b82f108.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/ship2.png"
|
||||
dest_files=["res://.godot/imported/ship2.png-dfba13504c314fdc4446dacd0ce91bc5.ctex"]
|
||||
source_file="res://scenes/tilemap/23900.png"
|
||||
dest_files=["res://.godot/imported/23900.png-aba6c607cdfb6350afef981f7b82f108.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
|
Before Width: | Height: | Size: 7.8 KiB |
@@ -1,34 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bry3qqgbuvpdt"
|
||||
path="res://.godot/imported/ship.png-1e5b46229cc4c1adf618fcb5da01fb4c.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/ship.png"
|
||||
dest_files=["res://.godot/imported/ship.png-1e5b46229cc4c1adf618fcb5da01fb4c.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
Before Width: | Height: | Size: 7.0 KiB |
@@ -1,34 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dct2op842kyxo"
|
||||
path="res://.godot/imported/ship1.png-fb0d0fe319583fdccb34710f90651bfb.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/ship1.png"
|
||||
dest_files=["res://.godot/imported/ship1.png-fb0d0fe319583fdccb34710f90651bfb.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
|
Before Width: | Height: | Size: 6.9 KiB |
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c2523fcn14gn4"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b3i0dm4vk3fvu" path="res://scenes/tilemap/ship2.png" id="1_o15fj"]
|
||||
[ext_resource type="Texture2D" uid="uid://cj1f2uy6qfvki" path="res://scenes/tilemap/23900.png" id="1_v0nwa"]
|
||||
|
||||
[node name="Ship_mark" type="Sprite2D"]
|
||||
position = Vector2(2.38419e-07, -1.19209e-07)
|
||||
scale = Vector2(0.496428, 0.496429)
|
||||
texture = ExtResource("1_o15fj")
|
||||
[node name="23900" type="Sprite2D"]
|
||||
rotation = 4.71239
|
||||
scale = Vector2(0.0257427, 0.0257427)
|
||||
texture = ExtResource("1_v0nwa")
|
||||
|
||||
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 318 KiB |
@@ -2,8 +2,6 @@
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://mobingoxskg1" path="res://scenes/tilemap/threat.png" id="1_pvxsy"]
|
||||
|
||||
[node name="Threat" type="Node2D"]
|
||||
|
||||
[node name="Threat" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.171358, 0.171358)
|
||||
[node name="Threat" type="Sprite2D"]
|
||||
scale = Vector2(0.0244268, 0.0244268)
|
||||
texture = ExtResource("1_pvxsy")
|
||||
|
||||
@@ -156,7 +156,7 @@ func on_data_received(coords: Dictionary) -> void:
|
||||
|
||||
|
||||
func _on_resize() -> void:
|
||||
var center = $canvas.size / 2.0
|
||||
var center: Vector2 = $canvas.size / 2.0
|
||||
$canvas/spr_mask.position = center
|
||||
$canvas/spr_mask.scale = $canvas.size / default_size
|
||||
|
||||
@@ -165,7 +165,7 @@ func _on_resize() -> void:
|
||||
func add_mark_from_screen_pos(id: int, scr_xy: Vector2, mark: Node) -> bool:
|
||||
if _marks.has(id):
|
||||
return false
|
||||
var wrld_pos = screen_to_world(_xyz, scr_xy)
|
||||
var wrld_pos: Vector2 = screen_to_world(_xyz, scr_xy)
|
||||
_marks[id] = { 'position': wrld_pos, 'mark': mark, 'gap_size': 0.0 }
|
||||
add_child(mark)
|
||||
return true
|
||||
@@ -184,7 +184,7 @@ func delete_mark(id: int) -> bool:
|
||||
func add_mark_from_lon_lat(id: int, lon: float, lat: float, mark: Node, gap_size: float = 32) -> bool:
|
||||
if _marks.has(id):
|
||||
return false
|
||||
var wrld_pos = lonlat_to_world(lon, lat)
|
||||
var wrld_pos: Vector2 = lonlat_to_world(lon, lat)
|
||||
_marks[id] = {'position': wrld_pos, 'mark': mark, 'gap_size': gap_size}
|
||||
add_child(mark)
|
||||
queue_redraw()
|
||||
@@ -249,7 +249,6 @@ func _input(e) -> void:
|
||||
func multiply_zoom(multiplier: float, pivot: Vector2) -> void:
|
||||
var p1: = screen_to_world(_xyz, pivot)
|
||||
_xyz.z = clampf(_xyz.z * multiplier, min_zoom_level, max_zoom_level)
|
||||
update_scale_label()
|
||||
var p2: = screen_to_world(_xyz, pivot)
|
||||
_xyz.x -= p2.x - p1.x
|
||||
_xyz.y -= p2.y - p1.y
|
||||
@@ -273,30 +272,30 @@ func set_zoom(zoom: float, pivot: Vector2) -> void:
|
||||
|
||||
func _draw() -> void:
|
||||
# Рисование плиток
|
||||
var z = min(max_zoom_level, _xyz.z)
|
||||
var t1 = screen_to_tile(Vector2(0, 0), z)
|
||||
var t2 = screen_to_tile($canvas.size, z) + Vector2(1, 1)
|
||||
var z: float = min(max_zoom_level, _xyz.z)
|
||||
var t1: = screen_to_tile(Vector2(0, 0), z)
|
||||
var t2: = screen_to_tile($canvas.size, z) + Vector2(1, 1)
|
||||
is_out_border1 = true
|
||||
is_out_border2 = true
|
||||
for tx in range(t1.x, t2.x):
|
||||
for ty in range(t1.y, t2.y):
|
||||
_draw_tile(tx, ty, z)
|
||||
# Рисование отметок
|
||||
var n = pow(2, z)
|
||||
var dx = n * tile_width
|
||||
var n: = pow(2, z)
|
||||
var dx: = n * tile_width
|
||||
var c: Vector2 = $canvas.size / 2.0
|
||||
var r = c.length()
|
||||
var r: float = c.length()
|
||||
visible_marks_count = 0
|
||||
for dot in _marks.values():
|
||||
var scr_pos = world_to_screen(dot.position)
|
||||
var scr_pos: Vector2 = world_to_screen(dot.position)
|
||||
scr_pos.x = posmod(scr_pos.x, dx)
|
||||
dot.mark.position = scr_pos
|
||||
dot.mark.visible = is_mark_visible(dot)
|
||||
dot.mark.visible = c.distance_to(scr_pos) < (r - dot.gap_size)
|
||||
visible_marks_count += int(dot.mark.visible)
|
||||
# Рисование границ
|
||||
var p1 = $canvas.position
|
||||
var p2 = $canvas.size / Vector2(1, 20)
|
||||
var p1: Vector2 = $canvas.position
|
||||
var p2: Vector2 = $canvas.size / Vector2(1, 20)
|
||||
if is_out_border1 and _dragging:
|
||||
draw_texture_rect(border1, Rect2(p1, p2), false, Color.WHITE, false)
|
||||
p1.y = p1.y + $canvas.size.y - p2.y
|
||||
@@ -455,74 +454,74 @@ func _draw_tile(tx: int, ty: int, z: float) -> void:
|
||||
|
||||
## convert lon/lat to world coords
|
||||
func lonlat_to_world(lon: float, lat: float) -> Vector2:
|
||||
var x = lon / 180.0
|
||||
var latsin = sin(deg_to_rad(lat) * sign(lat))
|
||||
var y = (sign(lat) * (log((1.0 + latsin) / (1.0 - latsin)) / 2.0)) / PI
|
||||
var x: = lon / 180.0
|
||||
var latsin: = sin(deg_to_rad(lat) * sign(lat))
|
||||
var y: float = (sign(lat) * (log((1.0 + latsin) / (1.0 - latsin)) / 2.0)) / PI
|
||||
return Vector2(x, y)
|
||||
|
||||
|
||||
## convert lon/lat to screen coords
|
||||
func lonlat_to_screen(lon: float, lat: float) -> Vector2:
|
||||
var w = lonlat_to_world(lon, lat)
|
||||
var w: Vector2 = lonlat_to_world(lon, lat)
|
||||
return world_to_screen(w)
|
||||
|
||||
|
||||
## convert lon/lat to tile coords
|
||||
func lonlat_to_tile(lon: float, lat: float, z: float) -> Vector2:
|
||||
var w = lonlat_to_world(lon,lat)
|
||||
var w: Vector2 = lonlat_to_world(lon,lat)
|
||||
return world_to_tile(w.x, w.y, z)
|
||||
|
||||
|
||||
## convert world coords to lon/lat
|
||||
func world_to_lonlat(wx: float, wy: float) -> Vector2:
|
||||
var lon = wx * 180.0
|
||||
var lat = rad_to_deg(atan(sinh(wy * PI)))
|
||||
var lon: float = wx * 180.0
|
||||
var lat: float = rad_to_deg(atan(sinh(wy * PI)))
|
||||
return Vector2(lon, lat)
|
||||
|
||||
|
||||
## convert screen coords to lon/lat
|
||||
func screen_to_lonlat(scr_xy: Vector2) -> Vector2:
|
||||
var w = screen_to_world(_xyz, scr_xy)
|
||||
var w: Vector2 = screen_to_world(_xyz, scr_xy)
|
||||
return world_to_lonlat(w.x, w.y)
|
||||
|
||||
|
||||
## convert tile coords to lon/lat
|
||||
func tile_to_lonlat(tx: float, ty: float, tz: float) -> Vector2:
|
||||
var w = tile_to_world(tx, ty, tz)
|
||||
var w: Vector2 = tile_to_world(tx, ty, tz)
|
||||
return world_to_lonlat(w.x, w.y)
|
||||
|
||||
|
||||
## convert screen coords to world coords
|
||||
func screen_to_world(xyz: Vector3, s: Vector2) -> Vector2:
|
||||
var n = pow(2.0, xyz.z)
|
||||
var span_w = n * tile_width
|
||||
var span_h = n * tile_height
|
||||
var px = s.x - $canvas.size.x / 2 + span_w / 2
|
||||
var py = s.y - $canvas.size.y / 2 + span_h / 2
|
||||
var xr = px / span_w
|
||||
var yr = py / span_h
|
||||
var x = (xr * 2.0 - 1.0) + xyz.x
|
||||
var y = ((-yr * 2.0) + 1.0) + xyz.y
|
||||
var n: float = pow(2.0, xyz.z)
|
||||
var span_w: float = n * tile_width
|
||||
var span_h: float = n * tile_height
|
||||
var px: float = s.x - $canvas.size.x / 2 + span_w / 2
|
||||
var py: float = s.y - $canvas.size.y / 2 + span_h / 2
|
||||
var xr: float = px / span_w
|
||||
var yr: float = py / span_h
|
||||
var x: float = (xr * 2.0 - 1.0) + xyz.x
|
||||
var y: float = ((-yr * 2.0) + 1.0) + xyz.y
|
||||
return Vector2(x, y)
|
||||
|
||||
|
||||
## convert screen coords to tile coords
|
||||
func screen_to_tile(scr_xy: Vector2, z: float) -> Vector2:
|
||||
var world = screen_to_world(_xyz, scr_xy)
|
||||
var world: Vector2 = screen_to_world(_xyz, scr_xy)
|
||||
return world_to_tile(world.x, world.y, z)
|
||||
|
||||
|
||||
## convert tile coords to screen coords
|
||||
func tile_to_screen(tx: float, ty: float, tz: float) -> Vector2:
|
||||
var w = tile_to_world(tx, ty, tz)
|
||||
var w: Vector2 = tile_to_world(tx, ty, tz)
|
||||
return world_to_screen(w)
|
||||
|
||||
|
||||
## convert tile coords to world coords
|
||||
func tile_to_world(tx: float, ty: float, tz: float) -> Vector2:
|
||||
var n = pow(2.0, floor(tz))
|
||||
var x = (tx / n) * 2.0 - 1.0
|
||||
var y = -((ty / n) * 2.0 - 1.0)
|
||||
var n: float = pow(2.0, floor(tz))
|
||||
var x: float = (tx / n) * 2.0 - 1.0
|
||||
var y: float = -((ty / n) * 2.0 - 1.0)
|
||||
return Vector2(x, y)
|
||||
|
||||
|
||||
@@ -551,7 +550,7 @@ func xyz_to_idx(x: float, y: float, z: float) -> int:
|
||||
|
||||
func get_tile(x: int, y: int, z: int) -> Tile:
|
||||
|
||||
var n = pow(2, z)
|
||||
var n: float = pow(2, z)
|
||||
if x >= 0:
|
||||
x %= int(n)
|
||||
else:
|
||||
@@ -561,7 +560,7 @@ func get_tile(x: int, y: int, z: int) -> Tile:
|
||||
if z < 0 or y < 0 or y >= n:
|
||||
return null
|
||||
|
||||
var idx = xyz_to_idx(x, y, z)
|
||||
var idx: int = xyz_to_idx(x, y, z)
|
||||
|
||||
var req: = get_node_or_null(NodePath(TILE_REQUEST_NAME % idx))
|
||||
if req:
|
||||
@@ -594,12 +593,12 @@ func get_tile(x: int, y: int, z: int) -> Tile:
|
||||
|
||||
|
||||
func lonlat_to_dms(lon: float, lat: float) -> String:
|
||||
var pf = 'N' if lat >= 0 else 'S'
|
||||
var pf: String = 'N' if lat >= 0 else 'S'
|
||||
lat = abs(lat)
|
||||
var deg = floor(lat)
|
||||
var minute = (lat - deg) * 60
|
||||
var second = (minute - floor(minute)) * 60
|
||||
var text = ('%02d' % deg) + ('%02d' % floor(minute)) + ('%02d' % floor(second)) + pf + ' '
|
||||
var deg: float = floor(lat)
|
||||
var minute: float = (lat - deg) * 60
|
||||
var second: float = (minute - floor(minute)) * 60
|
||||
var text: String = ('%02d' % deg) + ('%02d' % floor(minute)) + ('%02d' % floor(second)) + pf + ' '
|
||||
|
||||
pf = 'E' if lon >= 0 else 'W'
|
||||
lon = abs(lon)
|
||||
@@ -679,7 +678,7 @@ func clear() -> void:
|
||||
|
||||
func set_coordinates(lon: float, lat: float) -> void:
|
||||
var anim: Animation = $player.get_animation('goto')
|
||||
var new_pos = lonlat_to_world(lon, lat)
|
||||
var new_pos: Vector2 = lonlat_to_world(lon, lat)
|
||||
anim.track_insert_key(0, 0, _xyz.x)
|
||||
anim.track_insert_key(1, 0, _xyz.y)
|
||||
anim.track_insert_key(0, animation_time, new_pos.x)
|
||||
|
||||
@@ -55,7 +55,7 @@ const UM_MAX: = 55.0
|
||||
func _ready() -> void:
|
||||
if Engine.is_editor_hint():
|
||||
return
|
||||
var settings_file = settings.get_settings_file_path()
|
||||
var settings_file = get_settings_file_path()
|
||||
var abs_path = ProjectSettings.globalize_path(settings_file)
|
||||
log.info('Путь к файлу настроек: \"%s\"' % abs_path)
|
||||
var file = FileAccess.open(settings_file, FileAccess.READ)
|
||||
|
||||
@@ -24,7 +24,7 @@ class Unit extends Object:
|
||||
var tx_tick: int = 0 ## Тик-время отправки буфера
|
||||
var rx_tick: int = 0 ## Тик-время последнего приёма данных
|
||||
var online: bool = false ## Состояние подключения устройства
|
||||
var name: String = '<без имени>' ## Уникальное имя устройства
|
||||
var name: StringName = '<без имени>' ## Уникальное имя устройства
|
||||
func _init(nm) -> void: self.name = nm
|
||||
func _to_string() -> String:
|
||||
return String('Unit(\"%s\", %s)' % [self.name, 'на связи' if online else 'отключен'])
|
||||
|
||||
@@ -2,11 +2,11 @@ class_name yau_07 extends Node
|
||||
|
||||
## Протокол ячейки ЯУ-07.
|
||||
|
||||
const ONLINE_TIMEOUT = 5000 ## Время ожидания пакета от ячейки, милисекунды
|
||||
const RESEND_TIMEOUT = 300 ## Задержка для повторной отправки команды, милисекунды
|
||||
const RESEND_TIMEOUT_FLASH = 1500 ## Задержка для повторной отправки команды флеш, милисекунды
|
||||
const RETRY_COUNT = 5 ## Количество повторных отправок
|
||||
const BUFFER_SIZE = 2048 ## Размер буфера для приёма датаграмм
|
||||
const ONLINE_TIMEOUT: = 5000 ## Время ожидания пакета от ячейки, милисекунды
|
||||
const RESEND_TIMEOUT: = 300 ## Задержка для повторной отправки команды, милисекунды
|
||||
const RESEND_TIMEOUT_FLASH: = 1500 ## Задержка для повторной отправки команды флеш, милисекунды
|
||||
const RETRY_COUNT: = 5 ## Количество повторных отправок
|
||||
const BUFFER_SIZE: = 2048 ## Размер буфера для приёма датаграмм
|
||||
|
||||
|
||||
## Ячейка ЯУ-07.
|
||||
@@ -30,10 +30,10 @@ class YaU07 extends unit.Unit:
|
||||
var cmd_num_rx: = 0 ## Номер команды принятый
|
||||
var cmd_num_tx: = 0 ## Номер команды переданный
|
||||
var cmd_result: = 1 ## Результат выполнения команды. Устанавливается в ЯУ-07
|
||||
var cmd_data: = PackedByteArray() ## Данные команды. Устанавливается в ЯУ-07
|
||||
var cmd_data: = PackedByteArray() ## Данные команды. Устанавливается в ЯУ-07
|
||||
var cmd_retry: = RETRY_COUNT ## Счётчик оставшихся попыток выполнить команду
|
||||
var cmd_code_rx = 0 ## Код последней выполненой команды
|
||||
var cmd_code_tx = 0 ## Код последней отправленной команды
|
||||
var cmd_code_rx: = 0 ## Код последней выполненой команды
|
||||
var cmd_code_tx: = 0 ## Код последней отправленной команды
|
||||
var cmd_tick_tx: = 0 ## Время последней отправки команды
|
||||
var cmd_tick_rx: = 0 ## Время последнего приёма команды
|
||||
var status: = PackedByteArray() ## Поле "состояние прибора"
|
||||
@@ -46,7 +46,7 @@ class YaU07 extends unit.Unit:
|
||||
func _to_string() -> String: return String('яу07: %s %s' % [self.name, ['отключен', 'на связи'][int(online)]])
|
||||
|
||||
|
||||
func _init(nm):
|
||||
func _init(nm: StringName):
|
||||
self.name = nm
|
||||
tx_data.resize(BUFFER_SIZE)
|
||||
tx_data.fill(0)
|
||||
@@ -57,7 +57,7 @@ class YaU07 extends unit.Unit:
|
||||
online = false
|
||||
emit_signal('line_changed', self)
|
||||
|
||||
var rc = Error.ERR_BUSY
|
||||
var rc: = Error.ERR_BUSY
|
||||
if cmd_state == CmdState.SEND:
|
||||
rc = Error.OK
|
||||
cmd_tick_tx = tick
|
||||
@@ -96,16 +96,16 @@ class YaU07 extends unit.Unit:
|
||||
elif cmd_code == CmdCode.WRITE_FLASH:
|
||||
tx_data.encode_u8(7, 1)
|
||||
tx_data.encode_u16(8, 0)
|
||||
tx_data.encode_u16(10, len(fl_data))
|
||||
tx_len = 11 + len(fl_data) * 2
|
||||
for i in len(fl_data):
|
||||
tx_data.encode_u16(10, fl_data.size())
|
||||
tx_len = 11 + fl_data.size() * 2
|
||||
for i in fl_data.size():
|
||||
tx_data.encode_u16(12 + i * 2, fl_data[i])
|
||||
elif cmd_code == CmdCode.WRITE_FLASH_MP550:
|
||||
tx_data.encode_u8(7, id_sector)
|
||||
tx_data.encode_u16(8, 0)
|
||||
tx_data.encode_u16(10, len(fl_data) * 2)
|
||||
tx_len = 12 + len(fl_data) * 2
|
||||
for i in len(fl_data):
|
||||
tx_data.encode_u16(10, fl_data.size() * 2)
|
||||
tx_len = 12 + fl_data.size() * 2
|
||||
for i in fl_data.size():
|
||||
tx_data.encode_u16(12 + i * 2, fl_data[i])
|
||||
elif cmd_code == CmdCode.READ_FLASH:
|
||||
tx_len = 11
|
||||
@@ -130,7 +130,7 @@ class YaU07 extends unit.Unit:
|
||||
|
||||
cmd_num_tx = (cmd_num_rx + 1) % 0xffff
|
||||
|
||||
var ports_count = ports_data.size()
|
||||
var ports_count: = ports_data.size()
|
||||
tx_len = ports_count * 2 + 8
|
||||
tx_data.encode_u16(0, cmd_retry) # Исправление для сетевого стека "nm-callback" процессоров STM
|
||||
tx_data.encode_u16(2, cmd_num_tx)
|
||||
@@ -191,49 +191,49 @@ class YaU07 extends unit.Unit:
|
||||
## Возвращает - Код команды не найден, 0...255 - код команды.
|
||||
func get_cmd_code(rx_data: PackedByteArray):
|
||||
|
||||
var rx_data_len = rx_data.size()
|
||||
var rx_data_len: = rx_data.size()
|
||||
if rx_data_len < 7:
|
||||
return null
|
||||
var status_len = rx_data.decode_u16(6) # Длина массива байтового "состояние прибора"
|
||||
if rx_data_len <= (status_len + 6): # Нет поля "ответ на команду", разбор пакета завершить
|
||||
var status_len: = rx_data.decode_u16(6) # Длина массива байтового "состояние прибора"
|
||||
if rx_data_len <= (status_len + 6): # Нет поля "ответ на команду", разбор пакета завершить
|
||||
return null
|
||||
var cmd_code_pos = status_len + 8 # Положение в приёмном буфере "кода команды"
|
||||
var cmd_code_pos: = status_len + 8 # Положение в приёмном буфере "кода команды"
|
||||
if rx_data_len <= cmd_code_pos:
|
||||
return null
|
||||
return rx_data[cmd_code_pos] # "код команды"
|
||||
return rx_data[cmd_code_pos] # "код команды"
|
||||
|
||||
|
||||
func parse_isa(rx_data: PackedByteArray, status_len) -> bool:
|
||||
var ports_count_pos = status_len + 10 # Положение в приёмном буфере количества портов
|
||||
func parse_isa(rx_data: PackedByteArray, status_len: int) -> bool:
|
||||
var ports_count_pos: = status_len + 10 # Положение в приёмном буфере количества портов
|
||||
if rx_data.size() < ports_count_pos:
|
||||
return false
|
||||
var ports_count = rx_data[ports_count_pos] # Количество портов
|
||||
var counted_len = status_len + (ports_count * 4) + 11 # Вычисленная длина пакета
|
||||
var ports_count: = rx_data[ports_count_pos] # Количество портов
|
||||
var counted_len: = status_len + (ports_count * 4) + 11 # Вычисленная длина пакета
|
||||
if rx_data.size() < counted_len:
|
||||
return false
|
||||
var addr_pos = status_len + 11 # Смещение положения адреса в приёмном буфере
|
||||
var data_pos = status_len + 13 # Смещение положения данных в приёмном буфере
|
||||
var addr_pos: = status_len + 11 # Смещение положения адреса в приёмном буфере
|
||||
var data_pos: = status_len + 13 # Смещение положения данных в приёмном буфере
|
||||
var i: = 0
|
||||
while i < ports_count:
|
||||
var shift: = i * 4
|
||||
if rx_data.size() < (data_pos + shift):
|
||||
return false
|
||||
var isa_addr = rx_data.decode_u16(addr_pos + shift) # Адрес порта ISA яу-07
|
||||
var isa_data = rx_data.decode_u16(data_pos + shift) # Данные порта ISA яу-07
|
||||
var isa_addr: = rx_data.decode_u16(addr_pos + shift) # Адрес порта ISA яу-07
|
||||
var isa_data: = rx_data.decode_u16(data_pos + shift) # Данные порта ISA яу-07
|
||||
isa_ports[isa_addr] = isa_data
|
||||
i += 1
|
||||
cmd_data = rx_data.slice(addr_pos, (addr_pos + ports_count * 4) - 1)
|
||||
return i > 0
|
||||
|
||||
func parse_block(rx_data: PackedByteArray, status_len) -> bool:
|
||||
var ports_count_pos = status_len + 7 # Положение в приёмном буфере количества портов
|
||||
func parse_block(rx_data: PackedByteArray, status_len: int) -> bool:
|
||||
var ports_count_pos: = status_len + 7 # Положение в приёмном буфере количества портов
|
||||
if rx_data.size() < ports_count_pos:
|
||||
return false
|
||||
if rx_data.size() < (ports_count_pos + 5):
|
||||
return false
|
||||
var block_len = rx_data.decode_u16(ports_count_pos + 3)
|
||||
var block_adr = rx_data.decode_u16(ports_count_pos + 5)
|
||||
var block_data = []
|
||||
var block_len: = rx_data.decode_u16(ports_count_pos + 3)
|
||||
var block_adr: = rx_data.decode_u16(ports_count_pos + 5)
|
||||
var block_data: = []
|
||||
if rx_data.size() < (ports_count_pos + 7 + (block_len - 1) * 2):
|
||||
return false
|
||||
for i in block_len:
|
||||
@@ -242,7 +242,7 @@ class YaU07 extends unit.Unit:
|
||||
isa_block[block_adr] = block_data
|
||||
return true
|
||||
|
||||
func parse_flash(rx_data: PackedByteArray, status_len, cmd_code) -> bool:
|
||||
func parse_flash(rx_data: PackedByteArray, status_len: int, cmd_code: CmdCode) -> bool:
|
||||
if cmd_code == CmdCode.READ_FLASH:
|
||||
if rx_data.size() < (status_len + 14):
|
||||
return false
|
||||
@@ -268,7 +268,7 @@ class YaU07 extends unit.Unit:
|
||||
online = true
|
||||
emit_signal('line_changed', self)
|
||||
|
||||
var rx_data_len = rx_data.size()
|
||||
var rx_data_len: int = rx_data.size()
|
||||
if rx_data_len < 10:
|
||||
return false
|
||||
|
||||
@@ -276,14 +276,14 @@ class YaU07 extends unit.Unit:
|
||||
if cmd_state == CmdState.UNCK:
|
||||
cmd_state = CmdState.DONE
|
||||
|
||||
var status_len = rx_data.decode_u16(6) # Длина массива байтового "состояние прибора"
|
||||
var status_len: int = rx_data.decode_u16(6) # Длина массива байтового "состояние прибора"
|
||||
if rx_data_len < (status_len + 6):
|
||||
return false
|
||||
var i: = 0
|
||||
var len_rx_data: = rx_data.size()
|
||||
status.resize(status_len)
|
||||
while i < status_len:
|
||||
var byte_i = i + 8
|
||||
var byte_i: = i + 8
|
||||
if byte_i < len_rx_data:
|
||||
status[i] = rx_data[byte_i] # Массив байтовый "состояние прибора"
|
||||
i += 1
|
||||
@@ -292,11 +292,11 @@ class YaU07 extends unit.Unit:
|
||||
if rx_data_len == (status_len + 6):
|
||||
return true # Нет поля "ответ на команду", разбор пакета завершить
|
||||
|
||||
var cmd_code_pos = status_len + 8 # Положение в приёмном буфере "код команды"
|
||||
var cmd_code_pos: = status_len + 8 # Положение в приёмном буфере "код команды"
|
||||
if rx_data_len <= cmd_code_pos:
|
||||
return false
|
||||
|
||||
var cmd_status_pos = status_len + 9 # Положение в приёмном буфере "состояния выполнения команды"
|
||||
var cmd_status_pos: = status_len + 9 # Положение в приёмном буфере "состояния выполнения команды"
|
||||
if rx_data_len <= cmd_status_pos:
|
||||
return false
|
||||
cmd_result = rx_data[cmd_status_pos]
|
||||
@@ -304,7 +304,7 @@ class YaU07 extends unit.Unit:
|
||||
return false
|
||||
|
||||
var cmd_code: CmdCode = rx_data[cmd_code_pos] as CmdCode # "код команды"
|
||||
var rc = true
|
||||
var rc: = true
|
||||
if (cmd_code == CmdCode.READ_ISA) or (cmd_code == CmdCode.WRITE_ISA):
|
||||
rc = parse_isa(rx_data, status_len)
|
||||
|
||||
|
||||