feat: GeViScope SDK integration with C# Bridge and Flutter app

- Add GeViScope Bridge (C# .NET 8.0) on port 7720
  - Full SDK wrapper for camera control, PTZ, actions/events
  - 17 REST API endpoints for GeViScope server interaction
  - Support for MCS (Media Channel Simulator) with 16 test channels
  - Real-time action/event streaming via PLC callbacks

- Add GeViServer Bridge (C# .NET 8.0) on port 7710
  - Integration with GeViSoft orchestration layer
  - Input/output control and event management

- Update Python API with new routers
  - /api/geviscope/* - Proxy to GeViScope Bridge
  - /api/geviserver/* - Proxy to GeViServer Bridge
  - /api/excel/* - Excel import functionality

- Add Flutter app GeViScope integration
  - GeViScopeRemoteDataSource with 17 API methods
  - GeViScopeBloc for state management
  - GeViScopeScreen with PTZ controls
  - App drawer navigation to GeViScope

- Add SDK documentation (extracted from PDFs)
  - GeViScope SDK docs (7 parts + action reference)
  - GeViSoft SDK docs (12 chunks)

- Add .mcp.json for Claude Code MCP server config

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Administrator
2026-01-19 08:14:17 +01:00
parent c9e83e4277
commit a92b909539
76 changed files with 62101 additions and 176 deletions

View File

@@ -0,0 +1,381 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../data/data_sources/remote/geviserver_remote_data_source.dart';
import 'geviserver_event.dart';
import 'geviserver_state.dart';
class GeViServerBloc extends Bloc<GeViServerEvent, GeViServerState> {
final GeViServerRemoteDataSource remoteDataSource;
GeViServerBloc({required this.remoteDataSource})
: super(const GeViServerState()) {
on<ConnectGeViServerEvent>(_onConnect);
on<DisconnectGeViServerEvent>(_onDisconnect);
on<CheckStatusEvent>(_onCheckStatus);
on<SendCrossSwitchEvent>(_onSendCrossSwitch);
on<ClearVideoOutputEvent>(_onClearVideoOutput);
on<CloseContactEvent>(_onCloseContact);
on<OpenContactEvent>(_onOpenContact);
on<SendCustomActionEvent>(_onSendCustomAction);
on<SendMessageEvent>(_onSendMessage);
on<StartTimerEvent>(_onStartTimer);
on<StopTimerEvent>(_onStopTimer);
on<ClearActionResultEvent>(_onClearActionResult);
}
Future<void> _onConnect(
ConnectGeViServerEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(
connectionStatus: ConnectionStatus.connecting,
isLoading: true,
clearErrorMessage: true,
));
try {
final result = await remoteDataSource.connect(
address: event.address,
username: event.username,
password: event.password,
);
if (result['success'] == true) {
emit(state.copyWith(
connectionStatus: ConnectionStatus.connected,
serverAddress: event.address,
username: event.username,
connectedAt: DateTime.now(),
isLoading: false,
lastActionResult: 'Connected to ${event.address}',
lastActionSuccess: true,
));
} else {
emit(state.copyWith(
connectionStatus: ConnectionStatus.error,
isLoading: false,
errorMessage: result['message'] ?? 'Connection failed',
lastActionResult: result['message'] ?? 'Connection failed',
lastActionSuccess: false,
));
}
} catch (e) {
emit(state.copyWith(
connectionStatus: ConnectionStatus.error,
isLoading: false,
errorMessage: e.toString(),
lastActionResult: 'Connection error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onDisconnect(
DisconnectGeViServerEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
await remoteDataSource.disconnect();
emit(state.copyWith(
connectionStatus: ConnectionStatus.disconnected,
isLoading: false,
clearServerAddress: true,
clearUsername: true,
clearConnectedAt: true,
lastActionResult: 'Disconnected',
lastActionSuccess: true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
errorMessage: e.toString(),
lastActionResult: 'Disconnect error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onCheckStatus(
CheckStatusEvent event,
Emitter<GeViServerState> emit,
) async {
try {
final result = await remoteDataSource.getStatus();
final isConnected = result['is_connected'] == true;
emit(state.copyWith(
connectionStatus: isConnected
? ConnectionStatus.connected
: ConnectionStatus.disconnected,
serverAddress: result['address']?.toString(),
username: result['username']?.toString(),
));
} catch (e) {
emit(state.copyWith(
connectionStatus: ConnectionStatus.error,
errorMessage: e.toString(),
));
}
}
Future<void> _onSendCrossSwitch(
SendCrossSwitchEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.crossSwitch(
videoInput: event.videoInput,
videoOutput: event.videoOutput,
switchMode: event.switchMode,
);
final message = 'CrossSwitch(${event.videoInput}, ${event.videoOutput}, ${event.switchMode})';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'CrossSwitch sent successfully'
: result['message'] ?? 'CrossSwitch failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'CrossSwitch error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onClearVideoOutput(
ClearVideoOutputEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.clearOutput(
videoOutput: event.videoOutput,
);
final message = 'ClearVideoOutput(${event.videoOutput})';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'ClearOutput sent successfully'
: result['message'] ?? 'ClearOutput failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'ClearOutput error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onCloseContact(
CloseContactEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.closeContact(
contactId: event.contactId,
);
final message = 'CloseContact(${event.contactId})';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'CloseContact sent successfully'
: result['message'] ?? 'CloseContact failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'CloseContact error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onOpenContact(
OpenContactEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.openContact(
contactId: event.contactId,
);
final message = 'OpenContact(${event.contactId})';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'OpenContact sent successfully'
: result['message'] ?? 'OpenContact failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'OpenContact error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onSendCustomAction(
SendCustomActionEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.sendCustomAction(
typeId: event.typeId,
text: event.text,
);
final message = 'CustomAction(${event.typeId}, "${event.text}")';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'CustomAction sent successfully'
: result['message'] ?? 'CustomAction failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'CustomAction error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onSendMessage(
SendMessageEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.sendMessage(event.message);
_addToLog(emit, event.message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'Message sent successfully'
: result['message'] ?? 'Send message failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'Send message error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onStartTimer(
StartTimerEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.startTimer(
timerId: event.timerId,
timerName: event.timerName,
);
final message = 'StartTimer(${event.timerId}, "${event.timerName}")';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'StartTimer sent successfully'
: result['message'] ?? 'StartTimer failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'StartTimer error: $e',
lastActionSuccess: false,
));
}
}
Future<void> _onStopTimer(
StopTimerEvent event,
Emitter<GeViServerState> emit,
) async {
emit(state.copyWith(isLoading: true));
try {
final result = await remoteDataSource.stopTimer(
timerId: event.timerId,
timerName: event.timerName,
);
final message = 'StopTimer(${event.timerId}, "${event.timerName}")';
_addToLog(emit, message);
emit(state.copyWith(
isLoading: false,
lastActionResult: result['success'] == true
? 'StopTimer sent successfully'
: result['message'] ?? 'StopTimer failed',
lastActionSuccess: result['success'] == true,
));
} catch (e) {
emit(state.copyWith(
isLoading: false,
lastActionResult: 'StopTimer error: $e',
lastActionSuccess: false,
));
}
}
void _onClearActionResult(
ClearActionResultEvent event,
Emitter<GeViServerState> emit,
) {
emit(state.copyWith(clearLastActionResult: true, clearErrorMessage: true));
}
void _addToLog(Emitter<GeViServerState> emit, String message) {
final timestamp = DateTime.now().toIso8601String().substring(11, 19);
final logEntry = '[$timestamp] $message';
final newLog = [...state.messageLog, logEntry];
// Keep only last 100 messages
if (newLog.length > 100) {
newLog.removeRange(0, newLog.length - 100);
}
emit(state.copyWith(messageLog: newLog));
}
}

View File

@@ -0,0 +1,137 @@
import 'package:equatable/equatable.dart';
abstract class GeViServerEvent extends Equatable {
const GeViServerEvent();
@override
List<Object?> get props => [];
}
/// Connect to GeViServer
class ConnectGeViServerEvent extends GeViServerEvent {
final String address;
final String username;
final String password;
const ConnectGeViServerEvent({
required this.address,
required this.username,
required this.password,
});
@override
List<Object?> get props => [address, username, password];
}
/// Disconnect from GeViServer
class DisconnectGeViServerEvent extends GeViServerEvent {
const DisconnectGeViServerEvent();
}
/// Check connection status
class CheckStatusEvent extends GeViServerEvent {
const CheckStatusEvent();
}
/// Send CrossSwitch command
class SendCrossSwitchEvent extends GeViServerEvent {
final int videoInput;
final int videoOutput;
final int switchMode;
const SendCrossSwitchEvent({
required this.videoInput,
required this.videoOutput,
this.switchMode = 0,
});
@override
List<Object?> get props => [videoInput, videoOutput, switchMode];
}
/// Clear video output
class ClearVideoOutputEvent extends GeViServerEvent {
final int videoOutput;
const ClearVideoOutputEvent({required this.videoOutput});
@override
List<Object?> get props => [videoOutput];
}
/// Close digital contact
class CloseContactEvent extends GeViServerEvent {
final int contactId;
const CloseContactEvent({required this.contactId});
@override
List<Object?> get props => [contactId];
}
/// Open digital contact
class OpenContactEvent extends GeViServerEvent {
final int contactId;
const OpenContactEvent({required this.contactId});
@override
List<Object?> get props => [contactId];
}
/// Send custom action
class SendCustomActionEvent extends GeViServerEvent {
final int typeId;
final String text;
const SendCustomActionEvent({
required this.typeId,
this.text = '',
});
@override
List<Object?> get props => [typeId, text];
}
/// Send raw message
class SendMessageEvent extends GeViServerEvent {
final String message;
const SendMessageEvent({required this.message});
@override
List<Object?> get props => [message];
}
/// Start timer
class StartTimerEvent extends GeViServerEvent {
final int timerId;
final String timerName;
const StartTimerEvent({
this.timerId = 0,
this.timerName = '',
});
@override
List<Object?> get props => [timerId, timerName];
}
/// Stop timer
class StopTimerEvent extends GeViServerEvent {
final int timerId;
final String timerName;
const StopTimerEvent({
this.timerId = 0,
this.timerName = '',
});
@override
List<Object?> get props => [timerId, timerName];
}
/// Clear last action result (to dismiss success/error messages)
class ClearActionResultEvent extends GeViServerEvent {
const ClearActionResultEvent();
}

View File

@@ -0,0 +1,76 @@
import 'package:equatable/equatable.dart';
enum ConnectionStatus {
disconnected,
connecting,
connected,
error,
}
class GeViServerState extends Equatable {
final ConnectionStatus connectionStatus;
final String? serverAddress;
final String? username;
final DateTime? connectedAt;
final bool isLoading;
final String? lastActionResult;
final bool lastActionSuccess;
final String? errorMessage;
final List<String> messageLog;
const GeViServerState({
this.connectionStatus = ConnectionStatus.disconnected,
this.serverAddress,
this.username,
this.connectedAt,
this.isLoading = false,
this.lastActionResult,
this.lastActionSuccess = false,
this.errorMessage,
this.messageLog = const [],
});
bool get isConnected => connectionStatus == ConnectionStatus.connected;
GeViServerState copyWith({
ConnectionStatus? connectionStatus,
String? serverAddress,
String? username,
DateTime? connectedAt,
bool? isLoading,
String? lastActionResult,
bool? lastActionSuccess,
String? errorMessage,
List<String>? messageLog,
bool clearServerAddress = false,
bool clearUsername = false,
bool clearConnectedAt = false,
bool clearErrorMessage = false,
bool clearLastActionResult = false,
}) {
return GeViServerState(
connectionStatus: connectionStatus ?? this.connectionStatus,
serverAddress: clearServerAddress ? null : (serverAddress ?? this.serverAddress),
username: clearUsername ? null : (username ?? this.username),
connectedAt: clearConnectedAt ? null : (connectedAt ?? this.connectedAt),
isLoading: isLoading ?? this.isLoading,
lastActionResult: clearLastActionResult ? null : (lastActionResult ?? this.lastActionResult),
lastActionSuccess: lastActionSuccess ?? this.lastActionSuccess,
errorMessage: clearErrorMessage ? null : (errorMessage ?? this.errorMessage),
messageLog: messageLog ?? this.messageLog,
);
}
@override
List<Object?> get props => [
connectionStatus,
serverAddress,
username,
connectedAt,
isLoading,
lastActionResult,
lastActionSuccess,
errorMessage,
messageLog,
];
}