Files
geutebruck/debug_parse_rules.py
Administrator 14893e62a5 feat: Geutebruck GeViScope/GeViSoft Action Mapping System - MVP
This MVP release provides a complete full-stack solution for managing action mappings
in Geutebruck's GeViScope and GeViSoft video surveillance systems.

## Features

### Flutter Web Application (Port 8081)
- Modern, responsive UI for managing action mappings
- Action picker dialog with full parameter configuration
- Support for both GSC (GeViScope) and G-Core server actions
- Consistent UI for input and output actions with edit/delete capabilities
- Real-time action mapping creation, editing, and deletion
- Server categorization (GSC: prefix for GeViScope, G-Core: prefix for G-Core servers)

### FastAPI REST Backend (Port 8000)
- RESTful API for action mapping CRUD operations
- Action template service with comprehensive action catalog (247 actions)
- Server management (G-Core and GeViScope servers)
- Configuration tree reading and writing
- JWT authentication with role-based access control
- PostgreSQL database integration

### C# SDK Bridge (gRPC, Port 50051)
- Native integration with GeViSoft SDK (GeViProcAPINET_4_0.dll)
- Action mapping creation with correct binary format
- Support for GSC and G-Core action types
- Proper Camera parameter inclusion in action strings (fixes CrossSwitch bug)
- Action ID lookup table with server-specific action IDs
- Configuration reading/writing via SetupClient

## Bug Fixes
- **CrossSwitch Bug**: GSC and G-Core actions now correctly display camera/PTZ head parameters in GeViSet
- Action strings now include Camera parameter: `@ PanLeft (Comment: "", Camera: 101028)`
- Proper filter flags and VideoInput=0 for action mappings
- Correct action ID assignment (4198 for GSC, 9294 for G-Core PanLeft)

## Technical Stack
- **Frontend**: Flutter Web, Dart, Dio HTTP client
- **Backend**: Python FastAPI, PostgreSQL, Redis
- **SDK Bridge**: C# .NET 8.0, gRPC, GeViSoft SDK
- **Authentication**: JWT tokens
- **Configuration**: GeViSoft .set files (binary format)

## Credentials
- GeViSoft/GeViScope: username=sysadmin, password=masterkey
- Default admin: username=admin, password=admin123

## Deployment
All services run on localhost:
- Flutter Web: http://localhost:8081
- FastAPI: http://localhost:8000
- SDK Bridge gRPC: localhost:50051
- GeViServer: localhost (default port)

Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-31 18:10:54 +01:00

111 lines
4.3 KiB
Python

#!/usr/bin/env python3
"""Debug script to examine raw bytes of action mapping at offset 277187"""
import sys
sys.path.insert(0, r'C:\DEV\COPILOT\geutebruck-api\src\api')
import grpc
from protos import configuration_pb2
from protos import configuration_pb2_grpc
import json
def debug_parse():
"""Examine raw bytes to understand parsing issue"""
print("Connecting to SDK Bridge...")
with grpc.insecure_channel('localhost:50051') as channel:
stub = configuration_pb2_grpc.ConfigurationServiceStub(channel)
# Export full config
export_req = configuration_pb2.ExportJsonRequest()
export_resp = stub.ExportConfigurationJson(export_req)
config = json.loads(export_resp.json_data)
# Find node at offset 277187
nodes = [n for n in config['rootNodes'] if n['startOffset'] == 277187]
if not nodes:
print("Node not found!")
return
node = nodes[0]
# The marker name contains the raw binary data
# Let's examine it byte by byte
name = node.get('name', '')
print(f"Marker at offset {node['startOffset']}")
print(f"Marker name length: {len(name)} bytes")
print(f"Node type: {node.get('nodeType')}")
print()
# Convert string back to bytes (this is what C# is doing)
# But note: UTF-8 encoding/decoding corrupts binary data!
name_bytes_utf8 = name.encode('utf-8')
print(f"After UTF-8 round-trip: {len(name_bytes_utf8)} bytes")
print()
# Show first 100 bytes in hex
print("First 100 bytes (hex):")
for i in range(0, min(100, len(name)), 16):
hex_line = ' '.join(f'{ord(name[i+j]):02X}' if i+j < len(name) else ' ' for j in range(16))
ascii_line = ''.join(name[i+j] if 32 <= ord(name[i+j]) < 127 else '.' for j in range(16) if i+j < len(name))
print(f" {i:3d}: {hex_line:<48} {ascii_line}")
print()
print("Parsing simulation (starting from byte 4 after 'ules'):")
pos = 4 # Skip "ules"
prop_count = 0
action_count = 0
while pos + 2 < len(name):
b = ord(name[pos])
# Property marker: 01 <length> <name> <value>
if b == 0x01 and pos + 1 < len(name):
name_len = ord(name[pos + 1])
if name_len > 0 and name_len < 100 and pos + 2 + name_len < len(name):
prop_name_bytes = name[pos + 2:pos + 2 + name_len]
if prop_name_bytes.startswith('.'):
prop_count += 1
print(f" [{pos:3d}] Property: {prop_name_bytes}")
pos += 2 + name_len
# Try to parse value
if pos < len(name):
val_marker = ord(name[pos])
if val_marker == 0x01 and pos + 1 < len(name):
val = ord(name[pos + 1])
print(f" Value: boolean = {val != 0}")
pos += 2
elif val_marker == 0x00:
print(f" Value: null")
pos += 1
else:
print(f" Value marker: 0x{val_marker:02X} (not handled)")
pos += 1
continue
# Action marker: 07 01 40 <length> <action>
if pos + 4 < len(name):
if ord(name[pos]) == 0x07 and ord(name[pos+1]) == 0x01 and ord(name[pos+2]) == 0x40:
action_len = ord(name[pos+3]) | (ord(name[pos+4]) << 8)
print(f" [{pos:3d}] Action marker found! Length: {action_len}")
if action_len > 0 and action_len < 500 and pos + 5 + action_len <= len(name):
action = name[pos + 5:pos + 5 + action_len]
print(f" Action: {action}")
action_count += 1
pos += 5 + action_len
continue
# Unknown byte, advance
pos += 1
if pos > 90: # Safety limit
break
print()
print(f"Summary: Found {prop_count} properties, {action_count} actions")
if __name__ == '__main__':
debug_parse()