Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cake/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static void ApaxTest(this BuildContext context, (string folder, string na
{
context.ProcessRunner.Start(Helpers.GetApaxCommand(), new ProcessSettings()
{
Arguments = "pack",
Arguments = "test",
WorkingDirectory = context.GetAxFolder(lib),
RedirectStandardOutput = false,
RedirectStandardError = false,
Expand Down
48 changes: 25 additions & 23 deletions cake/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,32 +93,10 @@ private static void ProvisionTools(BuildContext context)
[IsDependentOn(typeof(ProvisionTask))]
public sealed class BuildTask : FrostingTask<BuildContext>
{

private void UpdateApaxVersion(string file, string version)
{
var sb = new StringBuilder();
foreach (var line in System.IO.File.ReadLines(file))
{
var newLine = line;

if (line.Trim().StartsWith("version"))
{
var semicPosition = line.IndexOf(":");
var lenght = line.Length - semicPosition;

newLine = $"{line.Substring(0, semicPosition)} : '{version}'";
}
sb.AppendLine(newLine);
}

System.IO.File.WriteAllText(file, sb.ToString());
}

public override void Run(BuildContext context)
{
context.Libraries.ToList().ForEach(lib =>
{
UpdateApaxVersion(context.GetApaxFile(lib), GitVersionInformation.SemVer);
context.ApaxInstall(lib);
context.ApaxBuild(lib);
});
Expand Down Expand Up @@ -153,6 +131,26 @@ public override void Run(BuildContext context)
[IsDependentOn(typeof(TestsTask))]
public sealed class CreateArtifactsTask : FrostingTask<BuildContext>
{
private void UpdateApaxVersion(string file, string version)
{
var sb = new StringBuilder();
foreach (var line in System.IO.File.ReadLines(file))
{
var newLine = line;

if (line.Trim().StartsWith("version"))
{
var semicPosition = line.IndexOf(":");
var lenght = line.Length - semicPosition;

newLine = $"{line.Substring(0, semicPosition)} : '{version}'";
}
sb.AppendLine(newLine);
}

System.IO.File.WriteAllText(file, sb.ToString());
}

public override void Run(BuildContext context)
{
if (!context.BuildParameters.DoPublish)
Expand All @@ -161,7 +159,11 @@ public override void Run(BuildContext context)
return;
}

context.Libraries.ToList().ForEach(lib => context.ApaxPack(lib));
context.Libraries.ToList().ForEach(lib =>
{
UpdateApaxVersion(context.GetApaxFile(lib), GitVersionInformation.SemVer);
context.ApaxPack(lib);
});

PackPackages(context, Path.Combine(context.RootDir, "ix.framework-packable-only.slnf"));
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/ctrl/apax.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "@ix-ax/ix.framework.core"
version: '0.1.0-alpha.3'
version : '0.1.0-updates-from-pku-org.1'
type: lib
targets:
- "1500"
Expand Down
199 changes: 135 additions & 64 deletions src/core/ctrl/src/Coordination/Sequencer/Sequencer.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ NAMESPACE ix.framework.core
StepBackwardCommand : CommandTask;
END_VAR
VAR PRIVATE
_configurationFlowOrder : ULINT;
_configurationFlowOrder : ULINT;
_numberOfConfiguredSteps : ULINT;
_coordinatorState : CoordinatorStates;
_step : IStep;
_steppingMode : eSteppingMode;
Expand All @@ -27,78 +28,23 @@ NAMESPACE ix.framework.core
///</summary>
METHOD PUBLIC Open
IF SUPER.Execute() THEN
IF THIS.InvalidContext() THEN RETURN; END_IF;
IF THIS. InvalidContext() THEN RETURN; END_IF;
_openCycleCounter := THIS.GetContext().OpenCycleCount();
CASE _coordinatorState OF
CoordinatorStates#Idle :
_configurationFlowOrder := ULINT#0;
_numberOfConfiguredSteps := ULINT#0;
_coordinatorState := CoordinatorStates#Configuring;
StepForwardCommand.Initialize(THIS.GetContext());
StepIn.Initialize(THIS.GetContext());
StepBackwardCommand.Initialize(THIS.GetContext());
CoordinatorStates#Configuring :
CurrentOrder := ULINT#1;
_coordinatorState := CoordinatorStates#Running;
END_CASE;
END_IF;
END_METHOD

///<summary>
/// Completes (finishes) the execution of this sequencer.
/// Returns the `order of execution` pointer to the first step of the sequence.
///</summary>
METHOD PUBLIC CompleteSequence
IF SUPER.Execute() THEN
IF THIS.InvalidContext(_step) THEN RETURN; END_IF;
IF _coordinatorState = CoordinatorStates#Running THEN
_step.DoneWhen(TRUE);
_coordinatorState := CoordinatorStates#Idle;
CurrentOrder := ULINT#1;
SUPER.DoneWhen(_sequenceMode =eSequenceMode#RunOnce);
// Finalize the StepIn Command in a case of step mode
StepIn.DoneWhen(_steppingMode = eSteppingMode#StepByStep);
END_IF;
END_IF;
END_METHOD

///<summary>
/// Moves the execution to the next step.
///</summary>
METHOD PUBLIC MoveNext
IF SUPER.Execute() THEN
IF THIS.InvalidContext(_step) THEN RETURN; END_IF;
IF _coordinatorState = CoordinatorStates#Running THEN
_step.DoneWhen(TRUE);
CurrentOrder := CurrentOrder + ULINT#1;
// Finalize the StepIn Command in a case of step mode
StepIn.DoneWhen(_steppingMode = eSteppingMode#StepByStep);
END_IF;
END_IF;
END_METHOD

///<summary>
/// Gets the state of the coordinator
///</summary>
METHOD PUBLIC GetCoordinatorState : CoordinatorStates
GetCoordinatorState := _coordinatorState;
END_METHOD

///<summary>
/// Terminates the currently executed step and initiates the RequestedStep to be executed
///</summary>
METHOD PUBLIC RequestStep
VAR_INPUT
RequestedStep : IStep;
END_VAR
IF SUPER.Execute() THEN
IF THIS.InvalidContext(RequestedStep) THEN RETURN; END_IF;
IF RequestedStep.GetStepOrder() <> ULINT#0 AND
_coordinatorState = CoordinatorStates#Running THEN
_step.DoneWhen(TRUE);
CurrentOrder := RequestedStep.GetStepOrder();
// Finalize the StepIn Command in a case of step mode
StepIn.DoneWhen(_steppingMode = eSteppingMode#StepByStep);
END_IF;
END_IF;
END_METHOD

///<summary>
/// Returns `TRUE` if the specified step is currently executing.
///</summary>
Expand All @@ -114,7 +60,42 @@ NAMESPACE ix.framework.core
_step := step;

THIS.DetermineOrder(step);


// Stepping inside the sequence
IF _coordinatorState = CoordinatorStates#Running THEN
// Stepping is possible only in StepByStepMode
IF _steppingMode = eSteppingMode#StepByStep THEN
// Stepping Forwards and Backwards commands cannot be executed simultaneously
StepForwardCommand.IsDisabled := StepBackwardCommand.IsBusy()
// Stepping Forwards disabled from last step
OR CurrentOrder >= _numberOfConfiguredSteps;
StepIn.IsDisabled := FALSE;
StepBackwardCommand.IsDisabled := StepForwardCommand.IsBusy()
// Stepping Backwards disabled from first step
OR CurrentOrder <= ULINT#1;
// StepForward command increments the CurrentOrder just to a maximum value of _numberOfConfiguredSteps
IF StepForwardCommand.Execute() THEN
IF CurrentOrder < _numberOfConfiguredSteps THEN
THIS.RestoreCurrentStep();
CurrentOrder := CurrentOrder + ULINT#1;
END_IF;
StepForwardCommand.DoneWhen(TRUE);
END_IF;
// StepBackward command decrements the CurrentOrder just to a minimum value of 1
IF StepBackwardCommand.Execute() THEN
IF CurrentOrder > ULINT#1 THEN
THIS.RestoreCurrentStep();
CurrentOrder := CurrentOrder - ULINT#1;
END_IF;
StepBackwardCommand.DoneWhen(TRUE);
END_IF;
ELSE
THIS.DisableAllSteppingComands();
END_IF;
ELSE
THIS.DisableAllSteppingComands();
END_IF;

IF _coordinatorState = CoordinatorStates#Running AND (CurrentOrder = step.GetStepOrder()) AND step.IsCalledJustOnceInThisPlcCycle() THEN
IF Enable THEN
step.SetIsActive(TRUE);
Expand Down Expand Up @@ -146,8 +127,70 @@ NAMESPACE ix.framework.core

Execute := step.Execute();
END_IF;
END_METHOD

END_METHOD

///<summary>
/// Moves the execution to the next step.
///</summary>
METHOD PUBLIC MoveNext
IF SUPER.Execute() THEN
IF THIS.InvalidContext(_step) THEN RETURN; END_IF;
IF _coordinatorState = CoordinatorStates#Running THEN
_step.DoneWhen(TRUE);
_step.SetIsActive(FALSE);
CurrentOrder := CurrentOrder + ULINT#1;
// Finalize the StepIn Command in a case of step mode
StepIn.DoneWhen(_steppingMode = eSteppingMode#StepByStep);
END_IF;
END_IF;
END_METHOD

///<summary>
/// Terminates the currently executed step and initiates the RequestedStep to be executed
///</summary>
METHOD PUBLIC RequestStep
VAR_INPUT
RequestedStep : IStep;
END_VAR
IF SUPER.Execute() THEN
IF THIS.InvalidContext(RequestedStep) THEN RETURN; END_IF;
IF RequestedStep.GetStepOrder() <> ULINT#0 AND
_coordinatorState = CoordinatorStates#Running THEN
_step.DoneWhen(TRUE);
_step.SetIsActive(FALSE);
CurrentOrder := RequestedStep.GetStepOrder();
// Finalize the StepIn Command in a case of step mode
StepIn.DoneWhen(_steppingMode = eSteppingMode#StepByStep);
END_IF;
END_IF;
END_METHOD

///<summary>
/// Completes (finishes) the execution of this sequencer.
/// Returns the `order of execution` pointer to the first step of the sequence.
///</summary>
METHOD PUBLIC CompleteSequence
IF SUPER.Execute() THEN
IF THIS.InvalidContext(_step) THEN RETURN; END_IF;
IF _coordinatorState = CoordinatorStates#Running THEN
_step.DoneWhen(TRUE);
_step.SetIsActive(FALSE);
_coordinatorState := CoordinatorStates#Idle;
CurrentOrder := ULINT#1;
SUPER.DoneWhen(_sequenceMode =eSequenceMode#RunOnce);
// Finalize the StepIn Command in a case of step mode
StepIn.DoneWhen(_steppingMode = eSteppingMode#StepByStep);
END_IF;
END_IF;
END_METHOD

///<summary>
/// Gets the state of the coordinator
///</summary>
METHOD PUBLIC GetCoordinatorState : CoordinatorStates
GetCoordinatorState := _coordinatorState;
END_METHOD

///<summary>
/// Sets the stepping mode of the sequencer
///</summary>
Expand Down Expand Up @@ -191,6 +234,7 @@ NAMESPACE ix.framework.core
step.Restore();
_step := step;
_configurationFlowOrder := _configurationFlowOrder + ULINT#1;
_numberOfConfiguredSteps := _configurationFlowOrder;

step.SetStepOrder(THIS,_configurationFlowOrder);
IF NOT step.IsCalledJustOnceInThisPlcCycle() THEN
Expand All @@ -202,6 +246,15 @@ NAMESPACE ix.framework.core
DetermineOrder := step.GetStepOrder();
END_METHOD

METHOD PUBLIC GetNumberOfConfiguredSteps : ULINT
IF _coordinatorState = CoordinatorStates#Running THEN
_numberOfConfiguredSteps := _configurationFlowOrder;
GetNumberOfConfiguredSteps := _numberOfConfiguredSteps;
ELSE
GetNumberOfConfiguredSteps := ULINT#0;
END_IF;
END_METHOD

METHOD PROTECTED InvalidContext : BOOL
IF THIS.GetContext() = NULL THEN
InvalidContext := TRUE; // TODO: We will need to message this, when messaging ready.
Expand All @@ -222,6 +275,24 @@ NAMESPACE ix.framework.core
InvalidContext := FALSE;
END_IF;
END_METHOD

METHOD INTERNAL DisableAllSteppingComands
StepForwardCommand.IsDisabled := TRUE;
StepIn.IsDisabled := TRUE;
StepBackwardCommand.IsDisabled := TRUE;
END_METHOD

METHOD INTERNAL RestoreCurrentStep
// Restore current step if running
IF _step.IsBusy() THEN
_step.Restore();
END_IF;
// Restore step in command if running, otherwise this commnad will be executed on the following step
IF StepIn.IsBusy() THEN
StepIn.Restore();
END_IF;
_step.SetIsActive(FALSE);
END_METHOD

END_CLASS
END_NAMESPACE
Expand Down
11 changes: 0 additions & 11 deletions src/core/ctrl/src/Coordination/eSequencerStates.st

This file was deleted.

Loading