Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed May 8, 2024
2 parents 2f9496f + 42735db commit 9f5591d
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 21 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
on:
workflow_dispatch:
push:
branches:
- dev
Expand All @@ -16,10 +17,10 @@ on:
env:
dotnet_sdk_version: '8.0.100'
REPOSITORY_NAME: ${{ github.event.repository.name }}
MORYX_PACKAGE_TARGET_DEV: 'https://www.myget.org/F/moryx/api/v2/package'
MORYX_PACKAGE_TARGET_V3_DEV: 'https://www.myget.org/F/moryx/api/v3/index.json'
MORYX_PACKAGE_TARGET_FUTURE: 'https://www.myget.org/F/moryx-future/api/v2/package'
MORYX_PACKAGE_TARGET_V3_FUTURE: 'https://www.myget.org/F/moryx-future/api/v3/index.json'
MORYX_PACKAGE_TARGET_DEV: 'https://www.myget.org/F/moryx-oss-ci/api/v2/package'
MORYX_PACKAGE_TARGET_V3_DEV: 'https://www.myget.org/F/moryx-oss-ci/api/v3/index.json'
MORYX_PACKAGE_TARGET_FUTURE: 'https://www.myget.org/F/moryx-oss-ci/api/v2/package'
MORYX_PACKAGE_TARGET_V3_FUTURE: 'https://www.myget.org/F/moryx-oss-ci/api/v3/index.json'
MORYX_PACKAGE_TARGET_RELEASE: 'https://api.nuget.org/v3/index.json'
MORYX_PACKAGE_TARGET_V3_RELEASE: 'https://api.nuget.org/v3/index.json'

Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
</a>
</p>

<p align="center">
<a href="https://www.nuget.org/packages/Moryx/">
<img alt="NuGet Release" src="https://img.shields.io/nuget/v/Moryx.ControlSystem?color=0098A1">
</a>
</p>

# MORYX Factory

**Public API definitions for MORYX Factory applications.**
Expand All @@ -25,13 +31,13 @@ This repository contains the APIs, domain objects and developer documentation fo

## Packages

