Alarm Tab Notes
If you intend to allow developers to set the comparison function used when triggering the alarm (>, =, <=, etc) then you should create a dictionary of the function codes. Declare it as a shared variable in the tag module:
SHARED FunctionCodes { Function code strings };
Then populate the dictionary in the Init state, again in the tag module:
MyTagInit [ If \AlarmManager\Started && \ExpressionManager\Started MyTagMain; [ { If (and only if ! ) you are allowing the developer to choose the comparison function, create list of function codes } IfThen(!Valid(FunctionCodes), FunctionCodes = Dictionary(); FunctionCodes["<"] = \AlarmManager\ALM_FUNC_LESS_THAN; FunctionCodes["<="] = \AlarmManager\ALM_FUNC_LESS_EQUAL; FunctionCodes[">="] = \AlarmManager\ALM_FUNC_GREATER_EQUAL; FunctionCodes[">"] = \AlarmManager\ALM_FUNC_GREATER_THAN; FunctionCodes["="] = \AlarmManager\ALM_FUNC_EQUAL; FunctionCodes["=="] = \AlarmManager\ALM_FUNC_EQUAL; FunctionCodes["!="] = \AlarmManager\ALM_FUNC_NOT_EQUAL; FunctionCodes["<>"] = \AlarmManager\ALM_FUNC_NOT_EQUAL; FunctionCodes["&"] = \AlarmManager\ALM_FUNC_AND_WITH; FunctionCodes["&&"] = \AlarmManager\ALM_FUNC_AND_WITH; FunctionCodes["|"] = \AlarmManager\ALM_FUNC_OR_WITH; FunctionCodes["||"] = \AlarmManager\ALM_FUNC_OR_WITH; FunctionCodes["^"] = \AlarmManager\ALM_FUNC_XOR_WITH; FunctionCodes["NAND"] = \AlarmManager\ALM_FUNC_NOT_AND_WITH; FunctionCodes["NOR"] = \AlarmManager\ALM_FUNC_NOT_OR_WITH; ); CriticalSection( Root = Self(); Refresh(); ); Started = 1; ] ]
In the module for the configuration panel, create the following variables:
FindFunction Module "FindFunc.WEB" { Finds function in FuncList }; FuncList { List of valid functions }; FuncIndex { Index into the FuncList array }; FuncValues { Values of the function descriptions }; FuncType { The long text string version of Function };
Then in the panel's Init state, initialize the arrays:
Init [ If 1 Switch; [ {***** Set up the function list *****} FuncList = New(12); FuncList[0] = \NoFunctionLabel; FuncList[1] = Concat(\GetPhrase("LessThanLabel"), " <"); FuncList[2] = Concat(\GetPhrase("LessThanEqualLabel"), " <="); FuncList[3] = Concat(\GetPhrase("GreaterThanLabel"), " >"); FuncList[4] = Concat(\GetPhrase("GreaterThanEqualLabel"), " >="); FuncList[5] = Concat(\GetPhrase("EqualToLabel"), " = ", \GetPhrase("OrLabel"), " =="); FuncList[6] = Concat(\GetPhrase("NotEqualToLabel"), " != ", \GetPhrase("OrLabel"), " <>"); FuncList[7] = Concat(\GetPhrase("ANDedWithLabel"), " & ", \GetPhrase("OrLabel"), " &&"); FuncList[8] = Concat(\GetPhrase("ORedWithLabel"), " | ", \GetPhrase("OrLabel"), " ||"); FuncList[9] = Concat(\GetPhrase("XORedWithLabel"), " ^"); FuncList[10] = Concat(\GetPhrase("NotANDedWithLabel"), " ! ( && )"); FuncList[11] = Concat(\GetPhrase("NotORedWithLabel"), " ! ( || )"); FuncValues = New(12); FuncValues[0] = ""; FuncValues[1] = "<"; FuncValues[2] = "<="; FuncValues[3] = ">"; FuncValues[4] = ">="; FuncValues[5] = "="; FuncValues[6] = "!="; FuncValues[7] = "&"; FuncValues[8] = "|"; FuncValues[9] = "^"; FuncValues[10] = "NAnd"; FuncValues[11] = "NOr"; {***** Find the current function type *****} FuncType = FindFunction(Parms[\#Function]); FuncIndex = LookUp(FuncList[0], 12, FuncType); { ... }
Finally, in the state for the tab where the alarm function is to be selected, display the list:
{***** Function *****} GUITransform(30, 155, 470, 110, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, \DialogLibrary.PDropList(\#Function, \FunctionLabel, FuncList, 0, FuncIndex { Labels, CanEdit, Index }, HasPriv ? 11 : 0, 0 { FocusID, No Trigger }, FuncIndex, 1, 0, 1 { Init, DrawBevel, VertAlign, AlignTitle }, FuncValues { Return Values }));