我必须创建一个简单的应用程序,作为使用 WPF 和 WCF 创建 HMI 屏幕的示例。
我不确定 WCF 在此类应用程序中应该做什么,我想我的应用程序必须连接到一个 OPC 服务器。应用程序是否使用 WCF 服务连接到 OPC 服务器,WCF 服务是驻留在应用程序内部还是外部?
WCF 服务是否仅用作与 OPC 服务器的连接?我还不太确定要模拟哪个过程,我需要一些简单的东西。
请,欢迎任何想法。
谢谢
看看 www.opcsystems.net,提供的大量工具包可用于使用 OPC 快速轻松地创建 WPF SCADA 应用程序。
听起来您将拥有一个 WPF 应用程序,它将充当 HMI,包含所有 UI 元素。WPF 应用程序将使用服务的地址(运行服务的主机地址)、绑定(可能是 tcp 或 http)和协定(接口)为 WCF 服务创建客户端代理。
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).
查看OPC Connect并使用一些免费或商业组件以您喜欢的语言与一些 OPC 服务器对话并可视化数据。
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...
当您提到 OPC 时,我假设您在谈论 OPC DA。OPC 只是一种通信协议,您可能希望为您的系统创建一个包装器。这是一个松散的示例,说明如何使用 C# 和托管包装器实现简单的 OPC DA 读取。
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/