I have two float properties ("Transmitted_Power" and "Reflected_Power") which I pass by reference to a method "I2C_Get_Transmitted_Reflected" using the followin syntax
var bool result = I2C_Get_Transmitted_Reflected(^RF_Driver::Device.Transmitted_Power, ^RF_Driver::Device.Reflected_Power);
The method "I2C_Get_Transmitted_Reflected" has the follwing conains the following input parameters (two references to float properties):
method bool I2C_Get_Transmitted_Reflected
(
arg float^ transmitted_mw
arg float^ reflected_mw
)
and contains the following code:
$if $prototyper
var float random_number1 = math_rand( 0.0, 15000.0 );
var float random_number2 = math_rand( 0.0, 15000.0 );
transmitted_mw^ = random_number1;
reflected_mw^ = random_number2;
return true;
$endif
$if !$prototyper
var bool result = false;
native ( result, transmitted_mw, reflected_mw)
{
// get transmitted counts
XInt16 DeviceDriver_Get_TransmittedCounts( void );
XInt16 transmitted_counts = DeviceDriver_Get_TransmittedCounts();
if(transmitted_counts != -99)
{
// get reflected counts
XInt16 DeviceDriver_Get_ReflectedCounts( void );
XInt16 reflected_counts = DeviceDriver_Get_ReflectedCounts();
if(reflected_counts != -99)
{
XBool ConvertBidir(XRef transmitted_mw, XRef reflected_mw, XInt16 value_CH0, XInt16 value_CH1);
result = ConvertBidir(transmitted_mw, reflected_mw, transmitted_counts, reflected_counts);
}
}
}
return result;
$endif
The method works perfectly fine in prototyper mode. However, when I pass the property references ("transmitted_mw" and "reflected_mw") to an external C function ""ConvertBidir" I run into trouble.
I pass the property references in the from of an XRef to the external function. The XRef struct contains an "Object" field which is an void pointer to the memory address of the floating point number and an "OnGet" and "OnSet" function pointer.
I can change the variable in the external C function by for example running
*(transmitted_mw.object) = 123.0;
But this does not run the internal "onset" EmWi function that is normally called when the variable has been changed. How can I implement this ? How do I call the "onset" function from the "OnSet" function pointer that is present in the XRef struct ?
Many thanks in advance,
Jim