uptown47
Lifetime Supporting Member
Hi all,
I'm trying to teach myself UDT's and I've got myself a bit bogged down...
Can someone clear up the point of having UDT's for me please? I'm struggling to get my head around the concept.
I understand 'classes' in C and so I've a good idea of what a UDT is trying to achieve but I'm just struggling to 'join the dots' at the moment.
Here's where I'm up to...
I created a UDT 10 (Valve Commands) that contained 2 BOOLs. They were:
Open_Valve
Close_Valve
I created a UDT 11 (Valve State) that contained 2 BOOLs. They were:
Valve_Is_Open
Valve_Is_Closed
I created a UDT 1 (Valve) that contained 2 UDT's. They were:
UDT 10
UDT 11.
I then created a DB based on UDT 1.
So far, so good I thought....
I could see that UDT's would be very handy when creating a lot of valves as you could just create DB's and call them Valve 1, Valve 2, etc etc.
My problem came when I started trying to use them in the code...
Presumably, I have to 'map' real world inputs/outputs on to the DB addresses that I've used?
So something like this:
Is this how they are used??
I began to wonder whether there is any point to UDT's but suddenly thought that they would make the job of 'updating' all the instances of "Valve" much easier perhaps??
To test my theory I opened up UDT 11 (Valve State) and added an INT so UDT 11 now looked like:
Valve_Is_Open BOOL
Valve_Is_Closed BOOL
Valve_Position INT
All this did was give me some 'interface' errors in UDT 1 so I did a "Check and Update" accesses.
This cleared the 'interface' errors but now my DB 1 and DB 2 (i.e. Valve 1 and Valve 2) only show STAT0.STAT1 instead of "Valve_Commands.Open_Valve" as it used to be....
So, in short, I'm struggling to understand the practical advantages of using UDT's and also how to 'map' IO on to the UDT's values...
Any help would be very much appreciated.
Cheers
;-)
I'm trying to teach myself UDT's and I've got myself a bit bogged down...
Can someone clear up the point of having UDT's for me please? I'm struggling to get my head around the concept.
I understand 'classes' in C and so I've a good idea of what a UDT is trying to achieve but I'm just struggling to 'join the dots' at the moment.
Here's where I'm up to...
I created a UDT 10 (Valve Commands) that contained 2 BOOLs. They were:
Open_Valve
Close_Valve
I created a UDT 11 (Valve State) that contained 2 BOOLs. They were:
Valve_Is_Open
Valve_Is_Closed
I created a UDT 1 (Valve) that contained 2 UDT's. They were:
UDT 10
UDT 11.
I then created a DB based on UDT 1.
So far, so good I thought....
I could see that UDT's would be very handy when creating a lot of valves as you could just create DB's and call them Valve 1, Valve 2, etc etc.
My problem came when I started trying to use them in the code...
Presumably, I have to 'map' real world inputs/outputs on to the DB addresses that I've used?
So something like this:
Code:
A I 0.0
= "Valve 1".Valve_Commands.Open_Valve
Is this how they are used??
I began to wonder whether there is any point to UDT's but suddenly thought that they would make the job of 'updating' all the instances of "Valve" much easier perhaps??
To test my theory I opened up UDT 11 (Valve State) and added an INT so UDT 11 now looked like:
Valve_Is_Open BOOL
Valve_Is_Closed BOOL
Valve_Position INT
All this did was give me some 'interface' errors in UDT 1 so I did a "Check and Update" accesses.
This cleared the 'interface' errors but now my DB 1 and DB 2 (i.e. Valve 1 and Valve 2) only show STAT0.STAT1 instead of "Valve_Commands.Open_Valve" as it used to be....
So, in short, I'm struggling to understand the practical advantages of using UDT's and also how to 'map' IO on to the UDT's values...
Any help would be very much appreciated.
Cheers
;-)