init
This commit is contained in:
9
DataPRO/IService/StateMachine/States/Arm.cs
Normal file
9
DataPRO/IService/StateMachine/States/Arm.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
internal class Arm : DASState
|
||||
{
|
||||
public override State State => State.Arm;
|
||||
}
|
||||
}
|
||||
9
DataPRO/IService/StateMachine/States/Arming.cs
Normal file
9
DataPRO/IService/StateMachine/States/Arming.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
internal class Arming : DASState
|
||||
{
|
||||
public override State State => State.Arming;
|
||||
}
|
||||
}
|
||||
26
DataPRO/IService/StateMachine/States/Configure.cs
Normal file
26
DataPRO/IService/StateMachine/States/Configure.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class Configure : DASStateSelector
|
||||
{
|
||||
public override IDASState StateSelector()
|
||||
{
|
||||
if (AllowApplyConfig())
|
||||
{
|
||||
return States.Instance.ConfigureStart;
|
||||
}
|
||||
return States.Instance.Configure;
|
||||
}
|
||||
|
||||
public override State State => State.Configure;
|
||||
|
||||
public bool AllowApplyConfig()
|
||||
{
|
||||
//needs to decide based on 1) are all channels resolved (or do we even require that?) 2) are there channels out of place
|
||||
//(or do we even care about that?) 3) are there any channels resolved?
|
||||
//for now we'll just return true till there's some logic ready to be put in place
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
DataPRO/IService/StateMachine/States/ConfigureStart.cs
Normal file
30
DataPRO/IService/StateMachine/States/ConfigureStart.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class ConfigureStart : DASStateSelector
|
||||
{
|
||||
public override State State => State.ConfigureStart;
|
||||
|
||||
public override IDASState StateSelector()
|
||||
{
|
||||
//more work needs to go in here ...
|
||||
return States.Instance.Diagnose;
|
||||
}
|
||||
|
||||
public override Action OnEntry
|
||||
{
|
||||
get
|
||||
{
|
||||
return ApplyConfig;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyConfig()
|
||||
{
|
||||
OnEnterState();
|
||||
Status.ConfigureStatus.ApplyConfig();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
29
DataPRO/IService/StateMachine/States/Diagnose.cs
Normal file
29
DataPRO/IService/StateMachine/States/Diagnose.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class Diagnose : DASStateSelector
|
||||
{
|
||||
public override State State => State.Diagnose;
|
||||
|
||||
public override IDASState StateSelector()
|
||||
{
|
||||
if (CanTransitToRealtimeStart())
|
||||
{
|
||||
return States.Instance.RealtimeStart;
|
||||
}
|
||||
|
||||
return States.Instance.Diagnose;
|
||||
}
|
||||
private bool CanTransitToRealtimeStart()
|
||||
{
|
||||
if (Status.DiagnoseParams.ProceedToRealtimeWhenDone && Status.DiagnoseParams.AllUnitsPassedDiagnostic)
|
||||
return true;
|
||||
|
||||
if (Status.DiagnoseParams.ProceedToRealtimeWhenDone && !Status.DiagnoseParams.RequireAllUnitsPassDiagnostic)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
DataPRO/IService/StateMachine/States/Download.cs
Normal file
9
DataPRO/IService/StateMachine/States/Download.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
internal class Download : DASState
|
||||
{
|
||||
public override State State => State.Download;
|
||||
}
|
||||
}
|
||||
39
DataPRO/IService/StateMachine/States/DownloadStart.cs
Normal file
39
DataPRO/IService/StateMachine/States/DownloadStart.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class DownloadStart : DASStateSelector
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
OnEnterState();
|
||||
Status.DownloadStatusInfo.Download();
|
||||
}
|
||||
|
||||
private bool CanTransitToPrepare()
|
||||
{
|
||||
return Status.DownloadParams.ProceedWhenDone && (Status.DownloadStatusInfo.AllDASFinished || !Status.DownloadParams.RequireAllDASFinish);
|
||||
}
|
||||
|
||||
public override IDASState StateSelector()
|
||||
{
|
||||
if (CanTransitToPrepare())
|
||||
{
|
||||
return States.Instance.Prepare;
|
||||
}
|
||||
return States.Instance.Download;
|
||||
}
|
||||
|
||||
public override Action OnEntry
|
||||
{
|
||||
get => Start;
|
||||
}
|
||||
|
||||
public override State State => State.DownloadStart;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
internal class HardwareDiscovery : DASState
|
||||
{
|
||||
public override State State => State.HardwareDiscovery;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class HardwareDiscoveryStart : DASStateSelector
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
OnEnterState();
|
||||
if (null != Status.HardwareDiscoveryParams.RequeryDevice)
|
||||
{
|
||||
Status.HardwareDiscoveryStatusInfo.RequeryDevice();
|
||||
}
|
||||
else { Status.HardwareDiscoveryStatusInfo.Ping(); }
|
||||
}
|
||||
|
||||
private bool CanTransitToDownload()
|
||||
{
|
||||
return CanTransitToConfigure() && Status.HardwareDiscoveryParams.GoToDownload;
|
||||
}
|
||||
|
||||
private bool CanTransitToConfigure()
|
||||
{
|
||||
return Status.HardwareDiscoveryParams.ProceedWhenDone && (Status.HardwareDiscoveryStatusInfo.AllDASFound || !Status.HardwareDiscoveryParams.RequireAllDASFound);
|
||||
}
|
||||
private bool CanTransitToArm()
|
||||
{
|
||||
return Status.HardwareDiscoveryParams.ProceedWhenDone && Status.HardwareDiscoveryStatusInfo.SomeUnitsInArmState;
|
||||
}
|
||||
|
||||
public override IDASState StateSelector()
|
||||
{
|
||||
if (CanTransitToDownload())
|
||||
return States.Instance.Download;
|
||||
|
||||
if (CanTransitToConfigure())
|
||||
return States.Instance.Configure;
|
||||
|
||||
if (CanTransitToArm())
|
||||
return States.Instance.Arm;
|
||||
|
||||
return States.Instance.HardwareDiscovery;
|
||||
}
|
||||
public override Action OnEntry
|
||||
{
|
||||
get => Start;
|
||||
}
|
||||
|
||||
public override State State => State.HardwareDiscoveryStart;
|
||||
}
|
||||
}
|
||||
23
DataPRO/IService/StateMachine/States/Prepare.cs
Normal file
23
DataPRO/IService/StateMachine/States/Prepare.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
internal class Prepare : DASState
|
||||
{
|
||||
private void PrepareDASFactory()
|
||||
{
|
||||
OnEnterState();
|
||||
if (null != DASFactory)
|
||||
{
|
||||
DASFactory.DetachAllDevices();
|
||||
DASFactory.TDASHostNames = new string[0];
|
||||
DASFactory.SliceDBHostNames = new string[0];
|
||||
}
|
||||
}
|
||||
public override State State => State.Prepare;
|
||||
public override Action OnEntry
|
||||
{
|
||||
get => PrepareDASFactory;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
DataPRO/IService/StateMachine/States/Realtime.cs
Normal file
9
DataPRO/IService/StateMachine/States/Realtime.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class Realtime : DASState
|
||||
{
|
||||
public override State State => State.Realtime;
|
||||
}
|
||||
}
|
||||
32
DataPRO/IService/StateMachine/States/RealtimeStart.cs
Normal file
32
DataPRO/IService/StateMachine/States/RealtimeStart.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.DASLib.Service.StateMachine
|
||||
{
|
||||
public class RealtimeStart : DASStateSelector
|
||||
{
|
||||
public override State State => State.RealtimeStart;
|
||||
public override Action OnEntry => Start;
|
||||
|
||||
public override IDASState StateSelector()
|
||||
{
|
||||
if (Status.RealtimeStatus.CouldNotStartRealtime)
|
||||
{
|
||||
return States.Instance.RealtimeStart;
|
||||
}
|
||||
else
|
||||
{
|
||||
return States.Instance.Realtime;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
OnEnterState();
|
||||
Status.RealtimeStatus.StartRealtime();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user