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

130 lines
4.1 KiB
Python

"""
Check existing mappings and add missing Claude Window Sensor mapping
"""
import asyncio
import sys
sys.path.insert(0, r'C:\DEV\COPILOT\geutebruck-api\src\api\protos')
import grpc
import configuration_pb2
import configuration_pb2_grpc
async def list_action_mappings():
"""List all action mappings"""
channel = grpc.aio.insecure_channel('localhost:50051')
stub = configuration_pb2_grpc.ConfigurationServiceStub(channel)
try:
request = configuration_pb2.ReadActionMappingsRequest()
response = await stub.ReadActionMappings(request, timeout=10.0)
mappings = []
for i, mapping in enumerate(response.mappings, 1):
mappings.append({
'id': i,
'name': mapping.name,
'input_count': len(mapping.input_actions),
'output_count': len(mapping.output_actions)
})
await channel.close()
return mappings
except grpc.RpcError as e:
print(f"Error reading mappings: {e.details()}")
await channel.close()
return []
async def create_action_mapping(name, message):
"""Create an action mapping"""
channel = grpc.aio.insecure_channel('localhost:50051')
stub = configuration_pb2_grpc.ConfigurationServiceStub(channel)
mapping_request = configuration_pb2.CreateActionMappingRequest(
mapping=configuration_pb2.ActionMappingInput(
name=name,
input_actions=[
configuration_pb2.ActionDefinition(
action="DigitalContactChanged",
parameters=[
configuration_pb2.ActionParameter(name="Contact", value="2"),
configuration_pb2.ActionParameter(name="State", value="closed")
]
)
],
output_actions=[
configuration_pb2.ActionDefinition(
action="SystemInfo",
parameters=[
configuration_pb2.ActionParameter(name="Message", value=message)
]
)
],
video_input=101028
)
)
try:
response = await stub.CreateActionMapping(mapping_request, timeout=10.0)
print(f" [OK] Action mapping created: {response.mapping.name}")
await channel.close()
return True
except grpc.RpcError as e:
print(f" [ERROR] Failed to create action mapping: {e.details()}")
await channel.close()
return False
async def main():
print("=" * 70)
print("CHECK AND ADD MISSING CLAUDE MAPPINGS")
print("=" * 70)
# 1. List current mappings
print("\n1. CHECKING CURRENT MAPPINGS:")
print("-" * 70)
mappings = await list_action_mappings()
claude_mappings = [m for m in mappings if "Claude" in m['name']]
print(f"Found {len(claude_mappings)} Claude mappings:")
for mapping in claude_mappings:
print(f" #{mapping['id']}: {mapping['name']}")
# 2. Check if Window Sensor mapping exists
has_window_sensor = any("Window Sensor" in m['name'] for m in mappings)
if not has_window_sensor:
print("\n2. ADDING MISSING WINDOW SENSOR MAPPING:")
print("-" * 70)
await create_action_mapping(
name="Claude Mapping - Window Sensor",
message="Claude: Window sensor activated"
)
else:
print("\n2. Window Sensor mapping already exists - skipping")
# 3. Add one more mapping for good measure
print("\n3. ADDING ADDITIONAL CLAUDE MAPPING:")
print("-" * 70)
await create_action_mapping(
name="Claude Mapping - Motion Detector",
message="Claude: Motion detected"
)
# 4. List final mappings
print("\n4. FINAL CLAUDE MAPPINGS:")
print("-" * 70)
mappings = await list_action_mappings()
claude_mappings = [m for m in mappings if "Claude" in m['name']]
for mapping in claude_mappings:
print(f" #{mapping['id']}: {mapping['name']}")
print("\n" + "=" * 70)
print(f"DONE - Total Claude mappings: {len(claude_mappings)}")
print("=" * 70)
if __name__ == "__main__":
asyncio.run(main())