<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5610484095461596271</id><updated>2024-12-19T04:31:26.874+01:00</updated><category term="WPF"/><category term="SCADA"/><category term="Allen Bradley"/><category term="PLC programming"/><category term="c#"/><category term="HMI"/><category term="PLC"/><category term="PLC Training"/><category term="WPF Controls"/><category term="simulation"/><category term="Tips for programmers"/><category term="simulators"/><category term=".Net"/><category term="Databinding"/><category term="Siemens"/><category term="OPC Client"/><category term="RSLinx"/><category term="Winforms"/><category term="emulators"/><category term="Chart"/><category term="Twincat"/><category term="Vodafone Station"/><category term="WPF Toolkit"/><title type='text'>WPF and C# with PLC.</title><subtitle type='html'>Tips and tricks to make PLC programs and custom SCADA / supervisors with .Net</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-5647091763925944595</id><published>2012-01-19T23:43:00.002+01:00</published><updated>2012-02-02T21:47:20.594+01:00</updated><title type='text'>New domain: http://www.mesta-automation.com</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I bought a domain to host articles and files.&lt;br /&gt;
I invite you to check that out :)&lt;br /&gt;
This blog will remain, even if i will not update it so frequently.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/5647091763925944595/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/5647091763925944595?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5647091763925944595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5647091763925944595'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2012/01/about-megaupload-shut-down.html' title='New domain: http://www.mesta-automation.com'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-570377080337724185</id><published>2012-01-05T19:43:00.008+01:00</published><updated>2012-01-05T20:39:43.762+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="Siemens"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips for programmers"/><title type='text'>Useful resources for PLC programming: PLC-DEV website</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwGq4ebykpaELxMD0CAHuBwEKjwg4Ur_87w3j4hw7M58Kkmwlov7l5geHbA3upliu2dzIa-7HoAKJviNSagOlmgrX5lrLaF9pDOqI_dF-4stHwpxfvV0Pk3GV4rjzshw_7VoNuRI79yvrh/s1600/plcdev.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;105&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwGq4ebykpaELxMD0CAHuBwEKjwg4Ur_87w3j4hw7M58Kkmwlov7l5geHbA3upliu2dzIa-7HoAKJviNSagOlmgrX5lrLaF9pDOqI_dF-4stHwpxfvV0Pk3GV4rjzshw_7VoNuRI79yvrh/s320/plcdev.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
I want to make a review on &lt;a href=&quot;http://www.plcdev.com/&quot;&gt;plc-dev website&lt;/a&gt; that contains some posts that i think they are really helpful and complete for PLC programmers.&lt;br /&gt;
The website has 3 main sections for the 2 most used marks of PLC, Siemens and Allen Bradley, and a talk about Modbus protocol, one of the most used protocols and a protocol that is supported from all PLCs:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.plcdev.com/allen_bradleys_plc_programming_handbook&quot;&gt;&lt;b&gt;Allen Bradley&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
Even if I think that the best blog to learn Allen Bradley programming (and ladder in general) is &lt;a href=&quot;http://www.contactandcoil.com/&quot;&gt;Nearly In Control&lt;/a&gt;&amp;nbsp;with his&amp;nbsp;&lt;a href=&quot;http://www.contactandcoil.com/rslogix-5000-tutorial/&quot;&gt;RsLogix 5000 tutorial&lt;/a&gt;, PLC DEV contains a mass of documentation about Allen Bradley and their products.&lt;br /&gt;
Some useful post for starters are:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/learn_ladder_logic_free_version_rslogix_500_and_rsemulator_500&quot;&gt;Learn Ladder Logic with a Free Version of RSLogix 500 and RSEmulator 500&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/rslogix_5000_tips_and_tricks&quot;&gt;RsLogix 5000 tips and tricks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;and a big collection of manuals that must be read (depending on the hardware you are using) is here:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/the_logix5000_essential_manuals&quot;&gt;RsLogix 5000 Essential Manuals&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.plcdev.com/siemens_simatic_step_7_programmers_handbook&quot;&gt;&lt;b&gt;Siemens&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
The section of Siemens programming is really helpful.&lt;br /&gt;
The pain of Siemens PLC is AWL / STL language of programming, both for programmers than for &quot;readers&quot; of programs.&lt;br /&gt;
Also this section contains some useful article that resume how to connect, upload and download programs with Step7 (not the best User Interface in the world as you already know), a quick reference for Siemens Libraries (OB, FC, FB, SFC, SFB), and it contains also some useful information about AWL/STL language and addressing.&lt;br /&gt;
The parts that i found more useful are:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/step_7_connecting_downloading_and_uploading&quot;&gt;Step 7 connecting, downloading, uploading&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/s7_library_functions&quot;&gt;S7 Library Functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/step_7_elementary_data_types&quot;&gt;Step 7 Elementary Data Types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/symbol_table_allowed_addresses_and_data_types&quot;&gt;Symbol Table Allowed Addresses and Data Types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/siemens_s7_indirect_addressing&quot;&gt;Siemens S7 Indirect Addressing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.plcdev.com/statement_list_stl_cheat_sheets&quot;&gt;AWL - STL quick documentation to read / write programs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.plcdev.com/modicon_programming_handbook&quot;&gt;&lt;b&gt;Modbus&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
Modbus protocol is a very common protocol that every device support.&lt;br /&gt;
This section explain what is a Modbus (RTU, TCP, Modbus +), the electrical wiring (RS 232, 422, 485, Ethernet) and it solves many doubts about the difference between Protocol and Networks.&lt;br /&gt;
&lt;a href=&quot;http://www.plcdev.com/modbus_faq&quot;&gt;Modbus FAQ&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/570377080337724185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/570377080337724185?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/570377080337724185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/570377080337724185'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2012/01/useful-resources-for-plc-programming.html' title='Useful resources for PLC programming: PLC-DEV website'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwGq4ebykpaELxMD0CAHuBwEKjwg4Ur_87w3j4hw7M58Kkmwlov7l5geHbA3upliu2dzIa-7HoAKJviNSagOlmgrX5lrLaF9pDOqI_dF-4stHwpxfvV0Pk3GV4rjzshw_7VoNuRI79yvrh/s72-c/plcdev.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-7926341786343762334</id><published>2011-09-29T20:51:00.001+02:00</published><updated>2011-09-29T21:01:34.639+02:00</updated><title type='text'>How to make a Sortable ObservableCollection C#</title><content type='html'>Time ago i had to implement a sortable observable collection that was able to sort its members based on different parameters.&lt;br /&gt;
After long and long searching i found this code, and i report it here so it can be useful for readers too. &lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;/*
/*
 * samples:
 * //sort ascending
 * MySortableList.Sort(x =&gt; x.Name, ListSortDirection.Ascending);
 *
 * //sort descending
 * MySortableList.Sort(x =&gt; x.Name, ListSortDirection.Descending);
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace TestSortableCollection
{
    public class SortableObservableCollection&lt;T&gt; : ObservableCollection&lt;T&gt;
    {
        public void Sort&lt;TKey&gt;(Func&lt;T, TKey&gt; keySelector, System.ComponentModel.ListSortDirection direction)
        {
            switch (direction)
            {
                case System.ComponentModel.ListSortDirection.Ascending:
                    {
                        ApplySort(Items.OrderBy(keySelector));
                        break;
                    }
                case System.ComponentModel.ListSortDirection.Descending:
                    {
                        ApplySort(Items.OrderByDescending(keySelector));
                        break;
                    }
            }
        }

        public void Sort&lt;TKey&gt;(Func&lt;T, TKey&gt; keySelector, IComparer&lt;TKey&gt; comparer)
        {
            ApplySort(Items.OrderBy(keySelector, comparer));
        }

        private void ApplySort(IEnumerable&lt;T&gt; sortedItems)
        {
            var sortedItemsList = sortedItems.ToList();

            foreach (var item in sortedItemsList)
            {
                Move(IndexOf(item), sortedItemsList.IndexOf(item));
            }
        }
    }
}

&lt;/pre&gt;&lt;br /&gt;
Use it in this way:&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;public class Person
{
public string Name{get;set;}
public int Age {get;set;}
}

public class PersonCollection:SortableObservableCollection&lt;person&gt;
{
public PersonCollection()
{
[...fill collection...]
this.Sort(x =&gt; x.Name, ListSortDirection.Ascending);
}
}
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/7926341786343762334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/7926341786343762334?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/7926341786343762334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/7926341786343762334'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/09/how-to-make-sortable.html' title='How to make a Sortable ObservableCollection C#'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-4728464249318235980</id><published>2011-09-13T21:13:00.015+02:00</published><updated>2012-01-25T22:09:56.636+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="Winforms"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF Controls"/><title type='text'>Multilanguage applications with C# with database support</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
As i wrote in an &lt;a href=&quot;http://mestaa.blogspot.com/2011/07/what-ffeatures-supervision-scada-should.html&quot;&gt;earlier post&lt;/a&gt;, the best way to realize a multilanguage application is to get translated text from a database.&lt;br /&gt;
This because even if you know 2 or 3 languages, you should be able to sell the application worldwide without even care on what language it is realized.&lt;br /&gt;
I think that one of the best database to use for translations is MS Access, because every translator has an office suite installed on his PC, and for him makes no difference translate on Excel or Access, but if you ask him to translate your sentences on &quot;a random SQL data viewer&quot;, it can be a pain.&lt;br /&gt;
To support multilanguage in my apps i use a method that, given the name of control, returns a string containing the translated text, like: &lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;lblSample.Content = Translation.GetString(&quot;lblSample&quot;);&lt;/pre&gt;The reference to the culture is contained inside Settings, and that&#39;s where i modify my language preferences, so when i load the program i know automatically what language i should use.&lt;br /&gt;
You can find the link for a working example at the bottom of the page.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;To realize a multilanguage selection you need:&lt;/b&gt;&lt;br /&gt;
- a listbox containing the list of languages,&lt;br /&gt;
- an &quot;Apply&quot; button&lt;br /&gt;
&lt;b&gt;Features:&lt;/b&gt;&lt;br /&gt;
- The listbox should automatically detect the new languages&lt;br /&gt;
- The application should change not only the texts, but also date/time format, right to left writing and so on.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1#: Create a database file with access like in the sample and add it to the project:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAsNLMkbuiEf_5ZTrkMDVx6awBypDWs4QdyMK2zl55Diji7aAXLsfa1Qh5fP70PXwtSq00wrLKOx5ETxEcG1QezSu2OU77RIEMAv2788FW5jObyIdetDoo1AoyCWUbt5nkNb5UWmCoV8WF/s1600/db.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAsNLMkbuiEf_5ZTrkMDVx6awBypDWs4QdyMK2zl55Diji7aAXLsfa1Qh5fP70PXwtSq00wrLKOx5ETxEcG1QezSu2OU77RIEMAv2788FW5jObyIdetDoo1AoyCWUbt5nkNb5UWmCoV8WF/s1600/db.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCqYLMOcQykL4vjnDfolVffak9wabJxdEsraGfT4MC2cp2h7XeRls9Q0CArKsNScd7iWjxKL_tZJnOaNyekZ-tTUSI3luOYDqrYoxJ9A4nagjnq3y5HNoJtH7MOy7C02TFUtDZO-GkCYY7/s1600/solution.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCqYLMOcQykL4vjnDfolVffak9wabJxdEsraGfT4MC2cp2h7XeRls9Q0CArKsNScd7iWjxKL_tZJnOaNyekZ-tTUSI3luOYDqrYoxJ9A4nagjnq3y5HNoJtH7MOy7C02TFUtDZO-GkCYY7/s1600/solution.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;2#: Download the translation class from&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2010/09/blog-post.html&quot;&gt;here&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2010/09/blog-post.html&quot;&gt;&lt;/a&gt;and paste it in your project, &lt;/b&gt;&lt;br /&gt;
or you can download the class with the working sample here:&lt;br /&gt;
&lt;a href=&quot;http://www.megaupload.com/?d=H5ISA83P&quot;&gt;http://www.megaupload.com/?d=H5ISA83P&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3#: Add the current culture field on &quot;Settings&quot;: this field will be used on all the project to &lt;/b&gt;set the national preferences.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXDTjJZGutatQteIBxYFDqe7yjyI36eeEqeRwYFP1e19SfMlSRIJdcQMcgi_dztstDFplbv8Pby3gTPF_ZMxPzBEmTkfidR7zOm-7odo4ItJY8AOkPRhN1QyKwBK_m2ZxUkq7vIe36vaOu/s1600/settings.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXDTjJZGutatQteIBxYFDqe7yjyI36eeEqeRwYFP1e19SfMlSRIJdcQMcgi_dztstDFplbv8Pby3gTPF_ZMxPzBEmTkfidR7zOm-7odo4ItJY8AOkPRhN1QyKwBK_m2ZxUkq7vIe36vaOu/s320/settings.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;4#: Customize the translation class modifying the namespace and the table rererences, if you modified them.&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;using ChangeLanguage.Properties; // modify the namespace with your project name
[...]
//connection string
        private static DatabaseResourceManager databaseResourceManager = new DatabaseResourceManager(settings.translationsConnectionString);    // here the connection string is declared inside settings; you can declare your own here.
[...]
OleDbCommand command = new OleDbCommand(&quot;Select * From Translations&quot;); // Here there is the reference to table name
[...]
command.CommandText = &quot;SELECT [key], [&quot; + language + &quot;] &quot; + &quot;FROM Translations&quot;; // Here there is another reference to table name
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;5#: Create the GUI like in the example:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mySH-3ktkNVzFRvLMfMnjxM8Svc7tH9RXlI5Y53s8_uKxF0WYZsXkWQ1gtRvUaH955HHu8EPIkhuk6GyZXajltB7A_uMORprMwYoaFs3QBuYvSYMImfLGLYpT4bpS0wMGrtyCaNxWbKg/s1600/GUI.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5mySH-3ktkNVzFRvLMfMnjxM8Svc7tH9RXlI5Y53s8_uKxF0WYZsXkWQ1gtRvUaH955HHu8EPIkhuk6GyZXajltB7A_uMORprMwYoaFs3QBuYvSYMImfLGLYpT4bpS0wMGrtyCaNxWbKg/s320/GUI.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;if you use xaml you can use this code:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;grid&gt;&lt;/grid&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;listbox height=&quot;146&quot; horizontalalignment=&quot;Left&quot; margin=&quot;12,32,0,0&quot; name=&quot;listLanguages&quot; verticalalignment=&quot;Top&quot; width=&quot;136&quot;&gt;&lt;/listbox&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;label content=&quot;Select Language:&quot; height=&quot;28&quot; horizontalalignment=&quot;Left&quot; margin=&quot;12,11,0,0&quot; name=&quot;lblLanguages&quot; verticalalignment=&quot;Top&quot; width=&quot;138&quot;&gt;&lt;/label&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;button click=&quot;btnApply_Click&quot; content=&quot;Apply&quot; height=&quot;23&quot; horizontalalignment=&quot;Left&quot; margin=&quot;41,184,0,0&quot; name=&quot;btnApply&quot; verticalalignment=&quot;Top&quot; width=&quot;75&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/button&gt;&lt;button content=&quot;Button&quot; height=&quot;31&quot; horizontalalignment=&quot;Left&quot; margin=&quot;327,12,0,0&quot; name=&quot;btnButton&quot; verticalalignment=&quot;Top&quot; width=&quot;124&quot;&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;label borderbrush=&quot;Black&quot; borderthickness=&quot;1&quot; content=&quot;Label&quot; height=&quot;29&quot; horizontalalignment=&quot;Left&quot; margin=&quot;327,54,0,0&quot; name=&quot;lblLabel&quot; verticalalignment=&quot;Top&quot; width=&quot;123&quot;&gt;&lt;/label&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;label borderbrush=&quot;Black&quot; borderthickness=&quot;1&quot; content=&quot;{Binding Date}&quot; height=&quot;29&quot; horizontalalignment=&quot;Left&quot; margin=&quot;327,113,0,0&quot; verticalalignment=&quot;Top&quot; width=&quot;124&quot;&gt;&lt;/label&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;label content=&quot;Date:&quot; height=&quot;27&quot; horizontalalignment=&quot;Left&quot; margin=&quot;327,93,0,0&quot; name=&quot;lblDateTime&quot; verticalalignment=&quot;Top&quot; width=&quot;124&quot;&gt;&lt;/label&gt;
&amp;nbsp; &amp;nbsp; 
&lt;/button&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;6# Then in the main window you can write methods to fill the language comboBox&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /// 
&lt;summary&gt; Detects languages in database and fill the listbox &lt;/summary&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void LoadCmbItems()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; List&lt;cultureinfo&gt; cultureList = Translations.GetCultureList();&lt;/cultureinfo&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; listLanguages.ItemsSource = cultureList;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; listLanguages.SelectedItem = settings.currentCulture;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Date = DateTime.Now;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception exc)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; MessageBox.Show(exc.Message, &quot;Language Database error&quot;, MessageBoxButton.OK, MessageBoxImage.Error);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;/pre&gt;and to load / change texts (but usually i do this only on the launch of application)&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void SetTextsInCurrentLanguage()
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LoadCmbItems();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lblLanguages.Content = Translations.GetString(&quot;lblLanguages&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; btnApply.Content = Translations.GetString(&quot;btnApply&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; btnButton.Content = Translations.GetString(&quot;btnButton&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lblLabel.Content = Translations.GetString(&quot;lblLabel&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; lblDateTime.Content = Translations.GetString(&quot;lblDateTime&quot;);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;/pre&gt;You can see that it&#39;s really simple to extract translation with this method, it&#39;s just needed that you pass the name of the control to the method GetString to receice the translated Content.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7#: Once you wrote all translations, you can update the constructor of the main window to load the localized language and settings:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.CurrentThread.CurrentCulture = settings.currentCulture;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.CurrentThread.CurrentUICulture = settings.currentCulture;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.DataContext = this; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; InitializeComponent();

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SetTextsInCurrentLanguage(); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&lt;/pre&gt;and also create the button &quot;Apply&quot;, that basically changes the settings (and in the example refresh the GUI also) :&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void btnApply_Click(object sender, RoutedEventArgs e)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; settings.currentCulture = (CultureInfo)listLanguages.SelectedItem;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.CurrentThread.CurrentCulture = settings.currentCulture; &amp;nbsp;//not so good to see... just to explain how it works
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.CurrentThread.CurrentUICulture = settings.currentCulture;//you should force the user to re-initialize the program
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; SetTextsInCurrentLanguage();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;/pre&gt;&lt;br /&gt;
You can download the full example here:&lt;br /&gt;
&lt;a href=&quot;http://mesta-automation.com/Downloads/changeLanguage.rar&quot;&gt;http://mesta-automation.com/Downloads/changeLanguage.rar&lt;/a&gt;&lt;br /&gt;
and read the full documentation here:&lt;br /&gt;
&lt;a href=&quot;http://en.csharp-online.net/Localization_Like_the_Pros&quot;&gt;http://en.csharp-online.net/Localization_Like_the_Pros&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Disclaimer&lt;br /&gt;
The sample code described herein is provided on an &quot;as is&quot; basis, without warranty of any kind, to the fullest extent permitted by law. Mestaa.blogspot.com does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations. &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/4728464249318235980/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/4728464249318235980?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/4728464249318235980'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/4728464249318235980'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/09/multilanguage-applications-with.html' title='Multilanguage applications with C# with database support'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAsNLMkbuiEf_5ZTrkMDVx6awBypDWs4QdyMK2zl55Diji7aAXLsfa1Qh5fP70PXwtSq00wrLKOx5ETxEcG1QezSu2OU77RIEMAv2788FW5jObyIdetDoo1AoyCWUbt5nkNb5UWmCoV8WF/s72-c/db.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-3869756891604658402</id><published>2011-07-26T00:15:00.003+02:00</published><updated>2012-08-28T14:47:03.234+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips for programmers"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Standard colors on HMI</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b style=&quot;color: red;&quot;&gt;Dear reader, this is an old version of the article. You can find the new version&lt;/b&gt; &lt;b&gt;&lt;a href=&quot;http://www.mesta-automation.com/standard-colors-on-hmi/&quot;&gt;on my new blog.&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The lack of a standard on what colors use on HMI systems is a serious problem. After watching many applications and searching for a standard, i noticed that the most of panels&#39; graphic pages depended on taste of the engineer that realized it.&lt;br /&gt;
It&#39;s not the first time that i see purple buttons, blue leds and green backgrounds.&lt;br /&gt;
Even if there isn&#39;t a written standard on what colors you should choose, i searched for the best ways to realize graphic page and keeps updating myself on making HMI colors as helpful as possible.&lt;br /&gt;
This is the standard that i use as much as i can:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt; &lt;b&gt;Led &lt;/b&gt;: green for active, gray for inactive, red for alarm.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Reserve leds&lt;/b&gt;: gray for inactive, red for alarm/reserve. &lt;/li&gt;
&lt;li&gt;&lt;b&gt;Motors and valve&lt;/b&gt;: green for active, gray for inactive, red for alarm&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Pipes and tanks&lt;/b&gt;: cyan for water, gray empty, other colors if acids or special liquids.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Momentary buttons&lt;/b&gt;: all grays and possibly with windows style and an image associated. All buttons must have a description (don&#39;t use only images, better use only description if you are forced to choose).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Toggle buttons&lt;/b&gt;: i like UP-DOWN switch levers. A button that stays pushed isn&#39;t a good way on how to represent a switch.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Alarm banner and log&lt;/b&gt;: Red (everything in red should be associated to something wrong)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Background&lt;/b&gt;: gray for numerous reasons, like it doesn&#39;t hurt eyes, no problem if there is low light of too much light, all operators are used to see gray backgrounds, gray means inactive - nothing wrong.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Animations&lt;/b&gt;: i use them only when i have to attract the attention of the operator, usually for alarms status or to pay attention at some particular operation. An abuse of animation distract the operator from it&#39;s job, so it should be for a good reason (NOT FOR A LOGO!). I don&#39;t even like to represent bottles that get filled and capped (for example), because the operator is not blind and can see what&#39;s happening inside the filling machine. A good animation can be a blinking gray-red led when it is in alarm state, a gauge that is changing value, a small alarm popup in the corner and so on... useful things anyway.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Pictures&lt;/b&gt;: use ISA symbols or schematic symbols if possible; 3D is your worst friend while representing a plant. It&#39;s important that the operator understand what&#39;s happening, not that he get fashinated. &lt;/li&gt;
&lt;/ul&gt;
Why gray or blue for inactive: gray means &quot;it&#39;s all normal&quot;, is the color of the background and a color that you wouldn&#39;t pay attention. Green is the color of &quot;go on&quot; with semaphore, it means that a component it&#39;s running. So why to make a button green? The button will never run. Same as red for buttons: red means STOP !, DANGER! EMERGENCY SWITCH, not &quot;finish automatic mode&quot;.&lt;br /&gt;
A button is a component that the operator should not pay attention at all, he just know when to push it, no need to say him &quot;PUSH IT!&quot;. Except for Reset Alarms of course :)&lt;br /&gt;
&lt;br /&gt;
I took some samples of what i think are bad screens:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR8gQkK7X9hz3v-lua1iWHt4Dbrn6szp4fYgQZZujQhxvwjZVOddy7Qe_w5-8H3PEwdsOmQJ_RERf-8vmXv2lMS8Y48gkqIpz2fJGazUJqOO3H-lPcHpJZVRNOUR0XlvD8nn6ZrNDbFs3a/s1600/899195957403777_1258659055.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;247&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR8gQkK7X9hz3v-lua1iWHt4Dbrn6szp4fYgQZZujQhxvwjZVOddy7Qe_w5-8H3PEwdsOmQJ_RERf-8vmXv2lMS8Y48gkqIpz2fJGazUJqOO3H-lPcHpJZVRNOUR0XlvD8nn6ZrNDbFs3a/s320/899195957403777_1258659055.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Blue background with light green pipes, green and gray tanks and green valves and pumps. Definetly not a good contrast and not good pictures too.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm3G0pIvEaztnk_sdGoLD2x-TgkVwG-SWMIhqcgTma-9TQT2zDat9ojiZAbRcPeyAN9pipH3uEcpwaNMUDzzgqeXPL9ZD2N4C4tQXKucjhB4jH2Jdhp5zr4w8AniJuP-T2f8IV_3dBZJRA/s1600/DCS_PLC_Scada_Systems.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgm3G0pIvEaztnk_sdGoLD2x-TgkVwG-SWMIhqcgTma-9TQT2zDat9ojiZAbRcPeyAN9pipH3uEcpwaNMUDzzgqeXPL9ZD2N4C4tQXKucjhB4jH2Jdhp5zr4w8AniJuP-T2f8IV_3dBZJRA/s320/DCS_PLC_Scada_Systems.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Here pictures are better, but the contrast green on green is still bad. And on top there buttons or tag without a graphic modeling, so i can&#39;t imagine how they can help an operator.&lt;br /&gt;
&lt;br /&gt;
This is what i call a useful screen.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ2V7Fe-kZrnFpT9xLResd0IwNZN1_wVwdGlL807Q34indtxeOOV02f2dOZ1YvHwM_wlWrmrmD4L30YmVEMMGbJw8eZ62sVTlDBuXXgkzmIvQ6sLjXgi7LCYzOKyhL1bMUj3CM4Ajh-GXu/s1600/wincc-flexible-runtime-screen-02-1024.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ2V7Fe-kZrnFpT9xLResd0IwNZN1_wVwdGlL807Q34indtxeOOV02f2dOZ1YvHwM_wlWrmrmD4L30YmVEMMGbJw8eZ62sVTlDBuXXgkzmIvQ6sLjXgi7LCYzOKyhL1bMUj3CM4Ajh-GXu/s320/wincc-flexible-runtime-screen-02-1024.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
with good contrast, not much led and the active ones in green (as you can see you notice them instantly on gray) and alarms in red. &lt;br /&gt;
This can be useful too, even if more complex:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUroEOdbt2qV06Bu84zhyyZwa950li3sf8bSGIi9JzDTpJOL9MWGjL4mLefX-dbUeE_Mf0ghHjXTpVPQA1bHSO9IAVajItDNRJYXXbJagZ_VrMV_YW2QoKlyIkg9GvSgSnGnlDZLt5QdkV/s1600/05.02.%252BEl%252Bnegocio%252Bde%252BSCADA%252Bpara%252Bel%252Bsector%252Bde%252Bla%252Benerg%25C3%25ADa.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;268&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUroEOdbt2qV06Bu84zhyyZwa950li3sf8bSGIi9JzDTpJOL9MWGjL4mLefX-dbUeE_Mf0ghHjXTpVPQA1bHSO9IAVajItDNRJYXXbJagZ_VrMV_YW2QoKlyIkg9GvSgSnGnlDZLt5QdkV/s320/05.02.%252BEl%252Bnegocio%252Bde%252BSCADA%252Bpara%252Bel%252Bsector%252Bde%252Bla%252Benerg%25C3%25ADa.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
Notice the good contrast for liquid levels on tank. I don&#39;t know if components are red because they are not active or in alarms (as i hope), but it&#39;s definetly a good representation.&lt;br /&gt;
&lt;br /&gt;
There is a very good article about using colors, animations and setting up a Graphical User Interface; you can read it here:&amp;nbsp;&lt;a href=&quot;http://www.rollthunder.com/SoftwareThatDoesntSuck/WpfForGoodAndNotEvil.htm&quot;&gt;http://www.rollthunder.com/SoftwareThatDoesntSuck/WpfForGoodAndNotEvil.htm&lt;/a&gt;&lt;br /&gt;
Even if it&#39;s really long, i try to write his points in short:&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;First Principle&lt;/b&gt;: That the         software that you write has zero value in and of         itself. You write software for one reason and one         reason only: to create value by&lt;b&gt; making the user of         your software happier than he would be without your         software&lt;/b&gt;.&amp;nbsp;        The only value that your software ever has or         ever will have is the degree to which it increases         the happiness of its users. It is extremely rare         that users are willing to pay for&amp;nbsp;software that decreases their overall         happiness.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;b&gt;Second Principle&lt;/b&gt;: That computer         programs &lt;b&gt;increase the happiness of users in one of         two ways&lt;/b&gt;. &amp;nbsp;The         majority of applications help a user solve a         specific&amp;nbsp;         problem – writing an email message or an article,         buying groceries or an airplane ticket, viewing a         bank statement and paying bills. The user’s only         goal in using this type of program is to finish the         task and get on with his life, or at least on to the         next task.&lt;b&gt; The faster a program converts a task from         not-finished to finished, the happier the user will         be.&lt;/b&gt;&lt;/div&gt;
The second way in which a         program increases a user’s happiness, less common         than the first, is by &lt;b&gt;putting the user into a         pleasurable state that he wants to maintain as long         as possible&lt;/b&gt;, or at least as long as it remains         pleasurable, like Games.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Third Principle&lt;/b&gt;: That&lt;b&gt; in         neither of these cases do users want to think about         the programs they are using&lt;/b&gt;.&amp;nbsp;        At all. Ever. In the former case, they want         to think about the problem they are solving: the         wording of the document they are writing, or whether         they have enough money to pay their bills, and which         unpaid creditor would hurt them the most.&amp;nbsp;        They don’t want the program to distract them         from the problem they’re thinking about.&amp;nbsp;        If they want to goof off and waste time,         they’ll bring up Solitaire, not admire the flashing         video buttons in the word processor.&amp;nbsp; &lt;/li&gt;
&lt;/ul&gt;
The point that i liked the most is this one:&lt;b&gt; Motion attracts a user’s         attention&lt;/b&gt;. Natural selection brutally pounded that         design pattern into the human brain and visual         system. Our savannah-based ancestors that noticed         the twitch of the saber-tooth tiger behind the tall         grass avoided being eaten and passed their attentive         genes on to their descendants. The ones who didn’t         notice the motion got eaten, and didn’t.        &amp;nbsp;Every single         user is the inheritor of roughly 13,000        &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;generations&lt;/i&gt;         of homo sapiens who noticed motion better than the         ones who didn’t make it.&lt;br /&gt;
[...]&lt;br /&gt;
As         user interface expert Jared Spool wrote of his test         of a Disney web page containing an animated logo,         that corporate branding icon so beloved of         marketeers everywhere: &lt;b&gt;“Users first tried to scroll         the animation off the page, and when they couldn’t,         actually covered it up with their hands so they         could read the rest of the text.”&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I really reccomend to check this article, is well written and with tons of examples.&lt;br /&gt;
And i hope you enjoyed this reading.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/3869756891604658402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/3869756891604658402?isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/3869756891604658402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/3869756891604658402'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/07/standard-colors-on-hmi.html' title='Standard colors on HMI'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiR8gQkK7X9hz3v-lua1iWHt4Dbrn6szp4fYgQZZujQhxvwjZVOddy7Qe_w5-8H3PEwdsOmQJ_RERf-8vmXv2lMS8Y48gkqIpz2fJGazUJqOO3H-lPcHpJZVRNOUR0XlvD8nn6ZrNDbFs3a/s72-c/899195957403777_1258659055.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-700285037796308915</id><published>2011-07-24T13:33:00.005+02:00</published><updated>2011-08-12T11:18:42.638+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="Siemens"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="simulators"/><title type='text'>Example on how to write sequences with Siemens Step 7 (S7-300)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The last post with RsLogix 5000 showed how to write sequence in an understandable way with Allen Bradley PLCs. Here it is a sample for Siemens Step 7.&lt;br /&gt;
&lt;br /&gt;
I will analyze the exercise #3 of learning pit, you can find the full text here:&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;a href=&quot;http://thelearningpit.com/lp/doc/bl/bl-ctr.html&quot;&gt;http://thelearningpit.com/lp/doc/bl/bl-ctr.html&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;This is the system with I/Os: &lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuyjFLp4OQud8cUdZM_3wSStNLp76SYMW379FbIosY0EKvR3Npj3Jpsmz8MTK8qSqtuvYMb8LbDNiljB2JldaTbK5npOf-uDyH2qlEYtZNlkSm-H31AIRz-2vBpYvE7wp95BXry9XydNjo/s1600/Immagine.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;280&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuyjFLp4OQud8cUdZM_3wSStNLp76SYMW379FbIosY0EKvR3Npj3Jpsmz8MTK8qSqtuvYMb8LbDNiljB2JldaTbK5npOf-uDyH2qlEYtZNlkSm-H31AIRz-2vBpYvE7wp95BXry9XydNjo/s400/Immagine.PNG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;And the state machine that we have to realize is this one:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8QgKej32k9d16RYLRPsfWqag1dAAiql26-QXRrDnqyrW5NJpEozk_RfsfauOfiZNCTr-MCatf2obuBvtO0hyphenhyphenCUi7iIYewZZ9XPRQc_bmDpHQ1AVQoXsXfGwhJCuQstnVGXnK02jTLTHUu/&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;365&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8QgKej32k9d16RYLRPsfWqag1dAAiql26-QXRrDnqyrW5NJpEozk_RfsfauOfiZNCTr-MCatf2obuBvtO0hyphenhyphenCUi7iIYewZZ9XPRQc_bmDpHQ1AVQoXsXfGwhJCuQstnVGXnK02jTLTHUu/&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-z4udIlX6eYc/Tiv2W5F9jUI/AAAAAAAAAXk/Sy1wwSNR_QI/s1600/state+machine.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-z4udIlX6eYc/Tiv2W5F9jUI/AAAAAAAAAXk/Sy1wwSNR_QI/s1600/state+machine.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;With green arrows there&#39;s the sequence that we should respect, and with black arrows the start/stop conditions.&lt;br /&gt;
Notice that when the cycle gets interrupted, it must restart from the last state (this means that you can&#39;t drain if you didn&#39;t heat before, and so on...); at the end of the cycle you can choose if restart the cycle to do more batches, or to stop it if the batch count is done or if the selector was in single batch position.&lt;br /&gt;
The sequence can be realized in this way:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo8biNLN6YcZBeL_a25nVimahDG_SazoVsId1AUqCDNMDnNEdwKAM2zxDqtQELli646urM1491ILKdRaV52ZpsLSuhjCECxckZyeD5JLSyx6T3Hr_BlGipSPDS39WrapAZZxGL_auBsP-Q/s1600/mixerbsl.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo8biNLN6YcZBeL_a25nVimahDG_SazoVsId1AUqCDNMDnNEdwKAM2zxDqtQELli646urM1491ILKdRaV52ZpsLSuhjCECxckZyeD5JLSyx6T3Hr_BlGipSPDS39WrapAZZxGL_auBsP-Q/s1600/mixerbsl.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;You can write each step of the sequence in a word (DB4.DBW0) and pass every step with a SHL_W (equally as BSL for Allen Bradley) instruction.&lt;br /&gt;
If you notice, you can read every rung of the sequence as you could read a green arrow in the diagram above, like &quot;When Step1 and High Level Sensor GO TO Step 2&quot; and so on.&lt;br /&gt;
With those steps we know how to enable outputs, because in STEP 1: Fill Mixer i should enable the filling pumps, checking if the product count respects the % of product 1 and 2:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqYvl8qpjMG5Zt4kGI4-izIpaLKtMEFRNm1JZ9zKNDBE2e0D7oOeEGAaI0Jsz6o9LCY-AbDYL39pne-S-p9pv3MazNHhNhG96yQfgQXH7jleYg8MLN2yCOQUW5PJNu24m_BdJM_jEsI9qM/s1600/mixerStep1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqYvl8qpjMG5Zt4kGI4-izIpaLKtMEFRNm1JZ9zKNDBE2e0D7oOeEGAaI0Jsz6o9LCY-AbDYL39pne-S-p9pv3MazNHhNhG96yQfgQXH7jleYg8MLN2yCOQUW5PJNu24m_BdJM_jEsI9qM/s1600/mixerStep1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&amp;nbsp;Step 2: Heat and Mix &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisMmf_eGfWfR7u1bxgvIhhbnj-TTWChaW8nbXYaH0LbVFrqHI6326m5ODsj6y_2EQrHMSgLJDb_DTg5H3RbAjm3h3EB6_dDZDYQV5CwG6yVZ5uzhjcbF1s_aeZOhmFpKpZLbQsP-BBBn2m/s1600/mixerStep2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisMmf_eGfWfR7u1bxgvIhhbnj-TTWChaW8nbXYaH0LbVFrqHI6326m5ODsj6y_2EQrHMSgLJDb_DTg5H3RbAjm3h3EB6_dDZDYQV5CwG6yVZ5uzhjcbF1s_aeZOhmFpKpZLbQsP-BBBn2m/s1600/mixerStep2.png&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;T1 is meant to keep the mixer running for 4 seconds after the step change, so you can mix for 4 seconds then start the drain pump.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Step 3: Drain Pump&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizZvmLYizQhueH2o45mTiXK5TFvEYv_dAzQgOHfBgWtgBW3l8oDw-wIeV2-BozroQHTgyRElVL_EPth-Uf7XucmgL7gOMvtzJAj0c-8KWoJSCGBiOPgF7NCx3JZnr2I6Cv02e8FZWysasd/s1600/mixerStep3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizZvmLYizQhueH2o45mTiXK5TFvEYv_dAzQgOHfBgWtgBW3l8oDw-wIeV2-BozroQHTgyRElVL_EPth-Uf7XucmgL7gOMvtzJAj0c-8KWoJSCGBiOPgF7NCx3JZnr2I6Cv02e8FZWysasd/s1600/mixerStep3.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Step 4: Increment batch count and reset product counter (because the mixer is empty)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2LsGsLD8r9nCgIhWSVfYp_c3jVOts5XhkF06TUvSzIo8VNgZ_rfKmyLHemyoRFOiM3QuIJyIajQ_JMWlPpSEz83c9Ckx7eTCy6SJGzYxzOxl9trQpPAQhacdYi0poa4PVN-GtpX_VkuQ9/s1600/mixerStep4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;391&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2LsGsLD8r9nCgIhWSVfYp_c3jVOts5XhkF06TUvSzIo8VNgZ_rfKmyLHemyoRFOiM3QuIJyIajQ_JMWlPpSEz83c9Ckx7eTCy6SJGzYxzOxl9trQpPAQhacdYi0poa4PVN-GtpX_VkuQ9/s400/mixerStep4.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Step 5: check product count and restart the cycle or stop it.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHhyphenhyphen1K1cVVjawm09RSQCBzHcJezY6gRfW2o75Vz4Dxn8FtDdg4uEPRnK1OzUWm1SunLYGe3S-x0x8a3TL2Dudp-CPM2GITxor0IQ9UBpkzLK45q6IVUOO-D6r0rt3byFi6UJkPbMMX5S-l/s1600/mixerStep5.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgHhyphenhyphen1K1cVVjawm09RSQCBzHcJezY6gRfW2o75Vz4Dxn8FtDdg4uEPRnK1OzUWm1SunLYGe3S-x0x8a3TL2Dudp-CPM2GITxor0IQ9UBpkzLK45q6IVUOO-D6r0rt3byFi6UJkPbMMX5S-l/s1600/mixerStep5.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;How to read this: in the last step of a cycle the 1st thing to do is to reset the steps of the cycle.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Then, if the selector is in Multiple batch, i check batch-count to see if i have to restart the cycle (2nd coil) or to stop the process (Reset automatic mode.)&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Of course if the selector is not in multiple batch mode i should reset the automatic mode wihtout checking for anything.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;To start the cycle use a segment like this:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0Dqo8spW3wThGWznEhQZSLO-SRoMPd9P8zqD6euEyw0_-VDkxEfPkpVzSGzN_XaDF9JXebS1L7faMXaSLhnaMa5cerqn_TfbNeICeUXQKozrkheA-aOdGrvnUdXMe366V40uS5c5LigGJ/s1600/start_cycle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0Dqo8spW3wThGWznEhQZSLO-SRoMPd9P8zqD6euEyw0_-VDkxEfPkpVzSGzN_XaDF9JXebS1L7faMXaSLhnaMa5cerqn_TfbNeICeUXQKozrkheA-aOdGrvnUdXMe366V40uS5c5LigGJ/s1600/start_cycle.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;The important part of this post is anyway the one with SHL_W, the rest is just about turning ON and OFF some outputs. I post the AWL code for the change steps sequence, just translating it from ladder, to show you how it&#39;s made.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXJmV63hSyhRP4HG8iBF652P1cj1RNjw3H4a2IC1H_zOQUe6y1h1WSn3CLZMFx4s6ObPm7L7U5eI1JJ3R9Em3lXMK7BBeM3h3Z6cs0AfhfkfNUagjrEnuRxAl7pHSJOuJsRDETtj706jFc/s1600/mixerbslawl.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXJmV63hSyhRP4HG8iBF652P1cj1RNjw3H4a2IC1H_zOQUe6y1h1WSn3CLZMFx4s6ObPm7L7U5eI1JJ3R9Em3lXMK7BBeM3h3Z6cs0AfhfkfNUagjrEnuRxAl7pHSJOuJsRDETtj706jFc/s1600/mixerbslawl.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;As you can see you can write a sequence using a SLW obtaining the same (almost...) readbility as with KOP.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;You can download the full exercise with simulation (to be used with PLC-SIM) here: &lt;a href=&quot;http://www.megaupload.com/?d=83C551Y6&quot;&gt;http://www.megaupload.com/?d=83C551Y6&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/700285037796308915/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/700285037796308915?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/700285037796308915'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/700285037796308915'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/07/writing-sequences-with-siemens-step-7.html' title='Example on how to write sequences with Siemens Step 7 (S7-300)'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuyjFLp4OQud8cUdZM_3wSStNLp76SYMW379FbIosY0EKvR3Npj3Jpsmz8MTK8qSqtuvYMb8LbDNiljB2JldaTbK5npOf-uDyH2qlEYtZNlkSm-H31AIRz-2vBpYvE7wp95BXry9XydNjo/s72-c/Immagine.PNG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-7363563420330191019</id><published>2011-07-17T12:43:00.009+02:00</published><updated>2012-01-25T22:00:13.345+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF Controls"/><title type='text'>WPF User Controls: 7 Segment Display</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiHZ4llWrdaqyv2awCVXkVUG1ufXceDwKkkWAGvmSRus2fl-WrbTPpT2A8ALSOkZ2vs6tE0fPp3qlX_5r_u2L3xzQzi6R_aqiYNZzw8PR2HSOdfX1h2SR6YZaYKwN5sRlo_yx3Hqzi3tO/s1600/7+segment.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;213&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiHZ4llWrdaqyv2awCVXkVUG1ufXceDwKkkWAGvmSRus2fl-WrbTPpT2A8ALSOkZ2vs6tE0fPp3qlX_5r_u2L3xzQzi6R_aqiYNZzw8PR2HSOdfX1h2SR6YZaYKwN5sRlo_yx3Hqzi3tO/s320/7+segment.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;7 segment displays is one of the best way to show present values in industrial programs. Operators are used to see numbers and values with&amp;nbsp; 7 segment led characters, and if the operator feels comfortable with what he sees, he works better and in a more correct way.&lt;br /&gt;
So it&#39;s our work to make them feeling &quot;at home&quot; with the graphic of our programs.&lt;br /&gt;
To make a 7 Segment Led it&#39;s just a question of adding a custom font.&lt;br /&gt;
The one that i like more is NI7SEG (you can download it from here: &lt;a href=&quot;http://www.qsl.net/om3cph/dds/ni7seg.zip&quot;&gt;ni7seg&lt;/a&gt;) or google it adding a .ttf at the end.&lt;br /&gt;
The code to add a Custom Font is pretty simple:&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&lt;window.resources&gt;
        &lt;fontfamily x:key=&quot;7SegFontFamily&quot;&gt;/7SegmentLed;Component/Fonts/#NI7Seg&lt;/fontfamily&gt;
        &lt;style targettype=&quot;{x:Type Label}&quot; x:key=&quot;7SegmentsBox&quot;&gt;
            &lt;setter Property=&quot;FontFamily&quot; Value=&quot;{DynamicResource 7SegFontFamily}&quot;/&gt;
            &lt;setter Property=&quot;HorizontalContentAlignment&quot; Value=&quot;Center&quot; /&gt;
            &lt;setter Property=&quot;Foreground&quot; Value=&quot;Red&quot; /&gt;
            &lt;setter Property=&quot;Background&quot; Value=&quot;Black&quot; /&gt;
...        
&lt;/style&gt;
&lt;/window.resources&gt;&lt;/pre&gt;where fontfamily refers to /nameofproject;Component/font_folder/name_of_font (to be seen inside the file, not the name of the ttf file).&lt;br /&gt;
&lt;br /&gt;
Then you can just create a label and apply the style: &lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&lt;label content=&quot;00&quot; x:name=&quot;lbl2&quot;&gt;&lt;/label&gt;&lt;/pre&gt;&lt;br /&gt;
A sample program can be found here:&lt;br /&gt;
&lt;a href=&quot;http://www.mesta-automation.com/Downloads/7segmentled.rar&quot;&gt;http://www.mesta-automation.com/Downloads/7segmentled.rar&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/7363563420330191019/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/7363563420330191019?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/7363563420330191019'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/7363563420330191019'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/07/wpf-controls-7-segment-led.html' title='WPF User Controls: 7 Segment Display'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqiHZ4llWrdaqyv2awCVXkVUG1ufXceDwKkkWAGvmSRus2fl-WrbTPpT2A8ALSOkZ2vs6tE0fPp3qlX_5r_u2L3xzQzi6R_aqiYNZzw8PR2HSOdfX1h2SR6YZaYKwN5sRlo_yx3Hqzi3tO/s72-c/7+segment.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-4901192980832191346</id><published>2011-07-13T23:34:00.003+02:00</published><updated>2011-07-22T18:24:21.009+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips for programmers"/><title type='text'>What features a supervision / SCADA system should contain</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;There are many ideas on how to make a good supervisor system and this make also a lot of confusion to engineers.&lt;br /&gt;
&lt;div&gt;Actually HMI panels are so powerful that they can be compared to SCADA, and when i visit some clients and i see their systems, 80% of times i can&#39;t understand why they choosed an expensive SCADA package instead of a simple panel.&lt;/div&gt;&lt;div&gt;HMI panels are better than scada for human machine interface, as they require less time to be programmed, they can just get replaced if they get broken and they require less downtime; they doesn&#39;t require an updated Operative System and they doesn&#39;t require an OPC Server.&lt;/div&gt;&lt;div&gt;And most of all, they are cheaper!&lt;/div&gt;&lt;div&gt;With this post i don&#39;t want to make a comparison with SCADA and HMI panels, but just to point out what a supervisor system should contain, it is up to you to understand if you need a simple Panel or a complex SCADA.&lt;/div&gt;&lt;div&gt;So a SCADA program needs:&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;Communication driver&lt;/b&gt;: can be OPC , Modbus or what else, the communication is the most important thing of those systems. It must refresh values on read at least once every second.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Graphical User Interface&lt;/b&gt;: should contain plant schemes, motors, valves, leds, pipes, sensors&#39; state, everything connected with the plant. It should represent all the plant status and its peculiarity, and also it should be as much dynamic as possible. This means that if you represent a motor (grey), when it runs you should represent it Green, and when it is in alarm state make it blinking grey-red.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Set Points entry and Present Values visualization:&lt;/b&gt; to permit the configuration and troubleshooting of the plant. A good way to create set point entry is to set the value on PLC, and when you receive the refresh events from communication driver you visualize just what the PLC contains in the memory.This can be not instantaneous, but you can always see if communication is up and running.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Alarm management: &lt;/b&gt;usually made with databases, your supervisor should contain at least an alarm banner, an alarm log and a page with active alarms.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Recipes management&lt;/b&gt;&amp;nbsp;(if needed): it&#39;s made with a database too, that contains various set points that should be transmitted once the operator select the recipe. An interface CRUD is needed for this database.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Plant Control&lt;/b&gt; (if needed): when there are heavy algorithms to be described with PLC language, for example when recipes are complex and the supervisor controls many PLCs, you can use the PLC to control drives and motors based on high level inputs (like &quot;go to position&quot;, &quot;set speed&quot;) coming from SCADA.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Data logging&lt;/b&gt;: based on database too, with a SCADA you should log all the critical process variables (pressures - temperatures - speeds and so on) and visualize them in charts like (x -&amp;gt; time ; y -&amp;gt; Set Point and Present Value and Max Threshold &amp;nbsp;+ Min Threshold).&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Production tracking&lt;/b&gt;: while a product is being made, it should be associated with all the process variables&#39; values during it&#39;s making time. This will create a database containing all the statistics needed to analyze the production and improve quality and times.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Reporting&lt;/b&gt;: if you give data about production, you should also give to clients a way to use those data. You can show them with reports and you can also analyze them with special recipes to check for production flaws automatically.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Multilanguage support&lt;/b&gt;: if you are going to sell the software worldwide you need to support all messages and labels with a language database (in this case an Access file is the best choice, because EVERYONE know how to compile Access tables). &lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;Scada are systems&amp;nbsp;very powerful&amp;nbsp;and expensive (in working hours or in money spent to buy all packages),but it&#39;s good to see them running once you made them :)&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/4901192980832191346/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/4901192980832191346?isPopup=true' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/4901192980832191346'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/4901192980832191346'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/07/what-ffeatures-supervision-scada-should.html' title='What features a supervision / SCADA system should contain'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-8172376537169974647</id><published>2011-05-08T10:43:00.008+02:00</published><updated>2011-07-12T21:22:41.554+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="emulators"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><title type='text'>PLC Training: Exercise #2 Solution with RSLogix 5000</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;With those posts i will show how to use&amp;nbsp; RSLogix 5000 and Emulate 5000 to simulate a simple program.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;I will also cover all the steps that are needed to realize a program with ladder logic and a simple sequence, to give a sample on how you could base your automation projects.&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;The text of the exercise is available here: &lt;a href=&quot;http://www.megaupload.com/?d=PIWQA7AS&quot;&gt;http://www.megaupload.com/?d=PIWQA7AS&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;a href=&quot;http://thelearningpit.com/lp/doc/sl/sl-rl.html&quot;&gt;http://thelearningpit.com/lp/doc/sl/sl-rl.html&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;Realize the automation of the following Filling system:&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;125&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuUFxaqy7NlqEdaAzavEQVr-5UNW8GbxdGOHI6WAk84BLQ-WQRbI7JKuabmkjwBhbrcZklGu_QfTI31POa9fm7Ojwhux3KU8g53AgRt67b7iImlsaX3_DOgUi4Dgk9V0iH38uXOZps6dBI/s400/Immagine.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Outputs&lt;/b&gt;:&lt;br /&gt;
- Motor contactor (contactor O:2/0) moves the conveyor&lt;br /&gt;
- Solenoid valve (contactor O:2/1) to fill the boxes&lt;br /&gt;
- Run pilot lamp (O:2/2) activated when the machine is running&lt;br /&gt;
- Fill pilot lamp (O:2/3) activated when the machine is filling&lt;br /&gt;
- Full pilot lamp (O:2/4) activated when the box on conveyor is full&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Inputs&lt;/b&gt;:&lt;br /&gt;
- Start Push button (I:0/0)&lt;br /&gt;
- Stop&amp;nbsp; Push Button (I:0/1)&lt;br /&gt;
- Prox Sensor (I:0/2) the box is in position on his right falling edge&lt;br /&gt;
- Level Sensor (I:0/3) the box is full when the sensor is ON&lt;br /&gt;
- Three-state Selector:&lt;br /&gt;
I:0/4 for Continous mode&lt;br /&gt;
I:0/5 for Manual Restart (after a box is full, this will bring the box out of level sensor and bring a new box in position)&lt;br /&gt;
I:0/6 for Filling bypass&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;You can find the various steps here:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;- Process analysis:&lt;a href=&quot;http://mestaa.blogspot.com/2011/04/plc-training-exercise-2-with-rslogix.html&quot;&gt; &lt;/a&gt;&lt;/b&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2011/04/plc-training-exercise-2-with-rslogix.html&quot;&gt;http://mestaa.blogspot.com/2011/04/plc-training-exercise-2-with-rslogix.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;- Input mapping: &lt;/b&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2011/04/plc-training-exercise-2-with-rslogix.html&quot;&gt;http://mestaa.blogspot.com/2011/04/plc-training-exercise-2-with-rslogix.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;- Writing and manage a sequence: &lt;/b&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2011/05/cycles.html&quot;&gt;http://mestaa.blogspot.com/2011/05/cycles.html&lt;/a&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2011/05/bsimulation-in-test-driven-development.html&quot;&gt; &lt;/a&gt;&lt;br /&gt;
&lt;b&gt;- Outputs Mapping: &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;- Simulating the process to debug the program:&lt;/b&gt; &lt;a href=&quot;http://mestaa.blogspot.com/2011/05/bsimulation-in-test-driven-development.html&quot;&gt;http://mestaa.blogspot.com/2011/05/bsimulation-in-test-driven-development.html&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;- Exercise file for RSLogix 5000: &lt;/b&gt;&lt;a href=&quot;http://www.megaupload.com/?d=9GXL96L7&quot;&gt;http://www.megaupload.com/?d=9GXL96L7&lt;/a&gt; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/8172376537169974647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/8172376537169974647?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/8172376537169974647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/8172376537169974647'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html' title='PLC Training: Exercise #2 Solution with RSLogix 5000'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuUFxaqy7NlqEdaAzavEQVr-5UNW8GbxdGOHI6WAk84BLQ-WQRbI7JKuabmkjwBhbrcZklGu_QfTI31POa9fm7Ojwhux3KU8g53AgRt67b7iImlsaX3_DOgUi4Dgk9V0iH38uXOZps6dBI/s72-c/Immagine.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-5278039208801801004</id><published>2011-05-04T22:48:00.012+02:00</published><updated>2011-05-08T13:02:34.635+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="simulators"/><title type='text'>PLC Training: Exercise #2 Cycles with RSLogix 5000</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;You can find the other parts of the exercise here: &lt;a href=&quot;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&quot;&gt;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&lt;/a&gt;&lt;b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;4) Cycle logic&lt;/b&gt;&lt;br /&gt;
To realize automatic cycles and sequences i often use a shift register with BSL block.&lt;br /&gt;
In this way it&#39;s possible to define the sequence&#39;s steps as bits, giving a comment to everyone.&lt;br /&gt;
In my opinion this is a clear way to read the current state of the cycle and what&#39;s happening inside.&lt;br /&gt;
Every cicle is made of 5 parts:&lt;br /&gt;
- Init (command outputs when in Stop state)&lt;br /&gt;
- Start (latches the 1st step)&lt;br /&gt;
- Stop (conditions to block the cycle and go to INIT state)&lt;br /&gt;
- Advance Step conditions (contains the BSL block)&lt;br /&gt;
- Outputs for every step (contains the commands for outputs)&lt;br /&gt;
&lt;br /&gt;
In the scheme above we see that we have 3 steps + a Stop state.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjlc7ph5j7YmcNvz30ja7qgZS11Qv33Xz7YmSyQbb0TZ6cx8Ip4T0EOnhv-LappkiIXyTOHlzyPa4455hefpCTjKAZgj0PB-cPdUM3Nq2ddGolcV436328EU2c52R3LwIttJ80Y3PfXPFm/s1600/Nuovo%252BImmagine%252Bbitmap.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;268&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjlc7ph5j7YmcNvz30ja7qgZS11Qv33Xz7YmSyQbb0TZ6cx8Ip4T0EOnhv-LappkiIXyTOHlzyPa4455hefpCTjKAZgj0PB-cPdUM3Nq2ddGolcV436328EU2c52R3LwIttJ80Y3PfXPFm/s400/Nuovo%252BImmagine%252Bbitmap.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;Step #1: Waiting for Box in position&lt;br /&gt;
Step #2: Box is full&lt;br /&gt;
Step #3: Box is moved outside the level sensor &lt;br /&gt;
We can notice also that to change steps are needed some signals and that the sequence can go only one way: &lt;br /&gt;
Stop -&amp;gt; 1 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 1 -&amp;gt; 2 ... while stop isn&#39;t pressed. &lt;br /&gt;
We  also notice that when Start is pressed, the sequence can restart only  from the 1st step, this because the exercise asks that the process must  be restarted.&lt;br /&gt;
When working with real processes anyway can happen  that the cycle step must be mantained when a user push stop for  mantainence, or that the system should recognize the current state from  the Inputs, so it can start an init or ending automatic sequence once  restarted.&lt;br /&gt;
&lt;br /&gt;
Usually i start writing my cycles from &quot;Step Advance&quot; and &quot;Commands&quot; blocks:&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNuNOONxKvzUpSyoDoegv8jWbNESv0hjDoXty7UfZxJ_O7BinAt4BeXFfw72rPzF5Ih1O2nZwPFUl6wsmPL0KzAi-QcLGjOPdlN7OgK71ZB1PnsXe2NpwoQWCX_YJm5r_YV9BW2Uf4E_xr/s1600/Step_Advance.JPG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNuNOONxKvzUpSyoDoegv8jWbNESv0hjDoXty7UfZxJ_O7BinAt4BeXFfw72rPzF5Ih1O2nZwPFUl6wsmPL0KzAi-QcLGjOPdlN7OgK71ZB1PnsXe2NpwoQWCX_YJm5r_YV9BW2Uf4E_xr/s1600/Step_Advance.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
As  you notice every step in the diagram has the same number as the step in  the cycle, and for every step there is the condition for advancing in  the same rung.&lt;br /&gt;
&lt;br /&gt;
Commands:&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhljKVR2XidFVGyvK7U53rnKaSGa8bZOwH6No8z77FiMdwAIJ02PuiaBWj7Dw9znSTXZis5DATwTkUR4T1of_-x-DHqx9Ww1rnFfqMbjPzwBmD_k53Kofky9lNYXLt-gyGiHP7YC4iRf018/s1600/outputscmd.JPG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhljKVR2XidFVGyvK7U53rnKaSGa8bZOwH6No8z77FiMdwAIJ02PuiaBWj7Dw9znSTXZis5DATwTkUR4T1of_-x-DHqx9Ww1rnFfqMbjPzwBmD_k53Kofky9lNYXLt-gyGiHP7YC4iRf018/s1600/outputscmd.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;I would like to point the attention on the use of Set/Reset coils for Motor Command.&lt;br /&gt;
Even  if i prefere to use normal coils instead of Set/Reset, i like even more  to see my steps in order from the 1st to the last one.&lt;br /&gt;
I know  that it&#39;s possible and easy to convert the OTL and OTU into a single OTE  coil, but for readability i prefere to use one rung for each step and  place them in ascending order.&lt;br /&gt;
That&#39;s why for every output that should be energized more than once during the cycle, usually i use latch/unlatch coils.&lt;br /&gt;
Be  careful on doing it with finite state machines, because it&#39;s easy to  make error if the cycle skips the rung that resets the coil.&lt;br /&gt;
Notice  that in the step #2 it&#39;s implemented the condition to start the motor  (manual restart + PB pressed). Usually it&#39;s a good habit to put a NO  contact on the top and an NC on the bottom to refere to the same  condition (like Automatic / Manual selector) but here it was used a  three state selector, and so i suppose to have 3 inputs.&lt;br /&gt;
&lt;br /&gt;
In the end i usually write the Start - Stop - Init rungs:&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAOcaw7xG4OTHwzAR31uqc90ozeVRcjASlKU0TVNWIcq_aKd5S22PH0_C658AEKQkcjVE4jLxtVGzVdXozwjZkpLtKYvMLC_-njrOSwoTDRE7tojRXgiRaV1QnQRTTNfNnDPDBSP1vboo1/s1600/init-start-stop.JPG&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAOcaw7xG4OTHwzAR31uqc90ozeVRcjASlKU0TVNWIcq_aKd5S22PH0_C658AEKQkcjVE4jLxtVGzVdXozwjZkpLtKYvMLC_-njrOSwoTDRE7tojRXgiRaV1QnQRTTNfNnDPDBSP1vboo1/s1600/init-start-stop.JPG&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;As  you can notice, to start the cycle it&#39;s enough to latch the 1st step,  the reset request is satisfied by the cicle stop and the init must reset  the commands.&lt;/div&gt;Cycle is enabled by pressing of start PB and  stopped by Stop PB, so i called the enable signal &quot;Automatic Mode&quot;, so  everyone can understand what&#39;s going on in the program.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5) Output Mapping&lt;/b&gt;&lt;br /&gt;
For  Outputs, except pilot lamps, i separate rungs in &quot;Automatic mode&quot; and  &quot;not Automatic mode&quot;, using the second essentially for jogging.&lt;br /&gt;
In  this exercise it&#39;s required the possibility to move the conveyor with a  &quot;bypass selector&quot; that is exactly a jogging control for conveyor.(i  will add the picture soon... be patient)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;6) Exercise file&lt;/b&gt;&lt;br /&gt;
you can find the exercise solved for RSLogix 5000 here: &lt;a href=&quot;http://www.megaupload.com/?d=9GXL96L7&quot;&gt;http://www.megaupload.com/?d=9GXL96L7&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Next part here: &lt;a href=&quot;http://mestaa.blogspot.com/2011/05/bsimulation-in-test-driven-development.html&quot;&gt;Simulation &lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/5278039208801801004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/5278039208801801004?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5278039208801801004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5278039208801801004'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/05/cycles.html' title='PLC Training: Exercise #2 Cycles with RSLogix 5000'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjlc7ph5j7YmcNvz30ja7qgZS11Qv33Xz7YmSyQbb0TZ6cx8Ip4T0EOnhv-LappkiIXyTOHlzyPa4455hefpCTjKAZgj0PB-cPdUM3Nq2ddGolcV436328EU2c52R3LwIttJ80Y3PfXPFm/s72-c/Nuovo%252BImmagine%252Bbitmap.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-6800626904020418685</id><published>2011-05-04T22:46:00.010+02:00</published><updated>2011-05-08T10:57:54.276+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="simulators"/><title type='text'>PLC Training: Exercise #2 Simulation with RSLogix 5000</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;You can find the other parts of the exercise here: &lt;a href=&quot;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&quot;&gt;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;RSEmulate Tutorial: &lt;/b&gt;&lt;br /&gt;
You can find a good tutorial for &lt;u&gt;RSEmulate 5000&lt;/u&gt; here: &lt;a href=&quot;http://www.plcdev.com/a_quick_tutorial_on_rslogix_emulator_5000&quot;&gt;http://www.plcdev.com/a_quick_tutorial_on_rslogix_emulator_5000&lt;/a&gt;.&lt;br /&gt;
Pay attention especially in the last part where it says that for inputs you should refere to local_input[1] and for output refere to local_output[0].&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7)Simulation &lt;/b&gt;&lt;br /&gt;
In test driven development usually it&#39;s a good habit to write simulation before the logic, and then test the logic while writing it.&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
To simulate a real plant just connect the output to inputs, designing an ideal behaviour of your plant.&lt;br /&gt;
For example we know that when the motor is ON the conveyor moves and the position of the box changes.&lt;br /&gt;
When the box is in a certain position we know also that the Prox Sensor must be ON.&lt;br /&gt;
So to simulate that the position increase use a DINT variable to increment when the motor is ON and to reset after a defined value (8 in my case). &lt;br /&gt;
Then turn ON the proximity when position is between 3 and 5.&lt;br /&gt;
The same can be done with the level sensor, but we have to remember that when the box is full, the level sensor remains ON until the box hasn&#39;t moved away from it.&lt;br /&gt;
The following is one way to simulate this process.&lt;br /&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrsyND2Q43hScYxqmEPG7yf-6ldxr-DZkdgg8zzp36ggs38BPoX9PTthpwaTGWdv-8r0JwysEo0HoL6oUGF0FnWDdYiGaPPXizVo1eZmtcCMf3q8kr86b5bmUfRNRSgpfpLbwJhmddKlSK/s1600/simulation.bmp&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrsyND2Q43hScYxqmEPG7yf-6ldxr-DZkdgg8zzp36ggs38BPoX9PTthpwaTGWdv-8r0JwysEo0HoL6oUGF0FnWDdYiGaPPXizVo1eZmtcCMf3q8kr86b5bmUfRNRSgpfpLbwJhmddKlSK/s1600/simulation.bmp&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPVyKi5yo86diVqPER__KLdOLUQiOMs520JjGjbyWEsLXal4Vt282hYM9l-kxX5jwuatznkRXcHlcBWMKu5ZwbZxxolda9MPZRggk9McX7Wft_2RLuLJKxc_cvc0oawv_1POT_POvEr4jl/s1600/Nuovo+Immagine+bitmap.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/6800626904020418685/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/6800626904020418685?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/6800626904020418685'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/6800626904020418685'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/05/bsimulation-in-test-driven-development.html' title='PLC Training: Exercise #2 Simulation with RSLogix 5000'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrsyND2Q43hScYxqmEPG7yf-6ldxr-DZkdgg8zzp36ggs38BPoX9PTthpwaTGWdv-8r0JwysEo0HoL6oUGF0FnWDdYiGaPPXizVo1eZmtcCMf3q8kr86b5bmUfRNRSgpfpLbwJhmddKlSK/s72-c/simulation.bmp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-1483281339240578869</id><published>2011-04-18T23:04:00.010+02:00</published><updated>2011-05-08T11:00:27.097+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="simulators"/><title type='text'>PLC Training: Exercise #2 Input Mapping</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;You can find the other parts of the exercise here: &lt;a href=&quot;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&quot;&gt;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&lt;/a&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;1) Sequence analisys and algorithym&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPVyKi5yo86diVqPER__KLdOLUQiOMs520JjGjbyWEsLXal4Vt282hYM9l-kxX5jwuatznkRXcHlcBWMKu5ZwbZxxolda9MPZRggk9McX7Wft_2RLuLJKxc_cvc0oawv_1POT_POvEr4jl/s1600/Nuovo+Immagine+bitmap.bmp&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;393&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPVyKi5yo86diVqPER__KLdOLUQiOMs520JjGjbyWEsLXal4Vt282hYM9l-kxX5jwuatznkRXcHlcBWMKu5ZwbZxxolda9MPZRggk9McX7Wft_2RLuLJKxc_cvc0oawv_1POT_POvEr4jl/s640/Nuovo+Immagine+bitmap.bmp&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Step #1: Waiting for Box in position&lt;br /&gt;
Step #2: Box is full&lt;br /&gt;
Step #3: Box is moved outside the level sensor&lt;br /&gt;
To change steps follow the arrow and the signal that has to be received.&lt;br /&gt;
From all steps you must be able to stop the machine if Stop push button is pressed&lt;br /&gt;
If the machine is stopped, pressing Start push button will restart the cycle from Step #1&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2) Writing the program:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Defining tasks:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT_5IMxgELGP371lMLGZ9tzcir87Ib21e9YY44lxIpuclMn_vEFf5f3pP8zDPItXEsbgKTit3Bi-OjHgKsVeupyAr0SRCOFeqG3fNlAgpc6e80iepGRy4Isr5dS43xRYzU6yBfCiVVtwfN/s1600/Tasks.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT_5IMxgELGP371lMLGZ9tzcir87Ib21e9YY44lxIpuclMn_vEFf5f3pP8zDPItXEsbgKTit3Bi-OjHgKsVeupyAr0SRCOFeqG3fNlAgpc6e80iepGRy4Isr5dS43xRYzU6yBfCiVVtwfN/s400/Tasks.JPG&quot; width=&quot;216&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
those 3 tasks should be in every program&lt;br /&gt;
&lt;i&gt;&lt;b&gt;-Simulation&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;b&gt;-Map Inputs&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;b&gt;-Map Outputs&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
- There should be an &lt;i&gt;&lt;b&gt;Alarm &lt;/b&gt;&lt;/i&gt;task also, but in this exercise alarms are not requested.&lt;br /&gt;
I gave the name &lt;i&gt;&lt;b&gt;MainProgram &lt;/b&gt;&lt;/i&gt;to the task that runs the cycle because this is a really simple program, with one short cycle and a start/stop without particular requests.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3)Input Mapping:&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkdorycpj6_fMYqWkMoHePWl5n6WE5Wa28m84Da0hokF_f06hahxg9uuv1YxFtcBA04druUBu2BITRaO7h1FrZZNUt0KTgoIvOcXuuNvEZgrBitnOqK1RL1nlfdkgZUEwUzwj3b2HVejD/s1600/IO+Mapping.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkdorycpj6_fMYqWkMoHePWl5n6WE5Wa28m84Da0hokF_f06hahxg9uuv1YxFtcBA04druUBu2BITRaO7h1FrZZNUt0KTgoIvOcXuuNvEZgrBitnOqK1RL1nlfdkgZUEwUzwj3b2HVejD/s640/IO+Mapping.JPG&quot; width=&quot;512&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
I usually map inputs in DINT variables, so i can force them without problems while debugging on the real plant.&lt;br /&gt;
Also it makes it easy to change a broken Input without having to change all the program.&lt;br /&gt;
Other programmers uses to map Input in UDT data types, with all the problems connected on the&amp;nbsp; debugging phase the real system when it is ready. &lt;br /&gt;
&lt;br /&gt;
As for the output i usually write an alias tag, because i always use outputs once in all program and with a coil segment.&lt;br /&gt;
&lt;br /&gt;
Next part is here: &lt;a href=&quot;http://mestaa.blogspot.com/2011/05/cycles.html&quot;&gt;Cycles and Outputs&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/1483281339240578869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/1483281339240578869?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/1483281339240578869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/1483281339240578869'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/04/plc-training-exercise-2-with-rslogix.html' title='PLC Training: Exercise #2 Input Mapping'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPVyKi5yo86diVqPER__KLdOLUQiOMs520JjGjbyWEsLXal4Vt282hYM9l-kxX5jwuatznkRXcHlcBWMKu5ZwbZxxolda9MPZRggk9McX7Wft_2RLuLJKxc_cvc0oawv_1POT_POvEr4jl/s72-c/Nuovo+Immagine+bitmap.bmp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-2136129606278337427</id><published>2011-04-12T22:49:00.011+02:00</published><updated>2011-07-24T13:42:15.414+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC Training"/><title type='text'>PLC Training: Some interesting exercises</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I found some interesting exercises about plc programming that cover almost all the topics that a programmer should know.&lt;br /&gt;
The document is mainly thought for Allen Bradley plcs users, but it can be useful also for others.&lt;br /&gt;
The exercises are:&lt;br /&gt;
1) Using simple relays logic to control a motor&lt;br /&gt;
&lt;b&gt;&lt;span id=&quot;goog_254429067&quot;&gt;&lt;/span&gt;&lt;a href=&quot;http://mestaa.blogspot.com/2011/05/plc-training-exercise-2-solution-with.html&quot;&gt;2) Using relays logic to control simple sequences&lt;/a&gt;&lt;span id=&quot;goog_254429068&quot;&gt;&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;
3) Using Timers, Retentive Timers and Counters&lt;br /&gt;
&lt;a href=&quot;http://mestaa.blogspot.com/2011/07/writing-sequences-with-siemens-step-7.html&quot;&gt;4) Using relays logic + everything saw before to control a batch mixing system&lt;/a&gt;&lt;br /&gt;
5) Using shift registers to determine the position of a bottle in a filling plant&lt;br /&gt;
6) Using various modules to control an elevator system.&lt;br /&gt;
&lt;br /&gt;
The pdf&amp;nbsp; was found on &lt;a href=&quot;http://thelearningpit.com/lp/logixpro.html&quot;&gt;http://thelearningpit.com/lp/logixpro.html&lt;/a&gt;&lt;a href=&quot;http://www.thelearningpit.com/&quot;&gt;&lt;/a&gt;, they also sells some kind of graphical simulation to run the plants if you&#39;re interested.&lt;br /&gt;
&amp;nbsp;I reccomend to try logixpro simulator (15 days trial) because it can really improve your ladder code with just your time.&lt;br /&gt;
You can download the exercise file directly from learning pit website or from here:&lt;br /&gt;
&lt;a href=&quot;http://www.megaupload.com/?d=PIWQA7AS&quot;&gt;http://www.megaupload.com/?d=PIWQA7AS&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/2136129606278337427/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/2136129606278337427?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/2136129606278337427'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/2136129606278337427'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/04/plc-training-some-interesting-exercise.html' title='PLC Training: Some interesting exercises'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-5393170653441010823</id><published>2011-04-08T20:38:00.026+02:00</published><updated>2012-03-06T20:21:31.365+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF Controls"/><title type='text'>HMI Controls for WPF: Led (and a tutorial on WPF User Control)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;You can downlaod the source code with sample here:&lt;a href=&quot;http://www.mesta-automation.com/Downloads/Led%20Wpf.rar&quot;&gt; http://www.mesta-automation.com/Downloads/Led%20Wpf.rar&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Every Scada system has his own framework that contains a lot of graphic&amp;nbsp;objects, from gauges to charts, that can be controlled directly by some Tags&amp;nbsp;or variables.&lt;br /&gt;
Unfortunately .Net doesn&#39;t come with this objects, so we have to create them.&lt;br /&gt;
In this sample i show how to create a simple graphical Led.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyh1RkN1qxf8M9mylDaaDRv7J02PSWOgmKAs_mdKth_b7JFBXIotGMr4svL5Q1tRLnAJrzCkbwbiE-Py6-n_ohQCKraA7BPvybd9Z8e0qc3TANUOz41Qok2hqNeu7yS0bankMzr40D_s4M/s1600/leds.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyh1RkN1qxf8M9mylDaaDRv7J02PSWOgmKAs_mdKth_b7JFBXIotGMr4svL5Q1tRLnAJrzCkbwbiE-Py6-n_ohQCKraA7BPvybd9Z8e0qc3TANUOz41Qok2hqNeu7yS0bankMzr40D_s4M/s1600/leds.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Create a new Control Library (File -&amp;gt; New -&amp;gt; Project -&amp;gt; WPF User Control&amp;nbsp;Library),&lt;br /&gt;
then create a new project to test the control( to&amp;nbsp;test and show how to use the control).&lt;br /&gt;
After the creation of this 2 projects, set the test project as startup project and add as reference the&amp;nbsp; control library.&lt;br /&gt;
Now we are ready to start creating the graphic part.&lt;br /&gt;
&lt;br /&gt;
Basically a led can be drawn as a Border object that inside it contains a color, and his background is of another color.&lt;br /&gt;
This is the code for the graphic part&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;Grid x:Name=&quot;gridBigLed&quot; &amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Border x:Name=&quot;border1&quot; BorderThickness=&quot;6&quot; Width=&quot;{Binding ActualHeight, ElementName=gridBigLed, Mode=OneWay}&quot; CornerRadius=&quot;{Binding ActualWidth, ElementName=gridBigLed, Mode=OneWay}&quot;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Border.Background&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RadialGradientBrush &amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;GradientStop Color=&quot;White&quot;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;GradientStop x:Name=&quot;backgroundColor&quot; Color=&quot;Red&quot; Offset=&quot;0.835&quot;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/RadialGradientBrush&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Border.Background&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Border.BorderBrush&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RadialGradientBrush&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;GradientStop Color=&quot;#FF020202&quot; Offset=&quot;0.383&quot;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;GradientStop Color=&quot;#FFE4E4E4&quot; Offset=&quot;1&quot;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/RadialGradientBrush&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Border.BorderBrush&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Border&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Grid&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
We bind the height of the border to the height of the grid, so we can resize the control when developing our application.&lt;br /&gt;
Corner radius is in binding with width too, to be sure that the border will be always circular.&lt;br /&gt;
For the background color you can use wathever you like. I used a radial gradient with Red(Off state) and White , and i will change it with green and&amp;nbsp; white (On state) depending on the state of a property. That&#39;s why I gave the name &quot;backgroundColor&quot; on the red GradientStop.&lt;br /&gt;
&lt;br /&gt;
To give properties to a UserControl we must use Dependency Properties.&lt;br /&gt;
We will give 3 properties to the user control: &lt;br /&gt;
- bool IsActive&lt;br /&gt;
- Color ColorOn (color when IsActive is true)&lt;br /&gt;
- Color ColorOff (color when IsActive is false)&lt;br /&gt;
&lt;br /&gt;
The declaration is the following:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;/// &amp;lt;summary&amp;gt;Dependency property to Get/Set the current IsActive (True/False)&amp;lt;/summary&amp;gt;
        public static readonly DependencyProperty IsActiveProperty =
            DependencyProperty.Register(&quot;IsActive&quot;, typeof(bool), typeof(Led),// null);
                new PropertyMetadata(new PropertyChangedCallback(Led.IsActivePropertyChanced)));

        /// &amp;lt;summary&amp;gt;Dependency property to Get/Set Color when IsActive is true&amp;lt;/summary&amp;gt;
        public static readonly DependencyProperty ColorOnProperty =
            DependencyProperty.Register(&quot;ColorOn&quot;, typeof(Color), typeof(Led), //null);
                new PropertyMetadata(Colors.Green,new PropertyChangedCallback(Led.OnColorOnPropertyChanged)));

        /// &amp;lt;summary&amp;gt;Dependency property to Get/Set Color when IsActive is false&amp;lt;/summary&amp;gt;
        public static readonly DependencyProperty ColorOffProperty =
            DependencyProperty.Register(&quot;ColorOff&quot;, typeof(Color), typeof(Led),// null);
                new PropertyMetadata(Colors.Red,new PropertyChangedCallback(Led.OnColorOffPropertyChanged)));

        /// &amp;lt;summary&amp;gt;Gets/Sets Value&amp;lt;/summary&amp;gt;
        public bool IsActive
        {
            get { return (bool)GetValue(IsActiveProperty); }
            set 
            {
                SetValue(IsActiveProperty, value);
            }
        }

        /// &amp;lt;summary&amp;gt;Gets/Sets Color when led is True&amp;lt;/summary&amp;gt;
        public Color ColorOn
        {
            get
            {
                return (Color)GetValue(ColorOnProperty);
            }
            set
            {
                SetValue(ColorOnProperty, value);
            }
        }

        /// &amp;lt;summary&amp;gt;Gets/Sets Color when led is False&amp;lt;/summary&amp;gt;
        public Color ColorOff
        {
            get
            {
                return (Color)GetValue(ColorOffProperty);
            }
            set
            {
                SetValue(ColorOffProperty, value);
            }
        }
&lt;/pre&gt;&lt;br /&gt;
Now there is a lot to talk about dependency properties, but basically:&lt;br /&gt;
you can set the starting value when you create the objects (ColorOn starts with Color.Green and ColorOff start with Color.Red)&lt;br /&gt;
and you should note that every property has is name written as string in the 1st field of DependencyProperty.Register method.&lt;br /&gt;
the properties also access to values contained in dependency properties&amp;nbsp; by getValue() and SetValue().&lt;br /&gt;
&lt;br /&gt;
Every Dependency Property should have is own method when it changes. Those methods describe the behaviour of our object, basically a change of IsActive should modify the color of the border and if i change a color at runtime, depending on the state, it should refresh the color instantly.&lt;br /&gt;
In this case i wrote the following methods:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;private static void IsActivePropertyChanced(DependencyObject d, DependencyPropertyChangedEventArgs e) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Led led = (Led)d;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ((bool)e.NewValue)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.backgroundColor.Color = led.ColorOn;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.backgroundColor.Color = led.ColorOff;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static void OnColorOnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Led led = (Led)d;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.ColorOn = (Color)e.NewValue;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (led.IsActive)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.backgroundColor.Color = led.ColorOn;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.backgroundColor.Color = led.ColorOff;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static void OnColorOffPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Led led = (Led)d;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.ColorOff = (Color)e.NewValue;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (led.IsActive)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.backgroundColor.Color = led.ColorOn;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led.backgroundColor.Color = led.ColorOff;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;
Note that every method is static and it access to the user control property by casting the dependencyobject d.&lt;br /&gt;
&lt;br /&gt;
As for the constructor, i wrote a refresh depending on what color it&#39;s set.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;public Led()
{
   InitializeComponent();
   if (this.IsActive)
       this.backgroundColor.Color = ColorOn;
   else
       this.backgroundColor.Color = ColorOff;       
}
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
In this way our control should work.&lt;br /&gt;
&lt;br /&gt;
Now to test we should try it with and without databinding. &lt;br /&gt;
This is the test that i wrote:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: xml&quot;&gt;&amp;lt;Window x:Class=&quot;LedTest.MainWindow&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns:uc=&quot;clr-namespace:LedControl;assembly=LedControl&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Title=&quot;MainWindow&quot; Height=&quot;350&quot; Width=&quot;525&quot;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Grid&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Grid.RowDefinitions&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RowDefinition Height=&quot;Auto&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RowDefinition Height=&quot;10&quot;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RowDefinition Height=&quot;Auto&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RowDefinition /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Grid.RowDefinitions&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Grid.ColumnDefinitions&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ColumnDefinition Width=&quot;Auto&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ColumnDefinition Width=&quot;Auto&quot;/&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ColumnDefinition /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Grid.ColumnDefinitions&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;uc:Led Name=&quot;led1&quot; Height=&quot;60&quot; Width=&quot;60&quot; IsActive=&quot;False&quot; Flashing=&quot;False&quot; FlashingPeriod=&quot;500&quot;&amp;nbsp; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock Grid.Column=&quot;1&quot;&amp;gt;Led without binding&amp;lt;/TextBlock&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Button Name=&quot;btnChange&quot;&amp;nbsp; Grid.Column=&quot;2&quot;&amp;nbsp; Content=&quot;Change&quot; Click=&quot;btnChange_Click&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;uc:Led Name=&quot;led2&quot; Grid.Row=&quot;2&quot; Height=&quot;60&quot; Width=&quot;60&quot; IsActive=&quot;{Binding LedStatus}&quot;&amp;nbsp; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TextBlock&amp;nbsp; Grid.Row=&quot;2&quot; Grid.Column=&quot;1&quot;&amp;gt;Led with binding&amp;lt;/TextBlock&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Button Name=&quot;btnChange2&quot;&amp;nbsp; Grid.Row=&quot;2&quot; Grid.Column=&quot;2&quot;&amp;nbsp; Content=&quot;Change&quot; Click=&quot;btnChange2_Click&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;&lt;/pre&gt;&lt;window x:class=&quot;LedTest.MainWindow&quot;&gt;&lt;grid&gt;&lt;grid.rowdefinitions&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;rowdefinition height=&quot;10&quot;&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;grid.columndefinitions&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&amp;nbsp;&lt;/columndefinition&gt;&lt;/columndefinition&gt;&lt;/grid.columndefinitions&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/grid.rowdefinitions&gt;&lt;/grid&gt;&lt;/window&gt;&lt;window x:class=&quot;LedTest.MainWindow&quot;&gt;&lt;grid&gt;&lt;grid.rowdefinitions&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;rowdefinition height=&quot;10&quot;&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;grid.columndefinitions&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&amp;nbsp;&lt;/columndefinition&gt;&lt;/columndefinition&gt;&lt;/grid.columndefinitions&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/grid.rowdefinitions&gt;&lt;/grid&gt;&lt;/window&gt;&lt;grid x:name=&quot;gridBigLed&quot;&gt;&lt;border borderthickness=&quot;6&quot; cornerradius=&quot;{Binding ActualWidth, ElementName=gridBigLed, Mode=OneWay}&quot; width=&quot;{Binding ActualHeight, ElementName=gridBigLed, Mode=OneWay}&quot; x:name=&quot;border1&quot;&gt;&lt;border.background&gt;&lt;radialgradientbrush&gt;&lt;window x:class=&quot;LedTest.MainWindow&quot;&gt;&lt;grid&gt;&lt;grid.rowdefinitions&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;rowdefinition height=&quot;10&quot;&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;grid.columndefinitions&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;uc:led &amp;nbsp;=&quot;&quot; flashing=&quot;False&quot; flashingperiod=&quot;500&quot; height=&quot;60&quot; isactive=&quot;False&quot; name=&quot;led1&quot; width=&quot;60&quot;&gt;&lt;br /&gt;
&lt;textblock grid.column=&quot;1&quot;&gt;&lt;/textblock&gt;&lt;/uc:led&gt;&lt;/columndefinition&gt;&lt;/columndefinition&gt;&lt;/grid.columndefinitions&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/grid.rowdefinitions&gt;&lt;/grid&gt;&lt;/window&gt;&lt;/radialgradientbrush&gt;&lt;/border.background&gt;&lt;/border&gt;&lt;/grid&gt;&lt;grid x:name=&quot;gridBigLed&quot;&gt;&lt;border borderthickness=&quot;6&quot; cornerradius=&quot;{Binding ActualWidth, ElementName=gridBigLed, Mode=OneWay}&quot; width=&quot;{Binding ActualHeight, ElementName=gridBigLed, Mode=OneWay}&quot; x:name=&quot;border1&quot;&gt;&lt;border.background&gt;&lt;radialgradientbrush&gt;&lt;window x:class=&quot;LedTest.MainWindow&quot;&gt;&lt;grid&gt;&lt;grid.rowdefinitions&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;rowdefinition height=&quot;10&quot;&gt;&lt;rowdefinition height=&quot;Auto&quot;&gt;&lt;grid.columndefinitions&gt;&lt;columndefinition width=&quot;Auto&quot;&gt;&lt;columndefinition width=&quot;Auto&quot;&gt; &lt;/columndefinition&gt;&lt;/columndefinition&gt;&lt;/grid.columndefinitions&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/rowdefinition&gt;&lt;/grid.rowdefinitions&gt;&lt;/grid&gt;&lt;/window&gt;&lt;/radialgradientbrush&gt;&lt;/border.background&gt;&lt;/border&gt;&lt;/grid&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: csharp&quot;&gt;public partial class MainWindow : Window,INotifyPropertyChanged
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool ledStatus;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public bool LedStatus
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { get { return ledStatus; } set { ledStatus = value; this.OnPropertyChanged(&quot;LedStatus&quot;); } }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MainWindow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led2.DataContext = this;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led1.ColorOn = Colors.Blue;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led1.ColorOff = Colors.Gray;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void btnChange_Click(object sender, RoutedEventArgs e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; led1.IsActive = !led1.IsActive;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void btnChange2_Click(object sender, RoutedEventArgs e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LedStatus = !LedStatus;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }


&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #region INotifyPropertyChanged members

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public event PropertyChangedEventHandler PropertyChanged;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected void OnPropertyChanged(string propertyName)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (PropertyChanged != null)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #endregion&amp;nbsp; &lt;/pre&gt;&lt;br /&gt;
The 1st button test the led by changing the color from codebehind, the second test it in binding with a property contained (in this case) in the mainwindow directly.&lt;br /&gt;
&lt;br /&gt;
Playing with Blend and adding more Dependency Properties will give even a better result.&lt;a href=&quot;http://www.blogger.com/goog_3442674&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;br /&gt;
Sample App is here:&amp;nbsp;&lt;a href=&quot;http://www.mesta-automation.com/Downloads/Led%20Wpf.rar&quot;&gt;http://www.mesta-automation.com/Downloads/Led%20Wpf.rar&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/5393170653441010823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/5393170653441010823?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5393170653441010823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5393170653441010823'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/04/led-for-wpf-how-to-create-wpf-user.html' title='HMI Controls for WPF: Led (and a tutorial on WPF User Control)'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyh1RkN1qxf8M9mylDaaDRv7J02PSWOgmKAs_mdKth_b7JFBXIotGMr4svL5Q1tRLnAJrzCkbwbiE-Py6-n_ohQCKraA7BPvybd9Z8e0qc3TANUOz41Qok2hqNeu7yS0bankMzr40D_s4M/s72-c/leds.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-2686189236410956781</id><published>2011-02-14T21:48:00.006+01:00</published><updated>2011-02-21T19:51:54.020+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term=".Net"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="Winforms"/><title type='text'>HMI Controls for Winforms: Gauge</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu7_aL6gKhCsgtLrWJUN77S-as6c8r-nJRx-Ao5CUUWlGzN71TuSlfqic0HdbMR3YChL_t6jy-CjMopwZHrtri2OcGUbGu3cEKpTgiDcrCyMaC0gfADIr7CHTbDhzOxJmG1rayhezwwIgn/s1600/Immagine1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;Even if i don&#39;t like to talk about Winforms, i found a good gauge and i used for 1-2 projects:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu7_aL6gKhCsgtLrWJUN77S-as6c8r-nJRx-Ao5CUUWlGzN71TuSlfqic0HdbMR3YChL_t6jy-CjMopwZHrtri2OcGUbGu3cEKpTgiDcrCyMaC0gfADIr7CHTbDhzOxJmG1rayhezwwIgn/s1600/Immagine1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;325&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu7_aL6gKhCsgtLrWJUN77S-as6c8r-nJRx-Ao5CUUWlGzN71TuSlfqic0HdbMR3YChL_t6jy-CjMopwZHrtri2OcGUbGu3cEKpTgiDcrCyMaC0gfADIr7CHTbDhzOxJmG1rayhezwwIgn/s400/Immagine1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The main page for this control and the discussion is here:&lt;br /&gt;
&lt;a href=&quot;http://www.codeproject.com/KB/miscctrl/ThermometerControl.aspx&quot;&gt;http://www.codeproject.com/KB/miscctrl/ThermometerControl.aspx&lt;/a&gt;&lt;br /&gt;
I add a project for download so you can check the source code and how to use this(it&#39;s really simple).&lt;br /&gt;
&lt;a href=&quot;http://depositfiles.com/files/qrsp1v2op&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.megaupload.com/?d=TVK7D9M9&quot;&gt;http://www.megaupload.com/?d=TVK7D9M9&lt;/a&gt;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/2686189236410956781/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/2686189236410956781?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/2686189236410956781'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/2686189236410956781'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/02/hmi-controls-for-winforms-gauge.html' title='HMI Controls for Winforms: Gauge'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu7_aL6gKhCsgtLrWJUN77S-as6c8r-nJRx-Ao5CUUWlGzN71TuSlfqic0HdbMR3YChL_t6jy-CjMopwZHrtri2OcGUbGu3cEKpTgiDcrCyMaC0gfADIr7CHTbDhzOxJmG1rayhezwwIgn/s72-c/Immagine1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-5279094038330608122</id><published>2011-02-14T21:39:00.006+01:00</published><updated>2012-03-05T18:27:38.217+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF Controls"/><title type='text'>HMI Controls for WPF: Gauge</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=WpfGauge&amp;amp;DownloadId=159139&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;/div&gt;&lt;b&gt;[Check the updated post here:&amp;nbsp;&lt;a href=&quot;http://www.mesta-automation.com/wpf-gauge-with-samples/&quot;&gt;http://www.mesta-automation.com/wpf-gauge-with-samples/&lt;/a&gt;]&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Most of times the Gauge indicator is used in HMI projects to visualize Speed - Pressure - Temperatures and so on.&lt;br /&gt;
I also prefere using Gause against other tipes of controls such as thermometers, bar graph and others, becuase the measure it&#39;s clear and the minimum, maximum and alarm threshold are evidents.&lt;br /&gt;
In WPF there are 2 kind of free gauges with free source code:&lt;br /&gt;
1)&lt;a href=&quot;http://www.blogger.com/%20http://wpfgauge.codeplex.com/&quot;&gt; http://wpfgauge.codeplex.com/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=WpfGauge&amp;amp;DownloadId=159139&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;235&quot; src=&quot;http://i3.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=WpfGauge&amp;amp;DownloadId=159139&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
this is a free gauge that has no animations (and it can be good ) but it&#39;s under the LGPL license, so this means that the code using this gauge must be GPL - licensed.&lt;br /&gt;
&lt;br /&gt;
2) &lt;a href=&quot;http://www.codeproject.com/KB/silverlight/circulargaugecontrol.aspx?msg=3745697#xx3745697xx&quot;&gt;http://www.codeproject.com/KB/silverlight/circulargaugecontrol.aspx?msg=3745697#xx3745697xx&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/KB/silverlight/circulargaugecontrol/gauge_cb.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;398&quot; src=&quot;http://www.codeproject.com/KB/silverlight/circulargaugecontrol/gauge_cb.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This one is the one that i prefere. It&#39;s BSD License (so you can use it basically everywhere) and it is for both Silverlight and WPF.&lt;br /&gt;
It&#39;s not autosizing and that&#39;s a pity, and to dimension it you have to play with some controls.&lt;br /&gt;
But anyway it&#39;s a great control with a threshold indicator and easy parameters to play around.&lt;br /&gt;
It&#39;s easy to change colors and sizes of scale and numbers, so it can become a manomether, a thermometer and a tachimeter depending on what application you are working on.&lt;br /&gt;
&lt;br /&gt;
The project can be downloaded from the original site or here:&lt;br /&gt;
&lt;a href=&quot;http://depositfiles.com/files/2knv7xjz4&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.megaupload.com/?d=5TMUYC9A&quot;&gt;http://www.megaupload.com/?d=5TMUYC9A&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/5279094038330608122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/5279094038330608122?isPopup=true' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5279094038330608122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/5279094038330608122'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/02/hmi-controls-for-wpf-gauge.html' title='HMI Controls for WPF: Gauge'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-6674944432506219720</id><published>2011-01-18T21:00:00.008+01:00</published><updated>2012-01-25T21:56:25.043+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="Databinding"/><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF Controls"/><title type='text'>WPF Control: Listbox of checkbox with Search google-like</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;One thing that i like of WPF is the possibility of making easy-to-use controls to manage data.&lt;br /&gt;
A control that i use a lot of times to filter dataviews, charts, get queryes parameters and so on is a listbox of checkbox.&lt;br /&gt;
This isn&#39;t that special, but with ICollectionView and the possibility of having a fast way to filter results like the search box in google.com it become a really powerful tool.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiq9oP_MWKyX89wjN4K6jaRvxSyG0R4FGwz6g6MihefGqsvVBkVdqQ0X5DZ1qUKyNdgzV0R9NNAgVoDM_1Iz1SrYnLoAOXJg69lr7YTttapsbcIQsebKO3i3uCbe_zKKkKARcHztCi89Vr/s1600/Immagine.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiq9oP_MWKyX89wjN4K6jaRvxSyG0R4FGwz6g6MihefGqsvVBkVdqQ0X5DZ1qUKyNdgzV0R9NNAgVoDM_1Iz1SrYnLoAOXJg69lr7YTttapsbcIQsebKO3i3uCbe_zKKkKARcHztCi89Vr/s400/Immagine.png&quot; width=&quot;310&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
I invite you to download the demo (link at the bottom of this page) to understand better.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s start from an example:&lt;br /&gt;
I have an observable collection of &quot;Fruits&quot;, objects that contain a property &quot;Name&quot; and a property &quot;Show&quot; that indicates if the object has to be visualized or filtered.&lt;br /&gt;
&lt;br /&gt;
To filter this collection i can use the ICollectionView, that permits to filter a collection and has a method Refresh() that reload the collection with the filter parameters.&lt;br /&gt;
&lt;br /&gt;
So in the properties i add:&lt;br /&gt;
&lt;i&gt;&amp;nbsp;class MyFruitCollection : ObservableCollection &lt;myfruit&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/myfruit&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;private ICollectionView filteredCollection;&lt;br /&gt;
public ICollectionView FilteredCollection { get { return filteredCollection; } }&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
and the filter string:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt; private string filter = &quot;&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Filter&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get { return this.filter.ToUpperInvariant(); }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (this.filter != value)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.filter = value;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; this.filteredCollection.Refresh(); //&lt;/b&gt;&lt;/i&gt;Notice that i call Refresh() at every change of filter&lt;i&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
In the constructor of my collection i add some fruits(just for example) and i load the ICollectionView datasource:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;i&gt; public MyFruitCollection() &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(new MyFruit(&quot;Orange&quot;));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(new MyFruit(&quot;Watermelon&quot;));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.filteredCollection = CollectionViewSource.GetDefaultView(this);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.filteredCollection.Filter = ContainsFilter;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
Then i set the filters on this method:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;private bool ContainsFilter(object item)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var fruit = item as MyFruit;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fruit == null)&amp;nbsp; //check if fruit is null&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (string.IsNullOrEmpty(this.Filter)) //check if search box is empty or null&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true; //show all items if there is no text in the search textbox&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; if (fruit.Name.ToUpperInvariant().Contains(this.Filter))&lt;/b&gt; &lt;/i&gt;&lt;b&gt;//checks if fruit.name contains the search text&lt;/b&gt;&lt;i&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return false; //if it doesn&#39;t contain anything don&#39;t show the item&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&lt;/i&gt;Xaml is pretty simple, as usual it&#39;s all about databinding:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX1YSjTNdwfkscjtMSYEdDhVvhvZ_N2rm6U-aR4QdXAO5fGBYVZWCgd_fFYvGi1XVCLmz7K7IuMZKRpSMs-eSpjZt5TkJdTHKPCVD-fjWaHDHdfR3qwoV7mkYcJyC6VyAViwRzy27C1kUD/s1600/Immagine2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;116&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX1YSjTNdwfkscjtMSYEdDhVvhvZ_N2rm6U-aR4QdXAO5fGBYVZWCgd_fFYvGi1XVCLmz7K7IuMZKRpSMs-eSpjZt5TkJdTHKPCVD-fjWaHDHdfR3qwoV7mkYcJyC6VyAViwRzy27C1kUD/s640/Immagine2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
And this is the code behind:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public partial class MainWindow : Window&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;MyFruitCollection fruitCollection = new MyFruitCollection();&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MainWindow()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;b&gt; this.DataContext = fruitCollection;&lt;/b&gt;&lt;/i&gt; //notice that all the application is in binding &lt;i&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;...&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
The resul is pretty cool and it makes apps a lot more confortable, just try yourself :)&lt;br /&gt;
Download the example here:&lt;br /&gt;
&lt;a href=&quot;http://mesta-automation.com/Downloads/Selection%20control.rar&quot;&gt;http://mesta-automation.com/Downloads/Selection%20control.rar&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/6674944432506219720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/6674944432506219720?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/6674944432506219720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/6674944432506219720'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/01/data-presentation-listbox-of-checkbox.html' title='WPF Control: Listbox of checkbox with Search google-like'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiq9oP_MWKyX89wjN4K6jaRvxSyG0R4FGwz6g6MihefGqsvVBkVdqQ0X5DZ1qUKyNdgzV0R9NNAgVoDM_1Iz1SrYnLoAOXJg69lr7YTttapsbcIQsebKO3i3uCbe_zKKkKARcHztCi89Vr/s72-c/Immagine.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-7231198572052632682</id><published>2011-01-05T22:26:00.007+01:00</published><updated>2011-01-07T20:53:56.000+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="HMI"/><category scheme="http://www.blogger.com/atom/ns#" term="SCADA"/><category scheme="http://www.blogger.com/atom/ns#" term="Tips for programmers"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>A good (free) set of 240 icons</title><content type='html'>A big problem and a big waste of time for a programmer is the research of icons and images to associate to buttons, panels, toolbars and so on.&lt;br /&gt;
I really hated to do that with Google image-finder, so i searched a lot until i found a site that contained a million of icons.&lt;br /&gt;
Of course it can&#39;t exist that for every program i search in a database containing so many designs, so i want to show you a set of icons that in my opinion cover almost all that a programmer needs.&lt;br /&gt;
As usual remember that an icon should HELP the operator, not just be pretty. If you feel that the icon is not so meaningful, it&#39;s better to remove it and just leave text on the button (so the operator is forced to read it).&lt;br /&gt;
This is a small (and almost useless) preview of the set, that contains more useful icons for sure:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://icons.iconarchive.com/icons/dryicons/aesthetica-2/icons.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;123&quot; src=&quot;http://icons.iconarchive.com/icons/dryicons/aesthetica-2/icons.jpg&quot; width=&quot;400&quot; /&gt;&amp;nbsp;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;But i invite you to visit this page: &lt;b&gt;&lt;a href=&quot;http://www.iconarchive.com/category/application/aesthetica-2-icons-by-dryicons.html&quot;&gt;http://www.iconarchive.com/category/application/aesthetica-2-icons-by-dryicons.html&lt;/a&gt;&lt;/b&gt; to see the complete set (that is really big, around 240 icons).&lt;br /&gt;
I want to point the attention on some icons:&lt;br /&gt;
- &lt;b&gt;Accept&lt;/b&gt;, &lt;b&gt;Add&lt;/b&gt;, &lt;b&gt;Remove &lt;/b&gt;and &lt;b&gt;Edit &lt;/b&gt;are pretty straightforward. I think that no one can do confusion with this set of icons.&lt;br /&gt;
- &lt;b&gt;Back&lt;/b&gt;, &lt;b&gt;Next&lt;/b&gt;, &lt;b&gt;Down &lt;/b&gt;and &lt;b&gt;Top &lt;/b&gt;are pretty useful too, even if i don&#39;t like to abuse of them because they are not always understandable if the context is not well defined.&lt;br /&gt;
- &lt;b&gt;Info&lt;/b&gt;, &lt;b&gt;Help&lt;/b&gt;, &lt;b&gt;Search &lt;/b&gt;and &lt;b&gt;Warning &lt;/b&gt;are awesome. It&#39;s impossible to don&#39;t understand what they means and they are similar to windows ones too.&lt;br /&gt;
- &lt;b&gt;Lock &lt;/b&gt;- &lt;b&gt;Unlock &lt;/b&gt;icons for password login is always useful.&lt;br /&gt;
- &lt;b&gt;Charts&lt;/b&gt;, &lt;b&gt;Folders&lt;/b&gt;, &lt;b&gt;Databases&lt;/b&gt;, &lt;b&gt;Home&lt;/b&gt;, &lt;b&gt;Word &lt;/b&gt;and &lt;b&gt;Calendar &lt;/b&gt;got always a use in programs, and they are included too.&lt;br /&gt;
&lt;br /&gt;
The rest is quite trashy, or not so useful, but it always depends on what you are doing.&lt;br /&gt;
I really invite you to check out this set, &lt;b&gt;downloadable &lt;/b&gt;from the bottom of this page:&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://www.iconarchive.com/category/application/aesthetica-2-icons-by-dryicons.html&quot;&gt;http://www.iconarchive.com/category/application/aesthetica-2-icons-by-dryicons.html&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;selecting Linux (.png) files included&lt;/b&gt; (so you get the version with the set of 16x16 - 32x32 - 48x48 - 64x64 - 128x128 pixels)&lt;br /&gt;
&lt;u&gt;Remember that if you use them you should read carefully the license, that permit a free use of this set, and to respect the work of this guys.&lt;/u&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/7231198572052632682/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/7231198572052632682?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/7231198572052632682'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/7231198572052632682'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2011/01/good-set-of-icons-240-useful-icons-of.html' title='A good (free) set of 240 icons'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-4762758732490313263</id><published>2010-12-21T21:13:00.005+01:00</published><updated>2012-01-25T22:05:41.878+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="emulators"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC programming"/><category scheme="http://www.blogger.com/atom/ns#" term="Siemens"/><category scheme="http://www.blogger.com/atom/ns#" term="simulation"/><category scheme="http://www.blogger.com/atom/ns#" term="simulators"/><title type='text'>Using PLC Simulators: Testing plants without plants</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;One thing that i usually do when i program is to write test routines for the program.&lt;br /&gt;
Test routines are useful because:&lt;br /&gt;
1 - you can check how the code is running and if he has some bugs, debugging it without doing some physical damage to the plant.&lt;br /&gt;
2 - you can check if the model of the machine in your mind is similar to the real machine, seeing how the code is going and what is still needed to complete the machine.&lt;br /&gt;
3 - other people that read the program checks how &quot;it should work&quot; through the test utility, for example what input you should expect if the motor starts running, or how you control an analogic output coming from a PID, or simulate movements whit motors and encoders, and so on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On PLC there are simulators (i often use RSEmulate of Allen Bradley, because we often use their plcs) that can execute programs and &quot;force&quot; input and output, so let&#39;s see how to use them.&lt;br /&gt;
I do an example with a ladder program:&lt;br /&gt;
I have a motor (O:0/0)&amp;nbsp; that&amp;nbsp; starts when i press a button (I:0/0).&lt;br /&gt;
The motor is connected toan encoder (I:0.1) and when encoder is arrived at 14 the motor must stop his run.&lt;br /&gt;
There is an alarm sensor (I:0/1) that must block the motor if the encoder fail.&lt;br /&gt;
This is a way to do the program:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTEaU4uBY4LjkmafZ1uUEmt7Mw6y0Ipm7omOXYhI8-OGUBqGDvIIV9n4zryo6guscY5YDmDw5GV9i7yb234R77gBIUtyB4yjyZA2h1gwJg9fZxeNPecOp_5UczKg6NbER9YhJodIPtcnoU/s1600/Immagine1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;385&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTEaU4uBY4LjkmafZ1uUEmt7Mw6y0Ipm7omOXYhI8-OGUBqGDvIIV9n4zryo6guscY5YDmDw5GV9i7yb234R77gBIUtyB4yjyZA2h1gwJg9fZxeNPecOp_5UczKg6NbER9YhJodIPtcnoU/s400/Immagine1.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
And this is how i test the inputs and encoders.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3GR__o6vHHUSUllI4E_0eEbZLBtUL3dnsGWg4VZT_u7czMv8vmJVoyS8scmd5guDiATtxGyC5omxYdlx1H9ditW_AoSMTXbdcX7JKR_h8yaVNrM-R_cLAzPSILvowOybS9VsfyIFqN90I/s1600/Immagine2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3GR__o6vHHUSUllI4E_0eEbZLBtUL3dnsGWg4VZT_u7czMv8vmJVoyS8scmd5guDiATtxGyC5omxYdlx1H9ditW_AoSMTXbdcX7JKR_h8yaVNrM-R_cLAzPSILvowOybS9VsfyIFqN90I/s400/Immagine2.png&quot; width=&quot;390&quot; /&gt;&lt;/a&gt;&lt;/div&gt;It&#39;s actually easy not only to test the entire application in this way, but also to see what should happen when the motor starts, and when it should stop.&lt;br /&gt;
&lt;br /&gt;
If you upload a program with a Test Routine (that of course is disabled), you can also understand in a easier way how the program works and save a lot of time, and there is not necessity of calling the constructor&#39;s assistance (that fired is main programmer 10 days ago and that is still searching for a cheap one, as usually).&lt;br /&gt;
&lt;br /&gt;
I add a solution for RsLogix 500, that can be emulated and tested with RsEmulate 500.&lt;br /&gt;
For &lt;b&gt;Siemens &lt;/b&gt;users, try to do this with the simulator of Step 7, and if you can&#39;t force Inputs automatically, just use&amp;nbsp; a DB and put in parallel test bits / words and merkers.&lt;br /&gt;
&lt;br /&gt;
Hope this post can be useful for someone, the program for RsLogix 500 can be found here:&lt;br /&gt;
&lt;a href=&quot;http://www.mesta-automation.com/Downloads/ProcessSimulation.rar&quot;&gt;http://www.mesta-automation.com/Downloads/ProcessSimulation.rar&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/4762758732490313263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/4762758732490313263?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/4762758732490313263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/4762758732490313263'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/12/using-plc-simulators-testing-plants.html' title='Using PLC Simulators: Testing plants without plants'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTEaU4uBY4LjkmafZ1uUEmt7Mw6y0Ipm7omOXYhI8-OGUBqGDvIIV9n4zryo6guscY5YDmDw5GV9i7yb234R77gBIUtyB4yjyZA2h1gwJg9fZxeNPecOp_5UczKg6NbER9YhJodIPtcnoU/s72-c/Immagine1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-980389542237865558</id><published>2010-12-20T22:05:00.006+01:00</published><updated>2011-08-24T08:32:05.442+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="Siemens"/><title type='text'>C# and Siemens PLC: LIBNODAVE</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Usually i work with Allen Bradley PLCs, but most of PLC&#39;s programmers use Siemens PLC.&lt;br /&gt;
One thing that i really appreciate of Siemens is the possibility to connect a PC to PLC in a total FREE way, using LIBNODAVE.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://www.kollewin.com/EX/09-15-07/200878163550227.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;http://www.kollewin.com/EX/09-15-07/200878163550227.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Libnodave is a free library compiled in some programming languages (C, C++, C# etc...) that permit to exchange data with Siemens PLC for free and to embed the driver in&amp;nbsp; the program.&lt;br /&gt;
You just have to add as reference the &lt;u&gt;libnodave.Net.dll&lt;/u&gt; and start to read and write data using the simple samples inside the docs.&lt;br /&gt;
The main page of libnodave is here:&lt;br /&gt;
&lt;a href=&quot;http://libnodave.sourceforge.net/&quot;&gt;http://libnodave.sourceforge.net/&lt;/a&gt;&lt;br /&gt;
and the download page of the full package is here:&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/libnodave/&quot;&gt;http://sourceforge.net/projects/libnodave/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
At the moment they have developed the version 0.8.4.5, but the project is still alive and healty.&lt;br /&gt;
There is also an help forum here:&lt;br /&gt;
&lt;a href=&quot;http://sourceforge.net/projects/libnodave/forums/forum/205657&quot;&gt;http://sourceforge.net/projects/libnodave/forums/forum/205657&lt;/a&gt;&lt;br /&gt;
that can help who is having troubles while writing is first driver.&lt;br /&gt;
&lt;br /&gt;
As usual, once you wrote how to communicate with the PLC, you can fire an event of &quot;DataChanged&quot; and use it to update your WPF UI with databinding, as seen in the previous posts.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;UPDATE&lt;/b&gt;: You can find a project contaning some communication samples on &lt;a href=&quot;http://siemensplctoolboxlib.codeplex.com/&quot;&gt;http://siemensplctoolboxlib.codeplex.com/&lt;/a&gt; . It&#39;s one layer above&amp;nbsp; libnodave and it&#39;s possible to download the the source code.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/980389542237865558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/980389542237865558?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/980389542237865558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/980389542237865558'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/12/c-and-siemens-plc-libnodave.html' title='C# and Siemens PLC: LIBNODAVE'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-3750475327697765951</id><published>2010-12-15T22:41:00.011+01:00</published><updated>2012-01-25T21:58:55.638+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Allen Bradley"/><category scheme="http://www.blogger.com/atom/ns#" term="c#"/><category scheme="http://www.blogger.com/atom/ns#" term="OPC Client"/><category scheme="http://www.blogger.com/atom/ns#" term="RSLinx"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>WPF and OPC: a full sample project with RSLinx and databinding</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;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.&lt;br /&gt;
&lt;br /&gt;
As usual i have my 2 tanks and i want to read what liquid is inside every tank (defined as 16bit integer).&lt;br /&gt;
1st tank word is N7:0, second is N7:1&lt;br /&gt;
For each tank there is a button that changes its content(writing the PLC word).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
This objects are defined in the OPC Client class and they are defined as &quot;public&quot;&amp;nbsp; because i want to access their properties from every window that needs to display real time values or to control them.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY4A5Lyfk6wk_NvhAQ7k7Xg1g-VE9GFs1vXAL38zQtxoFv1KteFYKfQdETdPUfGPHnlGNLSxHZq_pBu51HMj68zgVxra66lUKdBjNzVyZiwpcedwsHBO_0XcGmKwfKFC8Lz-F5fPaF5ZdG/s1600/Immagine4.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;491&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY4A5Lyfk6wk_NvhAQ7k7Xg1g-VE9GFs1vXAL38zQtxoFv1KteFYKfQdETdPUfGPHnlGNLSxHZq_pBu51HMj68zgVxra66lUKdBjNzVyZiwpcedwsHBO_0XcGmKwfKFC8Lz-F5fPaF5ZdG/s640/Immagine4.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
This is the MainWindow, where the program begin and where i create the opcclient object as static.&lt;br /&gt;
To access to it&#39;s properties i just need to bind UI items by databinding.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9UNL86GECQtesMM2tHzidvpuGfs0uoIM6yyuxErANcnfjy127EzUA_g5Kg4V9WrvIEJ1d5cYtYJDomxDB0XOXUhCOdcaDSSd6qulBRWrNr8m0cL8UtA7wPNriEN8aEtCH28ax48qtUjRw/s1600/Immagine5.png&quot; /&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;/div&gt;&lt;br /&gt;
To access the properties of objects in another window or page, i do like in this example.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ7Y5xFE1tP9picp02yz1f9q9YFP2ObDT8NPiyv2_Qne59T37kq4DTznaqcSB79IU61CvS13IBCQ3IOtUim-S0a2MUIiQih9bIH_O22-QZWZ8roFF8xUZs_gLEMMhFv3E7lNtl53OKZYIk/s1600/Immagine6.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQ7Y5xFE1tP9picp02yz1f9q9YFP2ObDT8NPiyv2_Qne59T37kq4DTznaqcSB79IU61CvS13IBCQ3IOtUim-S0a2MUIiQih9bIH_O22-QZWZ8roFF8xUZs_gLEMMhFv3E7lNtl53OKZYIk/s1600/Immagine6.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
And this is the final result&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzBtrVCMVJ3b3A96mwJtvX-3TFFV_118KWBE4pbWAUJX9BHF8l3WFbfy-Z698iNKli1BnNEYL3wE5DlELWegZSIlYNctBSMuGxo7dHNdPoF7FGGidH9UabP1pGwBFILLBrhjkD5pD1vPLw/s1600/Immagine.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzBtrVCMVJ3b3A96mwJtvX-3TFFV_118KWBE4pbWAUJX9BHF8l3WFbfy-Z698iNKli1BnNEYL3wE5DlELWegZSIlYNctBSMuGxo7dHNdPoF7FGGidH9UabP1pGwBFILLBrhjkD5pD1vPLw/s640/Immagine.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This is how the setup for PLC OPC Server, that should be called as [UNTITLED_2]&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEmVAoazFIJKrUuuespkgXwBQ1722jQMrHFZcr2HU0eCO0TppVeQOudtEshRPdycU-DzxUayE8I9ZISEg_uo9q6SKYX9NmxLHlMpaH-EqXieEjTg5D_sEBr1eVqezPIpVlsJGsje8ii3eS/s1600/Immagine2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;310&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEmVAoazFIJKrUuuespkgXwBQ1722jQMrHFZcr2HU0eCO0TppVeQOudtEshRPdycU-DzxUayE8I9ZISEg_uo9q6SKYX9NmxLHlMpaH-EqXieEjTg5D_sEBr1eVqezPIpVlsJGsje8ii3eS/s640/Immagine2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii-r1evtNszwmRS6LzggtXvQvZXGE47nx9UZdsyO511M7mi00dbcXhSiLxoLT1Pc2kJF5FK25RYPQGxnSwpmKWOsd3efL3THT_eKiNn5ZuoEXE2f7nLUBk7Bf0gVGsz3J5GI0jAWHwH0eu/s1600/Immagine3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;484&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii-r1evtNszwmRS6LzggtXvQvZXGE47nx9UZdsyO511M7mi00dbcXhSiLxoLT1Pc2kJF5FK25RYPQGxnSwpmKWOsd3efL3THT_eKiNn5ZuoEXE2f7nLUBk7Bf0gVGsz3J5GI0jAWHwH0eu/s640/Immagine3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Hope it&#39;s helpful.&lt;br /&gt;
Full solution here:&lt;br /&gt;
&lt;a href=&quot;http://depositfiles.com/files/bfiwxd7av&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mesta-automation.com/Downloads/opc%20sample%202.rar&quot;&gt;http://www.mesta-automation.com/Downloads/opc%20sample%202.rar&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Previus post describe more in details what&#39;s used in this example, if you&#39;re interested.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/3750475327697765951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/3750475327697765951?isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/3750475327697765951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/3750475327697765951'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/12/wpf-and-opc-full-sample-project-with.html' title='WPF and OPC: a full sample project with RSLinx and databinding'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY4A5Lyfk6wk_NvhAQ7k7Xg1g-VE9GFs1vXAL38zQtxoFv1KteFYKfQdETdPUfGPHnlGNLSxHZq_pBu51HMj68zgVxra66lUKdBjNzVyZiwpcedwsHBO_0XcGmKwfKFC8Lz-F5fPaF5ZdG/s72-c/Immagine4.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-2059178501803585835</id><published>2010-12-03T21:22:00.012+01:00</published><updated>2012-01-25T22:07:28.492+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Databinding"/><category scheme="http://www.blogger.com/atom/ns#" term="PLC"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Databinding #3: binding directly to a Property with INotifyPropertyChanged</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Hi,&lt;br /&gt;
this is the last part about databinding.&lt;br /&gt;
You can find the 1st part &lt;a href=&quot;http://mestaa.blogspot.com/2010/11/why-wpf-for-automation-observable.html&quot;&gt;here&lt;/a&gt; and the 2nd part &lt;a href=&quot;http://mestaa.blogspot.com/2010/11/databinding-2-and-itemstemplate-why-we.html&quot;&gt;here&lt;/a&gt;.&amp;nbsp; &lt;br /&gt;
We saw how to bind UI controls on UI elements and on elements that belongs to a collection.&lt;br /&gt;
We noticed also that when an observable collection changes(if one item get added or removed), is changes also the UI elements in bind with the collection; the limit of observable collection is that if i change a property in a element inside it, it doesn&#39;t update it.&lt;br /&gt;
To do this update of property inside elements of a collection, we need to implement an interface, called INotifyPropertyChanged, that fires an event when the property changes, updating all the elements that are in bind with it.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s analyse an example:&lt;br /&gt;
i 2 tanks, and i have a collection of 2 liquid (liquid[0] and liquid[1]). &lt;br /&gt;
Liquid[0] is the content inside the 1st tank, liquid[1] is the content inside the 2nd tank.&lt;br /&gt;
I want to change the color (or state) of content changing the property inside the class, and i want that the UI updates the color when it changes of course.&lt;br /&gt;
Let&#39;s write the new class for the content:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 300px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;class Liquid:System.ComponentModel.INotifyPropertyChanged
{
public string Name { get; private set; }

private SolidColorBrush liquidColor;
public SolidColorBrush LiquidColor { 
get
{
return liquidColor;
}
&lt;b&gt;private set 
{ 
liquidColor = value; 
this.OnPropertyChanged(&quot;LiquidColor&quot;);
}
}&lt;/b&gt;

public Liquid(string name, Color color) 
{
this.Name = name;
this.LiquidColor = new SolidColorBrush(color);            
}

public void Change(SolidColorBrush newColor) 
{
this.LiquidColor = newColor; 
}

&lt;b&gt;public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}&lt;/b&gt;&lt;/pre&gt;&lt;br /&gt;
This is the implementation if INotifyPropertyChanged.&lt;br /&gt;
In the bottom part there is the definition of the event that i throw, and inside the declaration of the property LiquidColor i throw the event every time that this the property changes.&lt;br /&gt;
Then i added a method Change, that changes the color with a new one.&lt;br /&gt;
&lt;br /&gt;
Let&#39;s define a liquid collection:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;class LiquidCollection:ObservableCollection&lt;liquid&gt;

{

public LiquidCollection() 

{ 

this.Add(new Liquid(&quot;Liquid Silos 1&quot;, Colors.Aqua));

this.Add(new Liquid(&quot;Liquid Silos 2&quot;, Colors.Orange));

}

}

&lt;/liquid&gt;&lt;/pre&gt;&lt;br /&gt;
Datacontest:&lt;liquid&gt;&lt;/liquid&gt;&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;public MainWindow()

{

InitializeComponent();



LiquidCollection liquids = new LiquidCollection();

ellipseSilos1.DataContext = liquids[0];

ellipseSilos2.DataContext = liquids[1];

}

&lt;/pre&gt;&lt;br /&gt;
and 2 button&#39;s callbacks that change colors to each silos:&lt;liquid&gt;&lt;/liquid&gt;&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;private void btnChangeS1_Click(object sender, RoutedEventArgs e)

{

((Liquid)ellipseSilos1.DataContext).Change(colors[i]);

if (i &amp;lt; 10) i++; else i = 0;

}



private void btnChangeS2_Click(object sender, RoutedEventArgs e)

{

((Liquid)ellipseSilos2.DataContext).Change(colors[i]);

if (i &amp;lt; 10) i++; else i = 0;

}

&lt;/pre&gt;&lt;br /&gt;
UI Databinding now refers directly to the property that changes:&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4rMa1EMu_zNGIFfKdeGCWcdtO7OrNys-_vZ6PM2jxC7qZw3UxJTR6s3spSxj_p-6i8sB5OVwwy4sZe-a3UVR0DiSfcbajEq7ChFs7R1M0_-1mAkD4ugy-eldKX9aRe94uDq4wlNjV2ZOM/s1600/Immagine1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;64&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4rMa1EMu_zNGIFfKdeGCWcdtO7OrNys-_vZ6PM2jxC7qZw3UxJTR6s3spSxj_p-6i8sB5OVwwy4sZe-a3UVR0DiSfcbajEq7ChFs7R1M0_-1mAkD4ugy-eldKX9aRe94uDq4wlNjV2ZOM/s640/Immagine1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;liquid&gt; &lt;br /&gt;
And we have the UI update when property changes inside the collection.&lt;/liquid&gt;&lt;br /&gt;
&lt;liquid&gt;&lt;/liquid&gt;&lt;br /&gt;
&lt;liquid&gt;&lt;/liquid&gt;&lt;br /&gt;
&lt;liquid&gt;As usual the complete solution can be found here:&amp;nbsp;&lt;/liquid&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.mesta-automation.com/Downloads/Databinding3.rar&quot;&gt;http://www.mesta-automation.com/Downloads/Databinding3.rar&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;liquid&gt;Next post i&#39;ll make a simple project in wpf  where i connect an opc server to the UI through databinding.&lt;br /&gt;
&lt;br /&gt;
&lt;/liquid&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/2059178501803585835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/2059178501803585835?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/2059178501803585835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/2059178501803585835'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/12/databinding-3-last-binding-directly-to.html' title='Databinding #3: binding directly to a Property with INotifyPropertyChanged'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4rMa1EMu_zNGIFfKdeGCWcdtO7OrNys-_vZ6PM2jxC7qZw3UxJTR6s3spSxj_p-6i8sB5OVwwy4sZe-a3UVR0DiSfcbajEq7ChFs7R1M0_-1mAkD4ugy-eldKX9aRe94uDq4wlNjV2ZOM/s72-c/Immagine1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-918867765576883076</id><published>2010-11-29T21:20:00.013+01:00</published><updated>2012-01-25T22:07:59.371+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Databinding"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Databinding #2 and ItemsTemplate: why we use observable collection and the 1st try to give a representation of an object</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is the 2nd article about databinding.&lt;br /&gt;
The 1st can be found &lt;a href=&quot;http://mestaa.blogspot.com/2010/11/why-wpf-for-automation-observable.html&quot;&gt;here &lt;/a&gt;and the 3rd &lt;a href=&quot;http://mestaa.blogspot.com/2010/12/databinding-3-last-binding-directly-to.html&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
As the name says, observable collection is a collection that send an event when items are added or removed from it.&lt;br /&gt;
This is really useful in automation for manage recipes for examples, but basically you can manage everything: it can be also a collection of machines, a collection of silos, and so on.&lt;br /&gt;
I use observable collection a lot for charts and to manage big lists of similar items.&lt;br /&gt;
&lt;br /&gt;
This is an example on how to use an observable collection:&lt;br /&gt;
Let&#39;s suppose that i have my usual tank, like in the previous example, and i want to add some new liquids to the listbox, and i want also to remove them.&lt;br /&gt;
Of course i want to see changes in real time, and i want to write as less code as possible.&lt;br /&gt;
&lt;br /&gt;
So as usual i define my data class:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;class Liquid
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; private set; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public SolidColorBrush LiquidColor { get; private set; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Liquid(string name, Color color) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Name = name;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.LiquidColor = new SolidColorBrush(color);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;/pre&gt;&lt;br /&gt;
And my observable collection of liquids, with 3 samples :&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; class LiquidCollection : ObservableCollection&lt;liquid&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public LiquidCollection() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&lt;/liquid&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(EmptyCilinder());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(OrangeLiquid());&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Liquid EmptyCilinder()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp; return new Liquid(&quot;Empty Cilinder&quot;, Colors.Gray);&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Liquid OrangeLiquid()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp; return new Liquid(&quot;Orange liquid&quot;, Colors.Orange); }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/pre&gt;&lt;br /&gt;
Then i add a custom color collection where i cover all the colors:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;class CustomColorCollection : ObservableCollection&lt;solidcolorbrush&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public CustomColorCollection() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(new SolidColorBrush(Colors.Aqua));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ....
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(new SolidColorBrush(Colors.Gold));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/solidcolorbrush&gt;&lt;/pre&gt;&lt;br /&gt;
Then i place 2 listbox, 1 textbox and 2 buttons in the User Interface, in the code behing as usual i set the datacontext:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;public MainWindow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstSelectColor.DataContext = new LiquidCollection();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstLiquidColors.DataContext = new CustomColorCollection();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;&lt;br /&gt;
and the 2 buttons callback:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 100px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;private void btnAddLiquid_Click(object sender, RoutedEventArgs e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
((LiquidCollection)lstSelectColor.DataContext).Add(new Liquid(txtNameNewLiquid.Text,&amp;nbsp;&amp;nbsp;&amp;nbsp; ((SolidColorBrush)lstLiquidColors.SelectedItem).Color));
}

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private void btnRemoveLiquid_Click(object sender, RoutedEventArgs e)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
((LiquidCollection)lstSelectColor.DataContext).Remove((Liquid)lstSelectColor.SelectedItem);
}&lt;/pre&gt;&lt;br /&gt;
And this is the UI (to binding items refere at the post of databinding #1):&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv9DymZbXSHGzHxbDZttS0riFQujymDh2miwSkHge1trsVSF40MGDhyM8hOomNJo4WAWTNbzzKeXMkK3GAQwgLy6yCt38DWBq5rYIsCm_KFFEFZUuhkU1HZlEq88BtixVeH6NEckrpGIYM/s1600/Immagine2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;254&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv9DymZbXSHGzHxbDZttS0riFQujymDh2miwSkHge1trsVSF40MGDhyM8hOomNJo4WAWTNbzzKeXMkK3GAQwgLy6yCt38DWBq5rYIsCm_KFFEFZUuhkU1HZlEq88BtixVeH6NEckrpGIYM/s640/Immagine2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
Compiling and running i obtain what i want, so i have a list of colors and a list of liquids that i can update, adding or removing.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSnaDMXkpzW6l9m44Ad5_oSb-jCkl03hcvNuumQJtUfkCG4jzw7QuSU-6KCI2StPvrHE9iShgkIn-aesVBb04XB_jYaI2gHpwEYUOS9IdQsXkErkC8FsT_Gfsh_t5Nz3CEn6qpDmKU-EGd/s1600/Immagine1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;297&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSnaDMXkpzW6l9m44Ad5_oSb-jCkl03hcvNuumQJtUfkCG4jzw7QuSU-6KCI2StPvrHE9iShgkIn-aesVBb04XB_jYaI2gHpwEYUOS9IdQsXkErkC8FsT_Gfsh_t5Nz3CEn6qpDmKU-EGd/s640/Immagine1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The only problem is that the list of color sux. In this case we need to use an ItemTemplate to give a representation of an object Color in the listbox.&lt;br /&gt;
&lt;br /&gt;
A good way can be represent it on a rectangle, and this could be done in this way:&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPEYX_6zovhfWTOvg_iBsW1wQFyCmf2bInZFcYkorUFkd-ayrhINUkvn8eVXZ3CHMAfS3z_ZpGY-rgPLwe_tuko00G_RXbWCY1jCznXwN93ZPbJ4-hH_YppMBXMl-IjnSobrOJO1s5g1uQ/s1600/Immagine4.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;88&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPEYX_6zovhfWTOvg_iBsW1wQFyCmf2bInZFcYkorUFkd-ayrhINUkvn8eVXZ3CHMAfS3z_ZpGY-rgPLwe_tuko00G_RXbWCY1jCznXwN93ZPbJ4-hH_YppMBXMl-IjnSobrOJO1s5g1uQ/s640/Immagine4.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
If we compile and debug we obtain something better, that it&#39;s similar to this: &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRF9ktpJYrf0zGDAh8OdMCn13XYgMriXe_YpKScpTS1NgNyTs5bx7tsZzD1wkXE_pJG81ZnVwY_Ddy5L9Zy-V171LzYBbgK5mwPVMX9-mxINB-cXcBsJXt6XS046ZNE6aVrO4Q9Ui6k25c/s1600/Immagine3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;297&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRF9ktpJYrf0zGDAh8OdMCn13XYgMriXe_YpKScpTS1NgNyTs5bx7tsZzD1wkXE_pJG81ZnVwY_Ddy5L9Zy-V171LzYBbgK5mwPVMX9-mxINB-cXcBsJXt6XS046ZNE6aVrO4Q9Ui6k25c/s640/Immagine3.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;I think that doing this with winforms it&#39;s really hard, but with WPF and a bit of imagination it will take not so much time, and the final users will be happier than to see a listbox with &quot;Green - Dark Green - Light Green - Purple - and so on...&quot;&lt;br /&gt;
&lt;br /&gt;
As usual you can find the full solution here:&lt;br /&gt;
&lt;a href=&quot;http://mesta-automation.com/Downloads/databinding2.rar&quot;&gt;http://mesta-automation.com/Downloads/databinding2.rar&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/918867765576883076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/918867765576883076?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/918867765576883076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/918867765576883076'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/11/databinding-2-and-itemstemplate-why-we.html' title='Databinding #2 and ItemsTemplate: why we use observable collection and the 1st try to give a representation of an object'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv9DymZbXSHGzHxbDZttS0riFQujymDh2miwSkHge1trsVSF40MGDhyM8hOomNJo4WAWTNbzzKeXMkK3GAQwgLy6yCt38DWBq5rYIsCm_KFFEFZUuhkU1HZlEq88BtixVeH6NEckrpGIYM/s72-c/Immagine2.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-8441272728514317048</id><published>2010-11-28T23:08:00.004+01:00</published><updated>2010-12-19T17:20:52.651+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Tips for programmers"/><title type='text'>Comments on code are good or bad ?</title><content type='html'>In this days i read a discussion on a forum between some programmers and they were discussing about &quot;Write or not to write comments on programs&quot;.&lt;br /&gt;
The discussion result wasn&#39;t so obvious, because many of them said that comments were not only useless, but also dangerous, and in the most of cases it would be better if they weren&#39;t ever written.&lt;br /&gt;
&lt;br /&gt;
This is an example of bad comments:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 20px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;&lt;b&gt;channel++;   //increment channel&lt;/b&gt; &lt;/pre&gt;&lt;br /&gt;
The good thing about this line was that both the code and the comment  agreed (experience shows this is quite often not the case). The bad  thing about this code is that they are both wrong, the problem being  that the original coder didn&#39;t understand the difference between channel  and timeslot [2] and chose the wrong variable name. Fortunately, when  he (or someone who came along later) realised the mistake he used a  snazzy re-factoring tool that avoids the problems with global &lt;b&gt;&quot;find and  replace&quot;&lt;/b&gt; and understands the code enough to only change the relevant  variable name and not other occurrences of the string or the same name  in another scope. The code now reads: &lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 20px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;&lt;b&gt; timeslot++;      //increment channel&lt;/b&gt; &lt;/pre&gt;&lt;br /&gt;
You might ask why the re-factoring programmer didn&#39;t change the comment  to match and it was because he wasn&#39;t looking at that particular line,  but at this one:&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 20px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;&lt;b&gt; uint32_t channel; // I think this is probably timeslot, not channel.&lt;/b&gt; &lt;/pre&gt;&lt;br /&gt;
The first person to come along realised the poor choice of variable name  and &quot;fixed&quot; it by adding a comment. The second decided it would be  better to change the variable name. Obviously, the second programmer  believes in saying it in the code and disregarding comments, because the  changed line now reads:  &lt;b&gt;uint32_t timeslot;  // I think this is probably // timeslot, not channel.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
So what&#39;s the truth about comments? is it better to write them or not ?&lt;br /&gt;
Another example can be this:&lt;b&gt;&lt;/b&gt;  &lt;br /&gt;
&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 98px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;r = n / 2;
while ( abs( r - (n/r) ) &amp;gt; t ) {
  r = 0.5 * ( r + (n/r) );
}
System.out.println( &quot;r = &quot; + r );&lt;/pre&gt;&lt;br /&gt;
Any idea what that bit of code does? It&#39;s perfectly readable, but what the heck does it do?  Let&#39;s add a comment.&lt;br /&gt;
&lt;div style=&quot;margin: 5px 20px 20px;&quot;&gt;&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 114px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;// square root of n with Newton-Raphson approximation
r = n / 2;
while ( abs( r - (n/r) ) &amp;gt; t ) {
  r = 0.5 * ( r + (n/r) );
}
System.out.println( &quot;r = &quot; + r );&lt;/pre&gt;&lt;/div&gt;That must be what I was getting at, right? Some sort of pleasant,  middle-of-the-road compromise between the two polar extremes of no  comments whatsoever and carefully formatted epic poems every second line  of code?  Not exactly. Rather than add a comment, I&#39;d refactor to this: &lt;br /&gt;
&lt;div style=&quot;margin: 5px 20px 20px;&quot;&gt;&lt;div class=&quot;smallfont&quot; style=&quot;margin-bottom: 2px;&quot;&gt;Codice:&lt;/div&gt;&lt;pre class=&quot;alt2&quot; dir=&quot;ltr&quot; style=&quot;border: 1px inset; height: 146px; margin: 0px; overflow: auto; padding: 6px; text-align: left; width: 640px;&quot;&gt;private double SquareRootApproximation(n) {
  r = n / 2;
  while ( abs( r - (n/r) ) &amp;gt; t ) {
    r = 0.5 * ( r + (n/r) );
  }
  return r;
}
System.out.println( &quot;r = &quot; + SquareRootApproximation(r) );&lt;/pre&gt;&lt;/div&gt;I haven&#39;t added a single comment, and yet this mysterious bit of code is now perfectly understandable.&lt;br /&gt;
&lt;br /&gt;
This guy (&lt;a href=&quot;http://www.makinggoodsoftware.com/2009/06/04/10-commandments-for-creating-good-code/&quot;&gt;http://www.makinggoodsoftware.com&lt;/a&gt;), that got a blog where he writes about tips to make a good code, wrote an interesting page on &quot;writing comments or not&quot;, and you can find his article here:&lt;br /&gt;
&lt;a href=&quot;http://www.makinggoodsoftware.com/2009/06/06/comments-are-evil/&quot;&gt;http://www.makinggoodsoftware.com/2009/06/06/comments-are-evil/&lt;/a&gt;&lt;br /&gt;
where he basically says that:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;The worst code is: Bad code without comments.&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Bad code is: Bad code with comments.&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;The average code is: Average code with comments.&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;Good code is: Good code with a few comments…&lt;/li&gt;
&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;…but… Great code doesn’t need comments!!!&lt;/li&gt;
&lt;/ul&gt;And he gives some advices on how to increase the readiblilty:&lt;br /&gt;
&lt;a href=&quot;http://www.makinggoodsoftware.com/2009/06/22/how-to-write-readable-code/&quot;&gt;http://www.makinggoodsoftware.com/2009/06/22/how-to-write-readable-code/&lt;/a&gt;&lt;br /&gt;
and&lt;br /&gt;
&lt;a href=&quot;http://www.makinggoodsoftware.com/2009/06/04/10-commandments-for-creating-good-code/&quot;&gt;http://www.makinggoodsoftware.com/2009/06/04/10-commandments-for-creating-good-code/&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
It&#39;s important to keep improving our code, to help us and other people mantaining the applications.</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/8441272728514317048/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/8441272728514317048?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/8441272728514317048'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/8441272728514317048'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/11/comments-on-code-is-good-or-bad.html' title='Comments on code are good or bad ?'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5610484095461596271.post-3236543581292913637</id><published>2010-11-26T22:29:00.017+01:00</published><updated>2011-02-17T21:28:52.609+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Databinding"/><category scheme="http://www.blogger.com/atom/ns#" term="WPF"/><title type='text'>Why WPF for automation? Databinding #1</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This is the 1st article of 3 about DataBinding.&lt;br /&gt;
Check the 2nd &lt;a href=&quot;http://mestaa.blogspot.com/2010/11/databinding-2-and-itemstemplate-why-we.html&quot;&gt;here &lt;/a&gt;and the 3rd &lt;a href=&quot;http://mestaa.blogspot.com/2010/12/databinding-3-last-binding-directly-to.html&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
It&#39;s clear that WPF has a better graphic and appearence, with all of those gradients, animations and so on, but what are the real benefits for a programmer ?&lt;br /&gt;
The Page-Switch application was a good start, but why should we learn xaml (that is also a new concept and quite hard) instead of using our loved winforms and GDI ?&lt;br /&gt;
I think that the best reason to learn WPF is that it permits to build &lt;u&gt;&lt;b&gt;easy-to-use&lt;/b&gt;&lt;/u&gt; and &lt;u&gt;&lt;b&gt;self-explained &lt;/b&gt;&lt;/u&gt;interfaces for operators, with really little code-writing.&lt;br /&gt;
Let&#39;s suppose that i wanted to display lisbox of radiobuttons, or treeview of checkbox... it would be hard to write this controls in winforms and they would have a lot of bugs inside.&lt;br /&gt;
That&#39;s why winforms got a lot of custom control (not free of course) around the ne. &lt;br /&gt;
In WPF, thanks to a pattern that separates graphics from code-behind, it&#39;s possible to have complex controls with not many troubles. &lt;br /&gt;
Model - View - View Model is the pattern that permit to developpers to separate physically the User Interface part from the code behind, and this is possible because of a powerful concept on wich WPF is based: DataBinding.&lt;br /&gt;
&lt;br /&gt;
Basically Model - View - View Model consist in this: &lt;br /&gt;
&lt;b&gt;Model &lt;/b&gt;: all the codebehind, services and so on&amp;nbsp; that permit to the application to run (like the code that was written in winforms) &lt;br /&gt;
&lt;b&gt;View&lt;/b&gt;: the User Interface, all the code that we write in XAML. &lt;br /&gt;
&lt;b&gt;View Model&lt;/b&gt;: this is new, this is the layer between UI and code behind, it&#39;s based on data binding and it save us a lot of code that can have a lot of bugs, and it&#39;s usually the code that connects the UI with business objects. One important fact to keep in mind is that in automation we have tons of controls to display tons of values, infact usually little scada and HMI displays timers, analogic values, alarms and some output status, but in bigger ones there are a lot of other factor too, like keeping track of values while time changes and so on. View Model permit to connect the User Interface with Objects, that can come for example from an OPC Client, with really little code. &lt;br /&gt;
&lt;br /&gt;
To explain it better i&#39;ll make an example:&lt;br /&gt;
I want to fill a tank (here is designed really poorly) with a liquid that i select from a listbox, and i want to see the tank changing color when i change its content.&lt;br /&gt;
I don&#39;t want to use events and a lot of code to do this thing, also i want to define a class Liquid and a collection of them, because they can change during production, and i would like to update them easily.&lt;br /&gt;
&lt;br /&gt;
So let&#39;s write the liquid class:&lt;br /&gt;
&lt;b&gt;using System.Windows.Media;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;namespace SilosSample.Data&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; class Liquid&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string Name { get; private set; } //name of liquid&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public LinearGradientBrush LiquidColor { get; private set; } //color&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public Liquid(string name, GradientStopCollection _gradStopCollection) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Name = name;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.LiquidColor = new LinearGradientBrush(_gradStopCollection);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Then fill the collection (in reality members would be taken from a database, with more parameters than a name and a color)&lt;br /&gt;
&lt;b&gt;using System.Collections.ObjectModel;&lt;br /&gt;
using System.Windows.Media;&lt;br /&gt;
using SilosSample.Data;&lt;br /&gt;
namespace SilosSample.ViewModel&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; class LinearGradientCollection : ObservableCollection&lt;liquid&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public LinearGradientCollection() &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(EmptyCilinder());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(Water());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.Add(OrangeLiquid());&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Liquid EmptyCilinder()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GradientStopCollection gradStopCollection = new GradientStopCollection();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add( new GradientStop(Colors.LightGray,0));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.Black, 0.992));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.DarkGray, 0.125));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.Gray, 0.802));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Liquid(&quot;Empty Cilinder&quot;, gradStopCollection);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Liquid Water()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GradientStopCollection gradStopCollection = new GradientStopCollection();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.LightCyan, 0));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.DarkBlue, 0.992));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Liquid(&quot;Water&quot;, gradStopCollection);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Liquid OrangeLiquid()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GradientStopCollection gradStopCollection = new GradientStopCollection();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.LightCoral, 0));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gradStopCollection.Add(new GradientStop(Colors.Orange, 0.992));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new Liquid(&quot;Orange liquid&quot;, gradStopCollection);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/liquid&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Sn6vwD5Hzg_9bzRFl8i_XBH4J_G2XXpPLCX7oIuj5YNCpaXhGG_UPtLumeTW40R__y_vM2tvjXricEGSk5eJ0U6cEZ8T19aN8wNPSY2MMevVgS7Q-jYxx1SXWK5CiOCoHwxmR05bXdkE/s1600/Immagine1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;And now i want to connect(to &lt;u&gt;bind&lt;/u&gt;) my user interface to the collection.&lt;br /&gt;
this is done in this way:&lt;br /&gt;
define a datacontext (it&#39;s the datasource, in this case my collection of colors) in the codebehind&amp;nbsp; for the listbox:&lt;br /&gt;
&lt;b&gt;public partial class MainWindow : Window&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MainWindow()&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; InitializeComponent();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;u&gt;&amp;nbsp; lstSelectColor.DataContext = new LinearGradientCollection(); &lt;/u&gt;&lt;/b&gt;//my collection &amp;nbsp;&lt;b&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;br /&gt;
Then write the User Interface and bind the properties that you want to control directly with XAML:&lt;br /&gt;
in this case i wanted that my listbox contains the collection (so datasource was in bind with all the datacontext), i wanted to display only the name (displayMemberPath is always the same as old one), and i wanted to synchronize the current element with the rest of the window, so i can update my controls without writing a single line of code.&lt;br /&gt;
Then to fill the silos there, i just need to bind the property &quot;Fill&quot; at the selected item of the listbox, just as it&#39;s written in the code.&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Sn6vwD5Hzg_9bzRFl8i_XBH4J_G2XXpPLCX7oIuj5YNCpaXhGG_UPtLumeTW40R__y_vM2tvjXricEGSk5eJ0U6cEZ8T19aN8wNPSY2MMevVgS7Q-jYxx1SXWK5CiOCoHwxmR05bXdkE/s1600/Immagine1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;379&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Sn6vwD5Hzg_9bzRFl8i_XBH4J_G2XXpPLCX7oIuj5YNCpaXhGG_UPtLumeTW40R__y_vM2tvjXricEGSk5eJ0U6cEZ8T19aN8wNPSY2MMevVgS7Q-jYxx1SXWK5CiOCoHwxmR05bXdkE/s640/Immagine1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
This is really a simple example, but it&#39;s amazing how powerful it is WPF and how little code you have to write to obtain sophisticated controls.&lt;br /&gt;
In a future post i&#39;ll cover also the interface &quot;INotifyPropertyChanged&quot;, that permit to update an item in a collection and also the items in bind with it (example: i have a collection of silos and i want to update the color of one of them).&lt;br /&gt;
&lt;br /&gt;
As usual i add the complete solution:&lt;a href=&quot;http://www.megaupload.com/?d=IQUX2NVX&quot;&gt;http://www.megaupload.com/?d=IQUX2NVX&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To see more about ObservableCollection, INotifyPropertyChanged and normal collections, see this post: &lt;a href=&quot;http://www.codeproject.com/KB/silverlight/SLListVsOCollections.aspx&quot;&gt;http://www.codeproject.com/KB/silverlight/SLListVsOCollections.aspx&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mestaa.blogspot.com/feeds/3236543581292913637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/5610484095461596271/3236543581292913637?isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/3236543581292913637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5610484095461596271/posts/default/3236543581292913637'/><link rel='alternate' type='text/html' href='http://mestaa.blogspot.com/2010/11/why-wpf-for-automation-observable.html' title='Why WPF for automation? Databinding #1'/><author><name>Michele Cattafesta</name><uri>http://www.blogger.com/profile/02322523612164607164</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7Sn6vwD5Hzg_9bzRFl8i_XBH4J_G2XXpPLCX7oIuj5YNCpaXhGG_UPtLumeTW40R__y_vM2tvjXricEGSk5eJ0U6cEZ8T19aN8wNPSY2MMevVgS7Q-jYxx1SXWK5CiOCoHwxmR05bXdkE/s72-c/Immagine1.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>