Skip to content

Commit c3b0c09

Browse files
Merge pull request #117 from PHOENIXCONTACT/feature/add-inputs-to-visualinstructorparameter
Add automatic support for Inputs to the VisualInstructionParameters
2 parents 28c1c0c + 43c179a commit c3b0c09

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/Moryx.ControlSystem/VisualInstructions/VisualInstruction.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class VisualInstruction
5454
/// <summary>
5555
/// Interface for classes that define instructions
5656
/// </summary>
57+
//TODO: remove in MORYX 10, will be replaced by VisualInstructionParameters
5758
public interface IVisualInstructions
5859
{
5960
/// <summary>

src/Moryx.ControlSystem/VisualInstructions/VisualInstructionParameters.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public class VisualInstructionParameters : Parameters, IVisualInstructions
1919
[EntrySerialize, DataMember]
2020
public VisualInstruction[] Instructions { get; set; }
2121

22+
/// <summary>
23+
/// Inputs for this activity.
24+
/// </summary>
25+
public object Inputs { get; set; }
26+
2227
/// <summary>
2328
/// Binder to resolve visual instruction bindings
2429
/// </summary>

src/Moryx.ControlSystem/VisualInstructions/VisualInstructorExtensions.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
// Copyright (c) 2024, Phoenix Contact GmbH & Co. KG
1+
// Copyright (c) 2024, Phoenix Contact GmbH & Co. KG
22
// Licensed under the Apache License, Version 2.0
33

44
using System;
55
using System.Collections.Generic;
66
using System.Linq;
77
using System.Reflection;
8+
using System.Reflection.Metadata;
89
using Moryx.AbstractionLayer;
910
using Moryx.ControlSystem.Cells;
1011

@@ -24,7 +25,9 @@ public static long Display(this IVisualInstructor instructor, string title, IVis
2425
return instructor.Display(new ActiveInstruction
2526
{
2627
Title = title,
27-
Instructions = parameter.Instructions
28+
Instructions = parameter.Instructions,
29+
//TODO: remove the casting in MORYX 10
30+
Inputs = (parameter as VisualInstructionParameters)?.Inputs,
2831
});
2932
}
3033

@@ -37,7 +40,9 @@ public static void Display(this IVisualInstructor instructor, string title, IVis
3740
instructor.Display(new ActiveInstruction
3841
{
3942
Title = title,
40-
Instructions = parameter.Instructions
43+
Instructions = parameter.Instructions,
44+
//TODO: remove the casting in MORYX 10
45+
Inputs = (parameter as VisualInstructionParameters)?.Inputs,
4146
}, autoClearMs);
4247
}
4348

@@ -50,7 +55,9 @@ public static long Display(this IVisualInstructor instructor, string title, Acti
5055
return instructor.Display(new ActiveInstruction
5156
{
5257
Title = title,
53-
Instructions = instructions
58+
Instructions = instructions,
59+
//TODO: remove the casting in MORYX 10
60+
Inputs = (activityStart.Activity.Parameters as VisualInstructionParameters)?.Inputs,
5461
});
5562
}
5663

@@ -122,7 +129,10 @@ public static long Execute(this IVisualInstructor instructor, string title, IVis
122129
{
123130
Title = title,
124131
Instructions = parameter.Instructions,
125-
PossibleResults = results
132+
PossibleResults = results,
133+
Results = results.Select(r => new InstructionResult { Key = r, DisplayValue = r }).ToArray(),
134+
//TODO: remove the casting in MORYX 10
135+
Inputs = (parameter as VisualInstructionParameters)?.Inputs,
126136
}, callback);
127137
}
128138

@@ -157,7 +167,9 @@ public static long Execute(this IVisualInstructor instructor, string title, Acti
157167
Title = title,
158168
Instructions = instructions,
159169
PossibleResults = results,
160-
Results = results.Select(r => new InstructionResult { Key = r, DisplayValue = r }).ToArray()
170+
Results = results.Select(r => new InstructionResult { Key = r, DisplayValue = r }).ToArray(),
171+
//TODO: remove the casting in MORYX 10
172+
Inputs = (activityStart.Activity.Parameters as VisualInstructionParameters)?.Inputs,
161173
}, callback);
162174
}
163175

0 commit comments

Comments
 (0)