| Package | Stable | Preview | Future |
|--|--|--|--|
| `Moryx.ControlSystem` | [![NuGet](https://img.shields.io/nuget/v/Moryx.ControlSystem.svg)](https://www.nuget.org/packages/Moryx.ControlSystem/) | [![MyGet](https://img.shields.io/myget/moryx/vpre/Moryx.ControlSystem)](https://www.myget.org/feed/moryx/package/nuget/Moryx.ControlSystem) | [![MyGet-Release](https://img.shields.io/myget/moryx-future/vpre/Moryx.ControlSystem)](https://www.myget.org/feed/moryx-future/package/nuget/Moryx.ControlSystem) |
| `Moryx.Orders` | [![NuGet](https://img.shields.io/nuget/v/Moryx.Orders.svg)](https://www.nuget.org/packages/Moryx.Orders/) | [![MyGet](https://img.shields.io/myget/moryx/vpre/Moryx.Orders)](https://www.myget.org/feed/moryx/package/nuget/Moryx.Orders) | [![MyGet-Release](https://img.shields.io/myget/moryx-future/vpre/Moryx.Orders)](https://www.myget.org/feed/moryx-future/package/nuget/Moryx.Orders) |
| `Moryx.Users` | [![NuGet](https://img.shields.io/nuget/v/Moryx.Users.svg)](https://www.nuget.org/packages/Moryx.Users/) | [![MyGet](https://img.shields.io/myget/moryx/vpre/Moryx.Users)](https://www.myget.org/feed/moryx/package/nuget/Moryx.Users) | [![MyGet-Release](https://img.shields.io/myget/moryx-future/vpre/Moryx.Users)](https://www.myget.org/feed/moryx-future/package/nuget/Moryx.USers) |
| `Moryx.ProcessData` | [![NuGet](https://img.shields.io/nuget/v/Moryx.ProcessData.svg)](https://www.nuget.org/packages/Moryx.ProcessData/) | [![MyGet](https://img.shields.io/myget/moryx/vpre/Moryx.ProcessData)](https://www.myget.org/feed/moryx/package/nuget/Moryx.ProcessData) | [![MyGet-Release](https://img.shields.io/myget/moryx-future/vpre/Moryx.ProcessData)](https://www.myget.org/feed/moryx-future/package/nuget/Moryx.ProcessData) |
| `Moryx.Simulation` | [![NuGet](https://img.shields.io/nuget/v/Moryx.Simulation.svg)](https://www.nuget.org/packages/Moryx.Simulation/) | [![MyGet](https://img.shields.io/myget/moryx/vpre/Moryx.Simulation)](https://www.myget.org/feed/moryx/package/nuget/Moryx.Simulation) | [![MyGet-Release](https://img.shields.io/myget/moryx-future/vpre/Moryx.Simulation)](https://www.myget.org/feed/moryx-future/package/nuget/Moryx.Simulation) |
| Package | |
|--|--|
| `Moryx.ControlSystem` | |
| `Moryx.Orders` | |
| `Moryx.Users` | |
| `Moryx.ProcessData` | |
| `Moryx.Simulation` | |
## Contribute

You can contribute to the MORYX Factory Domain by reporting bugs and suggesting extensions to APIs.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.0.0
8.1.0
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2022, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0

using System;
using System.Collections.Generic;

namespace Moryx.ControlSystem.VisualInstructions
Expand Down Expand Up @@ -33,6 +34,12 @@ public class ActiveInstruction
/// <summary>
/// Results of the instruction
/// </summary>
[Obsolete("Use the result objects in 'Results' property instead!")]
public IReadOnlyList<string> PossibleResults { get; set; } = new string[0];

/// <summary>
/// Possible results of the instruction
/// </summary>
public InstructionResult[] Results { get; set; } = Array.Empty<InstructionResult>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace Moryx.ControlSystem.VisualInstructions
/// Response of the client for an <see cref="ActiveInstruction"/>
/// </summary>
public class ActiveInstructionResponse

{
/// <summary>
/// Runtime unique identifier of this instruction per client-identifier
Expand All @@ -26,6 +25,12 @@ public class ActiveInstructionResponse
/// <summary>
/// Selected result option by the user
/// </summary>
[Obsolete("Use result object from 'SelectedResult' instead")]
public string Result { get; set; }

/// <summary>
/// Selected result option by the user
/// </summary>
public InstructionResult SelectedResult { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ public static IReadOnlyList<string> PossibleResults(Type resultEnum, params stri
return ParseEnum(resultEnum, exceptions).Keys.ToList();
}

/// <summary>
/// Determine possible string buttons from enum result
/// </summary>
public static IReadOnlyList<InstructionResult> PossibleInstructionResults(Type resultEnum, params string[] exceptions)
{
return ParseEnum(resultEnum, exceptions).Select(pair => new InstructionResult
{
Key = pair.Value.ToString("D"),
DisplayValue = pair.Key
}).ToList();
}

/// <summary>
/// Parse the given result back to an enum value
/// </summary>
Expand All @@ -29,6 +41,34 @@ public static int ResultToEnumValue(Type resultEnum, string result)
return ParseEnum(resultEnum)[result];
}

/// <summary>
/// Parse the given result back to an enum value
/// </summary>
public static int ResultToEnumValue(Type resultEnum, InstructionResult result)
{
return int.Parse(result.Key);
}

/// <summary>
/// Convert string result to typed enum
/// </summary>
public static TEnum ResultToGenericEnumValue<TEnum>(string result)
where TEnum : Enum
{
var numeric = ResultToEnumValue(typeof(TEnum), result);
return (TEnum)Enum.ToObject(typeof(TEnum), numeric);
}

/// <summary>
/// Convert string result to typed enum
/// </summary>
public static TEnum ResultToGenericEnumValue<TEnum>(InstructionResult result)
where TEnum : Enum
{
var numeric = int.Parse(result.Key);
return (TEnum)Enum.ToObject(typeof(TEnum), numeric);
}

/// <summary>
/// Parse the given enum to an dictionary of button text and value
/// </summary>
Expand Down Expand Up @@ -70,7 +110,7 @@ private static IDictionary<string, int> ParseEnum(Type resultEnum, params string
{
return allValues;
}

// Case 3: All values are explicitly hidden => display nothing
if (allValues.Count == hiddenValues.Count)
{
Expand Down
22 changes: 22 additions & 0 deletions src/Moryx.ControlSystem/VisualInstructions/InstructionResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Moryx.ControlSystem.VisualInstructions
{
/// <summary>
/// Object representing a possible result for an instructions
/// </summary>
public class InstructionResult
{
/// <summary>
/// Key of the result. This value needs to be unique for the instruction the result is used for.
/// </summary>
public string Key { get; set; }

/// <summary>
/// Human readable value of the result
/// </summary>
public string DisplayValue { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Reflection;
using Moryx.AbstractionLayer;
using Moryx.ControlSystem.Cells;
Expand Down Expand Up @@ -65,6 +66,26 @@ public static long Execute(this IVisualInstructor instructor, string title, IVis
}, callback);
}

/// <summary>
/// Execute these instructions and report the result on completion
/// Can (but must not) be cleared with the <see cref="IVisualInstructor.Clear"/> method
/// </summary>
/// <typeparam name="T">Type of enum used for possible instruction results</typeparam>
public static long Execute<T>(this IVisualInstructor instructor, string title, IVisualInstructions parameter, Action<T> callback) where T: Enum
{
return instructor.Execute(
title,
parameter,
EnumInstructionResult.PossibleResults(typeof(T)),
result =>
{
if (result.SelectedResult?.Key == null)
callback(EnumInstructionResult.ResultToGenericEnumValue<T>(result.Result));

Check warning on line 83 in src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs

View workflow job for this annotation

GitHub Actions / Build / Build

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

Check warning on line 83 in src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs

View workflow job for this annotation

GitHub Actions / IntegrationTests / IntegrationTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'

Check warning on line 83 in src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs

View workflow job for this annotation

GitHub Actions / UnitTests / UnitTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'
else
callback(EnumInstructionResult.ResultToGenericEnumValue<T>(result.SelectedResult));
});
}

/// <summary>
/// Executes the instructions of an activity with defining own results
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Moryx.Orders/Facade/IOrderManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public interface IOrderManagement

/// <summary>
/// Tries to advise the <see cref="Operation"/>.
/// The returned advice result contains information regarding the successful or unsuccesful attempt.
/// The returned advice result contains information regarding the successful or unsuccessful attempt.
/// </summary>
/// <param name="operation">The <see cref="Operation"/> to advice.</param>
/// <param name="advice">The <see cref="OperationAdvice"/> to apply on the <see cref="Operation"/>.</param>
Expand Down
12 changes: 11 additions & 1 deletion src/Moryx.Orders/Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,23 @@ public class Operation
/// <summary>
/// Current state classification of this operation
/// </summary>
public virtual OperationClassification State { get => (OperationClassification)((int)FullState & 0xFF); protected set => FullState = value; }
public virtual OperationClassification State
{
get => (OperationClassification)((int)FullState & 0xFF);
protected set => FullState = value;
}

/// <summary>
/// Current state classification of this operation
/// </summary>
public virtual OperationClassification FullState { get; protected set; }

/// <summary>
/// Detailed display name of the state
/// TODO: Remove this property in next major and replace rework OperationClassification
/// </summary>
public virtual string StateDisplayName { get; protected set; }

/// <summary>
/// Source information of the operation
/// </summary>
Expand Down
10 changes: 7 additions & 3 deletions src/Moryx.Orders/OperationClassification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Moryx.Orders
/// <summary>
/// Enum providing the classification of the internal state machine of the operation for an external representation
/// The lowest 8 bits define the state of the operation. The following 16 bits contain flags for the executable
/// actions on the operation and the trailing 8 bits overal classification information.
/// actions on the operation and the trailing 8 bits overall classification information.
/// Bit: 31 - 24 | 23 - 8 | 7 - 0 |
/// Flag: Type | Usage | State |
/// </summary>
Expand Down Expand Up @@ -60,7 +60,6 @@ public enum OperationClassification
/// </summary>
Failed = 11,


/// <summary>
/// Flag if the operation can be reloaded
/// </summary>
Expand All @@ -84,6 +83,11 @@ public enum OperationClassification
/// <summary>
/// Flag if the operation can be adviced
/// </summary>
CanAdvice = (1 << 20)
CanAdvice = (1 << 20),

/// <summary>
/// Flag if the operation is running but has no process
/// </summary>
IsAmountReached = (1 << 22),
}
}
1 change: 0 additions & 1 deletion src/Moryx.Orders/OperationLogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using Microsoft.Extensions.Logging;
using Moryx.Logging;

namespace Moryx.Orders
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public void GetAllValuesIfNoResultIsDecorated()
{
// Act
var instructionResult = EnumInstructionResult.PossibleResults(typeof(TestResults1));
var possibleResults = EnumInstructionResult.PossibleInstructionResults(typeof(TestResults1));

// Assert
Assert.AreEqual(2, instructionResult.Count, "There should be 2 results because all of the results are not decorated");
Assert.AreEqual(2, instructionResult.Count(), "There should be 2 results because all of the results are not decorated");
Assert.AreEqual(2, possibleResults.Count(), "There should be 2 results because all of the results are not decorated");
}

private enum TestResults2
Expand Down Expand Up @@ -106,9 +108,11 @@ public void ParseResponse()

// Act
var enumValue = (TestResults1)EnumInstructionResult.ResultToEnumValue(typeof(TestResults1), instructionResult[1]);
var directValue = EnumInstructionResult.ResultToGenericEnumValue<TestResults1>(instructionResult[1]);

// Assert
Assert.AreEqual(TestResults1.Value2, enumValue);
Assert.AreEqual(TestResults1.Value2, directValue);
}

private class MyInput
Expand Down

0 comments on commit 9f5591d

Please sign in to comment.