With the protocol object, it is possible to log out runtime data using the protocol.Log() method. However, when using DMS Monitors, use of SLProtocol is strictly prohibited which raises the question whether it is possible to log data using the IDms object?
Could you share the code/method where you would like to include logging? It’s not fully clear to me what/when you would like to log.
var dms = protocol.GetDms();
var remoteElement = dms.GetElement(new DmsElementId(elementId));
remoteElement.GetStandaloneParameter(12000).StartValueMonitor(protocol, change =>
{
var changeValue = change.Value;
//Log changeValue here.
};
We've made some progress to allow SLProtocol to be used after you've finished the Run method. (so during the Monitor Handler for example). This in ongoing efforts to allow more communication directly from QActions.
An initial release of these change is present since DataMiner:
Main Release Version
10.3.0
10.2.9
So theoretically since those versions you should be able to use SLProtocol within the handlers of the Monitors. You'd need to remove the 'static' from the QAction, turning it into an instanced QAction and then make a private SLProtocol protocol variable and make sure you always update that variable every time the Run begins.
IMPORTANT: This is still in an 'alpha' version and there are some known race conditions on element stop or multithreaded timers that can cause a SLScripting crash.
But in most cases this will now actually work just fine. You could mitigate the race conditions by implementing the IDisposable on the QAction (also supported since the above mentioned DataMiner versions) and then making the protocol variable null and making sure to always check for null before running the handler code.
If you'd prefer to use it later, when we've worked our the corner cases and bugs and its more stable then currently I would recommend installed something like the SeriLog NuGet and logging directly to your own file.
Any internal logging mechanisms have not been made public for use right now.
Thanks Jan, this is good news, I’ll be following this development with keen interest. I might also try some prototypes with the suggestions you’ve made in the meantime.
Checking the IDmsElement, this also doesn’t appear to have logging capabilities?