private void DoModifyRetractStartReplace(string[] lineArray, int lineNumber) { int oldRetractIndex = 2; int replaceIndex = 3; int pIndex = 4; int sIndex = 5; int gIndex = 6; int fIndex = 7; String oldRetract = lineArray[oldRetractIndex].ToUpper(); String replaceStr = lineArray[replaceIndex].ToUpper(); String pValueStr = lineArray[pIndex].ToUpper(); String sValueStr = lineArray[sIndex].ToUpper(); String gValueStr = lineArray[gIndex].ToUpper(); String fValueStr = lineArray[fIndex].ToUpper(); int pValue; int sValue; int gValue; int fValue; // process OldTemperature if (!int.TryParse(oldRetract, out int oldValue)) { throw new Exception($"Nonnumeric MODIFY RETRACT old value at line {lineNumber}"); } // process REPLACE string if (!replaceStr.Equals("REPLACE")) { throw new Exception($"Invalid MODIFY RETRACT at line {lineNumber}"); } // P-Value if (!int.TryParse(pValueStr, out pValue) || !int.TryParse(sValueStr, out sValue) || !int.TryParse(gValueStr, out gValue) || !int.TryParse(fValueStr, out fValue)) { throw new Exception($"Invalid MODIFY RETRACT modification value at line {lineNumber}"); } RetractModifier retractMod = new RetractModifier(); // process OldTemperature retractMod.oldRetractValue = oldValue; retractMod.newPValue = pValue; retractMod.newSValue = sValue; retractMod.newGValue = gValue; retractMod.newFValue = fValue; retractMod.retractCmd = BFBConstants.RETRACT_START; RetractStartModifers.Add(retractMod); }
// MODIFY RETRACTSTART XXXX BY [PERCENTAGE [+|-]YYYY|ADD [+|-]YYYY|REPLACE YYYY] // MODIFY RETRACTSTART XXXX REPLACE P-VALUE S-VALUE G-VALUE F-VALUE private void DoModifyRetractStart(string[] lineArray, int lineNumber) { int oldRetractIndex = 2; int byIndex = 3; int modTypeIndex = 4; int modValueIndex = 5; // check parameter count and validate line if (lineArray.Length != 6 && lineArray.Length != 8) { throw new Exception("Invalid MODIFY RETRACTSTART at line " + lineNumber); } if (!lineArray[byIndex].ToUpper().Equals("REPLACE")) { ValidateRetractLine(lineArray, oldRetractIndex, byIndex, modTypeIndex, modValueIndex); } else { DoModifyRetractStartReplace(lineArray, lineNumber); return; } RetractModifier retractMod = new RetractModifier(); // process OldTemperature int.TryParse(lineArray[oldRetractIndex], out retractMod.oldRetractValue); int.TryParse(lineArray[modValueIndex], out int modValue); string modType = lineArray[modTypeIndex].ToUpper(); if (modType.Equals("PERCENTAGE")) { double percentage = modValue; retractMod.newPValue = Convert.ToInt32(retractMod.oldRetractValue + (percentage / 100) * retractMod.oldRetractValue); retractMod.newSValue = retractMod.newPValue; } else if (modType.Equals("ADD")) { retractMod.newPValue = retractMod.oldRetractValue + modValue; retractMod.newSValue = retractMod.newPValue; } else if (modType.Equals("REPLACE")) { retractMod.newPValue = modValue; retractMod.newSValue = retractMod.newPValue; } retractMod.newGValue = -1; retractMod.newFValue = -1; retractMod.retractCmd = BFBConstants.RETRACT_START; RetractStartModifers.Add(retractMod); }