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.
};
Hi Reza,
I'm assuming you are using this in a connector as you refer to SLProtocol. In the handler you indeed don't have an SLProtocol object to log to the element logging.
There are a few options if you want to log the value you receive:
- Write to a dedicated (debug) log file you manage yourself in code
- Generate information events (using SLNet connection)
- Set a parameter and trigger a QAction to further handle the value
The latter one would be my preferred option as you'll likely want to do something with the value you receive anyway. You could set a parameter in your element with the following code:
var thisElement = change.Dms.GetElement(new DmsElementId(change.MonitorSource));
var internalParameter = thisElement.GetStandaloneParameter<string>(internalParameterId);
internalParameter.SetValue(change.Value);
This "internalParameterId" will be a parameter in your connector that triggers another QAction. You can then further handle this update in that QAction and have access to the SLProtocol object.
Thanks Joey, these are all great suggestions, I’ll try them out.
Checking the IDmsElement, this also doesn’t appear to have logging capabilities?