//================================================================================================// // // process condition statement // //================================================================================================// public bool SH_processConditionStatement(SignalHead thisHead, ArrayList thisCStatList, int[] localFloats, SIGSCRfile sigscr) { // loop through all conditions bool condition = true; bool newcondition = true; bool termnegate = false; SignalScripts.SCRAndOr condstring = SignalScripts.SCRAndOr.NONE; foreach (object thisCond in thisCStatList) { // single condition : process if (thisCond is SignalScripts.SCRNegate) { termnegate = true; } else if (thisCond is SignalScripts.SCRScripts.SCRConditions) { SignalScripts.SCRScripts.SCRConditions thisSingleCond = (SignalScripts.SCRScripts.SCRConditions)thisCond; newcondition = SH_processSingleCondition(thisHead, thisSingleCond, localFloats, sigscr); if (termnegate) { termnegate = false; newcondition = newcondition ? false : true; } switch (condstring) { case (SignalScripts.SCRAndOr.AND): condition &= newcondition; break; case (SignalScripts.SCRAndOr.OR): condition |= newcondition; break; default: condition = newcondition; break; } } // AND or OR indication (to link previous and next part) else if (thisCond is SignalScripts.SCRAndOr) { condstring = (SignalScripts.SCRAndOr)thisCond; } // subcondition else { ArrayList subCond = (ArrayList)thisCond; newcondition = SH_processConditionStatement(thisHead, subCond, localFloats, sigscr); if (termnegate) { termnegate = false; newcondition = newcondition ? false : true; } switch (condstring) { case (SignalScripts.SCRAndOr.AND): condition &= newcondition; break; case (SignalScripts.SCRAndOr.OR): condition |= newcondition; break; default: condition = newcondition; break; } } } return(condition); }
//================================================================================================// // process condition statement //================================================================================================// private static bool ProcessConditionStatement(SignalHead head, ArrayList conditionals, int[] localFloats) { // loop through all conditions bool result = true; bool negate = false; SignalScripts.SCRAndOr condstring = SignalScripts.SCRAndOr.NONE; foreach (object condition in conditionals) { bool newcondition; // single condition : process if (condition is SignalScripts.SCRNegate) { negate = true; } else if (condition is SignalScripts.SCRScripts.SCRConditions singleCondition) { newcondition = ProcessSingleCondition(head, singleCondition, localFloats); if (negate) { negate = false; newcondition = !newcondition; } switch (condstring) { case (SignalScripts.SCRAndOr.AND): result &= newcondition; break; case (SignalScripts.SCRAndOr.OR): result |= newcondition; break; default: result = newcondition; break; } } // AND or OR indication (to link previous and next part) else if (condition is SignalScripts.SCRAndOr or) { condstring = or; } // subcondition else { ArrayList subCond = (ArrayList)condition; newcondition = ProcessConditionStatement(head, subCond, localFloats); if (negate) { negate = false; newcondition = !newcondition; } switch (condstring) { case (SignalScripts.SCRAndOr.AND): result &= newcondition; break; case (SignalScripts.SCRAndOr.OR): result |= newcondition; break; default: result = newcondition; break; } } } return(result); }