init
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,142 @@
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class GlobalStatusInformation : IStatusInfo
|
||||
{
|
||||
private static readonly object MyLock = new object();
|
||||
|
||||
private List<IDASCommunication> _unitsInRealtime = new List<IDASCommunication>();
|
||||
/// <summary>
|
||||
/// returns an array of all devices that are known to be in realtime
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDASCommunication[] GetUnitsInRealtime()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
return _unitsInRealtime.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// adds a device to the list of units known to be in realtime
|
||||
/// </summary>
|
||||
/// <param name="device"></param>
|
||||
public void AddUnitInRealtime(IDASCommunication device)
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (_unitsInRealtime.Contains(device)) { return; }
|
||||
|
||||
_unitsInRealtime.Add(device);
|
||||
}
|
||||
}
|
||||
|
||||
private List<IDASCommunication> _unitsInArm = new List<IDASCommunication>();
|
||||
/// <summary>
|
||||
/// returns an array of units known to be in arm
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDASCommunication[] GetUnitsInArm()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
return _unitsInArm.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// adds a device to the list of devices known to be in arm
|
||||
/// </summary>
|
||||
/// <param name="device"></param>
|
||||
public void AddUnitInArm(IDASCommunication device)
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (_unitsInArm.Contains(device))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_unitsInArm.Add(device);
|
||||
}
|
||||
}
|
||||
|
||||
private List<IDASCommunication> _unitsAtLowPower = new List<IDASCommunication>();
|
||||
/// <summary>
|
||||
/// returns an array of all known devices that are at low power
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDASCommunication[] GetUnitsAtLowPower()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
return _unitsAtLowPower.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// adds a unit to the list of units currently at low power
|
||||
/// removes from high power list if present in it
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
public void AddUnitAtLowPower(IDASCommunication das)
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (_unitsAtLowPower.Contains(das)) { return; }
|
||||
_unitsAtLowPower.Add(das);
|
||||
if (!_unitsAtHighPower.Contains(das)) { return; }
|
||||
|
||||
_unitsAtHighPower.Remove(das);
|
||||
}
|
||||
}
|
||||
private List<IDASCommunication> _unitsAtHighPower = new List<IDASCommunication>();
|
||||
/// <summary>
|
||||
/// returns an array of all units that are known to be at high power
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IDASCommunication[] GetUnitsAtHighPower()
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
return _unitsAtHighPower.ToArray();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// adds unit to the list of devices known to be at high power
|
||||
/// removes from the low power list if present
|
||||
/// </summary>
|
||||
/// <param name="das"></param>
|
||||
public void AddUnitAtHighPower(IDASCommunication das)
|
||||
{
|
||||
lock (MyLock)
|
||||
{
|
||||
if (_unitsAtHighPower.Contains(das)) { return; }
|
||||
_unitsAtHighPower.Add(das);
|
||||
if (!_unitsAtLowPower.Contains(das)) { return; }
|
||||
_unitsAtLowPower.Remove(das);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// whether excitation is on or off, currently this is just
|
||||
/// controlled by Configure->TurnOffExcitation and Configure->PrepareForDiagnostics
|
||||
/// the status is only changed currently if all units successfully switch to low power or vice versa
|
||||
/// </summary>
|
||||
public bool ExcitationOn { get; set; } = false;
|
||||
/// <summary>
|
||||
/// resets all status back to defaults
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
ExcitationOn = false;
|
||||
lock (MyLock)
|
||||
{
|
||||
_unitsAtHighPower.Clear();
|
||||
_unitsAtLowPower.Clear();
|
||||
_unitsInRealtime.Clear();
|
||||
_unitsInArm.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user