Skip to content

Commit

Permalink
added inspector documentation, some UI tweaks and code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Specter-13 committed Aug 11, 2023
1 parent d45f59a commit e47daa4
Show file tree
Hide file tree
Showing 32 changed files with 286 additions and 57 deletions.
2 changes: 1 addition & 1 deletion build_docu.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dotnet run --project ..\ix\src\ix.compiler\src\ixd\Ix.ixd.csproj --framework net7.0 -x .\src\core\ctrl\ -o .\docfx\apictrl\
dotnet ixd -x .\src\abstractions\ctrl .\src\data\ctrl\ .\src\core\ctrl -o .\docfx\apictrl\
dotnet ixd -x .\src\abstractions\ctrl .\src\data\ctrl\ .\src\core\ctrl .\src\inspectors\ctrl -o .\docfx\apictrl\
dotnet docfx .\docfx\docfx.json --debug
dotnet docfx serve .\docs\
16 changes: 16 additions & 0 deletions docfx/articles/inspectors/AXOANALOGUEINSPECTOR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## AxoAnalogueInspector

Provides evaluation of *continuous* values. The inspector checks that the input value falls within the limit of *Min* and *Max*. The inspection passes when the input value is within the required limit without interruption for the duration of stabilization time.

![Analog inspector](~/images/analog-inspector.png)


Common inspector data are extended with following analogue inspector data:

```C#
RequiredMin : LREAL; // min required value for inspection
DetectedStatus : LREAL; // detected value
RequiredMax: LREAL; // max required value for inspection
```
16 changes: 16 additions & 0 deletions docfx/articles/inspectors/AXODATAINSPECTOR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## AxoDataInspector

Provides evaluation of alphanumerical values. The input value compares against the Required value. The inspection passes when the input value matches the required value without interruption for the duration of stabilization time. In addition to exact comparison, data inspector allows for simple pattern matching where # = any number and * = any character.

![Data inspector](~/images/data-inspector.png)

Common inspector data are extended with following data inspector data:

```C#
RequiredStatus : STRING; //required value for inspection
DetectedStatus : STRING; //detected value for inspection
StarNotationEnabled: BOOL; //star notation enable/disable
```
13 changes: 13 additions & 0 deletions docfx/articles/inspectors/AXODIGITALINSPECTOR.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## AxoDigitalInspector

Inspector provides evaluation of *discrete* value. The input value compares against the *Required* value. The inspection passes when the input value matches the required value without interruption for the duration of stabilization time.

![Digital inspector](~/images/digital-inspector.png)

Common inspector data are extended with following digital inspector data:

```C#
RequiredStatus : BOOL; //required value for inspection
DetectedStatus : BOOL; //detected value for inspection
```
114 changes: 114 additions & 0 deletions docfx/articles/inspectors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# **AXOpen.Inspectors**

**AXOpen.Inspectors** provides mechanism of inspection of different types of data. The input value is compared to required value. If input value is the same as required value for a *stabilization* time period, the inspection will succeed. If values are different, *timeout* will occur and inspection will fail.

Inspectors can integrate with coordination primitives like [AxoSequencer](../core/AXOSEQUENCER.md). In consequence, inspectors offer extended capabilities in decision flow for failed checks.

Each inspector contains:

1. `Inspect` method, which input is current parent and inspection variable
2. `OnFail` method, which provides methods for making a decision after a failed inspection (see Handling failure section)
3. `UpdateComprehensiveResult` methods, which input is object of type `AxoComprehesiveResult`, which can be used to gather results of all inspections.

4. `Common data` about inspection inputs and result. See below.

## Example inspection
Example of inspection within a sequencer in PLC:
```
_presenceInspector.WithCoordinator(THIS).Inspect(THIS,_inspectionResult)
.UpdateComprehensiveResult(_comprehensiveResult)
.OnFail().CarryOn();
```

1. A _presenceInspector is created instance of `AxoDigitalInspector`

2. A coordinator is passed to this inspector with `WithCoordinator(THIS)` method, in this case it is a sequencer, parent object.
3. `Inspect` methods takes parent and inspection variable, on which inspection is performing.
4. If inspection fails, the result is updated to `_comprehensiveResult` object with `UpdateComprehensiveResult` method.
5. If inspection fail, `OnFail` method provides `CarryOn` method, which tells the coordinator to continue in execution.

## Common inspector data

The inspectors contain common data, which are used to store data about inspection. Each inspectors contain following data:

```C#
Timestamp: LDATE_AND_TIME; // timestamp of inspection
PassTime : TIME; // stabilization time, inspection must be success for this period of time
FailTime : TIME; // timeout, after which inspection fails
Result : eInspectorResult; // result of inspection
IsExcluded: BOOL; // inspection will be performed, however result will be omitted in overall result
IsByPassed : BOOL; // inspection will be skipped
NumberOfAllowedRetries : UINT; // maximum number of retries of inspection, from which overinspection will occur
RetryAttemptsCount : UINT; // actual number of retries, if RetryAttemptsCount > NumberOfAllowedRetries, overinspection occurs
```



