we would like to get a list of all acknowledges states ( so client is aware of conditions occured while not connected )
1. browse all sources
2. query source conditions
3. get condition state
Code:
OpcLabs.EasyOpc.Engine.NetApiResultException (0x80070057): OPC NET API error - result ID: E_INVALIDARG; IOPCEventServer.GetConditionState
+ The client method called (or event/callback invoked) was 'GetConditionState'.
--- End of inner exception stack trace ---
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ErrorTransformingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.EasyAEClientCompositor.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.CompositeEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.DelegatingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.DelegatingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.DelegatingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.LicensingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.DelegatingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ErrorTransformingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.ForwardingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.Implementation.DelegatingEasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.EasyAEClient.GetConditionState(ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName, Int64[] attributes)
at OpcLabs.EasyOpc.AlarmsAndEvents.IEasyAEClientExtension.GetConditionState(IEasyAEClient client, ServerDescriptor serverDescriptor, AENodeDescriptor sourceDescriptor, String conditionName)
at TestOPC.OPCConnector.OPCConnector.GetAcknowledgeStatus() in C:\WorkingSpace\Repositories\TestOPC\TestOPC\OPCConnector\OPCConnector.cs:line 227
Code:
EasyAEClient _aeClient = new();
ServerDescriptor _aeServer = new( "localhost", "XXX" );
AENodeElementCollection alarmConditions = _aeClient.BrowseSources(_aeServer, "");
foreach( AENodeElement alarmCondition in alarmConditions )
{
AEConditionElementCollection conditionList = _aeClient.QuerySourceConditions( _aeServer, alarmCondition.QualifiedName );
foreach (AEConditionElement conditionElement in conditionList)
{
try
{
AEConditionState condition = _aeClient.GetConditionState( _aeServer, alarmCondition.QualifiedName, conditionElement.Name );
Console.WriteLine("ConditionState:");
Console.WriteLine(" .ActiveSubcondition: {0}", condition.ActiveSubcondition);
Console.WriteLine(" .Enabled: {0}", condition.Enabled);
Console.WriteLine(" .Active: {0}", condition.Active);
Console.WriteLine(" .Acknowledged: {0}", condition.Acknowledged);
Console.WriteLine(" .Quality: {0}", condition.Quality);
}
catch( Exception )
{
// ignored
}
}
}