Now that i wrote about databinding, pages and so on, i publish an example on how to connect real time values readed from a PLC (in this case an Allen Bradley PLC, but it can be anyone), update an object collection with this values, and then display them on different pages.
As usual i have my 2 tanks and i want to read what liquid is inside every tank (defined as 16bit integer).
1st tank word is N7:0, second is N7:1
For each tank there is a button that changes its content(writing the PLC word).
This is the new code to analyze: i have 2 buttons that writes the words on PLC, then i have the callback where i read values in PLC, cast them and update my objects.
This objects are defined in the OPC Client class and they are defined as "public" because i want to access their properties from every window that needs to display real time values or to control them.
This is the MainWindow, where the program begin and where i create the opcclient object as static.
To access to it's properties i just need to bind UI items by databinding.
To access the properties of objects in another window or page, i do like in this example.
And this is the final result
This is how the setup for PLC OPC Server, that should be called as [UNTITLED_2]
Hope it's helpful.
Full solution here:
http://www.mesta-automation.com/Downloads/opc%20sample%202.rar
Previus post describe more in details what's used in this example, if you're interested.
As usual i have my 2 tanks and i want to read what liquid is inside every tank (defined as 16bit integer).
1st tank word is N7:0, second is N7:1
For each tank there is a button that changes its content(writing the PLC word).
This is the new code to analyze: i have 2 buttons that writes the words on PLC, then i have the callback where i read values in PLC, cast them and update my objects.
This objects are defined in the OPC Client class and they are defined as "public" because i want to access their properties from every window that needs to display real time values or to control them.
This is the MainWindow, where the program begin and where i create the opcclient object as static.
To access to it's properties i just need to bind UI items by databinding.
To access the properties of objects in another window or page, i do like in this example.
And this is the final result
This is how the setup for PLC OPC Server, that should be called as [UNTITLED_2]
Hope it's helpful.
Full solution here:
http://www.mesta-automation.com/Downloads/opc%20sample%202.rar
Previus post describe more in details what's used in this example, if you're interested.
1 comment:
Awesome!
Post a Comment