Create Any structure in C#
Hi,
Is it possible to create an Any structure in C# from an input or output variable? The reason behind this is, that my function block inherits a base class consists of several function with Any as arguments (Because the function should be used by multiple inherited classes but with different datatypes)
[code type="csharp"]
public class Base
{
...
public bool function1(ref Any data)
{
...
}
}
[FunctionBlock]
public class Derived : Base
{
[Input]
public int Value1;
[Output]
public bool Value2;
...
public void __Process()
{
Any intValue = new Any(&Value1, sizeof(Value1), Eclr.TypeInfo.GetHandleFromType(Value1.GetType()));
base.function1(intValue );
Any boolValue = new Any(&Value2, sizeof(Value2), Eclr.TypeInfo.GetHandleFromType(Value2.GetType()));
base.function1(boolValue );
}
}
[/code]
Is it possible to create an Any structure in C# from an input or output variable? The reason behind this is, that my function block inherits a base class consists of several function with Any as arguments (Because the function should be used by multiple inherited classes but with different datatypes)
[code type="csharp"]
public class Base
{
...
public bool function1(ref Any data)
{
...
}
}
[FunctionBlock]
public class Derived : Base
{
[Input]
public int Value1;
[Output]
public bool Value2;
...
public void __Process()
{
Any intValue = new Any(&Value1, sizeof(Value1), Eclr.TypeInfo.GetHandleFromType(Value1.GetType()));
base.function1(intValue );
Any boolValue = new Any(&Value2, sizeof(Value2), Eclr.TypeInfo.GetHandleFromType(Value2.GetType()));
base.function1(boolValue );
}
}
[/code]
Comments
you can create ANY Inputs or outputs using the ANY_NUM attribute.
https://github.com/PLCnext/CSharpExamples/blob/master/PLCnext_CSharpExamples/02_Any/Any.md
kind regards,
Oliver.