Hello,
I have a little problem with property. (I use CODESYS V3.5 SP14)
I writted an objet FB1 FB1 Function blockVARErrorFB1: Struct1;END_VAR
I use MyFB1 : VAR_GLOBALMyFB:FB1;END_VAR
Struct1 is a structure, declared like this : Struct1:ErrorBit1:BOOL;ErrorBit2:BOOL;Error_Code:INT;END_STRUCT
I can write 3 properties to get the value of each variable ErrorFB1.ErrorBit1, ErrorFB1.ErrorBit2, .... wtih properties like this : Property Read1 : Bool;GETRead1:= ErrorFB1.ErrorBit1;
It works well.
But I try to write only one property to get the entire structure ErrorFB1 : Property ReadAll : ErrorFB1;
but It don't work.
I read somewhere, that I have to declare a REFERENCE, so I wrote :
Property ReadAll : REFERENCE TO ErrorFB1;GETReadAll :=ErrorFB1;
In my programme I use : Default1:=MyFB.ReadAll;
And I get an exception when I run the simulation mode.
I am a beginner in the use of OOP. I looked for examples but I founded only "simple" one.
I have certainly made a monstrous mistake somewhere, but I do not see it
Thank you in advance for any help.
BR
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I have a little problem with property. (I use CODESYS V3.5 SP14)
I writted an objet FB1
FB1 Function blockVARErrorFB1: Struct1;END_VAR
I use MyFB1 :
VAR_GLOBALMyFB:FB1;END_VAR
Struct1 is a structure, declared like this :
Struct1:ErrorBit1:BOOL;ErrorBit2:BOOL;Error_Code:INT;END_STRUCT
I can write 3 properties to get the value of each variable ErrorFB1.ErrorBit1, ErrorFB1.ErrorBit2, .... wtih properties like this :
Property Read1 : Bool;GETRead1:= ErrorFB1.ErrorBit1;
It works well.
But I try to write only one property to get the entire structure ErrorFB1 :
Property ReadAll : ErrorFB1;
but It don't work.
I read somewhere, that I have to declare a REFERENCE, so I wrote :
Property ReadAll : REFERENCE TO ErrorFB1;GETReadAll :=ErrorFB1;
In my programme I use :
Default1:=MyFB.ReadAll;
And I get an exception when I run the simulation mode.
I am a beginner in the use of OOP. I looked for examples but I founded only "simple" one.
I have certainly made a monstrous mistake somewhere, but I do not see it
Thank you in advance for any help.
BR
Hello,
I found my error;
As the property is a REFERENCE, I have to write "REF=" instead of "=" in the GET acces :
Property ReadAll : REFERENCE TO ErrorFB1;
GET
ReadAll REF=ErrorFB1;
BR