/// <summary> /// Initializes a given commands math expression based on supplied unit type /// </summary> /// <param name="bthcmd"></param> /// <param name="Unit_Type"></param> public void InitExpression(BluetoothCmd bthcmd, UserSetting.UNIT_TYPE Unit_Type) { if (bthcmd.Command_Types == null || bthcmd.Command_Types.Length == 0) { return; } InitUnitType(bthcmd, Unit_Type); if (string.IsNullOrEmpty(sExpression)) { return; } string varvalue; e = null; arguments = null; e = new Expression(sExpression.Trim()); arguments = new List <Argument>(); for (int idx = 0; idx < bthcmd.Command_Types.Length; idx++) { varvalue = ProcessValues.GetVariable(idx); arguments.Add(new Argument(varvalue)); e.addArguments(arguments[idx]); //arguments[idx].setArgumentValue(0); // ToDo: initial value? } min = bthcmd.Value_Min; max = bthcmd.Value_Max; decimals = bthcmd.Decimals; }
/// <summary> /// Initializes a given commands math expression based on supplied unit type /// </summary> /// <param name="bthcmd"></param> /// <param name="Unit_Type"></param> /// <param name="sb"></param> public void InitExpression(BluetoothCmd bthcmd, UserSettings.UNIT_TYPE Unit_Type, StringBuilder sb) { InitUnitType(bthcmd, Unit_Type); if (string.IsNullOrEmpty(sExpression)) { return; } string varvalue; e = null; arguments = null; e = new Expression(sExpression.Trim()); arguments = new List <Argument>(); for (int idx = 0; idx < bthcmd.Command_Types.Length; idx++) { varvalue = ProcessValues.GetVariable(idx); arguments.Add(new Argument(varvalue)); e.addArguments(arguments[idx]); //arguments[idx].setArgumentValue(0); // ToDo: initial value? } min = bthcmd.Value_Min; max = bthcmd.Value_Max; decimals = bthcmd.Decimals; if (decimals < 0) { decimals = 0; } else if (decimals > MAX_DECIMALS) { decimals = MAX_DECIMALS; } if (decimals == 0) { formatter = VALUE_FORMATTER; } else { sb.Clear(); sb.Append(VALUE_FORMATTER); sb.Append("."); for (int i = 0; i < decimals; i++) { sb.Append(VALUE_FORMATTER); } formatter = sb.ToString(); } }