标定实例读取打开INCA(标定变量读取测量实例)「标定软件inca使用教程」

ETAS通过INCA软件产品,为汽车电子系统的标定、诊断和验证提供灵活的工具。
INCA工具用于ECU开发和试验,以及车辆、试验台、工作台或电脑虚拟环境中电子控制系统的验证和标定。
在全球范围内,超过35000台用于开发和省擦痕那个项目的装置使用INCA工具。
INCA工具具有多种功能,包括计算机上功能模型的预标定、ECU闪存编程、测量数据分析、标定数据管理以及ECU参数的自动优化。
生成的标定和测量数据可以进行持续处理和评估。
由于PVE测试项目工作中需要实现对INCA的操控以更好的达到实操体验,因此需要运用INCA官方提供的虚拟COM组件incacome.dll进行二次开发,本文展示INCA操控的模块,以供和大家一起探讨、学习交流心得。
上位机软件的INCA模块如图:INCA的操控包含:INCA的配置、INCA的启动、INCA初始化硬件配置、进入试验环境、设定参数或启动某些功能、添加变量到INCA、读取测量变量与标定变量、设定标定变量、批量导入INCA变量、批量设定标定变量等。
定义部分需要的全局变量,启动INCA,实例化INCA就能打开INCA软件:private Inca inca; private Experiment experiment; private IncaExperimentView experimentView;public void StartInca() { this.inca = new Inca(); }进入试验环境或工作空间:

标定实例读取打开INCA(标定变量读取测量实例)

IncaDataBase incaDataBase = inca.GetCurrentDataBase();OpenDBWrokSpace(incaDataBase);private void OpenDBWrokSpace(IncaDataBase incaDB) { HardwareConfiguration myHWC = incaDB.GetActiveHardwareConfiguration(); if (myHWC == null) { System.Windows.Forms.MessageBox.Show("获取硬件配置失败。

", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ExperimentEnvironment myExpEnv = myHWC.GetAssignedExperimentEnvironment(); var success = myExpEnv.SetHardwareConfiguration(myHWC); //Opens the INCA Experiment assigned to the active workbase IncaExperimentView myExpEnvView = myExpEnv.OpenExperiment(); GetExperiment(); }private void GetExperiment() { if (inca != null && experiment == null) { experiment = inca.GetOpenedExperiment();//试验中 experimentView = this.inca.GetOpenedExperimentView(); //init params var b = this.experiment.IsIncaOnlineExperiment(); IncaOnlineExperiment onlineExperiment = this.experiment as IncaOnlineExperiment; WorkbaseDevice myDevice = experiment.GetDevice("XCP: 1") as WorkbaseDevice } }
读取所有标定变量,并添加到集合:public List<string> ReadIncaAllCalibrationElement() { CalibrationElement[] calibrationElementArray = experiment.GetAllCalibrationElements(); List<string> calist = new List<string>(); foreach (var calElement in calibrationElementArray) { calist.Add(calElement.GetName()); } return calist; }读取所有测量变量,并添加到集合: public List<string> ReadIncaAllMeasureElement() { MeasureElement[] measureElementArray = experiment.GetAllMeasureElements(); List<string> meslist = new List<string>(); foreach (var mElement in measureElementArray) { meslist.Add(mElement.GetName()); } return meslist; }启动读取变量值:public bool StartReadIncaMeasure() { if (this.experiment == null) return false; OnlineExperiment onlineExperiment = experiment as OnlineExperiment; return onlineExperiment.StartMeasurement(); }添加变量到INCA:public bool AddIncaMeasureElement(string measure) { if (this.experiment == null) return false; var measureElement = this.experiment.GetMeasureElement(measure); if (experimentView.OpenViewForMeasureElementWithMaxLabels(measureElement, 1)) return StartReadIncaMeasure(); return false; }根据标定变量名称获取标定变量值: public string GetCalibrationElementValue(string calibrationElement) { try { if (experiment == null) return ""; var calibElement = experiment.GetCalibrationElement(calibrationElement); var calibrationData = calibElement.GetValue(); CalibrationScalarData scalarData = calibrationData as CalibrationScalarData; var arra = scalarData.GetDoublePhysValue(); var type = scalarData.GetPhysType(); var tValue = ""; switch (type) { case "char": tValue = scalarData.GetCharPhysValue(); break; case "real64": tValue = scalarData.GetDoublePhysValue().ToString(); break; default: break; } return tValue; } catch (Exception ex) { return ""; } }根据测量变量名称获取测量变量的值: public string GetMeasureElementValue(string measureElement) { try { if (experiment == null) return ""; AddIncaMeasureElement(measureElement); MeasureScalarData measureData = experiment.GetMeasureElement(measureElement).GetValue() as MeasureScalarData; var type = measureData.GetPhysType(); var tValue = ""; switch (type) { case "char": tValue = measureData.GetCharPhysValue(); break; case "real64": tValue = measureData.GetDoublePhysValue().ToString(); break; default: break; } return tValue; } catch (Exception ex) { return ""; } finally { } }设定标定变量的值,标定前一定要切换到WD: public bool SetCalibrationElement(string calibrationElement, string setValue) { try { if (experiment == null) return false; var caliElement = experiment.GetCalibrationElement(calibrationElement); WorkbaseDevice workDev = caliElement.GetDevice() as WorkbaseDevice; workDev.SwitchToReferencePage();//切换wd CalibrationScalarData calibrationData = caliElement.GetValue() as CalibrationScalarData; var type = calibrationData.GetPhysType(); switch (type) { case "char": { return calibrationData.SetCharPhysValue(setValue); } case "real64": { double val; double.TryParse(setValue, out val); return calibrationData.SetDoublePhysValue(val); } default: break; } return false; } catch (Exception ex) { return false; } }关闭INCA软件: public bool CloseIncaTool() { return this.inca.CloseTool(); }INCA中还有很多其他功能,可根据自己需要进行二次开发

联系我们

在线咨询:点击这里给我发消息