Created
June 8, 2017 17:28
-
-
Save mrupperman/8fb74333effa20506fb45f7cc345f8cb to your computer and use it in GitHub Desktop.
Niagara Supervisor Global Override
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOrd ord = BOrd.make("station:|slot:/Drivers/NiagaraNetwork|bql:select slotPath, type, toString from control:ControlPoint where slotPath like '*OCC_MODE'"); | |
public void onOccupied() throws Exception | |
{ | |
GetPoints("occ"); | |
} | |
public void onUnoccupied() throws Exception | |
{ | |
GetPoints("unocc"); | |
} | |
public void onAuto() throws Exception | |
{ | |
GetPoints("auto"); | |
} | |
public void GetPoints(String cmd) | |
{ | |
BITable result = (BITable)ord.resolve().get(); | |
ColumnList columns = result.getColumns(); | |
Column pSlot = columns.get(0); | |
Column pType = columns.get(1); | |
TableCursor c = (TableCursor)result.cursor(); | |
while (c.next()) | |
{ | |
if (c.get(pType).toString().endsWith("control:BooleanWritable")) | |
{ | |
OverrideBooleanPoints(cmd, pSlot, pType, c); | |
} | |
if (c.get(pType).toString().endsWith("control:EnumWritable")) | |
{ | |
OverrideEnumPoints(cmd, pSlot, pType, c); | |
} | |
} | |
} | |
public void OverrideBooleanPoints(String mode, Column pSlot, Column pType, TableCursor c) | |
{ | |
BBooleanWritable occPoint = (BBooleanWritable)BOrd.make("station:|" + c.get(pSlot).toString()).resolve().get(); | |
if (mode == "occ") | |
{ | |
occPoint.active(new BOverride()); | |
} | |
if (mode == "unocc") | |
{ | |
occPoint.inactive(new BOverride()); | |
} | |
if (mode == "auto") | |
{ | |
occPoint.auto(); | |
} | |
} | |
public void OverrideEnumPoints(String mode, Column pSlot, Column pType, TableCursor c) | |
{ | |
BDynamicEnum occEnum = getOccMode(); | |
BEnumWritable occPoint = (BEnumWritable)BOrd.make("station:|" + c.get(pSlot).toString()).resolve().get(); | |
BFacets facets = occPoint.getFacets(); | |
BEnumRange enumModes = (BEnumRange)(facets.get(BFacets.RANGE)); | |
int occ, unocc, standby; | |
if (enumModes.getTag(3).toString().endsWith("Occupied")) | |
{ | |
if (mode == "occ") | |
{ | |
BEnumOverride occOvrd = new BEnumOverride(occEnum.make(3)); | |
occPoint.doOverride(occOvrd); | |
} | |
} | |
if (enumModes.getTag(2).toString().endsWith("Occupied")) | |
{ | |
if (mode == "occ") | |
{ | |
BEnumOverride occOvrd = new BEnumOverride(occEnum.make(2)); | |
occPoint.doOverride(occOvrd); | |
} | |
} | |
if (mode == "unocc") | |
{ | |
BEnumOverride occOvrd = new BEnumOverride(occEnum.make(1)); | |
occPoint.doOverride(occOvrd); | |
} | |
if (mode == "auto") | |
{ | |
occPoint.auto(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment