public LogProfileAndMath(LogProfile profile, MathValueConfiguration mathValueConfiguration)
 {
     this.profile = profile;
     this.mathValueConfiguration = mathValueConfiguration;
     this.mathValueProcessor     = new MathValueProcessor(
         this.profile,
         this.mathValueConfiguration);
 }
        public MathValueProcessor(LogProfile profile, MathValueConfiguration mathValueConfiguration)
        {
            this.profile    = profile;
            this.mathValues = new List <MathValueAndDependencies>();

            foreach (MathValue mathValue in mathValueConfiguration.MathValues)
            {
                ProfileParameter xParameter  = null;
                Conversion       xConversion = null;
                ProfileParameter yParameter  = null;
                Conversion       yConversion = null;

                foreach (ProfileParameter parameter in this.profile.AllParameters)
                {
                    // TODO: Find the parameter in a configuration file that contains all parameters and conversions,
                    // pick the appropriate conversion even if it's not what the user chose for this log profile.
                    if (parameter.Name == mathValue.XParameter)
                    {
                        xParameter  = parameter;
                        xConversion = parameter.Conversion;
                    }

                    if (parameter.Name == mathValue.YParameter)
                    {
                        yParameter  = parameter;
                        yConversion = parameter.Conversion;
                    }
                }

                if ((xParameter != null) &&
                    (xConversion != null) &&
                    (yParameter != null) &&
                    (yConversion != null))
                {
                    MathValueAndDependencies valueAndDependencies = new MathValueAndDependencies(
                        mathValue,
                        xParameter,
                        xConversion,
                        yParameter,
                        yConversion);

                    this.mathValues.Add(valueAndDependencies);
                }
            }
        }
 public bool Initialize()
 {
     try
     {
         using (Stream stream = File.OpenRead("MathValues.configuration"))
         {
             XmlSerializer serializer = new XmlSerializer(typeof(MathValueConfiguration));
             this.Configuration = (MathValueConfiguration)serializer.Deserialize(stream);
             return(true);
         }
     }
     catch (Exception exception)
     {
         this.logger.AddUserMessage("Unable to load math-value configuration.");
         this.logger.AddDebugMessage(exception.ToString());
         return(false);
     }
 }
Exemple #4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Logger(Vehicle vehicle, LogProfileAndMath profileAndMath, MathValueConfiguration mathValueConfiguration)
 {
     this.vehicle        = vehicle;
     this.profileAndMath = profileAndMath;
 }