I have a common interface between various frequency drives (ItfDrive).
In a function block I have
VAR_INPUT ItfFlushingPump : ItfDrive;END_VAR
How can I check that the interface is valid/has an assignment to an function block which has implemented this interface?
Is there some similar way as with references using __ISVALIDREF()?
If no drive is assigned to the function block, and the function block is trying to access any properties or methods of the interface, it will crash ... That's what I want to avoid.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the open source cobolt library, I have put in a GVL a function block instance g_InvalidMetric. So for most of the methods which return an IMetric, on error, they will return this global metric, rather thn nothing. This means, if you do want to call the methods anyway, it will not give you an exception, only invalid data.
In this case, you would look at the error message returned, or look at some property of the Interface to know if it is valid.
Check out the Host Application in the Example Project of cobolt for how this looks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
I have a common interface between various frequency drives (ItfDrive).
In a function block I have
How can I check that the interface is valid/has an assignment to an function block which has implemented this interface?
Is there some similar way as with references using __ISVALIDREF()?
If no drive is assigned to the function block, and the function block is trying to access any properties or methods of the interface, it will crash ... That's what I want to avoid.
In the open source cobolt library, I have put in a GVL a function block instance g_InvalidMetric. So for most of the methods which return an IMetric, on error, they will return this global metric, rather thn nothing. This means, if you do want to call the methods anyway, it will not give you an exception, only invalid data.
In this case, you would look at the error message returned, or look at some property of the Interface to know if it is valid.
Check out the Host Application in the Example Project of cobolt for how this looks.