""" Test server creation offline using existing .set file This tests the bool type fix without needing to connect to GeViServer """ import sys sys.path.insert(0, r'C:\DEV\COPILOT\geutebruck-api\src\sdk-bridge\GeViScopeBridge\bin\Debug\net8.0') from GeViScopeBridge.Services.FolderTreeParser import FolderTreeParser from GeViScopeBridge.Services.FolderTreeWriter import FolderTreeWriter from GeViScopeBridge.Models import FolderNode import clr def test_offline(): # Read existing .set file input_file = r'C:\DEV\COPILOT_codex\TestMKS.set' print(f"Reading {input_file}...") with open(input_file, 'rb') as f: data = f.read() print(f"Read {len(data)} bytes") # Parse the configuration parser = FolderTreeParser() root = parser.Parse(data) print(f"Parsed configuration with {len(root.Children)} top-level nodes") # Find GeViGCoreServer node gcore_node = None for child in root.Children: if child.Name == "GeViGCoreServer": gcore_node = child break if gcore_node is None: print("ERROR: GeViGCoreServer node not found!") return print(f"Found GeViGCoreServer with {len(gcore_node.Children)} servers") # Check if server 16 already exists server_exists = any(c.Name == "16" for c in gcore_node.Children) if server_exists: print("Server 16 already exists, removing it first...") gcore_node.Children = [c for c in gcore_node.Children if c.Name != "16"] # Create new server with CORRECT bool types print("\nCreating server 16 with BOOL types (not int32)...") new_server = FolderNode() new_server.Type = "folder" new_server.Name = "16" new_server.Children = [] # Add fields in correct order: Alias, DeactivateEcho, DeactivateLiveCheck, Enabled, Host, Password, User alias_node = FolderNode() alias_node.Type = "string" alias_node.Name = "Alias" alias_node.StringValue = "Test Server 16 - Bool Fix" new_server.Children.append(alias_node) echo_node = FolderNode() echo_node.Type = "bool" # BOOL not int32! echo_node.Name = "DeactivateEcho" echo_node.BoolValue = False new_server.Children.append(echo_node) live_check_node = FolderNode() live_check_node.Type = "bool" # BOOL not int32! live_check_node.Name = "DeactivateLiveCheck" live_check_node.BoolValue = False new_server.Children.append(live_check_node) enabled_node = FolderNode() enabled_node.Type = "bool" # BOOL not int32! enabled_node.Name = "Enabled" enabled_node.BoolValue = True new_server.Children.append(enabled_node) host_node = FolderNode() host_node.Type = "string" host_node.Name = "Host" host_node.StringValue = "192.168.1.116" new_server.Children.append(host_node) password_node = FolderNode() password_node.Type = "string" password_node.Name = "Password" password_node.StringValue = "test123" new_server.Children.append(password_node) user_node = FolderNode() user_node.Type = "string" user_node.Name = "User" user_node.StringValue = "admin" new_server.Children.append(user_node) # Add to GeViGCoreServer gcore_node.Children.append(new_server) print(f"Added server 16 to GeViGCoreServer (now {len(gcore_node.Children)} servers)") # Write back to new file output_file = r'C:\DEV\COPILOT\TestMKS_with_bool_server_16.set' print(f"\nWriting to {output_file}...") writer = FolderTreeWriter() output_data = writer.Write(root) with open(output_file, 'wb') as f: f.write(output_data) print(f"Successfully wrote {len(output_data)} bytes") print(f"Size change: {len(output_data) - len(data):+d} bytes") print("\nDone! You can now upload this .set file using GeViSet to test if server 16 appears correctly.") if __name__ == "__main__": test_offline()