[!INCLUDE [AxoDigitalInspector](AXODIGITALINSPECTOR.md)]

[!INCLUDE [AxoAnalogueInspector](AXOANALOGUEINSPECTOR.md)]

[!INCLUDE [AxoDataInspector](AXODATAINSPECTOR.md)]



## Handling failure

When an inspector fails, OnFail() provides a series of methods for making decisions about the process. In order for this is feature to work the inspector needs to be aware of the coordinator of `IAxoCoordinator`. The coordinator must be passed to the inspector by `WithCoordinator(coordinator)` method.


| Syntax | Description |
| ----------- | ----------- |
| Dialog(inRetryStep, inTerminateStep) | Opens dialog for the user to take a decision. Parameter `inRetryStep` represent state from which the inspection should start again. Parameter `inTerminateStep` represent terminate state of coordinator. |
| Retry(inRetryStep) | Retries the inspector. Retry state parameter tells from which state the inspection should start again. |
| Override() | Marks the inspection as failed but continues with the following states of the coordinator. |
| Terminate(inTerminateStep) | Marks the inspection as failed and aborts the execution of the coordinator. |

The following example specify, that when inspection fails, dialog is shown and is requesting user decision.

```
_valueInspector.WithCoordinator(THIS).Inspect(THIS,_inspectionValue).OnFail().Dialog(Steps[20], Steps[145]);
```

![Inspection failure](~/images/inspection-failure-dialog.png)

## Over-inspection
When `RetryAttemptsCount` is same as `NumberOfAllowedRetries`, no more inspection are allowed, as data are overinspected.

![Overinspected](~/images/overinspected.png)


## Preserving overall result

Overall result of a series of inspections can be preserved in `AxoComprehensiveResult`. Each inspector has `UpdateComprehensiveResult` method that provides the update function. Once the `UpdateComprehensiveResult` marks the overall result as Failed, successive inspection will not overwrite the result.

```
IF (Steps[30].Execute(THIS, TRUE, 'Example Digital inspection')) THEN
_presenceInspector.WithCoordinator(THIS).Inspect(THIS,_inspectionResult)
.UpdateComprehensiveResult(_comprehensiveResult)
.OnFail().CarryOn();
END_IF;
IF (Steps[40].Execute(THIS, TRUE, 'Example Analog inspection')) THEN
_valueInspector.WithCoordinator(THIS).Inspect(THIS,_inspectionValue)
.UpdateComprehensiveResult(_comprehensiveResult)
.OnFail().CarryOn();
END_IF;
END_IF;
```

10 changes: 10 additions & 0 deletions docfx/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
href: ~/articles/data/AxoDataExchange.md
- name: Data fragmets exchange
href: ~/articles/data/AxoDataFragmentExchange.md

