Page 1 of 1

Set a value for a NON IEncodeable event field

Posted: 29 Jul 2021, 16:21
by uonabi
Hi,
I created a new Variable type called "VarStat" derived from "Types\VariablesType\BaseDataVariableType\DataItemType\BaseAnalogType\AnalogItemType".
VarStat is Double data type and has 3 children: Avg , Max, Min (all Double data type):

VARIABLE TYPE DEFINITION:
VarStat (Double)
Variable - Avg - BaseDataVariableType (TypeDefinition) - Double (DataType)
Variable - Min - BaseDataVariableType (TypeDefinition) - Double (DataType)
Variable - Max - BaseDataVariableType (TypeDefinition) - Double (DataType)

Then I created an event called "LogEvent" with the parameter "NewValue" of "VarStat" type:

EVENT DEFINTION:
NewValue
Variable - NewValue - VarStat (TypeDefinition) - Double (DataType)

In the .Net source code, I call the event and set the value for event field by:
e.Set(e.ToPath(new QualifiedName("2:NewValue"),NewValueVar)
where NewValueVar is a VarStatModel variable.

I have this error:
"Argument 2: cannot convert from VarStatModel to UnifiedAutomation.UABase.IEncodeable"

If I call
e.Set(e.ToPath(new QualifiedName("2:NewValue"),NewValueVar.Value)
the code is without error but the event (in UAExpert) return only the VarStat value (Double) without Avg, Min and Max.

The question is:
How I can set an NON IEncodeable event field ?
Note in the .Net source code I create the tag with :
VarStatModel NewValueVar = new VarStatModel ();
It is not a VarStatType, because it is Double (TypeDefnition is VarStat).

I hope I was clear.
Thanks

Re: Set a value for a NON IEncodeable event field

Posted: 02 Sep 2021, 08:24
by Support Team
Hello,

Variant does not have a constructor having a Model class as argument. Please use the value of the model (maybe you have to cast the Value to double, depending on your implementation) and pass it to the constructor.