开发者

I need to create a small HMI/SCADA WPF application that uses WCF

I have to create a simple app, that will suit as an example of using WPF and WCF for creating HMI screens.

I'm not sure what WCF is supposed to do in such application, I guess there must be an OPC server that my application connects to. Does app connect to OPC server using WCF service and does the WCF service reside inside the application or outside?

Is WCF service meant to be used only as a connection to OPC server? I'm not yet quite sure which process to simulate, I ne开发者_如何转开发ed something simple.

Please, any ideas are welcomed.

Thank you


It sounds like what you will have is a WPF application that will act as the HMI, containing all the UI elements. The WPF application will create a client proxy for a WCF service using the address (the host address that the service is running on), binding (probably tcp or http) and contract (an interface) of the service.

The WCF service will be hosted somewhere (the host address) and expose an endpoint that specifies a binding and a contract. This is what your WPF app's client proxy will communicate with. The methods implemented in the service's contract will instantiate OPC classes and write or read OPC Items as needed.

In its simplest form, you would probably have one solution with two projects: one for the WPF application (with the client proxy) and one for the WCF service (with OPC implementations).


Have a look at www.opcsystems.net, great bit of kit on offer for creating WPF SCADA applications using OPC quickly and easily.


Take a look at OPC Connect and use some free or commercial components for your prefered language to talk to some OPC server and visualize data.


If you want to create WPF consumer, your best WCF way to go is using the new OPC-UA implementations.

For example, the KepwareEx server implements those spec and exposes wcf endpoint out of the box.

I do not have any affiliation with Kepware but we used their products a lot.

more info on their UA Guidance document that shows what I am talking about. You can rig that client end to allow xaml integration (I haven't done it).

Also, it's worth looking into the architectural descriptions of the guys at Status Vision, who are coming out with an OPC UA -> Silverlight/XAML toolkit...


When you mention OPC, I'm assuming your talking about OPC DA. OPC is just a communications protocol and you'll probably want to create a wrapper for your system. This is a loose example of how you might implement a simple OPC DA read using C# and the managed wrapper.

namespace ScadaServiceLibrary
{
    [ServiceContract]
    public interface IDataClass
    {
        [OperationContract]
        string RetrieveValues(string OpcPath);
    }

    public class DataClass : IDataClass
    {

        ....

        public string RetrieveValue(string OpcPath)
        {
            // Retrieve data here. ScadaServer is a Opc.Da.Server type.
            // Example assumes you have a dictionary of the item handles keyed 
            // to the path.

            string value = null;

            Opc.Da.Item item = new Opc.Da.Item();

            item.ItemName = OpcPath;
            item.ClientHandle = Handles[OpcPath];
            item.Active = true;
            item.ActiveSpecified = true;

            Opc.Da.Item[] items = new Opc.Da.Item[1];
            items[0] = item;
            Opc.Da.ItemValueResult[] results = ScadaServer.Read(items);

            if (results != null && results.Length > 0)
            {
                Opc.Da.ItemValueResult result = results[0];
                value = result.Value.ToString();
            }

            return value;
        }
    }
}


You can use Open Automation Software's WPF HMI .NET product which uses WCF for communications with data sources from Modbus, AB, Siemens, OPC, MQTT, AWS, etc. https://www.openautomationsoftware.com/products/hmi-scada-for-net/wpf-hmi-net/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