Skip to content

Commit

Permalink
Merge pull request #93 from PHOENIXCONTACT/fix/workersupport-result-i…
Browse files Browse the repository at this point in the history
…nvocation

Use correct invocation of instruction results
  • Loading branch information
Toxantron authored Oct 11, 2024
2 parents 457aff8 + 64f1478 commit 0f8aa29
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.2
8.2.3
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public static int ResultToEnumValue(Type resultEnum, InstructionResult result)
return int.Parse(result.Key);
}

/// <summary>
/// Extract result from response object depending on what values is present
/// </summary>
public static int ResultToEnumValue(Type resultEnum, ActiveInstructionResponse response)
{
if(response.SelectedResult != null)
return ResultToEnumValue(resultEnum, response.SelectedResult);

if (response.Result != null)

Check warning on line 60 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.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 60 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / UnitTests / UnitTests

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

Check warning on line 60 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / IntegrationTests / IntegrationTests

'ActiveInstructionResponse.Result' is obsolete: 'Use result object from 'SelectedResult' instead'
return ResultToEnumValue(resultEnum, response.Result);

Check warning on line 61 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.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 61 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / UnitTests / UnitTests

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

Check warning on line 61 in src/Moryx.ControlSystem/VisualInstructions/EnumInstructionResult.cs

View workflow job for this annotation

GitHub Actions / IntegrationTests / IntegrationTests

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

throw new ArgumentException("No result found on response", nameof(response));
}

/// <summary>
/// Convert string result to typed enum
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ private static long ExecuteWithEnum(this IVisualInstructor instructor, string ti

var results = EnumInstructionResult.PossibleResults(attr.ResultEnum);
var resultObjects = EnumInstructionResult.PossibleInstructionResults(attr.ResultEnum);

return instructor.Execute(new ActiveInstruction
{
Title = title,
Instructions = parameters,
PossibleResults = results,

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

View workflow job for this annotation

GitHub Actions / Build / Build

'ActiveInstruction.PossibleResults' is obsolete: 'Use the result objects in 'Results' property instead!'

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

View workflow job for this annotation

GitHub Actions / UnitTests / UnitTests

'ActiveInstruction.PossibleResults' is obsolete: 'Use the result objects in 'Results' property instead!'

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

View workflow job for this annotation

GitHub Actions / IntegrationTests / IntegrationTests

'ActiveInstruction.PossibleResults' is obsolete: 'Use the result objects in 'Results' property instead!'
Results = resultObjects.ToArray(),
Inputs = inputs
}, instructionResponse => callback(EnumInstructionResult.ResultToEnumValue(attr.ResultEnum, instructionResponse.Result), instructionResponse.Inputs, activityStart));
}, instructionResponse => callback(EnumInstructionResult.ResultToEnumValue(attr.ResultEnum, instructionResponse), instructionResponse.Inputs, activityStart));
}

private static VisualInstruction[] GetInstructions(ActivityStart activity)
Expand Down

0 comments on commit 0f8aa29

Please sign in to comment.