using DTS.Common.Interface.DASFactory; using DTS.Common.Interface.DataRecorders; using System; using System.Text; namespace DTS.DASLib.Service.StateMachine { public class HardwareDiscoveryParameters { public bool ReadIds { get; set; } = false; /// /// ip addresses that we expliticly want to connect to /// if not specified in known tdas or known slice ip addresses will try connecting as both slice and tdas /// public string[] Addresses { get; set; } = new string[0]; /// /// range of address to ping /// items must be in the form of aaa.bbb.ccc.ddd /// will ping all addresses iterating from item1 upto the 4th byte on item 2 /// any ip that responds will be added to ips to connect to /// if it's not known whether it's a SLICE or TDAS then will be added to both lists to connect to /// public Tuple[] AddressRanges { get; set; } = new Tuple[0]; /// /// ip address that are known to be TDAS, so we don't have to try connecting to as a slice /// public string[] KnownTDASIPAddresses { get; set; } = new string[0]; /// /// ip addresses that are known to be SLICE, so we don't have to try connecting to as a TDAS /// public string[] KnownSLICEIPAddresses { get; set; } = new string[0]; /// /// controls whether we should remain in state or not /// sometimes the user just wants to see the hardware detected and not go onto resolve channels or any additional /// actions /// public bool ProceedWhenDone { get; set; } = false; /// /// whether all das are required to be found /// public bool RequireAllDASFound { get; set; } = false; /// /// whether to proceed to download state after completion /// public bool GoToDownload { get; set; } = false; /// /// controls whether we are ping and connecting or just pinging ... /// public bool Connect { get; set; } = false; /// /// controls whether UDP/Multicast discovery should be performed /// public bool UseMulticastDiscover { get; set; } = false; public int ConnectTimeoutMS { get; set; } = 30000; //30 seconds /// /// whether to run auto-sense or not /// note that DisableAutoSense overrules this setting /// public bool RunAutoSense { get; set; } = true; /// /// specific device to query, when present /// this is used to signal that there's a device already attached that /// we want to requery /// this is done when the device configuration is changed /// public IDASCommunication RequeryDevice { get; set; } = null; /// /// serial numbers that are required to connect /// public string[] RequiredSerials { get; set; } = new string[0]; /// /// controls whether to perform hardware checks (voltage/memory/firmware/etc) /// after connecting to hardware /// public bool DoHardwareChecks { get; set; } = false; /// /// hardware that we expect to be connected once ping and connect completes /// used as part of DoHardwareChecks /// public IDASHardware[] ExpectedHardware { get; set; } = new IDASHardware[0]; public delegate bool UnitIsInDbDelegate(IDASCommunication das); public UnitIsInDbDelegate UnitIsInDbQuery { get; set; } = null; public delegate string FirmwareExpectedVersionDelegate(IDASCommunication das); public FirmwareExpectedVersionDelegate UnitExpectedFirmwareQuery { get; set; } = null; public delegate bool IsCalDateExpiredDelegate(IDASCommunication das); public IsCalDateExpiredDelegate CalDateExpiredQuery { get; set; } = null; public delegate long UnitExpectedMaxMemoryDelegate(IDASCommunication das); public UnitExpectedMaxMemoryDelegate UnitExpectedMaxMemoryQuery { get; set; } = null; public delegate void UpdateMaxMemoryDelegate(IDASCommunication das); public UpdateMaxMemoryDelegate UpdateMaxMemoryAction { get; set; } = null; /// /// whether to check the input/battery voltage for units or not /// public bool DoVoltageChecks { get; set; } = true; public void Reset() { ReadIds = false; Addresses = new string[0]; AddressRanges = new Tuple[0]; ProceedWhenDone = false; RequireAllDASFound = false; KnownSLICEIPAddresses = new string[0]; KnownTDASIPAddresses = new string[0]; RequeryDevice = null; RequiredSerials = new string[0]; DoHardwareChecks = false; ExpectedHardware = new IDASHardware[0]; UnitIsInDbQuery = null; UnitExpectedFirmwareQuery = null; CalDateExpiredQuery = null; UnitExpectedMaxMemoryQuery = null; UpdateMaxMemoryAction = null; DoVoltageChecks = true; } public override string ToString() { var sb = new StringBuilder(); sb.AppendLine($"ReadIds={ReadIds.ToString()}"); sb.AppendLine($"Addresses={string.Join(",", Addresses)}"); sb.Append("AddressRanges="); for (int i = 0; i < AddressRanges.Length; i++) { if (i > 0) { sb.Append(", "); } sb.Append($"({AddressRanges[i].Item1},{AddressRanges[i].Item2})"); } sb.AppendLine(); sb.AppendLine($"ProceedWhenDone={ProceedWhenDone.ToString()}"); sb.AppendLine($"RequireAllDASFound={RequireAllDASFound.ToString()}"); sb.AppendLine($"KnownSLICEIPAddresses={string.Join(",", KnownSLICEIPAddresses)}"); sb.AppendLine($"KnownTDASIPAddresses={string.Join(",", KnownTDASIPAddresses)}"); sb.Append("RequiryDevice="); if (null == RequeryDevice) { sb.AppendLine("null"); } else { sb.AppendLine(RequeryDevice.SerialNumber); } sb.AppendLine($"RequiredSerials={string.Join(",", RequiredSerials)}"); sb.AppendLine($"DoHardwareChecks={DoHardwareChecks.ToString()}"); sb.Append("ExpectedHardware="); for (var i = 0; i < ExpectedHardware.Length; i++) { if (i > 0) { sb.Append(", "); } sb.Append(ExpectedHardware[i].SerialNumber); } sb.AppendLine(); sb.Append("UnitIsInDbQuery="); sb.AppendLine(null == UnitIsInDbQuery ? "[null]" : "[defined]"); sb.Append("UnitExpectedFirmwareQuery="); sb.AppendLine(null == UnitExpectedFirmwareQuery ? "[null]" : "[defined]"); sb.Append("CalDateExpiredQuery="); sb.AppendLine(null == CalDateExpiredQuery ? "[null]" : "[defined]"); sb.Append("UnitExpectedMaxMemoryQuery="); sb.AppendLine(null == UnitExpectedMaxMemoryQuery ? "[null]" : "[defined]"); sb.Append("UpdateMaxMemoryAction="); sb.AppendLine(null == UpdateMaxMemoryAction ? "[null]" : "[defined]"); sb.Append("DoVoltageChecks="); sb.AppendLine(DoVoltageChecks.ToString()); return sb.ToString(); } } }