![]() ![]() ![]() Usually i declare a plc variable in this way: To write an Hmi and access to plc values i often use global static variables, that contains the values that i read from the plc. The communication driver is usually synchronized with the plc, this means that the driver sends a request to the plc and waits until the plc answers the waiting time can be short or long, depending on the protocol and cable.Ī synchronized communication can be a pain for your graphic user interface, because it will lock the pages for the most of the time that’s why the communication has to be hosted on a secondary thread and plc-variables needs to be synchronized with the GUI thread. Once you created your pages, you need to develop the communication driver for your plc, or to use an existing driver. – Plc driver: multithreaded communication to avoid to block the graphic user interface thread. – Plc variables: global static variables that can be read(-only) from all pages. – Graphical User Interface: written in WPF using the PageSwitcher class. The structure of the Hmi will be the following: In this post i will make an example on how to write a simple Hmi (2 pages) that can access to a variable that get updated from another thread. Writing an Hmi with C# and WPF is quite easy, once that you know how to structure your project. In the series I implement a real plc driver for Siemens S7, a dummy plc driver so you can run the application (in part 2), and use PRISM and DI to architect the project in a very elegant and maintainable way. If you want to build your HMI with WPF and MVVM you can check also my new series HMI with C# and WPF. ![]() UPDATE : I see that this article is quite popular, however it takes a simple approach to get you started, by using timers and other shortcomings. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |