first init

This commit is contained in:
TotMaxim
2025-11-10 19:35:17 +03:00
commit f6649907d4
17 changed files with 297 additions and 0 deletions

4
.editorconfig Normal file
View File

@@ -0,0 +1,4 @@
root = true
[*]
charset = utf-8

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

8
.idea/imi_case_y5.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.12" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

4
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/imi_case_y5.iml" filepath="$PROJECT_DIR$/.idea/imi_case_y5.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

1
icon.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
icon.svg.import Normal file
View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://beh7rub2lmwwk"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.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
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

24
main.gd Normal file
View File

@@ -0,0 +1,24 @@
extends Control
var dictionary_yau07: Dictionary
func _ready() -> void:
var device_yau07: Array = get_tree().get_nodes_in_group('device-addr')
for device in device_yau07:
device.connect('toggled', on_modify_device.bind(device.get_meta('device')))
func _exit_tree():
for device in dictionary_yau07:
if dictionary_yau07[device]:
dictionary_yau07[device].close_udp_unit()
func on_modify_device(toggled: bool, name_device: String) -> void:
if toggled:
var udp_broadcast := UDPBroadcast.new(name_device)
udp_broadcast.add_timer_to_scene(self)
udp_broadcast.start_broadcast()
dictionary_yau07[name_device] = udp_broadcast
else:
dictionary_yau07[name_device].close_udp_unit()

1
main.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://d1qwoxkckvdbc

84
main.tscn Normal file
View File

@@ -0,0 +1,84 @@
[gd_scene load_steps=2 format=3 uid="uid://bxorauom63ib6"]
[ext_resource type="Script" uid="uid://d1qwoxkckvdbc" path="res://main.gd" id="1_ig7tw"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_ig7tw")
[node name="Panel" type="Panel" parent="."]
layout_mode = 0
offset_right = 907.0
offset_bottom = 607.0
[node name="Yau-07-addr" type="GridContainer" parent="."]
layout_mode = 0
offset_left = 32.0
offset_top = 24.0
offset_right = 140.0
offset_bottom = 440.0
[node name="CheckButton" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-Н1"
metadata/device = "ПРД-Н1"
[node name="CheckButton2" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-В1"
metadata/device = "ПРД-В1"
[node name="CheckButton3" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-К1"
metadata/device = "ПРД-К1"
[node name="CheckButton4" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-Н2"
metadata/device = "ПРД-Н2"
[node name="CheckButton5" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-В2"
metadata/device = "ПРД-В2"
[node name="CheckButton6" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-К2"
metadata/device = "ПРД-К2"
[node name="CheckButton7" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-Н3"
metadata/device = "ПРД-Н3"
[node name="CheckButton8" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-В3"
metadata/device = "ПРД-В3"
[node name="CheckButton9" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-К3"
metadata/device = "ПРД-К3"
[node name="CheckButton10" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-Н4"
metadata/device = "ПРД-Н4"
[node name="CheckButton11" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-В4"
metadata/device = "ПРД-В4"
[node name="CheckButton12" type="CheckButton" parent="Yau-07-addr" groups=["device-addr"]]
layout_mode = 2
text = "ПРД-К4"
metadata/device = "ПРД-К4"

26
project.godot Normal file
View File

@@ -0,0 +1,26 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="imi_case_y5"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.4", "GL Compatibility")
config/icon="res://icon.svg"
[display]
window/size/viewport_width=900
window/size/viewport_height=600
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

79
udp_broadcast.gd Normal file
View File

@@ -0,0 +1,79 @@
class_name UDPBroadcast
const addres_list: Dictionary = {
'ПРД-Н1': [50011, "10.1.1.11"],
'ПРД-В1': [50012, "10.1.1.12"],
'ПРД-К1': [50013, "10.1.1.13"],
'ПРД-Н2': [50021, "10.1.1.21"],
'ПРД-В2': [50022, "10.1.1.22"],
'ПРД-К2': [50023, "10.1.1.23"],
'ПРД-Н3': [50031, "10.1.1.31"],
'ПРД-В3': [50032, "10.1.1.32"],
'ПРД-К3': [50033, "10.1.1.33"],
'ПРД-Н4': [50041, "10.1.1.41"],
'ПРД-В4': [50042, "10.1.1.42"],
'ПРД-К4': [50043, "10.1.1.43"],
}
const broadcast_addr: Array = [50000, "10.1.1.255"]
#const bind_addr: Array = [50_000, "10.1.1.70"] TODO: Порт по умолчанию
var _socket: SocketUDP
var self_name: String
var _timer: Timer
func _init(name: String):
self_name = name
_socket = SocketUDP.new()
_timer = Timer.new()
_timer.wait_time = 1.0 / 3.0
_timer.timeout.connect(_on_timer_timeout)
if addres_list.has(name):
var port: int = addres_list[name][0]
var addr: String = addres_list[name][1]
bind_unit_addres(port, addr)
else:
push_error("Неизвестное устройство: %s" % name)
func bind_unit_addres(port_for_bind: int, addr_for_bind: String) -> void:
print('Привязка адреса: %s' % addr_for_bind)
var bind_result = _socket.bind(port_for_bind, addr_for_bind)
if bind_result != OK:
push_error("Не удалось привязаться к %s: %s" % [addr_for_bind, error_string(bind_result)])
func start_broadcast() -> void:
_timer.start()
func stop_broadcast() -> void:
_timer.stop()
func send_broadcast(message: String) -> bool:
_socket.set_broadcast_enabled(true)
var data: PackedByteArray = message.to_utf8_buffer()
_socket.send_to(broadcast_addr[1], broadcast_addr[0], data)
return true
func close_udp_unit() -> void:
_timer.stop()
_socket.close()
func add_timer_to_scene(parent: Node) -> void:
parent.add_child(_timer)
func _on_timer_timeout() -> void:
send_broadcast("hello")
class SocketUDP extends PacketPeerUDP:
func send_to(addr: String, port: int, data: PackedByteArray):
set_dest_address(addr, port)
var rc: = put_packet(data)
if rc != OK:
push_error('%s: %s:%s' % [error_string(rc), addr, port])

1
udp_broadcast.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://c6evva823qhqm