Created
June 8, 2017 17:33
-
-
Save mrupperman/19244dc3db5c41d1b3a49d553b75f315 to your computer and use it in GitHub Desktop.
Enum Override Example
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
public void onExecute() throws Exception | |
{ | |
process((BComponent)getProgram().getParent()); | |
} | |
public void process(BComplex c) | |
throws Exception | |
{ | |
if (c instanceof javax.baja.control.BEnumWritable) | |
{ | |
System.out.println("Found enumWritable: " + c.getName()); | |
//cast the BComplex passed in to BEnumWritable | |
BEnumWritable myEnum = (BEnumWritable)c; | |
// get the current facets of the EnumWritable | |
BFacets facets = myEnum.getFacets(); | |
// get the points range | |
BEnumRange facetsRange = (BEnumRange)(facets.get(BFacets.RANGE)); | |
// get the current value | |
BDynamicEnum val = (BDynamicEnum)myEnum.getOut().getValueValue(); | |
//get the current range | |
BEnumRange range = val.getRange(); | |
System.out.println("range " + range); | |
String valRange = val.encodeToString(); | |
System.out.println("valRange: " + valRange); | |
// All the above stuff is just grabbing the Enum point's facets. But I can't find an easy way to then set this | |
// program to use the facets. So really all you need are the next lines below. And on the property sheet manually setup the facets | |
// for the DynamicEnum that is going to be used to set the override. | |
//setup the DynamicEnum you will use to override the point | |
BDynamicEnum myOverride = getDynamicEnum(); | |
System.out.println("myOverride " + myOverride); | |
//configure the override with an expiration time and the DynamicEnum to override with | |
BEnumOverride theOverride = new BEnumOverride(getOverrideTime(), myOverride); | |
//If you do not want an override time, but just a permanent override, remark out the line above and remove the slashed | |
//from the line below this comment. | |
//BEnumOverride theOverride = new BEnumOverride(myOverride); | |
// Now override the point | |
myEnum.doOverride(theOverride); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment