134 lines
4.8 KiB
C#
134 lines
4.8 KiB
C#
using GenesisCordonelInterface.Core.Threading;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using GciPublicModels = GenesisCordonelInterface.API.PublicModels;
|
|
|
|
namespace TBF.Rig.BridgeComponents.GciBridge.Interfaces
|
|
{
|
|
/// <summary>
|
|
/// Public data contract layer for the GciBridge.
|
|
///
|
|
/// This class defines all Data Transfer Objects (DTOs) that are exposed
|
|
/// to external consumers (e.g. TBF, UI, or other integration layers).
|
|
///
|
|
/// Responsibilities:
|
|
/// - Provide stable, dependency-free models for external usage
|
|
/// - Decouple internal GCI implementation (GenesisMeter, Xylem libraries)
|
|
/// from external systems
|
|
/// - Define request/response contracts for all supported operations
|
|
/// - Contain mapping methods between public DTOs and internal domain models
|
|
///
|
|
/// Architecture:
|
|
/// External world (TBF / UI)
|
|
/// ↓
|
|
/// GciPublicModels (this layer)
|
|
/// ↓
|
|
/// Internal GCI API (InterfaceGCIToLaatzen, GenesisMeter, etc.)
|
|
///
|
|
/// Notes:
|
|
/// - Public models must NOT expose internal types (e.g. GenesisMeter, IPort, etc.)
|
|
/// - All mapping between internal and external representations must be done here
|
|
/// - DTOs are designed to be simple, serializable, and stable over time
|
|
/// - Any change in internal implementation should not affect these models
|
|
///
|
|
/// Pattern:
|
|
/// Each operation follows a consistent structure:
|
|
/// Request → Operation → Result
|
|
///
|
|
/// Example:
|
|
/// GciInitSlotRequest → InitSlot → GciInitSlotResult
|
|
/// GetSlot → GciSlotInfo
|
|
/// GetPcbId → GciGetPcbIdResult
|
|
///
|
|
/// This layer acts as a boundary between domain logic and integration logic.
|
|
/// </summary>
|
|
public class PublicModels
|
|
{
|
|
public static bool HideSensitiveValues { get; set; } = true;
|
|
|
|
private static string FormatPassword(string password)
|
|
{
|
|
if (!HideSensitiveValues)
|
|
return password ?? "<null>";
|
|
|
|
if (string.IsNullOrEmpty(password))
|
|
return "<empty>";
|
|
|
|
return "********";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Public DTOs exposed to external systems.
|
|
/// These models represent the contract of the GCI API.
|
|
/// They must remain stable and independent of internal implementation.
|
|
/// </summary>
|
|
#region ================================== PUBLIC MODELS ===========================================
|
|
|
|
/// <summary>
|
|
/// Represents query input for data storage readers.
|
|
/// Each value is used to execute the same query template once.
|
|
/// A single-item list represents a single query.
|
|
/// </summary>
|
|
public class DataQuery
|
|
{
|
|
/// <summary>
|
|
/// Parameter values used for repeated execution of the same query template.
|
|
/// </summary>
|
|
public List<string> QueryParams { get; } = new List<string>();
|
|
}
|
|
|
|
public class UdsPasswordResult
|
|
{
|
|
public bool Success { get; set; }
|
|
public string PcbId { get; set; }
|
|
public string Password { get; set; }
|
|
public string Message { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format(
|
|
"Success={0}, PcbId={1}, Password={2}, Message={3}",
|
|
Success,
|
|
PcbId,
|
|
FormatPassword(Password),
|
|
Message);
|
|
}
|
|
}
|
|
|
|
public class GciFullLoginResult
|
|
{
|
|
public int SlotId { get; set; }
|
|
public bool Success { get; set; }
|
|
public string Message { get; set; }
|
|
|
|
public RetryResult<GciPublicModels.GciConnectResult> ConnectResult { get; set; }
|
|
public RetryResult<GciPublicModels.GciGetPcbIdResult> PcbResult { get; set; }
|
|
public RetryResult<UdsPasswordResult> PasswordResult { get; set; }
|
|
public RetryResult<GciPublicModels.GciSetPasswordResult> SetPasswordResult { get; set; }
|
|
public RetryResult<GciPublicModels.GciLoginResult> LoginResult { get; set; }
|
|
|
|
public GciFullLoginResult Fail(string message)
|
|
{
|
|
Success = false;
|
|
Message = message;
|
|
return this;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format(
|
|
"SlotId={0}, Success={1}, Message={2}, Connect={3}, Pcb={4}, Password={5}, SetPassword={6}, Login={7}",
|
|
SlotId,
|
|
Success,
|
|
Message,
|
|
ConnectResult,
|
|
PcbResult,
|
|
PasswordResult,
|
|
SetPasswordResult,
|
|
LoginResult);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|