Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use correct invocation of instruction results #93

Merged
merged 1 commit into from
Oct 11, 2024
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 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 @@
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 @@ -62,7 +62,7 @@
{
Title = title,
Instructions = parameter.Instructions,
PossibleResults = results

Check warning on line 65 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 65 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 65 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!'
}, callback);
}

Expand All @@ -80,7 +80,7 @@
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 / UnitTests / UnitTests

'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'
else
callback(EnumInstructionResult.ResultToGenericEnumValue<T>(result.SelectedResult));
});
Expand All @@ -96,7 +96,7 @@
{
Title = title,
Instructions = instructions,
PossibleResults = results,

Check warning on line 99 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 99 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 99 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 = results.Select(r => new InstructionResult { Key = r, DisplayValue = r }).ToArray()
}, callback);
}
Expand Down Expand Up @@ -163,14 +163,15 @@

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
Loading