Scripting control to Publishers
-
Hi, all
I have a story to help. Scripting control to publishers. Want to write control scripts for publishers By enabling / disable the publisher
such as
1.Scripting control to Data sources.var d = 'DP_835f4865-3de8-47cc-9c7b-3121b7a65bf9'; //Change to your data source's XID RuntimeManager.enableDataSource(d);
2.Scripting control to Data point.
var d = 'DP_835f4865-3de8-47cc-9c7b-3121b7a65bf9'; //Change to your data source's XID RuntimeManager.enableDataPoint(d);
I try to write like this and it is not available.
var d = 'DP_835f4865-3de8-47cc-9c7b-3121b7a65bf9'; //Change to your data source's XID RuntimeManager.enablePublishers(d); error RuntimeManager.enablePublishers is not a function
-
Hi JoHn-Beer,
It does seem like those functions should exist for completeness. Currently there would be two ways to do this,
- Use the JsonEmport tool. You could export the publishers JSON, find the publisher you wished to toggle, change the 'enabled' property appropriately and reimport.
- Go through the actual runtime manager, like
function enablePublisher(xid, enabled) { var publisher = com.serotonin.m2m2.db.dao.PublisherDao.getByXid(xid); publisher.enabled = enabled; com.serotonin.m2m2.Common.runtimeManager.savePublisher(publisher); }
And then call it as needed. I'll create a git issue about putting such a function into the script environments' RuntimeManager utility.