Files
geutebruck/test_action_mapping_upload.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

155 lines
4.4 KiB
Python

"""
Test script to verify action mapping upload/download
Tests if Pan Left action is correctly stored and retrieved
"""
import requests
import json
BASE_URL = "http://localhost:8000"
def authenticate():
response = requests.post(f'{BASE_URL}/api/v1/auth/login', json={
'username': 'admin',
'password': 'admin123'
})
if response.status_code != 200:
raise Exception(f"Authentication failed")
return response.json()['access_token']
def test_action_mapping_roundtrip():
token = authenticate()
headers = {'Authorization': f'Bearer {token}'}
print("="*80)
print("TEST: Action Mapping Upload/Download Roundtrip")
print("="*80)
print()
# Step 1: Get the existing mapping
mapping_name = "GeVi PanLeft_101027"
print(f"Step 1: Getting existing mapping '{mapping_name}'...")
response = requests.get(
f'{BASE_URL}/api/v1/configuration/action-mappings',
headers=headers
)
if response.status_code != 200:
print(f"ERROR: Failed to get mappings: {response.status_code}")
return
mappings = response.json()['mappings']
target_mapping = None
for mapping in mappings:
if mapping['name'] == mapping_name:
target_mapping = mapping
break
if not target_mapping:
print(f"ERROR: Mapping '{mapping_name}' not found!")
print(f"Available mappings: {[m['name'] for m in mappings]}")
return
mapping_id = target_mapping['id']
print(f"Found mapping ID: {mapping_id}")
print(f"Current output actions:")
for action in target_mapping.get('output_actions', []):
print(f" - {action['action']}")
print(f" Parameters: {action.get('parameters', {})}")
print()
# Step 2: Update with Pan Left action
print("Step 2: Updating with GSC Pan Left action...")
new_output_actions = [
{
"action": "PanLeft",
"parameters": {
"GscServer": "gscope-cdx-3",
"PTZ head": "101027"
}
}
]
update_data = {
"name": mapping_name,
"output_actions": new_output_actions
}
print(f"Sending update:")
print(json.dumps(update_data, indent=2))
print()
response = requests.put(
f'{BASE_URL}/api/v1/configuration/action-mappings/{mapping_id}',
headers=headers,
json=update_data
)
if response.status_code != 200:
print(f"ERROR: Update failed: {response.status_code}")
print(response.text)
return
print("[OK] Update successful")
print()
# Step 3: Download the mapping back
print("Step 3: Downloading mapping back from server...")
response = requests.get(
f'{BASE_URL}/api/v1/configuration/action-mappings',
headers=headers
)
if response.status_code != 200:
print(f"ERROR: Failed to get mappings: {response.status_code}")
return
mappings = response.json()['mappings']
downloaded_mapping = None
for mapping in mappings:
if mapping['id'] == mapping_id:
downloaded_mapping = mapping
break
if not downloaded_mapping:
print(f"ERROR: Mapping with ID {mapping_id} not found after update!")
return
print(f"Downloaded mapping:")
print(f" Name: {downloaded_mapping['name']}")
print(f" Output actions:")
for action in downloaded_mapping.get('output_actions', []):
print(f" - Action: {action['action']}")
print(f" Parameters: {action.get('parameters', {})}")
print()
# Step 4: Verify
print("Step 4: Verification...")
downloaded_action = downloaded_mapping['output_actions'][0]
if downloaded_action['action'] == "PanLeft":
print("[OK] Action name preserved: PanLeft")
else:
print(f"[ERROR] Action name changed: Expected 'PanLeft', got '{downloaded_action['action']}'")
if 'GscServer' in downloaded_action.get('parameters', {}):
print(f"[OK] GscServer parameter preserved: {downloaded_action['parameters']['GscServer']}")
else:
print(f"[ERROR] GscServer parameter missing or changed")
print(f" Parameters: {downloaded_action.get('parameters', {})}")
print()
print("="*80)
print("TEST COMPLETE")
print("="*80)
if __name__ == '__main__':
try:
test_action_mapping_roundtrip()
except Exception as e:
print(f"ERROR: {str(e)}")
import traceback
traceback.print_exc()