尝试从Opc Server获取历史数据时如何修复“ BadServiceUnsupported”错误

时间:2019-02-14 15:41:57

标签: c# opc-ua

我正在尝试从opc服务器获取标签的历史数据,但出现“ BadServiceUnsupported”错误。我已经在KepserverEX V6中为特定标签配置了Opc Server和Local Historian。

我正在使用此opc库https://github.com/OPCFoundation/UA-.NETStandard

我成功读取了标签值,但是在调用HistoryRead方法时,历史数据存在问题:

m_Session.HistoryRead( null, new ExtensionObject(details), TimestampsToReturn.Source, false, nodesToRead, out results, out diagnosticInfos);

获取“ BadServiceUnsupported”例外。

我还在KepserverEx中的项目设置上启用了HDA连接,但似乎并不能解决问题。

如何解决此问题?

2 个答案:

答案 0 :(得分:1)

要解决此问题,可以运行OPC UA包装服务器:https://github.com/OPCFoundation/UA-.NETStandard/blob/master/ComIOP/README.md

包装服务器将成为您的应用程序和KepServerEX之间的桥梁。它是这样的:

[Your Application] --- (OPC-UA) ---> [OPC UA Wrapper Server] --- (OPC-HDA) ---> [KepServerEX]

我已经使用m_Session.HistoryRead()测试了上述情况,可以从KepServerEX v6.6成功读取历史值

要使服务器包装打开与KepServerEX的HDA连接,请打开Opc.Ua.ComServerWrapper.Config.xml并为HDA启用ComClientConfiguration。它应该看起来像这样:

<ComClientConfiguration i:type="ComHdaClientConfiguration">
    <ServerUrl>opc.com://localhost/Kepware.KEPServerEX_HDA.V6/{5C905440-YOUR_CLSID_HERE}</ServerUrl>
    <ServerName>HDA</ServerName>
    <MaxReconnectWait>10000</MaxReconnectWait>
    <SeperatorChars></SeperatorChars>
    <AddCapabilitiesToServerObject>true</AddCapabilitiesToServerObject>
    <AttributeSamplingInterval>1000</AttributeSamplingInterval>
    <TreatUncertainAsBad>true</TreatUncertainAsBad>
    <PercentDataBad>0</PercentDataBad>
    <PercentDataGood>100</PercentDataGood>
    <SteppedSlopedExtrapolation>false</SteppedSlopedExtrapolation>
</ComClientConfiguration>

答案 1 :(得分:0)

在这种情况下,没有任何要解决的问题。 Kepserver仅支持OPC Classic(COM / DCOM)的HDA,不支持OPC UA。