Trying to add alarms to a BStringWritable. I have a couple hundred points that need this alarm so this needs to be done through some automation.
Program services doesn’t seem to work and Vykon pro util module has batch alarm adding point for Booleans, Enums and Numerics only, doesn’t have a BatchAddStringChangeOfValueAlarmExt.
Here is a program object that I used for a basic alarm extensions:
/* Auto-generated ProgramImpl Code */
import java.util.*; /* java Predefined*/
import javax.baja.nre.util.*; /* nre Predefined*/
import javax.baja.sys.*; /* baja Predefined*/
import javax.baja.status.*; /* baja Predefined*/
import javax.baja.util.*; /* baja Predefined*/
import com.tridium.program.*; /* program-rt Predefined*/
import javax.baja.naming.*; /* baja User Defined*/
import javax.baja.control.*; /* control User Defined*/
import javax.baja.alarm.ext.*; /* alarm-rt User Defined*/
import javax.baja.alarm.ext.offnormal.*; /* alarm-rt User Defined*/
import javax.baja.alarm.ext.fault.*; /* alarm-rt User Defined*/
public class ProgramImpl
extends com.tridium.program.ProgramBase
{
////////////////////////////////////////////////////////////////
// Getters
////////////////////////////////////////////////////////////////
public String getPointName() { return getString("pointName"); }
////////////////////////////////////////////////////////////////
// Setters
////////////////////////////////////////////////////////////////
public void setPointName(String v) { setString("pointName", v); }
////////////////////////////////////////////////////////////////
// Program Source
////////////////////////////////////////////////////////////////
/**
Add Alarm Extension
Program to add a String Change of State Alarm Extension to String Points
**/
/**
For example, If you want to add an Out Of Range Alarm Extension slot to a Boolean Writable whose displayName is like "pump"
1. Go the the Property sheet of this program object, and type in "pump" (without the quotes)
2. Come back to this screen and make sure the Program is Up-To_Date, if not Recompile this program object and then execute it.
**/
public void onStart() throws Exception
{
// start up code here
}
public void onExecute() throws Exception
{
// execute code (set executeOnChange flag on inputs)
process(Sys.getStation());
}
public void process(BComponent c) throws Exception
{
try
{
//System.out.println("starting try block");
String x = c.getName();
if (x != null && x.toLowerCase().indexOf(getPointName().toLowerCase())>-1) //converts name strings to lower case and compares components name to string property
{
//System.out.println("comparing name");
if (c.getType().toString().equals("control:StringWritable"))
{
//System.out.println("comparing type");
BOrd sourceOrd = BOrd.make("station:|" + c.getSlotPath().toString());
BComponent source = (BComponent) sourceOrd.resolve().get();
BStringChangeOfStateAlgorithm b = new BStringChangeOfStateAlgorithm();
((BStringWritable) source).add("Alarm", new BAlarmSourceExt());
sourceOrd = BOrd.make("station:|" + c.getSlotPath().toString() + "/Alarm");
BAlarmSourceExt ase = (BAlarmSourceExt) sourceOrd.resolve().get();
ase.setOffnormalAlgorithm(b);
}
}
// recurse
System.out.println("recursing");
BComponent[] kids = c.getChildComponents();
for(int i=0; i<kids.length; ++i)
process(kids[i]);
//
} // try
catch ( Exception e )
{
System.out.println(e);
}
}
public void onStop() throws Exception
{
// shutdown code here
}
}
This one uses to find a point name and a string writable.
If you to add a query here and such, you’ll have to modify this program to do that.
I only modify my original program to add this to strings.