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

204 lines
6.1 KiB
Python

"""
Deep investigation of GSC and G-Core server actions
This script will:
1. Download complete configuration from GeViServer
2. Analyze action mapping structure
3. Identify all GSC and G-Core specific actions
4. Test edit/upload scenarios
"""
import requests
import json
from typing import Dict, List, Any
BASE_URL = "http://localhost:8000"
def authenticate() -> str:
"""Get authentication token"""
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: {response.status_code}")
return response.json()['access_token']
def download_configuration(token: str) -> Dict[str, Any]:
"""Download complete configuration from GeViServer"""
headers = {'Authorization': f'Bearer {token}'}
print("="*80)
print("DOWNLOADING COMPLETE CONFIGURATION")
print("="*80)
print()
# Get action mappings
response = requests.get(
f'{BASE_URL}/api/v1/configuration/action-mappings',
headers=headers
)
if response.status_code != 200:
raise Exception(f"Failed to download mappings: {response.status_code}")
return response.json()
def analyze_actions(config: Dict[str, Any]) -> Dict[str, Any]:
"""Analyze all actions to identify GSC and G-Core specific ones"""
print("ANALYZING ACTION STRUCTURE")
print("-"*80)
print()
mappings = config.get('mappings', [])
# Categorize actions
base_actions = set()
gcore_actions = set()
gsc_actions = set()
# Categorize by action name patterns and parameters
for mapping in mappings:
for action in mapping.get('output_actions', []):
action_name = action.get('action', '')
parameters = action.get('parameters', {})
# Check if action has server parameters
has_gcore_param = 'GCoreServer' in parameters
has_gsc_param = 'GscServer' in parameters
if has_gcore_param:
gcore_actions.add(action_name)
elif has_gsc_param:
gsc_actions.add(action_name)
else:
base_actions.add(action_name)
print(f"Base Actions: {len(base_actions)}")
print(f"G-Core Actions: {len(gcore_actions)}")
print(f"GSC Actions: {len(gsc_actions)}")
print()
# Show examples
if gcore_actions:
print("G-Core Actions (examples):")
for action in sorted(list(gcore_actions))[:10]:
print(f" - {action}")
print()
if gsc_actions:
print("GSC Actions (examples):")
for action in sorted(list(gsc_actions))[:10]:
print(f" - {action}")
print()
return {
'base_actions': sorted(list(base_actions)),
'gcore_actions': sorted(list(gcore_actions)),
'gsc_actions': sorted(list(gsc_actions))
}
def examine_server_specific_mappings(config: Dict[str, Any]):
"""Look at actual action mappings that use server parameters"""
print("="*80)
print("EXAMINING SERVER-SPECIFIC ACTION MAPPINGS")
print("="*80)
print()
mappings = config.get('mappings', [])
gcore_mappings = []
gsc_mappings = []
for mapping in mappings:
mapping_name = mapping.get('name', 'Unnamed')
for action in mapping.get('output_actions', []):
action_name = action.get('action', '')
parameters = action.get('parameters', {})
if 'GCoreServer' in parameters:
gcore_mappings.append({
'mapping': mapping_name,
'action': action_name,
'server': parameters['GCoreServer'],
'all_params': parameters
})
if 'GscServer' in parameters:
gsc_mappings.append({
'mapping': mapping_name,
'action': action_name,
'server': parameters['GscServer'],
'all_params': parameters
})
print(f"Found {len(gcore_mappings)} G-Core action mappings")
print(f"Found {len(gsc_mappings)} GSC action mappings")
print()
# Show detailed examples
if gcore_mappings:
print("G-Core Mapping Examples:")
for mapping in gcore_mappings[:5]:
print(f"\n Mapping: {mapping['mapping']}")
print(f" Action: {mapping['action']}")
print(f" Server: {mapping['server']}")
print(f" Parameters:")
for key, value in mapping['all_params'].items():
print(f" - {key}: {value}")
if gsc_mappings:
print("\nGSC Mapping Examples:")
for mapping in gsc_mappings[:5]:
print(f"\n Mapping: {mapping['mapping']}")
print(f" Action: {mapping['action']}")
print(f" Server: {mapping['server']}")
print(f" Parameters:")
for key, value in mapping['all_params'].items():
print(f" - {key}: {value}")
print()
return gcore_mappings, gsc_mappings
def main():
try:
# Authenticate
print("Authenticating...")
token = authenticate()
print("[OK] Authenticated")
print()
# Download configuration
config = download_configuration(token)
print(f"[OK] Downloaded {len(config.get('mappings', []))} action mappings")
print()
# Analyze actions
analysis = analyze_actions(config)
# Examine server-specific mappings
gcore_mappings, gsc_mappings = examine_server_specific_mappings(config)
# Save results
results = {
'analysis': analysis,
'gcore_mappings': gcore_mappings,
'gsc_mappings': gsc_mappings
}
with open('server_actions_analysis.json', 'w') as f:
json.dump(results, f, indent=2)
print("="*80)
print("RESULTS SAVED TO: server_actions_analysis.json")
print("="*80)
except Exception as e:
print(f"[ERROR] {str(e)}")
import traceback
traceback.print_exc()
if __name__ == '__main__':
main()