init
This commit is contained in:
@@ -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,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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user