Hi Dojo,
I'm working on an application that will manage some remote elements.
In order to fetch the changes on Element Name and Element Alarm Level (Severity), I'm using the Class Library Monitors.
My question is if I should define what elements I need to track/monitor? And adjust this list when I add/remove managed elements?
Currently I just Start the monitors after startup:
IDms dms = protocol.GetDms(); dms.StartElementNameMonitor(protocol, OnElementNameChange); dms.StartElementAlarmLevelMonitor(protocol, OnAlarmLevelChange);
In the methods OnElementNameChange & OnAlarmLevelChange, I believe I'm receiving all the name & severity changes from the system, while I'm only interested in the subset I was managing.
So far it seems to work just fine, but I want to be sure this is the correct way of using it.
Thanks in advance!
There are also extension methods defined on IDmsElement to monitor e.g; name changes and alarm level changes see ElementMonitorExtenions.
var element = myDms.GetElement("myElement");
element.StartNameMonitor(protocol, OnElementNameChange);
element.StartAlarmLevelMonitor(protocol, OnAlarmLevelChange);
When you stop the element that starts monitors. All the started monitors will stop & clean up.
So when you then start that element again, you need to make sure your element restarts all the monitors you need.
This means you need to keep track in a saved table (for example) what elements you’re monitoring. After an element restart you then parse that table and restart the monitors.
Great! I can do that. Thanks guys!
Thanks Pedro, Though it’s not fully clear if and how I should be managing the re-initiation of Monitors after they restart.
The documentation is not clear about this:
https://help.dataminer.services/development/#t=DataMinerDevelopmentLibrary_Customerpart1PDGPDGAdvancedFunctionalityCleanup_rules.htmXREF_97683_6_12_3_Cleanup&rhsearch=Monitors&rhsyns=
“This means that all monitors must be manually restarted when the element is restarted.”
Should I be in charge to keep track of what monitored elements are getting a restart or Stop/start? Or is this only intended to make sure that after restart of the managing application, we need to do a fresh Monitor request after our start up? Thanks.