174 lines
9.4 KiB
C#
174 lines
9.4 KiB
C#
using System.Collections.Generic;
|
|
using Peak.Can.Basic;
|
|
using TPCANHandle = System.UInt16;
|
|
|
|
namespace HC_APTBS.Models
|
|
{
|
|
/// <summary>
|
|
/// Complete bench parameter configuration: CAN parameter map plus relay definitions.
|
|
/// Loaded from bench.xml at startup and edited via the BenchParamConfig view.
|
|
/// </summary>
|
|
public class BenchConfiguration
|
|
{
|
|
/// <summary>PCAN channel handle used for bench communication.</summary>
|
|
public TPCANHandle Channel { get; set; } = PCANBasic.PCAN_USBBUS1;
|
|
|
|
/// <summary>All bench parameters, keyed by name for quick lookup.</summary>
|
|
public Dictionary<string, CanBusParameter> ParametersByName { get; set; } = new();
|
|
|
|
/// <summary>Bench parameters grouped by CAN message ID for frame decoding.</summary>
|
|
public Dictionary<uint, List<CanBusParameter>> ParametersById { get; set; } = new();
|
|
|
|
/// <summary>Relay / solenoid output definitions, keyed by name.</summary>
|
|
public Dictionary<string, Relay> Relays { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Application-wide configuration settings persisted in config.xml.
|
|
/// </summary>
|
|
public class AppSettings
|
|
{
|
|
// ── Temperature control ───────────────────────────────────────────────
|
|
|
|
/// <summary>Maximum allowable oil temperature (°C) before the bench raises an alarm.</summary>
|
|
public int TempMax { get; set; } = 45;
|
|
|
|
/// <summary>Minimum oil temperature (°C) required before tests begin.</summary>
|
|
public int TempMin { get; set; } = 35;
|
|
|
|
// ── Refresh intervals ─────────────────────────────────────────────────
|
|
|
|
/// <summary>UI status refresh period (ms) during normal bench operation.</summary>
|
|
public int RefreshBenchInterfaceMs { get; set; } = 20;
|
|
|
|
/// <summary>UI refresh period (ms) while reading pump EEPROM data over K-Line.</summary>
|
|
public int RefreshWhileReadingMs { get; set; } = 1500;
|
|
|
|
/// <summary>CAN bus polling interval (ms) on the read thread.</summary>
|
|
public int RefreshCanBusReadMs { get; set; } = 2;
|
|
|
|
/// <summary>Interval (ms) between pump-status CAN request messages.</summary>
|
|
public int RefreshPumpRequestMs { get; set; } = 250;
|
|
|
|
/// <summary>Interval (ms) between pump-parameter CAN request messages.</summary>
|
|
public int RefreshPumpParamsMs { get; set; } = 4;
|
|
|
|
/// <summary>Blink period (ms) for LED indicator controls.</summary>
|
|
public int BlinkIntervalMs { get; set; } = 1000;
|
|
|
|
/// <summary>Flasher relay toggle interval (ms).</summary>
|
|
public int FlasherIntervalMs { get; set; } = 800;
|
|
|
|
// ── PID temperature controller ────────────────────────────────────────
|
|
|
|
/// <summary>Proportional gain.</summary>
|
|
public double PidP { get; set; } = 0.1;
|
|
|
|
/// <summary>Integral gain.</summary>
|
|
public double PidI { get; set; } = 0.1;
|
|
|
|
/// <summary>Derivative gain.</summary>
|
|
public double PidD { get; set; } = 0.04;
|
|
|
|
/// <summary>PID loop period (ms).</summary>
|
|
public int PidLoopMs { get; set; } = 250;
|
|
|
|
// ── Safety limits ─────────────────────────────────────────────────────
|
|
|
|
/// <summary>Maximum allowable bench speed (RPM) before the bench triggers an emergency stop.</summary>
|
|
public int SecurityRpmLimit { get; set; } = 2500;
|
|
|
|
/// <summary>Maximum allowable bench pressure (bar).</summary>
|
|
public int MaxPressureBar { get; set; } = 26;
|
|
|
|
// ── Test tolerance extensions ─────────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// Fractional tolerance extension for UP tests.
|
|
/// A value of 0.08 extends each tolerance bound by 8% of its magnitude.
|
|
/// </summary>
|
|
public double ToleranceUpExtension { get; set; } = 0.08;
|
|
|
|
/// <summary>
|
|
/// Fractional tolerance extension for PFP tests.
|
|
/// A value of 0.1 extends each tolerance bound by 10% of its magnitude.
|
|
/// </summary>
|
|
public double TolerancePfpExtension { get; set; } = 0.1;
|
|
|
|
// ── Encoder ───────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Encoder pulses per revolution (default 4096 for PSG encoder).</summary>
|
|
public int EncoderResolution { get; set; } = 4096;
|
|
|
|
// ── Motor control ─────────────────────────────────────────────────────
|
|
|
|
/// <summary>Analogue output voltage (V) that corresponds to maximum RPM.</summary>
|
|
public double VoltageForMaxRpm { get; set; } = 10;
|
|
|
|
/// <summary>Maximum motor speed the bench can command (RPM).</summary>
|
|
public int MaxRpm { get; set; } = 2500;
|
|
|
|
// ── Direction ─────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Default relay state for the "right" rotation direction.</summary>
|
|
public bool RightRelayValue { get; set; } = true;
|
|
|
|
/// <summary>Last rotation direction selected by the operator.</summary>
|
|
public short LastRotationDirection { get; set; } = RotationDirection.Right;
|
|
|
|
/// <summary>When true, the T-in temperature sensor check is bypassed.</summary>
|
|
public bool DefaultIgnoreTin { get; set; } = true;
|
|
|
|
// ── Log rotation ──────────────────────────────────────────────────────
|
|
|
|
/// <summary>Number of daily log files to retain before the oldest is deleted.</summary>
|
|
public int DaysKeepLogs { get; set; } = 7;
|
|
|
|
// ── Report ────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Company name printed in the report header.</summary>
|
|
public string CompanyName { get; set; } = string.Empty;
|
|
|
|
/// <summary>Company address/info printed in the report header.</summary>
|
|
public string CompanyInfo { get; set; } = string.Empty;
|
|
|
|
/// <summary>Absolute path to the company logo image for the report.</summary>
|
|
public string ReportLogoPath { get; set; } = string.Empty;
|
|
|
|
// ── K-Line port ───────────────────────────────────────────────────────
|
|
|
|
/// <summary>Serial port or FTDI device identifier for the K-Line interface.</summary>
|
|
public string KLinePort { get; set; } = string.Empty;
|
|
|
|
// ── UI ────────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>UI language code, e.g. "ESP" or "ENG".</summary>
|
|
public string Language { get; set; } = "ESP";
|
|
|
|
// ── Relations ─────────────────────────────────────────────────────────
|
|
|
|
/// <summary>RPM-to-voltage lookup table for motor speed control.</summary>
|
|
public List<RpmVoltageRelation> Relations { get; set; } = new();
|
|
|
|
// ── Sensor calibration ────────────────────────────────────────────────
|
|
|
|
/// <summary>Calibration data for each analogue sensor channel (keyed by channel number).</summary>
|
|
public Dictionary<int, SensorConfiguration> Sensors { get; set; } = new();
|
|
|
|
// ── Alarms ────────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Active alarm definitions loaded from alarms.xml.</summary>
|
|
public List<Alarm> Alarms { get; set; } = new();
|
|
|
|
// ── Clients ───────────────────────────────────────────────────────────
|
|
|
|
/// <summary>Client/operator database, keyed by name (sorted).</summary>
|
|
public SortedDictionary<string, string> Clients { get; set; } = new();
|
|
|
|
// ── Pump IDs ──────────────────────────────────────────────────────────
|
|
|
|
/// <summary>List of known pump identifiers available in the database.</summary>
|
|
public List<string> PumpIds { get; set; } = new();
|
|
}
|
|
}
|