private static Limit GetLimit(LimitType limitType, FeatureType featureType) { var limit = Limit.Create(limitType, featureType); limit.AddCycles(GetCycles()); return(limit); }
private Vector3 LimitValue(Vector3 sourceValue, LimitType limitType, Vector3 limitMin, Vector3 limitMax) { float x = sourceValue.x, y = sourceValue.y, z = sourceValue.z; if ((limitType & LimitType.XMax) != 0) { x = Mathf.Clamp(x, float.MinValue, limitMax.x); } if ((limitType & LimitType.XMin) != 0) { x = Mathf.Clamp(x, limitMin.x, float.MaxValue); } if ((limitType & LimitType.YMax) != 0) { y = Mathf.Clamp(y, float.MinValue, limitMax.y); } if ((limitType & LimitType.YMin) != 0) { y = Mathf.Clamp(y, limitMin.y, float.MaxValue); } if ((limitType & LimitType.ZMax) != 0) { z = Mathf.Clamp(z, float.MinValue, limitMax.z); } if ((limitType & LimitType.ZMin) != 0) { z = Mathf.Clamp(z, limitMin.z, float.MaxValue); } return(new Vector3(x, y, z)); }
public LevelTarget(JSONNode json) { switch (json["limit_type"]) { case "Time": LimitType = LimitType.Time; TimeSpan = json["limit"].AsInt; break; case "Moves": LimitType = LimitType.Moves; Moves = json["limit"].AsInt; break; } StarsLevels = new List<int>(); for (var i = 0; i < json["stars_levels"].AsArray.Count; i++) { StarsLevels.Add(json["stars_levels"][i].AsInt); } _prices = new List<KeyValuePair<int, int>>(); for (int i = 0; i < json["prices"].AsArray.Count; i++) { KeyValuePair<int, int> pair = new KeyValuePair<int, int>(json["prices"][i]["index"].AsInt, json["prices"][i]["price"].AsInt); _prices.Add(pair); } }
public int GetLimit(LimitType limitType) { int limit = 0; if (Fields.Count > 0) { limit = Fields[0].Value; for (int i = 1; i < Fields.Count; i++) { if (limitType == LimitType.ltLowerLimit) { if (Fields[i].Value < limit) { limit = Fields[i].Value; } } else { if (Fields[i].Value > limit) { limit = Fields[i].Value; } } } } return(limit); }
public static LimitUsed Create(string companyKey, string documentNumber, LimitType limitType, FeatureType featureType, CycleType cycleType, LevelType levelType, long amount) => new LimitUsed(companyKey, documentNumber, limitType, featureType, cycleType, levelType, amount);
public int LimitValue(LimitType type) { if (!_limits.ContainsKey(type)) { throw new IndexOutOfRangeException(); } return(_limits[type].Value()); }
public void Decode(byte[] bytes) { using (var ms = new MemoryStream(bytes)) { Value = dc.GetInt32(ms.ReadBytes(4), 0); Type = (LimitType)ms.ReadByte(); } }
public string LimitDisplay(LimitType type) { if (!_limits.ContainsKey(type)) { throw new IndexOutOfRangeException(); } return(_limits[type].Display); }
private LimitLevelResumeDto GetResume(IEnumerable <LimitLevelResumeDto> limitUseds, LimitType limitType, FeatureType featureType, CycleType cycleType, LevelType levelType) => limitUseds.FirstOrDefault(l => l.LimitType == limitType && l.FeatureType == featureType && l.CycleType == cycleType && l.LevelType == levelType);
private void CheckExistsRule(LimitType limitType, string existsMessage, int excludeSysNo, params int[] productSysNos) { bool exists = _daBuyLimitRule.CheckExistsRule(limitType, excludeSysNo, productSysNos); if (exists) { throw new BizException(existsMessage); } }
/// <summary> /// 验证商品/套餐是否已存在规则设置 /// </summary> /// <param name="limitType">规则类型</param> /// <param name="excludeSysNo">排除规则系统编号</param> /// <param name="itemSysNos">商品或套餐系统编号</param> public bool CheckExistsRule(LimitType limitType, int excludeSysNo, params int[] itemSysNos) { DataCommand cmd = DataCommandManager.GetDataCommand("NewPromotion_BuyLimitRule_CheckExistsRule"); cmd.SetParameterValue("@ExcludeSysNo", excludeSysNo); cmd.SetParameterValue("@LimitType", (int)limitType); cmd.ReplaceParameterValue("#ItemSysNos#", string.Join(",", itemSysNos)); return(cmd.ExecuteScalar <bool>()); }
public static int GetDailyApiLimit(LimitType limitType) { switch (limitType) { case LimitType.DailyApiRequests: return(GetApiLimits().DailyApiRequests.Max); } return(0); }
public Ability(AbilityType type, PhaseType phase, LimitType limit, string text) { if (text == null) throw new ArgumentNullException("text"); this.type = type; this.phase = phase; this.limit = limit; this.text = text; }
/// <summary> /// Creates a new framerate limit description. /// </summary> /// <param name="limitType">Which type of limiting to apply.</param> /// <param name="targetFps">Used only with <see cref="LimitType.FixedFPS"/>, the target frames per second to restrict rendering to.</param> public FramerateLimit(LimitType limitType, int targetFps = 0) { if (limitType == LimitType.FixedFPS && targetFps <= 0) { limitType = LimitType.Unbounded; } Type = limitType; _fps = targetFps; }
public static LimitTypeDto ToDto(this LimitType code) { var dto = new LimitTypeDto { Name = code.Name, DisplayName = code.DisplayName }; ((IData)code).ToDto((IDataDto)dto); return(dto); }
private string GetInLimit(LimitType limitType, int value) { if (limitType == LimitType.Normal) { return($"Normal: {value}"); } if (limitType == LimitType.Exact) { return($"Exact: {value}"); } return("-"); }
public Ability(AbilityType type, PhaseType phase, LimitType limit, string text) { if (text == null) { throw new ArgumentNullException("text"); } this.type = type; this.phase = phase; this.limit = limit; this.text = text; }
public Limit(LimitType lt, Equation equa) { int type = 0; switch (lt) { case LimitType.Less: type = 1; break; case LimitType.More: type = 2; break; } limit = LP_DLL.Limit(type, equa.IntPtr()); }
public ResourceDynamicMetaObject(Expression expression, IResourceProvider value) : base(expression, BindingRestrictions.GetTypeRestriction(expression, value.GetType()), value) { foreach (var item in LimitType.GetInterfaces()) { if (LimitType.GetTypeInfo().Module != item.GetTypeInfo().Module) { continue; } var methods = item.GetMethods(); this.Interfaces[item] = methods; } }
private String GetTypeString(LimitType type) { switch (type) { case LimitType.Counter: return("Counter"); case LimitType.Time: return("Time"); default: return("Unknown"); } }
internal Action(ActionInput input) : this() { Name = input.Name; if (input.AttributesUsed != null) { AttributesUsed.AddRange(input.AttributesUsed); } if (input.SkillsUsed != null) { SkillsUsed.AddRange(input.SkillsUsed); } Limit = input.Limit; }
public SpanOp(int count, bool allowIncomplete, TOnlineOp opState, KeyComparer <TKey> comparer) { _cmp = comparer; _limitType = LimitType.Count; _count = count; _allowIncomplete = allowIncomplete; _width = default(TKey); _lookup = Lookup.EQ; _expand = int.MaxValue; _opState = opState; }
private static bool HasLimitType(List <LimitType> list, LimitType limitType) { if (list == null || list.Count == 0) { return(false); } if (list.Contains(limitType)) { return(true); } return(false); }
public static LimitCustomer CreateLimitCustomer(LimitType limitType, FeatureType featureType, CycleType cycleType, LimitLevel limitLevel) { var customer = LimitCustomer.Create("ACESSO", "document123"); var cycle = Cycle.Create(cycleType); cycle.AddLimitLevel(limitLevel); var limit = Limit.Create(limitType, featureType); limit.AddCycle(cycle); customer.AddLimit(limit); return(customer); }
public LimitRateAttribute(LimitType type, int limit, int seconds) { if (limit <= 0) { throw new ArgumentOutOfRangeException(nameof(limit)); } if (seconds <= 0) { throw new ArgumentOutOfRangeException(nameof(seconds)); } Limit = limit; Seconds = seconds; Type = type; }
public static string ToString(this LimitType t) { switch (t) { case LimitType.upper: return("upper"); case LimitType.lower: return("lower"); default: return("unknown"); } ; }
public InspectorPlusVar(LimitType _limitType, float _min, float _max, bool _progressBar, int _iMin, int _iMax, bool _active, string _type, string _name, string _dispName, VectorDrawType _vectorDrawType, bool _relative, bool _scale, float _space, bool[] _labelEnabled, string[] _label, bool[] _labelBold, bool[] _labelItalic, int[] _labelAlign, bool[] _buttonEnabled, string[] _buttonText, string[] _buttonCallback, bool[] buttonCondense, int _numSpace, string _classType, Vector3 _offset, bool _QuaternionHandle, bool _canWrite, string _tooltip, bool _hasTooltip, bool _toggleStart, int _toggleSize, int _toggleLevel, bool _largeTexture, float _textureSize, string _textFieldDefault, bool _textArea) { limitType = _limitType; min = _min; max = _max; progressBar = _progressBar; iMax = _iMax; iMin = _iMin; active = _active; type = _type; name = _name; dispName = _dispName; vectorDrawType = _vectorDrawType; relative = _relative; scale = _scale; space = _space; labelEnabled = _labelEnabled; label = _label; labelBold = _labelBold; labelItalic = _labelItalic; labelAlign = _labelAlign; buttonEnabled = _buttonEnabled; buttonText = _buttonText; buttonCallback = _buttonCallback; numSpace = _numSpace; classType = _classType; offset = _offset; QuaternionHandle = _QuaternionHandle; canWrite = _canWrite; tooltip = _tooltip; hasTooltip = _hasTooltip; toggleStart = _toggleStart; toggleSize = _toggleSize; toggleLevel = _toggleLevel; largeTexture = _largeTexture; textureSize = _textureSize; textFieldDefault = _textFieldDefault; textArea = _textArea; }
protected override OpResult _Store(LimitType _obj) { if (_obj == null) { return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "LimitType object cannot be created as it is null")); } if (Exists(_obj)) { ExecuteNonQuery(GetQuery_UpdateQuery(_obj)); return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj)); } ExecuteNonQuery(GetQuery_InsertQuery(_obj)); _obj.FromDb = true; return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj)); }
public LimitUsed(string companyKey, string documentNumber, LimitType limitType, FeatureType featureType, CycleType cycleType, LevelType levelType, long amount) { CompanyKey = companyKey; DocumentNumber = documentNumber; LimitType = limitType; FeatureType = featureType; CycleType = cycleType; LevelType = levelType; Amount = amount; Timestamp = DateTime.Now; }
public static void LimitInput(TextBox textBox, LimitType limit, IEnumerable <string> allowedStrings = null) { List <Func <string, bool> > tag = new List <Func <string, bool> >(); if (allowedStrings?.Count() > 0) { tag.Add(v => allowedStrings.Contains(v)); } tag.Add(limit == LimitType.Double ? (Func <string, bool>)(v => !double.TryParse(v, out double _)) : (v => !int.TryParse(v, out int _)) ); textBox.Tag = tag; textBox.PreviewTextInput += (s, e) => { if (s is TextBox textBox && textBox.Tag is List <Func <string, bool> > canChanges) { e.Handled = !string.IsNullOrWhiteSpace(e.Text) && (e.Text != "-" || textBox.CaretIndex != 0) && canChanges.Any(c => c(textBox.Text.Insert(textBox.CaretIndex, e.Text))); } }; DataObject.AddPastingHandler(textBox, (s, e) => { if (s is TextBox textBox && textBox.Tag is Func <string, bool> canChange) { if (e.DataObject.GetDataPresent(typeof(string))) { string text = (string)e.DataObject.GetData(typeof(string)); if (canChange(textBox.Text.Insert(textBox.CaretIndex, text))) { e.CancelCommand(); } } else { e.CancelCommand(); } } });
public async Task<Limit> DisableLimit(string customerId, LimitType limitType, string author) { // Retrieve current limit var limit = await _limitRepository.Get(customerId, limitType); // Throw NotFound if it doesn't exist if (limit == null) throw new NotFoundException(LimitMessages.DepositLimitNotFound); // Disable limit limit.Disable(author); _limitRepository.AddOrUpdate(limit); //Log limit var log = new Log(limit); _logRepository.Add(log); return limit; }
public SpanOp(TKey width, Lookup lookup, TOnlineOp opState, KeyComparer <TKey> comparer) { _cmp = comparer; _limitType = LimitType.Width; _count = 0; _allowIncomplete = false; _width = width; _lookup = lookup; _expand = int.MaxValue; _opState = opState; //_whilePredicate = null; //_sumMapper = null; //_sumLimit = default(TResult); }
public LimitLevel GetLimitLevel(LimitType limitType, FeatureType featureType, CycleType cycleType, LevelType levelType) { var limit = Limits.FirstOrDefault(l => l.Type == limitType && l.FeatureType == featureType); if (limit is null) { return(null); } var cycle = limit.Cycles.FirstOrDefault(c => c.Type == cycleType); if (cycle is null) { return(null); } return(cycle.LimitLevels.FirstOrDefault(l => l.Type == levelType)); }
public void SetTarget(LimitType limitType, int limit, List<int> starsLevels, IEnumerable<KeyValuePair<int, int>> prices = null) { LimitType = limitType; switch (limitType) { case LimitType.Moves: Moves = limit; break; case LimitType.Time: TimeSpan = limit; break; } StarsLevels = starsLevels; if (prices != null) { foreach (var p in prices) { _prices.Add(new KeyValuePair<int, int>(p.Key, p.Value)); } } }
public static string FormatMessage(LimitType type) { switch (type) { case LimitType.CodeSize: return "Code size limit was exceeded"; case LimitType.CodeOutput: return "Code output limit was exceeded"; case LimitType.MemoryUsage: return "Memory usage limit was exceeded"; case LimitType.ExecutionTime: return "Execution time limit was exceeded"; case LimitType.DirSize: return "Directory size limit was exceeded"; default: throw new ArgumentException("Unknown limit type " + type); } }
private int CheckAgainstFuelcutLimiter(SymbolCollection symbols, string filename, int requestedairmass, ref LimitType AirmassLimiter) { int retval = requestedairmass; if (fuelcutAirInletLimit < requestedairmass) { retval = fuelcutAirInletLimit; AirmassLimiter = LimitType.FuelCutLimiter; logger.Debug("Reduced airmass because of FuelCutLimiter: " + requestedairmass.ToString()); } return retval; }
public Limit(GroupSelector selector, LimitType type) : base(selector) { limit_type = type; }
public Limit(LimitType lt, Equation equa) { int type = 0; switch(lt){ case LimitType.Less: type = 1; break; case LimitType.More: type = 2; break; } limit = LP_DLL.Limit(type, equa.IntPtr()); }
public ITextBuilder Phase(PhaseType phase, string text, LimitType limit) { this.abilities.Add(new Ability(AbilityType.Passive, phase, limit, text)); return this; }
public ITextBuilder AnyPhase(string text, LimitType limit) { return Phase(PhaseType.None, text, limit); }
public ITextBuilder Response(string text, LimitType limit) { this.abilities.Add(new Ability(AbilityType.Response, PhaseType.None, limit, text)); return this; }
private int CheckAgainstAirmassLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool autogearbox, ref LimitType AirmassLimiter) { int airmasslimit = requestedairmass; string message; if (autogearbox) { airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(bstknkMaxAirmassAuMap, bstknkMaxAirmassMap_Xaxis, bstknkMaxAirmassMap_Yaxis, rpm, 0)); message = "Reduced airmass because of BstKnkCal.MaxAirmassAu: " + requestedairmass.ToString() + " rpm: " + rpm.ToString(); } else { airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(bstknkMaxAirmassMap, bstknkMaxAirmassMap_Xaxis, bstknkMaxAirmassMap_Yaxis, rpm, 0)); message = "Reduced airmass because of BstKnkCal.MaxAirmass: " + requestedairmass.ToString() + " rpm: " + rpm.ToString(); } if (airmasslimit < requestedairmass) { requestedairmass = airmasslimit; AirmassLimiter = LimitType.AirmassLimiter; logger.Debug(message); } return requestedairmass; }
public LimitExceededException(LimitType type) : base(FormatMessage(type)) { LimitType = type; }
private int CalculateMaxAirmassforcell(SymbolCollection symbols, string filename, int pedalposition, int rpm, int requestairmass, bool autogearbox, bool E85, bool Convertable, bool OverboostEnabled, bool E85Automatic, bool TorqueLimitEnabled, bool Gear1stLimitAvailable, out LimitType limiterType) { int retval = requestairmass; //logger.Debug("Pedalpos: " + pedalposition.ToString() + " Rpm: " + rpm.ToString() + " requests: " + requestairmass.ToString() + " mg/c"); //calculate the restricted airmass for the current point limiterType = LimitType.None; if (TorqueLimitEnabled) { LimitType TrqLimiterType = LimitType.None; retval = CheckAgainstTorqueLimiters(symbols, filename, rpm, requestairmass, E85, Convertable, autogearbox, OverboostEnabled, E85Automatic, Gear1stLimitAvailable, out TrqLimiterType); if (retval < requestairmass) { limiterType = TrqLimiterType; } } LimitType AirmassLimiterType = LimitType.None; int TorqueLimitedAirmass = retval; retval = CheckAgainstAirmassLimiters(symbols, filename, rpm, retval, autogearbox, ref AirmassLimiterType); retval = CheckAgainstTurboSpeedLimiter(symbols, filename, rpm, retval, ref AirmassLimiterType); // finally check agains fuelcut limiter retval = CheckAgainstFuelcutLimiter(symbols, filename, retval, ref AirmassLimiterType); if (retval < TorqueLimitedAirmass) { limiterType = AirmassLimiterType; } return retval; }
private int CheckAgainstTorqueLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool E85, bool Convertable, bool Automatic, bool OverboostEnabled, bool E85Automatic, bool Gear1stLimitAvailable, out LimitType TrqLimiter) { TrqLimiter = LimitType.None; int LimitedAirMass = requestedairmass; int torque = AirmassToTorque(symbols, filename, requestedairmass, rpm, useTrionicCalculationForTorque.Checked); if (E85Automatic && E85 && Automatic) { int torquelimitE85Auto = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimE85Auto, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (torque > torquelimitE85Auto) { logger.Debug("Torque E85Autolimit is limited from " + torque.ToString() + " to " + torquelimitE85Auto.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitE85Auto; TrqLimiter = LimitType.TorqueLimiterEngineE85Auto; } } else if (E85) { int torquelimitE85 = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimE85, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (torque > torquelimitE85) { logger.Debug("Torque E85limit is limited from " + torque.ToString() + " to " + torquelimitE85.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitE85; TrqLimiter = LimitType.TorqueLimiterEngineE85; } } else if (Automatic) { int torquelimitAuto = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimAuto, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (torque > torquelimitAuto) { logger.Debug("Torque Autolimit is limited from " + torque.ToString() + " to " + torquelimitAuto.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitAuto; TrqLimiter = LimitType.TorqueLimiterEngine; } } else { int torquelimitOverboost = 0; if (OverboostEnabled) { torquelimitOverboost = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimOverboost, xdummy, airTorqueMap_Yaxis, rpm, 0)); } int torquelimitPetrol = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (OverboostEnabled && torque > torquelimitOverboost) { logger.Debug("Torque OverBoostLimit is limited from " + torque.ToString() + " to " + torquelimitOverboost.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitOverboost; TrqLimiter = LimitType.OverBoostLimiter; } else if (OverboostEnabled && torque < torquelimitOverboost && torque > torquelimitPetrol) { logger.Debug("Torque OverBoostLimit replaced Petrol limit " + torquelimitPetrol.ToString() + " with " + torquelimitOverboost.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitOverboost; TrqLimiter = LimitType.OverBoostLimiter; } else if (torque > torquelimitPetrol) { logger.Debug("Torque Petrol is limited from " + torque.ToString() + " to " + torquelimitPetrol.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitPetrol; TrqLimiter = LimitType.TorqueLimiterEngine; } } if (!isCarAutomatic.Checked) { int[] gears = new int[6]; gears.SetValue(0, 0); gears.SetValue(1, 1); gears.SetValue(2, 2); gears.SetValue(3, 3); gears.SetValue(4, 4); gears.SetValue(5, 5); if (Convertable) { int torquelimitConvertable = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimConvertible, xdummy, gears, comboBoxEdit1.SelectedIndex, 0)); if (torque > torquelimitConvertable) { torque = torquelimitConvertable; TrqLimiter = LimitType.TorqueLimiterGear; //logger.Debug("Convertable gear torque limit hit"); } } int torquelimitManual = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimGear, xdummy, gears, comboBoxEdit1.SelectedIndex, 0)); if (torque > torquelimitManual) { torque = torquelimitManual; TrqLimiter = LimitType.TorqueLimiterGear; //logger.Debug("Manual gear torque limit hit"); } // and check 5th gear limiter as well!!! (if checkbox is 5) if (comboBoxEdit1.SelectedIndex == 5) { //logger.Debug("Checking fifth gear!"); int torquelimit5th = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim5th, xdummy, enginetorquelim5th_Yaxis, rpm, 0)); if (torque > torquelimit5th) { torque = torquelimit5th; TrqLimiter = LimitType.TorqueLimiterGear; //logger.Debug("Fifth gear torque limit hit"); } } } else { // automatic! if (comboBoxEdit1.SelectedIndex == 0) { //logger.Debug("Checking reverse gear!"); int torquelimitreverse = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimReverse, xdummy, enginetorquelimReverse_Yaxis, rpm, 0)); if (torque > torquelimitreverse) { torque = torquelimitreverse; TrqLimiter = LimitType.TorqueLimiterGear; //logger.Debug("Reverse gear torque limit hit"); } } else if (comboBoxEdit1.SelectedIndex == 1) { //logger.Debug("Checking first gear!"); if (Gear1stLimitAvailable) { int torquelimit1st = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim1st, xdummy, enginetorquelim1st_Yaxis, rpm, 0)); if (torque > torquelimit1st) { torque = torquelimit1st; TrqLimiter = LimitType.TorqueLimiterGear; //logger.Debug("First gear torque limit hit"); } } } } int TestLimitedAirmass = Convert.ToInt32(GetInterpolatedTableValue(airTorqueMap, airTorqueMap_Xaxis, enginetorque_Yaxis, rpm, torque)); if (TestLimitedAirmass < LimitedAirMass) { LimitedAirMass = TestLimitedAirmass; if(TrqLimiter == LimitType.None) TrqLimiter = LimitType.AirTorqueCalibration; } // logger.Debug("1. Torque is " + torque.ToString() + " at " + rpm.ToString() + " rpm and airmass " + requestedairmass.ToString() + " res: " + LimitedAirMass.ToString() + " type: " + TrqLimiter.ToString()); if (TrqLimiter == LimitType.None) LimitedAirMass = requestedairmass; // bugfix for if no limiter is active // logger.Debug("2. Torque is " + torque.ToString() + " at " + rpm.ToString() + " rpm and airmass " + requestedairmass.ToString() + " res: " + LimitedAirMass.ToString() + " type: " + TrqLimiter.ToString()); return LimitedAirMass; }
public SaveIndex(LimitType LimitType) { this.LimitType = LimitType; }
private int CheckAgainstTorqueLimiters(SymbolCollection symbols, string filename, int rpm, int requestedairmass, bool E85, bool Automatic, bool OverboostEnabled, out LimitType TrqLimiter, bool HighOutput) { // first convert airmass to torque TrqLimiter = LimitType.None; int LimitedAirMass = requestedairmass; int torque = Convert.ToInt32(GetInterpolatedTableValue(nominalTorqueMap, nominalTorqueMap_Xaxis, nominalTorqueMap_Yaxis, rpm, requestedairmass)); if (E85) { int torquelimitE85 = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimE85, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (torque > torquelimitE85) { logger.Debug("Torque E85limit is limited from " + torque.ToString() + " to " + torquelimitE85.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitE85; TrqLimiter = LimitType.TorqueLimiterEngineE85; } } else { int torquelimitOverboost = 0; if (OverboostEnabled) { torquelimitOverboost = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimOverboost, xdummy, airTorqueMap_Yaxis, rpm, 0)); } int torquelimitPetrol = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelim, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (OverboostEnabled && torque > torquelimitOverboost) { logger.Debug("Torque OverBoostLimit is limited from " + torque.ToString() + " to " + torquelimitOverboost.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitOverboost; TrqLimiter = LimitType.OverBoostLimiter; } else if (OverboostEnabled && torque < torquelimitOverboost && torque > torquelimitPetrol) { logger.Debug("Torque OverBoostLimit replaced Petrol limit " + torquelimitPetrol.ToString() + " with " + torquelimitOverboost.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitOverboost; TrqLimiter = LimitType.OverBoostLimiter; } else if (torque > torquelimitPetrol) { logger.Debug("Torque Petrol is limited from " + torque.ToString() + " to " + torquelimitPetrol.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitPetrol; TrqLimiter = LimitType.TorqueLimiterEngine; } } // Trq_ManGear = only manual gearbox if (!isCarAutomatic.Checked) { // Gear values have the same meaning as in ECMStat.ManualGear // Actual gear (manual gearbox). int[] gears = new int[8]; gears.SetValue(0, 0); // Undefined gear 0 gears.SetValue(1, 1); // First gear 1 gears.SetValue(2, 2); // Second gear 2 gears.SetValue(3, 3); // Third gear 3 gears.SetValue(4, 4); // Fourth gear 4 gears.SetValue(5, 5); // Fifth gear 5 gears.SetValue(6, 6); // Sixth gear 6 gears.SetValue(7, 7); // Reverse gear 7 int torquelimitManual = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimGear, xdummy, gears, cbGearSelectionEdit.SelectedIndex, 0)); if (torque > torquelimitManual) { logger.Debug("Manual gear torque limited from " + torque.ToString() + " to " + torquelimitManual.ToString() + " at " + rpm.ToString() + " rpm"); TrqLimiter = LimitType.TorqueLimiterGear; } } else { int torquelimitAutomatic = Convert.ToInt32(GetInterpolatedTableValue(enginetorquelimAuto, xdummy, airTorqueMap_Yaxis, rpm, 0)); if (torque > torquelimitAutomatic) { logger.Debug("Automatic gear torque limited from " + torque.ToString() + " to " + torquelimitAutomatic.ToString() + " at " + rpm.ToString() + " rpm"); torque = torquelimitAutomatic; TrqLimiter = LimitType.TorqueLimiterGear; } } int TestLimitedAirmass = Convert.ToInt32(GetInterpolatedTableValue(airTorqueMap, airTorqueMap_Xaxis, airTorqueMap_Yaxis, rpm, torque)); if (TestLimitedAirmass < LimitedAirMass) { LimitedAirMass = TestLimitedAirmass; if (TrqLimiter == LimitType.None) TrqLimiter = LimitType.AirTorqueCalibration; } // logger.Debug("1. Torque is " + torque.ToString() + " at " + rpm.ToString() + " rpm and airmass " + requestedairmass.ToString() + " res: " + LimitedAirMass.ToString() + " type: " + TrqLimiter.ToString()); if (TrqLimiter == LimitType.None) LimitedAirMass = requestedairmass; // bugfix for if no limiter is active // logger.Debug("2. Torque is " + torque.ToString() + " at " + rpm.ToString() + " rpm and airmass " + requestedairmass.ToString() + " res: " + LimitedAirMass.ToString() + " type: " + TrqLimiter.ToString()); return LimitedAirMass; }
private int CalculateMaxAirmassforcell(SymbolCollection symbols, string filename, int pedalposition, int rpm, int requestairmass, bool autogearbox, bool E85, bool OverboostEnabled, out LimitType limiterType, bool HighOutput) { // calculate the restricted airmass for the current point int retval = requestairmass; limiterType = LimitType.None; logger.Debug("Pedalpos: " + pedalposition.ToString() + " Rpm: " + rpm.ToString() + " requests: " + requestairmass.ToString() + " mg/c"); // first check against torquelimiters LimitType TrqLimiterType = LimitType.None; retval = CheckAgainstTorqueLimiters(symbols, filename, rpm, requestairmass, E85, autogearbox, OverboostEnabled, out TrqLimiterType, HighOutput); if (retval < requestairmass) { limiterType = TrqLimiterType; } // secondly check against airmasslimiters LimitType AirmassLimiterType = LimitType.None; int TorqueLimitedAirmass = retval; retval = CheckAgainstAirmassLimiters(symbols, filename, rpm, retval, autogearbox, E85, ref AirmassLimiterType); // finally check agains fuelcut limiter retval = CheckAgainstFuelcutLimiter(symbols, filename, retval, ref AirmassLimiterType); if (retval < TorqueLimitedAirmass) { limiterType = AirmassLimiterType; } return retval; }
public void DrawFieldGUI() { if (canWrite) { GUILayout.Space(30.0f); if (type == typeof(float).Name) { GUILayout.Label("Limit: "); limitType = (LimitType)EditorGUILayout.EnumPopup(limitType); bool oldEnabled = GUI.enabled; GUI.enabled = limitType == LimitType.Min || limitType == LimitType.Range; min = EditorGUILayout.FloatField(min, GUILayout.Width(80.0f)); GUI.enabled = limitType == LimitType.Max || limitType == LimitType.Range; max = EditorGUILayout.FloatField(max, GUILayout.Width(80.0f)); if (limitType == LimitType.Range) { GUILayout.Label("ProgressBar: "); progressBar = GUILayout.Toggle(progressBar, ""); } GUI.enabled = oldEnabled; } else if (type == typeof(int).Name) { GUILayout.Label("Limit: "); limitType = (LimitType)EditorGUILayout.EnumPopup(limitType); bool oldEnabled = GUI.enabled; GUI.enabled = limitType == LimitType.Min || limitType == LimitType.Range; iMin = EditorGUILayout.IntField(iMin, GUILayout.Width(80.0f)); GUI.enabled = limitType == LimitType.Max || limitType == LimitType.Range; iMax = EditorGUILayout.IntField(iMax, GUILayout.Width(80.0f)); if (limitType == LimitType.Range) { GUILayout.Label("ProgressBar: "); progressBar = GUILayout.Toggle(progressBar, ""); } GUI.enabled = oldEnabled; } else if (type == typeof(Vector3).Name || type == typeof(Vector2).Name) { GUILayout.Label("Draw: "); vectorDrawType = (VectorDrawType)EditorGUILayout.EnumPopup(vectorDrawType); bool oldEnabled = GUI.enabled; GUI.enabled = vectorDrawType != VectorDrawType.None; GUILayout.Label("Relative: "); relative = GUILayout.Toggle(relative, ""); if (vectorDrawType == VectorDrawType.Direction) { GUILayout.Label("Scale: "); scale = GUILayout.Toggle(scale, ""); } if (vectorDrawType == VectorDrawType.Scale || vectorDrawType == VectorDrawType.Rotation) { GUILayout.Label("Offset: "); offset.x = EditorGUILayout.FloatField(offset.x); offset.y = EditorGUILayout.FloatField(offset.y); offset.z = EditorGUILayout.FloatField(offset.z); } GUI.enabled = oldEnabled; } else if (type == typeof(Quaternion).Name) { QuaternionHandle = GUILayout.Toggle(QuaternionHandle, new GUIContent("Draw handle")); GUILayout.Space(20.0f); GUI.enabled = QuaternionHandle; GUILayout.Label("Offset: "); offset.x = EditorGUILayout.FloatField(offset.x); offset.y = EditorGUILayout.FloatField(offset.y); offset.z = EditorGUILayout.FloatField(offset.z); GUI.enabled = true; } else if (type == typeof(bool).Name) { toggleStart = GUILayout.Toggle(toggleStart, "Toggle group"); GUI.enabled = toggleStart; toggleSize = EditorGUI.IntSlider(GUILayoutUtility.GetRect(150.0f, 18.0f), toggleSize, 1, Mathf.Max(1, (maxSize - index) - 1)); GUI.enabled = true; } else if (type == typeof(Texture).Name || type == typeof(Texture2D).Name) { largeTexture = GUILayout.Toggle(largeTexture, new GUIContent("large preview")); GUI.enabled = largeTexture; textureSize = EditorGUILayout.Slider(textureSize, 35.0f, 300.0f); GUI.enabled = true; } else if (type == typeof(string).Name) { GUILayout.Label("Default text"); textFieldDefault = GUILayout.TextField(textFieldDefault, GUILayout.Width(180.0f)); GUILayout.Label("Text area: "); textArea = GUILayout.Toggle(textArea, ""); } } else GUILayout.Label("Read only"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (property) { EditorGUILayout.BeginHorizontal(); GUILayout.TextField(""); GUILayout.Toggle(false, new GUIContent("")); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginVertical("Box", GUILayout.Height(space), GUILayout.ExpandWidth(true)); numSpace = Mathf.FloorToInt(space / 25.0f); bool guiEnabled = GUI.enabled; if (numSpace > 0) GUILayout.Space((space - numSpace * 25.0f) / 2.0f); for (int i = 0; i < numSpace; i += 1) { GUI.enabled = true; GUILayout.BeginHorizontal(); GUILayout.Space(10.0f); labelEnabled[i] = GUILayout.Toggle(labelEnabled[i], ""); GUI.enabled = labelEnabled[i]; GUILayout.Label("Label "); label[i] = EditorGUILayout.TextField("", label[i]); labelBold[i] = GUILayout.Toggle(labelBold[i], new GUIContent("B")); labelItalic[i] = GUILayout.Toggle(labelItalic[i], new GUIContent("I")); GUILayout.Label("Align"); labelAlign[i] = EditorGUILayout.IntSlider(labelAlign[i], 0, 2, GUILayout.Width(150.0f)); GUILayout.Space(40.0f); GUI.enabled = true; for (int j = 0; j < 4; j += 1) { GUI.enabled = true; //button buttonEnabled[i * 4 + j] = GUILayout.Toggle(buttonEnabled[i * 4 + j], ""); GUI.enabled = buttonEnabled[i * 4 + j]; GUILayout.Label("Button "); buttonText[i * 4 + j] = EditorGUILayout.TextField("", buttonText[i * 4 + j], GUILayout.Width(50.0f)); GUILayout.Label("Callback "); buttonCallback[i * 4 + j] = EditorGUILayout.TextField("", buttonCallback[i * 4 + j], GUILayout.Width(50.0f)); bool buttonToCome = false; for (int k = j; k < 4; k += 1) if (buttonEnabled[i * 4 + k]) buttonToCome = true; if (!buttonToCome || j == 3) { GUI.enabled = true; if (j > 1) buttonCondense[i] = GUILayout.Toggle(buttonCondense[i], new GUIContent("Condense")); break; } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } if (numSpace > 0) GUILayout.Space(-(space - numSpace * 25.0f) / 2.0f); else GUILayout.Space(space); GUI.enabled = guiEnabled; GUILayoutUtility.GetRect(18.0f, -4.0f, "TextField"); EditorGUILayout.EndVertical(); GUILayoutUtility.GetRect(18, -10.0f - 10.0f, "TextField");//really hack-ish, but we need to get some space back Rect rect = GUILayoutUtility.GetRect(18, 10.0f, "TextField"); EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeVertical); if (Event.current.type == EventType.mouseDown) { pressed = false; if (rect.Contains(Event.current.mousePosition)) { startpos = Event.current.mousePosition; pressed = true; } } if (Event.current.type == EventType.mouseDrag && pressed) { space += (Event.current.mousePosition - startpos).y; startpos = Event.current.mousePosition; EditorWindow.GetWindow(typeof(InspectorPlusWindow)).Repaint(); space = Mathf.Clamp(space, 0.0f, 4 * 25.0f); GUI.changed = true; } if (Event.current.type == EventType.mouseUp) pressed = false; }
private DataTable CalculateDataTable(string filename, SymbolCollection symbols, out LimitType[] limitResult) { limitResult = null; // do the math! entirefile = File.ReadAllBytes(filename); try { if (IsBinaryBiopower(symbols)) { isFuelE85.Enabled = true; } else { isFuelE85.Checked = false; isFuelE85.Enabled = false; } if (isCarAutomatic.Checked) { isOverboostActive.Enabled = false; } else { if (IsOverboostEnabled(filename, symbols)) { isOverboostActive.Enabled = true; } else { isOverboostActive.Enabled = false; } } // TODO: isCarHighOutput, Get the high output/low output from the loaded binary. xdummy.SetValue(0, 0); int[] pedalrequestmap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "PedalMapCal.Trq_RequestMap"), GetSymbolLength(symbols, "PedalMapCal.Trq_RequestMap")); limitResult = new LimitType[pedalrequestmap.Length]; int[] resulttable = new int[pedalrequestmap.Length]; // result pedal_Rows = GetSymbolLength(symbols, "PedalMapCal.n_EngineMap") / 2; pedal_Columns = GetSymbolLength(symbols, "PedalMapCal.X_PedalMap") / 2; pedal_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "PedalMapCal.n_EngineMap"), GetSymbolLength(symbols, "PedalMapCal.n_EngineMap")); pedal_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "PedalMapCal.X_PedalMap"), GetSymbolLength(symbols, "PedalMapCal.X_PedalMap")); airTorqueMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqMastCal.m_AirTorqMap"), GetSymbolLength(symbols, "TrqMastCal.m_AirTorqMap")); airTorqueMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqMastCal.Trq_EngXSP"), GetSymbolLength(symbols, "TrqMastCal.Trq_EngXSP")); airTorqueMap_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqMastCal.n_EngineYSP"), GetSymbolLength(symbols, "TrqMastCal.n_EngineYSP")); bstknkMaxAirmassMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.MaxAirmass"), GetSymbolLength(symbols, "BstKnkCal.MaxAirmass")); string bstknkMaxAirmassMap_XaxisName = "BstKnkCal.OffsetXSP"; if (!SymbolExists(bstknkMaxAirmassMap_XaxisName, symbols)) { bstknkMaxAirmassMap_XaxisName = "BstKnkCal.fi_offsetXSP"; // in case of flexifuel binary } bstknkMaxAirmassMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, bstknkMaxAirmassMap_XaxisName), GetSymbolLength(symbols, bstknkMaxAirmassMap_XaxisName)); for (int a = 0; a < bstknkMaxAirmassMap_Xaxis.Length; a++) { int val = (int)bstknkMaxAirmassMap_Xaxis.GetValue(a); if (val > 32000) val = -(65536 - val); bstknkMaxAirmassMap_Xaxis.SetValue(val, a); } bstknkMaxAirmassMap_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.n_EngYSP"), GetSymbolLength(symbols, "BstKnkCal.n_EngYSP")); if (SymbolExists("BstKnkCal.MaxAirmassAu", symbols)) { bstknkMaxAirmassAuMap = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(symbols, "BstKnkCal.MaxAirmassAu"), GetSymbolLength(symbols, "BstKnkCal.MaxAirmassAu")); } nominalTorqueMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqMastCal.Trq_NominalMap"), GetSymbolLength(symbols, "TrqMastCal.Trq_NominalMap")); nominalTorqueMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqMastCal.m_AirXSP"), GetSymbolLength(symbols, "TrqMastCal.m_AirXSP")); nominalTorqueMap_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqMastCal.n_EngineYSP"), GetSymbolLength(symbols, "TrqMastCal.n_EngineYSP")); for (int a = 0; a < nominalTorqueMap.Length; a++) { int val = (int)nominalTorqueMap.GetValue(a); if (val > 32000) val = -(65536 - val); nominalTorqueMap.SetValue(val, a); } fuelcutAirInletLimit = Convert.ToInt32(readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FCutCal.m_AirInletLimit"), GetSymbolLength(symbols, "FCutCal.m_AirInletLimit")).GetValue(0)); if (isFuelE85.Checked) { ffMaxAirmassMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FFAirCal.m_maxAirmass"), GetSymbolLength(symbols, "FFAirCal.m_maxAirmass")); ffMaxAirmassMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FFAirCal.fi_offsetXSP"), GetSymbolLength(symbols, "FFAirCal.fi_offsetXSP")); for (int a = 0; a < ffMaxAirmassMap_Xaxis.Length; a++) { int val = (int)ffMaxAirmassMap_Xaxis.GetValue(a); if (val > 32000) val = -(65536 - val); ffMaxAirmassMap_Xaxis.SetValue(val, a); } } // Try old style TrqLimCal.Trq_MaxEngineManTab1/2 or TrqLimCal.Trq_MaxEngineAutTab1/2 string engineTorqueLimiter; if (isCarAutomatic.Checked) { if (isCarHighOutput.Checked) { engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineAutTab1"; } else { engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineAutTab2"; } } else { if (isCarHighOutput.Checked) { engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineManTab1"; } else { engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineManTab2"; } } if (!SymbolExists(engineTorqueLimiter, symbols)) { // If the old style symbol does not exist, default to the newer style TrqLimCal.Trq_MaxEngineTab1/2 if (isCarHighOutput.Checked) { engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineTab1"; } else { engineTorqueLimiter = "TrqLimCal.Trq_MaxEngineTab2"; } } enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, engineTorqueLimiter), GetSymbolLength(symbols, engineTorqueLimiter)); if (isFuelE85.Checked) { if (isCarHighOutput.Checked) { enginetorquelimE85 = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FFTrqCal.FFTrq_MaxEngineTab1"), GetSymbolLength(symbols, "FFTrqCal.FFTrq_MaxEngineTab1")); } else { enginetorquelimE85 = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FFTrqCal.FFTrq_MaxEngineTab2"), GetSymbolLength(symbols, "FFTrqCal.FFTrq_MaxEngineTab2")); } } enginetorquelimOverboost = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqLimCal.Trq_OverBoostTab"), GetSymbolLength(symbols, "TrqLimCal.Trq_OverBoostTab")); enginetorquelimGear = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TrqLimCal.Trq_ManGear"), GetSymbolLength(symbols, "TrqLimCal.Trq_ManGear")); // Newer style automatic torque limits if (isCarHighOutput.Checked) { enginetorquelimAuto = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TMCCal.Trq_MaxEngineTab"), GetSymbolLength(symbols, "TMCCal.Trq_MaxEngineTab")); } else { enginetorquelimAuto = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TMCCal.Trq_MaxEngineLowTab"), GetSymbolLength(symbols, "TMCCal.Trq_MaxEngineLowTab")); } try { int[] injConstant = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "InjCorrCal.InjectorConst"), GetSymbolLength(symbols, "InjCorrCal.InjectorConst")); injectorConstant = Convert.ToInt32(injConstant.GetValue(0)); injectorBatteryCorrection = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "InjCorrCal.BattCorrTab"), GetSymbolLength(symbols, "InjCorrCal.BattCorrTab")); injectorBatteryCorrection_axis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "InjCorrCal.BattCorrSP"), GetSymbolLength(symbols, "InjCorrCal.BattCorrSP")); if (isFuelE85.Checked) { fuelVEMap = readdatafromfile(filename, (int)GetSymbolAddress(symbols, "FFFuelCal.TempEnrichFacMAP"), GetSymbolLength(symbols, "FFFuelCal.TempEnrichFacMAP")); } else { fuelVEMap = readdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.TempEnrichFacMap"), GetSymbolLength(symbols, "BFuelCal.TempEnrichFacMap")); } fuelVE_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.AirXSP"), GetSymbolLength(symbols, "BFuelCal.AirXSP")); fuelVE_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.RpmYSP"), GetSymbolLength(symbols, "BFuelCal.RpmYSP")); if (SymbolExists("ExhaustCal.T_Lambda1Map", symbols)) { EGTMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "ExhaustCal.T_Lambda1Map"), GetSymbolLength(symbols, "ExhaustCal.T_Lambda1Map")); } } catch (Exception E) { logger.Debug(E.Message); } // step thru the complete pedal and rpm range for (int colcount = 0; colcount < pedal_Columns; colcount++) { for (int rowcount = 0; rowcount < pedal_Rows; rowcount++) { // get the current value from the request map int rpm = (int)pedal_Xaxis.GetValue(rowcount); int requestedtorque = (int)pedalrequestmap.GetValue((colcount * pedal_Rows) + rowcount); int airmassrequestforcell = TorqueToAirmass(requestedtorque, rpm, false); LimitType limiterType = LimitType.None; int resultingAirMass = CalculateMaxAirmassforcell(symbols, filename,/*pedalpos*/((int)pedal_Yaxis.GetValue(colcount) / 10), /* rpm */(int)pedal_Xaxis.GetValue(rowcount), airmassrequestforcell, isCarAutomatic.Checked, isFuelE85.Checked, isOverboostActive.Checked, out limiterType, isCarHighOutput.Checked); resulttable.SetValue(resultingAirMass, (colcount * pedal_Rows) + rowcount); limitResult.SetValue(limiterType, (colcount * pedal_Rows) + rowcount); } } // now show resulttable DataTable dt = new DataTable(); foreach (int xvalue in pedal_Xaxis) { dt.Columns.Add(xvalue.ToString()); } // now fill the table rows m_MaxValueInTable = 0; for (int r = pedal_Yaxis.Length - 1; r >= 0; r--) { object[] values = new object[pedal_Columns]; for (int t = 0; t < pedal_Xaxis.Length; t++) { int currValue = (int)resulttable.GetValue((r * pedal_Columns) + t); if (currValue > m_MaxValueInTable) m_MaxValueInTable = currValue; values.SetValue(resulttable.GetValue((r * pedal_Columns) + t), t); } dt.Rows.Add(values); } return dt; } catch (Exception E) { logger.Debug("Failed to calculate for file : " + filename); } return null; }
private int CheckAgainstTurboSpeedLimiter(SymbolCollection symbols, string filename, int rpm, int requestedairmass, ref LimitType AirmassLimiter) { int ambientpressure = Convert.ToInt32(spinEdit1.EditValue) * 10; // 100.0 kPa = 1000 as table value unit is 0.1 kPa int airmasslimit = Convert.ToInt32(GetInterpolatedTableValue(turbospeed, xdummy, turbospeed_Yaxis, ambientpressure, 0)); // Second limitation is based on engine rpm to prevent the turbo from overspeeding at high rpm. // Interpolated correction factor applied to the calculated airmass value from main turbospeed table LimEngCal.TurboSpeedTab. int correctionfactor = Convert.ToInt32(GetInterpolatedTableValue(turbospeed2, xdummy, turbospeed2_Yaxis, rpm, 0)); airmasslimit = airmasslimit * correctionfactor / 1000; // correction factor value unit is 0.001 if (airmasslimit < requestedairmass) { requestedairmass = airmasslimit; AirmassLimiter = LimitType.TurboSpeedLimiter; } return requestedairmass; }
private DataTable CalculateDataTable(string filename, SymbolCollection symbols, out LimitType[] limitResult) { limitResult = null; // do the math! try { if (IsBinaryBiopower(symbols)) { isFuelE85.Enabled = true; } else { isFuelE85.Checked = false; isFuelE85.Enabled = false; } if (IsBinaryConvertable(symbols)) { isCarConvertible.Enabled = true; } else { isCarConvertible.Checked = false; isCarConvertible.Enabled = false; } if (IsOverboostEnabled(filename, symbols)) { isOverboostActive.Enabled = true; } else { isOverboostActive.Enabled = false; } bool e85automatic = IsBinaryBiopowerAuto(symbols); bool torqueLimitEnabled = HasBinaryTorqueLimiterEnabled(symbols, filename); bool gear1stLimitAvailable = Has1stGearLimit(symbols); xdummy.SetValue(0, 0); int[] pedalrequestmap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "PedalMapCal.m_RequestMap"), GetSymbolLength(symbols, "PedalMapCal.m_RequestMap")); limitResult = new LimitType[pedalrequestmap.Length]; int[] resulttable = new int[pedalrequestmap.Length]; // result pedal_Rows = GetSymbolLength(symbols, "PedalMapCal.n_EngineMap") / 2; pedal_Columns = GetSymbolLength(symbols, "PedalMapCal.X_PedalMap") / 2; pedal_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "PedalMapCal.n_EngineMap"), GetSymbolLength(symbols, "PedalMapCal.n_EngineMap")); pedal_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "PedalMapCal.X_PedalMap"), GetSymbolLength(symbols, "PedalMapCal.X_PedalMap")); airTorqueMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirTorqMap"), GetSymbolLength(symbols, "TorqueCal.m_AirTorqMap")); airTorqueMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngXSP"), GetSymbolLength(symbols, "TorqueCal.M_EngXSP")); airTorqueMap_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngYSP"), GetSymbolLength(symbols, "TorqueCal.n_EngYSP")); bstknkMaxAirmassMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.MaxAirmass"), GetSymbolLength(symbols, "BstKnkCal.MaxAirmass")); bstknkMaxAirmassMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.OffsetXSP"), GetSymbolLength(symbols, "BstKnkCal.OffsetXSP")); for (int a = 0; a < bstknkMaxAirmassMap_Xaxis.Length; a++) { int val = (int)bstknkMaxAirmassMap_Xaxis.GetValue(a); if (val > 32000) val = -(65536 - val); bstknkMaxAirmassMap_Xaxis.SetValue(val, a); } bstknkMaxAirmassMap_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BstKnkCal.n_EngYSP"), GetSymbolLength(symbols, "BstKnkCal.n_EngYSP")); if (SymbolExists("BstKnkCal.MaxAirmassAu", symbols)) { bstknkMaxAirmassAuMap = readIntdatafromfile(m_currentfile, (int)GetSymbolAddress(symbols, "BstKnkCal.MaxAirmassAu"), GetSymbolLength(symbols, "BstKnkCal.MaxAirmassAu")); } turbospeed = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.TurboSpeedTab"), GetSymbolLength(symbols, "LimEngCal.TurboSpeedTab")); turbospeed_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.p_AirSP"), GetSymbolLength(symbols, "LimEngCal.p_AirSP")); turbospeed2 = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.TurboSpeedTab2"), GetSymbolLength(symbols, "LimEngCal.TurboSpeedTab2")); turbospeed2_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LimEngCal.n_EngSP"), GetSymbolLength(symbols, "LimEngCal.n_EngSP")); nominalTorqueMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_NominalMap"), GetSymbolLength(symbols, "TorqueCal.M_NominalMap")); nominalTorqueMap_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.m_AirXSP"), GetSymbolLength(symbols, "TorqueCal.m_AirXSP")); nominalTorqueMap_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngYSP"), GetSymbolLength(symbols, "TorqueCal.n_EngYSP")); for (int a = 0; a < nominalTorqueMap.Length; a++) { int val = (int)nominalTorqueMap.GetValue(a); if (val > 32000) val = -(65536 - val); nominalTorqueMap.SetValue(val, a); } fuelcutAirInletLimit = Convert.ToInt32(readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "FCutCal.m_AirInletLimit"), GetSymbolLength(symbols, "FCutCal.m_AirInletLimit")).GetValue(0)); enginetorquelim = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxTab")); enginetorquelimE85Auto = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxE85TabAut"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxE85TabAut")); enginetorquelimAuto = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxAutTab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxAutTab")); enginetorquelimE85 = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_EngMaxE85Tab"), GetSymbolLength(symbols, "TorqueCal.M_EngMaxE85Tab")); enginetorque_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngYSP"), GetSymbolLength(symbols, "TorqueCal.n_EngYSP")); enginetorquelimConvertible = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_CabGearLim"), GetSymbolLength(symbols, "TorqueCal.M_CabGearLim")); enginetorquelimGear = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_ManGearLim"), GetSymbolLength(symbols, "TorqueCal.M_ManGearLim")); enginetorquelim5th = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_5GearLimTab"), GetSymbolLength(symbols, "TorqueCal.M_5GearLimTab")); enginetorquelim5th_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_Eng5GearSP"), GetSymbolLength(symbols, "TorqueCal.n_Eng5GearSP")); enginetorquelimReverse = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_ReverseTab"), GetSymbolLength(symbols, "TorqueCal.M_ReverseTab")); enginetorquelimReverse_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_EngSP"), GetSymbolLength(symbols, "TorqueCal.n_EngSP")); enginetorquelim1st = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_1GearTab"), GetSymbolLength(symbols, "TorqueCal.M_1GearTab")); enginetorquelim1st_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.n_Eng1GearSP"), GetSymbolLength(symbols, "TorqueCal.n_Eng1GearSP")); enginetorquelimOverboost = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "TorqueCal.M_OverBoostTab"), GetSymbolLength(symbols, "TorqueCal.M_OverBoostTab")); try { int[] injConstant = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "InjCorrCal.InjectorConst"), GetSymbolLength(symbols, "InjCorrCal.InjectorConst")); injectorConstant = Convert.ToInt32(injConstant.GetValue(0)); injectorBatteryCorrection = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "InjCorrCal.BattCorrTab"), GetSymbolLength(symbols, "InjCorrCal.BattCorrTab")); injectorBatteryCorrection_axis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "InjCorrCal.BattCorrSP"), GetSymbolLength(symbols, "InjCorrCal.BattCorrSP")); fuelVEMap = readdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.Map"), GetSymbolLength(symbols, "BFuelCal.Map")); E85VEMap = readdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.E85Map"), GetSymbolLength(symbols, "BFuelCal.E85Map")); fuelVE_Xaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.AirXSP"), GetSymbolLength(symbols, "BFuelCal.AirXSP")); fuelVE_Yaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "BFuelCal.RpmYSP"), GetSymbolLength(symbols, "BFuelCal.RpmYSP")); open_loop = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LambdaCal.MaxLoadNormTab"), GetSymbolLength(symbols, "LambdaCal.MaxLoadNormTab")); if (isFuelE85.Checked) { open_loop = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LambdaCal.MaxLoadE85Tab"), GetSymbolLength(symbols, "LambdaCal.MaxLoadE85Tab"));// } open_loopyaxis = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "LambdaCal.RpmSp"), GetSymbolLength(symbols, "LambdaCal.RpmSp")); if (SymbolExists("ExhaustCal.T_Lambda1Map", symbols)) { EGTMap = readIntdatafromfile(filename, (int)GetSymbolAddress(symbols, "ExhaustCal.T_Lambda1Map"), GetSymbolLength(symbols, "ExhaustCal.T_Lambda1Map")); } } catch (Exception E) { logger.Debug(E.Message); } // step thru the complete pedal and rpm range for (int colcount = 0; colcount < pedal_Columns; colcount++) { for (int rowcount = 0; rowcount < pedal_Rows; rowcount++) { // get the current value from the request map int airmassrequestforcell = (int)pedalrequestmap.GetValue((colcount * pedal_Rows) + rowcount); logger.Debug("Current request = " + airmassrequestforcell.ToString() + " mg/c"); LimitType limiterType = LimitType.None; int resultingAirMass = CalculateMaxAirmassforcell(symbols, filename, ((int)pedal_Yaxis.GetValue(colcount) / 10), /* rpm */(int)pedal_Xaxis.GetValue(rowcount), airmassrequestforcell, isCarAutomatic.Checked, isFuelE85.Checked, isCarConvertible.Checked, isOverboostActive.Checked, e85automatic, torqueLimitEnabled, gear1stLimitAvailable, out limiterType); resulttable.SetValue(resultingAirMass, (colcount * pedal_Rows) + rowcount); limitResult.SetValue(limiterType, (colcount * pedal_Rows) + rowcount); } } // now show resulttable DataTable dt = new DataTable(); foreach (int xvalue in pedal_Xaxis) { dt.Columns.Add(xvalue.ToString()); } // now fill the table rows m_MaxValueInTable = 0; for (int r = pedal_Yaxis.Length - 1; r >= 0; r--) { object[] values = new object[pedal_Columns]; for (int t = 0; t < pedal_Xaxis.Length; t++) { int currValue = (int)resulttable.GetValue((r * pedal_Columns) + t); if (currValue > m_MaxValueInTable) m_MaxValueInTable = currValue; values.SetValue(resulttable.GetValue((r * pedal_Columns) + t), t); } dt.Rows.Add(values); } return dt; } catch (Exception E) { logger.Debug("Failed to calculate for file : " + filename); } return null; }