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>
This commit is contained in:
Administrator
2025-12-31 18:10:54 +01:00
commit 14893e62a5
4189 changed files with 1395076 additions and 0 deletions

View File

@@ -0,0 +1,173 @@
using System;
using System.IO;
using System.Linq;
using GeViSetEditor.Core.Models;
namespace GeViSetEditor.Core.Writers
{
/// <summary>
/// Safe writer that preserves binary integrity
/// Only modifies action mappings, keeps everything else intact
/// </summary>
public class SafeSetFileWriter
{
/// <summary>
/// Write SafeSetFile back to binary format
/// Returns byte array that can be sent to GeViServer
/// </summary>
public byte[] Write(SafeSetFile setFile)
{
if (setFile.OriginalData == null || setFile.OriginalData.Length == 0)
{
throw new InvalidOperationException("Cannot write: OriginalData is missing");
}
Console.WriteLine($"Writing .set file: {setFile.FileSize} bytes");
Console.WriteLine($"Action mappings: {setFile.ActionMappings.Count}");
// Start with exact copy of original data
byte[] output = setFile.GetDataForWriting();
Console.WriteLine($" Output data created: {output.Length} bytes");
// Verify header is intact
if (VerifyHeader(output))
{
Console.WriteLine(" Header verification: PASSED");
}
else
{
Console.WriteLine(" Header verification: FAILED (proceeding anyway for round-trip test)");
// Don't throw - allow round-trip test to see byte comparison
}
// TODO: If action mappings were modified, update them here
// For now, we just preserve everything as-is for safe round-trip
Console.WriteLine($"Write complete: {output.Length} bytes");
return output;
}
/// <summary>
/// Write to file
/// </summary>
public void WriteToFile(SafeSetFile setFile, string filePath)
{
byte[] data = Write(setFile);
// Create backup if file exists
if (File.Exists(filePath))
{
string backupPath = filePath + ".backup";
File.Copy(filePath, backupPath, true);
Console.WriteLine($"Created backup: {backupPath}");
}
File.WriteAllBytes(filePath, data);
Console.WriteLine($"Wrote {data.Length} bytes to {filePath}");
}
/// <summary>
/// Verify the output file is valid before writing to server
/// </summary>
public bool Verify(byte[] data)
{
if (data == null || data.Length < 100)
{
Console.WriteLine("Verification failed: File too small");
return false;
}
if (!VerifyHeader(data))
{
Console.WriteLine("Verification failed: Invalid header");
return false;
}
// Additional checks
if (data.Length > 10 * 1024 * 1024) // 10MB max
{
Console.WriteLine("Verification failed: File too large");
return false;
}
Console.WriteLine("Verification passed");
return true;
}
private bool VerifyHeader(byte[] data)
{
// Check for "GeViSoft Parameters" header
string expectedHeader = "GeViSoft Parameters";
int offset = (data[0] == 0x00) ? 1 : 0;
if (offset + 2 + expectedHeader.Length > data.Length)
return false;
if (data[offset] != 0x07) // Pascal string marker
return false;
byte headerLen = data[offset + 1];
if (headerLen < 10 || headerLen > 50)
return false;
string actualHeader = System.Text.Encoding.UTF8.GetString(data, offset + 2, Math.Min(headerLen, expectedHeader.Length));
return actualHeader.StartsWith("GeViSoft");
}
/// <summary>
/// Compare two .set files for differences
/// Useful for testing round-trip conversion
/// </summary>
public ComparisonResult Compare(byte[] original, byte[] modified)
{
var result = new ComparisonResult
{
OriginalSize = original.Length,
ModifiedSize = modified.Length
};
if (original.Length != modified.Length)
{
result.IsIdentical = false;
result.Differences.Add($"Size mismatch: {original.Length} vs {modified.Length}");
return result;
}
for (int i = 0; i < original.Length; i++)
{
if (original[i] != modified[i])
{
result.DifferentBytes++;
if (result.Differences.Count < 10) // Limit to first 10 differences
{
result.Differences.Add($"Byte {i} (0x{i:X}): {original[i]:X2} != {modified[i]:X2}");
}
}
}
result.IsIdentical = (result.DifferentBytes == 0);
if (result.IsIdentical)
{
Console.WriteLine("Files are identical!");
}
else
{
Console.WriteLine($"Files differ in {result.DifferentBytes} bytes");
}
return result;
}
}
public class ComparisonResult
{
public bool IsIdentical { get; set; }
public int OriginalSize { get; set; }
public int ModifiedSize { get; set; }
public int DifferentBytes { get; set; }
public List<string> Differences { get; set; } = new();
}
}