Hi Claes,
Referencing rt_plc_arithm.c for code examples, several custom class objects have been built successfully using a similar methodology as found for Summer. On several occasions, it has been noticed that unconnected input pointers don't contain a NULL address. A simple program was written to verify:
Results are below:
Interestingly, **ptr for unconnected inputs returns the associated input value. It appears for an unconnected input, the connection pointer points to the input value location, instead of NULL. That makes sense as a default, but it means (*ptr != NULL) is not a valid test for an unconnected input.
Do you agree with this conclusion? If yes, can you suggest a method to check for an unconnected input for custom class objects? Maybe, check to see if the pointer address is not equal to the memory address of the associated input value? Or perhaps, check to see if the input selector flag is on?
Update: The conditional statement below correctly tests for an unconnected input:
pwr_tFloat32 **ptr; /* Pointer to an input connection pointer */
pwr_tFloat32 *pcx; /* Pointer to local associated input value */
ptr = &o->ibl05P; /* memory location of an unconnected input pointer */
pcx = &o->ibl05; /* memory location of associated input value */
if (*ptr != pcx) /* if input connection address != local input value address */
{ // connected }
else
{ // not connected }
/Ron