Now that we have OPC events triggering rule scripts in KSX, I wanted to develop a simple and elegant way to process the events. On a couple of different projects, I have used the concept of a filter graph, that is, a chain of connected filters that can each consume, alter and/or pass on incoming objects to other filters further down the graph. The very core of KSX is the node tree, which is simply an object graph. So by making nodes that receive events (through a rule script) and then consume, alter and/or pass them on, we can easily create a filter graph and elegantly process all of the events that we receive.
I made a couple of different types of filters, one based on the event source, one based on the event message and one based on the event severity. I then created a simple event consumer that logs events to the transcript, and records the event details as attribute values that can be stored in the historical database and queried later. Now I can easily drag and drop nodes into the graph to create the desired filters. So to log only events with a severity above 100, and with the source equal to “Sources.Sagmill” I just drag a source filter node onto my event source node, and drag a severity filter onto it. Lastly I drag a event logger node onto the end of the graph. Now I just set the high and low attributes on the severity filter, and the pattern string on the source filter and I’m done. Events from the Sagmill with severity over 100 are logged.