""" Direct test using working Python implementation Creates FINAL_FIX_TEST mapping with GSC PanLeft and G-Core PanRight """ import sys import os from pathlib import Path # Add COPILOT_codex to path for working implementation sys.path.insert(0, r'C:\DEV\COPILOT_codex') os.chdir(r'C:\DEV\COPILOT_codex') from geviset_parser import load_set, save_set from action_mapping_manager import add_action_mapping print("=" * 80) print("FINAL FIX TEST - Direct .set file manipulation") print("=" * 80) print() # Load current configuration set_file = Path(r"C:\DEV\COPILOT\TestMKS.set") print(f"Loading configuration from: {set_file}") tree = load_set(set_file) # Prepare output actions with ALL fixes applied: # 1. Camera parameter in action strings for BOTH GSC and G-Core # 2. Action-specific @@ values from ActionIdLookup # 3. Only 2 filter flags at mapping level # 4. VideoInput = 0 at mapping level (camera in action string) output_actions = [ { "name": "GSC PanLeft", "action": "PanLeft", "parameters": { "Caption": "GSC PanLeft", "GscServer": "GEVISCOPE_01_UPDATED", "PTZ head": "101027" }, "is_gsc": True, "action_id": 4198 # GSC:PanLeft @@ value }, { "name": "G-Core PanRight", "action": "PanRight", "parameters": { "Caption": "G-Core PanRight", "GCoreServer": "gscope-cdu-10", "PTZ head": "101027" }, "is_gsc": False, "action_id": 9294 # G-Core:PanRight @@ value } ] print("Creating mapping with:") print(f" Mapping name: FINAL_FIX_TEST") print(f" Output actions: {len(output_actions)}") for i, action in enumerate(output_actions, 1): print(f" Action {i}: {action['name']} (@@={action['action_id']})") for param_name, param_value in action['parameters'].items(): print(f" {param_name}: {param_value}") print() # Add mapping using working implementation add_action_mapping( tree, mapping_name="FINAL_FIX_TEST", output_actions=output_actions ) # Save back to file output_file = Path(r"C:\DEV\COPILOT\TestMKS.set") print(f"Saving to: {output_file}") save_set(tree, output_file) print() print("✓ Mapping created successfully!") print() print("=" * 80) print("FIXES APPLIED IN PYTHON (same as C# code):") print("=" * 80) print("1. BuildActionString includes Camera parameter for BOTH GSC and G-Core") print("2. Mapping-level VideoInput = 0 (camera is in action strings)") print("3. Only 2 filter flags: .Temp and .VideoInput") print("4. Action-specific @@ values (PanLeft: GSC=4198, PanRight: G-Core=9294)") print("5. No mapping-level fields in output actions") print() print("=" * 80) print("NEXT STEP: Upload TestMKS.set to GeViServer and verify in GeViSet") print("=" * 80) print() print("Expected in GeViSet:") print("- Mapping name: FINAL_FIX_TEST") print("- Output Action 1: 'GSC PanLeft' (should show as PanLeft, NOT CrossSwitch)") print("- Output Action 2: 'G-Core PanRight' (should show as PanRight, NOT CrossSwitch)") print()