Ejemplo n.º 1
0
 /// <summary>
 /// 从文件加载
 /// </summary>
 /// <param name="fileName"></param>
 public void LoadFromFile(String fileName)//载入参数
 {
     Models.Settings.BaseSetting loadSetting = null;
     using (System.Xml.XmlReader reader = new System.Xml.XmlTextReader(fileName))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(Models.Settings.BaseSetting));
         loadSetting = serializer.Deserialize(reader) as Models.Settings.BaseSetting;
     }
     if (Device.Connect.IsConnected)
     {
         WaitReadyIFPLC();
         this.ECUSetting.Attach(loadSetting.ECUSetting);
         this.MAPCalibrationParams.Attach(loadSetting.MAPCalibration);
         //   this.ECUCorrectionParams.Attach(loadSetting.ECUCalibration);
         this.CorrectionSetting.Attach(loadSetting.CorrectSetting);
         //  this.InjectorCorrection.Attach(loadSetting.InjectorCorrection);
         // this.Additional.Attach(loadSetting.Additional);
     }
     else
     {
         this.ECUSetting = new ECUSetting(loadSetting.ECUSetting, this);
         if (this.MAPCalibrationParams != null)
         {
             this.MAPCalibrationParams.UnRegisetCurveChange(Device);
         }
         //   loadSetting.MAPCalibration.MAPValues = loadSetting.MAPCalibration.SMAPValues[1].Select(m => return (byte)m).ToArray();   //Convert.ToBytebyte(Convert.ToBytebyte(
         //byte[][] temp = new byte[12][];
         //temp[0] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[1] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[2] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[3] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[4] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[5] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[6] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[7] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[8] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[9] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[10] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //temp[11] = new byte[] { 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120, 120 };
         //loadSetting.MAPCalibration.MAPValues = temp;
         this.MAPCalibrationParams = new MAPCalibrationParams(loadSetting.MAPCalibration);
         this.ECUCorrectionParams  = new Storage.ECUCorrectionParams(loadSetting.ECUCalibration);    //暂时不能删
         this.CorrectionSetting    = new Storage.CorrectionSetting(loadSetting.CorrectSetting);
         this.InjectorCorrection   = new Storage.InjectorCorrection(loadSetting.InjectorCorrection); //暂时不能删
         this.Additional           = new AdditionalSettings(loadSetting.Additional);
     }
     this.MAPCalibrationParams.RegisetCurveChange(this.Device);//暂时不能删
     this.SaveChanges();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 保存当前数据到文件
 /// </summary>
 /// <param name="path">保存路径</param>
 public void SaveToFile(String path)
 {
     LoadAutoAndWait();
     Models.Settings.BaseSetting model = new Models.Settings.BaseSetting();
     model.ECUSetting     = ECUSetting.Detaching();
     model.MAPCalibration = this.MAPCalibrationParams.Detaching();
     //     model.ECUCalibration = this.ECUCorrectionParams.Detaching();
     model.CorrectSetting = this.CorrectionSetting.Detaching();
     //  model.InjectorCorrection = this.InjectorCorrection.Detaching();
     model.Additional = this.Additional.Detaching();
     using (System.IO.StreamWriter stream = new StreamWriter(path))
     {
         System.Xml.Serialization.XmlSerializer xs = new XmlSerializer(typeof(Models.Settings.BaseSetting));
         xs.Serialize(stream, model);
     }
 }