I am currently evaluating the QuickOPC A&E SDK. I am using it through it's Nuget package (Version: 5.51.465)
So I have an OPC A&E Server (Using IntelliMax by Sensys) which is publishing 50 events per second. The events have some vendor specific attributes attached so I use the following code to subscribe to these events:
public class TestClass
{
public static void Main(string[] args)
{
var client = EasyAEClient.Create();
client.Notification += PublishCallback;
var servers = client.BrowseServers("");
ServerElement myIntendedServer = null;
foreach (var server in servers)
{
if (server.ProgId.Equals("Kepware.KEPServerEX_AE.V6"))
{
myIntendedServer = server;
break;
}
}
if (myIntendedServer != null)
{
var eventCategories = client.QueryEventCategories("", myIntendedServer.ProgId);
long[] categoryIds = new long[eventCategories.Count];
var attributeDictionary = new AEAttributeSetDictionary();
for (int i = 0; i < eventCategories.Count; i++)
{
categoryIds[i] = eventCategories[i].CategoryId;
if (eventCategories[i].AttributeElements != null && eventCategories[i].AttributeElements.Count > 0)
{
long[] attributes = new long[eventCategories[i].AttributeElements.Count];
for (int j = 0; j < eventCategories[i].AttributeElements.Count; j++)
{
attributes[j] = eventCategories[i].AttributeElements[j].AttributeId;
}
attributeDictionary.Add(eventCategories[i].CategoryId, attributes);
}
}
var filter = new AESubscriptionFilter
{
Categories = categoryIds
};
client.SubscribeEvents("", "Kepware.KEPServerEX_AE.V6", 0, null, filter, attributeDictionary);
System.Threading.Thread.Sleep(int.MaxValue);
client.UnsubscribeAllEvents();
}
}
private static void PublishCallback(object sender, EasyAENotificationEventArgs e)
{
if (e.Exception != null)
{
Console.WriteLine("Server disconneced: ", e);
}
else if (e.RefreshComplete)
{
Console.WriteLine("RefreshComplete sent");
}
else if (e.EventData == null)
{
Console.WriteLine("Server connected");
}
else
{
Console.WriteLine("Event received: [{0}]", e.EventData.ToString());
if (e.EventData.AttributeValues != null && e.EventData.AttributeValues.Count > 0)
{
Console.WriteLine("Vendor Specific Events: ");
foreach (var attribute in e.EventData.AttributeValues)
{
Console.WriteLine("[{0}]:[{1}]", attribute.Key, attribute.Value);
}
}
}
}
}
I receive the events with vendor specific attributes. But if, during this subscription I disable the vendor specific events on the server side (I disable->enable the events, and restart the server so the disconnect and connect events are also published), I keep receiving the Vendor specific attributes in the events. I even restarted the test application with this code and the vendor specific attributes disabled on the server side. I still receive them in events.