Example #1
0
        private PeugeotScreen GenerateScreen(XElement commandElement)
        {
            PeugeotScreen screen = new PeugeotScreen();

            screen.Name = commandElement.
                          Element(PeugeotTraceStrings.Card).
                          Element(PeugeotTraceStrings.Param).
                          Elements(PeugeotTraceStrings.Attribut).First(e =>
                                                                       e.Attribute(PeugeotTraceStrings.Name).Value ==
                                                                       PeugeotTraceStrings.Screentitle).Value;

            IList <string> parameterIds = new List <string>();
            IList <string> values       = new List <string>();
            IList <string> units        = new List <string>();

            IEnumerable <XElement> attributes = commandElement.
                                                Element(PeugeotTraceStrings.Card).
                                                Element(PeugeotTraceStrings.Param).
                                                Elements(PeugeotTraceStrings.Attribut);

            foreach (XElement paramId in attributes.Where(
                         a => a.Attribute(PeugeotTraceStrings.Name).Value ==
                         PeugeotTraceStrings.Title))
            {
                parameterIds.Add(paramId.Value);
            }
            foreach (XElement paramId in attributes.Where(
                         a => a.Attribute(PeugeotTraceStrings.Name).Value ==
                         PeugeotTraceStrings.Measure))
            {
                values.Add(paramId.Value);
            }
            foreach (XElement paramId in attributes.Where(
                         a => a.Attribute(PeugeotTraceStrings.Name).Value ==
                         PeugeotTraceStrings.Unit))
            {
                units.Add(paramId.Value);
            }

            if (parameterIds.Count != values.Count ||
                parameterIds.Count != units.Count)
            {
                throw new ApplicationException();
            }

            for (int i = 0; i < parameterIds.Count; i++)
            {
                PeugeotRawParameterPoint pt = new PeugeotRawParameterPoint();
                pt.ParameterName = parameterIds[i];
                pt.Value         = values[i];
                pt.Units         = units[i];
                screen.Points.Add(pt);
            }
            return(screen);
        }
 private void InitializeSetWithScreenData(PsaParametersSet set,
                                          PeugeotScreen screen)
 {
     set.Type         = PsaParametersSetTypeMapper.Get(screen.Name);
     set.OriginalName = screen.Name;
     foreach (PeugeotRawParameterPoint p in screen.Points)
     {
         PsaParameterData parameter = new PsaParameterData(p.ParameterName); // passed original type ID
         parameter.Type          = DataTypeResolver2.GetType(p.ParameterName);
         parameter.OriginalName  = p.ParameterName;
         parameter.HasTimestamps = false;
         parameter.Values.Add(p.Value);
         parameter.Units = UnitsConverter.Convert(p.Units);
         parameter.AdditionalSourceInfo = GenerateAdditionalSourceInfo(parameter.OriginalTypeId);
         set.Parameters.Add(parameter);
     }
 }
        private void UpdateSetWithScreenData(PsaParametersSet set,
                                             PeugeotScreen screen)
        {
            foreach (PeugeotRawParameterPoint p in screen.Points)
            {
                // At first it was by type but an issue raised with unsupported data

                /*PsaParameterData target = set.Parameters.FirstOrDefault(pr =>
                 *  pr.Type == PeugeotParameterTypeConverter.Convert(p.ParameterName));*/
                if (set.Parameters.Any(pt => String.IsNullOrEmpty(pt.OriginalName)))
                {
                    throw new NotSupportedException();
                }
                PsaParameterData target = set.Parameters.FirstOrDefault(
                    pr => pr.OriginalName.Equals(p.ParameterName, StringComparison.OrdinalIgnoreCase));
                target.Values.Add(p.Value);
            }
        }