private void SetOriginalToCurrent() { try { this.mDriverFirstName_Original = this.mDriverFirstName; this.mDriverLastName_Original = this.mDriverLastName; this.mRatings_Original = (Ratings)this.mRatings.Clone(); } catch (Exception ex) { Console.WriteLine("Could not set original values: " + ex.ToString()); } }
public void ReadCarInfo() { if (this.mPath != null && this.mFileName != null) { try { FileStream fs = new FileStream(this.mPath + @"\" + this.mFileName, FileMode.Open); BinaryReader br = new BinaryReader(fs); byte[] buffer = br.ReadBytes(1500); fs.Close(); Encoding encoding = Encoding.Default; string str = encoding.GetString(buffer); //Console.WriteLine("*" + str + "*"); this.mNumber = this.GetCarParameter(str, "car_number", false); this.mDriverFirstName = this.GetCarParameter(str, "first_name", false); this.mDriverLastName = this.GetCarParameter(str, "last_name", false); //GET RATINGS int deviationPartStart = str.IndexOf(@"[AIParamDeviation]"); int meanPartStart = str.IndexOf(@"[AIParamMean]"); int careerPartStart = str.IndexOf(@"[CareerStats]"); string deviationPart = str.Substring(deviationPartStart, meanPartStart - deviationPartStart - 1); string meanPart = str.Substring(meanPartStart, careerPartStart - meanPartStart - 1); this.mRatings = new Ratings(); this.mRatings.GetRating("dr_aggr").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverAggression", true)); this.mRatings.GetRating("dr_aggr").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverAggression", true)); this.mRatings.GetRating("dr_cons").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverConsistency", true)); this.mRatings.GetRating("dr_cons").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverConsistency", true)); this.mRatings.GetRating("dr_fin").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverFinishing", true)); this.mRatings.GetRating("dr_fin").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverFinishing", true)); this.mRatings.GetRating("dr_qual").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverQualifying", true)); this.mRatings.GetRating("dr_qual").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverQualifying", true)); this.mRatings.GetRating("dr_rc").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverRoadCourse", true)); this.mRatings.GetRating("dr_rc").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverRoadCourse", true)); this.mRatings.GetRating("dr_st").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverShortTrack", true)); this.mRatings.GetRating("dr_st").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverShortTrack", true)); this.mRatings.GetRating("dr_sw").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverSpeedway", true)); this.mRatings.GetRating("dr_sw").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverSpeedway", true)); this.mRatings.GetRating("dr_ss").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamDriverSuperspeedway", true)); this.mRatings.GetRating("dr_ss").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamDriverSuperspeedway", true)); this.mRatings.GetRating("veh_aero").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamVehicleAero", true)); this.mRatings.GetRating("veh_aero").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamVehicleAero", true)); this.mRatings.GetRating("veh_chas").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamVehicleChassis", true)); this.mRatings.GetRating("veh_chas").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamVehicleChassis", true)); this.mRatings.GetRating("veh_eng").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamVehicleEngine", true)); this.mRatings.GetRating("veh_eng").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamVehicleEngine", true)); this.mRatings.GetRating("veh_rel").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamVehicleReliability", true)); this.mRatings.GetRating("veh_rel").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamVehicleReliability", true)); this.mRatings.GetRating("pc_cons").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamPitcrewConsistency", true)); this.mRatings.GetRating("pc_cons").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamPitcrewConsistency", true)); this.mRatings.GetRating("pc_spe").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamPitcrewSpeed", true)); this.mRatings.GetRating("pc_spe").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamPitcrewSpeed", true)); this.mRatings.GetRating("pc_strat").Dev = Convert.ToDouble(this.GetCarParameter(deviationPart, "aiParamPitcrewStrategy", true)); this.mRatings.GetRating("pc_strat").Mean = Convert.ToDouble(this.GetCarParameter(meanPart, "aiParamPitcrewStrategy", true)); this.mRatings.Changed += new EventHandler(RatingsValuesChanged); this.SetOriginalToCurrent(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw ex; } } }