Set to Active/Quiet State Filtered System Object and Print to Console
var filter = new Filter();
// filter the BO
filter.objectModel = "GMS_BACNET_EO_BA_BO_1";
var binaryOutputs = searchSync(filter);
//Check whether there are BO satisfying the filter...
if (binaryOutputs == null || binaryOutputs.length == 0){
console("objects not found");
terminate();
}
//... and count them
console("Binary objects count = {0}",binaryOutputs.length);
for (var i=0; i<binaryOutputs.length;i++){
//Obtain the designation
var binaryOutput = binaryOutputs[i].designation;
//Get the list of commands on the Present Value, filtering by "WritePrio"
var commandList = getCommandList(binaryOutput,"Present_Value",true,"WritePrio");
if (commandList.commands) {
for (var j=0; j<commandList.commands.length; j++){
//Obtain the name of the available command
var currentValue = read(binaryOutput,"Present_Value");
console("{0} on object {1} executed - Old Value: {2}",commandList.commands[j].name, i, currentValue);
}
executePropertyCommand(binaryOutput,"Present_Value","WritePrio",[["Value", 1], ["Priority", 8]]);
var newValue = read(binaryOutput,"Present_Value");
console("New Value: {0}", newValue);
}
}
console("Going to sleep...");
sleep(2000);
for (var i=0; i<binaryOutputs.length;i++){
//Obtain the designation
var binaryOutput = binaryOutputs[i].Designation;
//Get the list of command on the Present Value, filtering by "WritePrio"
var commandList = getCommandList(binaryOutput,"Present_Value",true,"WritePrio");
if (commandList.commands) {
for (var j=0; j<commandList.commands.length; j++){
//Obtain the name of the available command
var currentValue = read(binaryOutput,"Present_Value");
console("{0} on object {1} executed - Old Value: {2}",commandList.commands[j].name, i, currentValue);
}
executePropertyCommand(binaryOutput,"Present_Value","WritePrio",[["Value", 0], ["Priority", 8]]);
var newValue = read(binaryOutput,"Present_Value");
console("New Value: {0}", newValue);
}
}