- name: AXOpen.Inspectors
href: ~/articles/inspectors/README.md
items:
- name: AxoDigitalInspector
href: ~/articles/inspectors/AXODIGITALINSPECTOR.md
- name: AxoAnalogueInspector
href: ~/articles/inspectors/AXOANALOGUEINSPECTOR.md
- name: AxoDataInspector
href: ~/articles/inspectors/AXODATAINSPECTOR.md
- name: AXOpen.Messaging
href: ~/articles/messaging/README.md
items:
Expand Down
Binary file added docfx/images/analog-inspector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docfx/images/data-inspector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docfx/images/digital-inspector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docfx/images/inspection-failure-dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docfx/images/overinspected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ private async void OnDialogInvoked(object? sender, AxoDialogEventArgs e)
/// </summary>
public void Dispose()
{
_axoDialogProxyService.DialogInvoked -= OnDialogInvoked;
_axoDialogProxyService.Dispose();
if (_axoDialogProxyService != null)
{
_axoDialogProxyService.DialogInvoked -= OnDialogInvoked;
_axoDialogProxyService.Dispose();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
NAMESPACE AXOpen.Inspectors



/// <summary>
/// Class representing inspection of value within an interval.
/// </summary>
CLASS AxoAnalogueInspector EXTENDS AxoInspector IMPLEMENTS IAxoAnalogueInspector

VAR PUBLIC
Expand All @@ -12,12 +16,13 @@ NAMESPACE AXOpen.Inspectors
END_VAR



/// <summary>
/// Inspection method, which contains main logic of inspection.
/// </summary>
METHOD PUBLIC Inspect : IInspector
VAR_INPUT
_parent : AXOpen.Core.IAxoObject;
Status : LREAL;

END_VAR

VAR
Expand Down Expand Up @@ -48,7 +53,6 @@ NAMESPACE AXOpen.Inspectors
//initialize and invoke inspector task
_inspectorTask.Invoke();


//do inspection
IF (_inspectorTask.Execute()) THEN
IF (_data.IsByPassed) THEN
Expand All @@ -66,18 +70,20 @@ NAMESPACE AXOpen.Inspectors

_data.DetectedStatus := Status;

tmpResult := (_minimum <= _value) AND (_maximum >= _value);
IF(NOT tmpResult) THEN
tmpResult := (_minimum <= _value) AND (_maximum >= _value);

IF(NOT tmpResult) THEN
_lastOutValue := Status;
END_IF;
_inspectorTask._failTimer(TRUE, _data.FailTime);
_inspectorTask._passTimer(tmpResult, _data.PassTime);

IF(_inspectorTask._passTimer.output OR _inspectorTask._failTimer.output) THEN
_inspectorTask.DoneWhen(TRUE);
END_IF;

_inspectorTask._failTimer(TRUE, _data.FailTime);
_inspectorTask._passTimer(tmpResult, _data.PassTime);

IF(_inspectorTask._passTimer.output OR _inspectorTask._failTimer.output) THEN
_inspectorTask.DoneWhen(TRUE);
THIS.OnDone();
END_IF;
END_IF;

END_IF;
END_METHOD

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ NAMESPACE AXOpen.Inspectors

VAR PUBLIC

{#ix-set:AttributeName = "<#Min#>"}
RequiredMin : LREAL;


{#ix-set:AttributeName = "<#Detected#>"}
DetectedStatus : LREAL;


{#ix-set:AttributeName = "<#Max#>"}
RequiredMax: LREAL;

END_VAR
Expand Down
1 change: 0 additions & 1 deletion src/inspectors/ctrl/src/AxoComprehensiveResult.st
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
NAMESPACE AXOpen.Inspectors

CLASS AxoComprehensiveResult IMPLEMENTS IAxoComprehensiveResult
// this probably should not be public, but it is for test purposes
VAR PUBLIC

Result : eOverallResult;
Expand Down
21 changes: 13 additions & 8 deletions src/inspectors/ctrl/src/AxoDataInspector/AxoDataInspector.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ USING System.Strings;

NAMESPACE AXOpen.Inspectors


/// <summary>
/// Class representing inspection of string value with support of star notation.
/// </summary>
CLASS AxoDataInspector EXTENDS AxoInspector IMPLEMENTS IAxoDataInspector

VAR PUBLIC
Expand All @@ -14,7 +16,9 @@ NAMESPACE AXOpen.Inspectors
END_VAR



/// <summary>
/// Inspection method, which contains main logic of inspection.
/// </summary>
METHOD PUBLIC Inspect : IInspector
VAR_INPUT
_parent : AXOpen.Core.IAxoObject;
Expand Down Expand Up @@ -97,15 +101,16 @@ NAMESPACE AXOpen.Inspectors
tmpResult := _data.DetectedStatus = _data.RequiredStatus;
END_IF;
IF(NOT tmpResult) THEN
IF(NOT tmpResult) THEN
_lastOutValue := Status;
END_IF;
_inspectorTask._failTimer(TRUE, _data.FailTime);
_inspectorTask._passTimer(tmpResult, _data.PassTime);
END_IF;
_inspectorTask._failTimer(TRUE, _data.FailTime);
_inspectorTask._passTimer(tmpResult, _data.PassTime);
IF(_inspectorTask._passTimer.output OR _inspectorTask._failTimer.output) THEN
IF(_inspectorTask._passTimer.output OR _inspectorTask._failTimer.output) THEN
_inspectorTask.DoneWhen(TRUE);
THIS.OnDone();
THIS.OnDone();
END_IF;
END_IF;
END_METHOD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ NAMESPACE AXOpen.Inspectors

VAR PUBLIC

{#ix-set:AttributeName = "<#Required#>"}
RequiredStatus: STRING;


{#ix-set:AttributeName = "<#Detected#>"}
DetectedStatus : STRING;


{#ix-set:AttributeName = "<#Star notation#>"}
StarNotationEnabled: BOOL;

END_VAR
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
NAMESPACE AXOpen.Inspectors


/// <summary>
/// Class representing inspection of bool value.
/// </summary>
CLASS AxoDigitalInspector EXTENDS AxoInspector IMPLEMENTS IAxoDigitalInspector

VAR PUBLIC
{#ix-set:AttributeName = "<#Inspector data#>"}
_data : AxoDigitalInspectorData;
END_VAR


/// <summary>
/// Inspection method, which contains main logic of inspection.
/// </summary>
METHOD PUBLIC Inspect : IInspector
VAR_INPUT
_parent: AXOpen.Core.IAxoObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ NAMESPACE AXOpen.Inspectors

VAR PUBLIC

{#ix-set:AttributeName = "<#Required#>"}
RequiredStatus : BOOL;


{#ix-set:AttributeName = "<#Detected#>"}
DetectedStatus : BOOL;


Expand Down
Loading

0 comments on commit e47daa4

Please sign in to comment.