Exemple #1
0
        private void PutDataByPath(string path, AnalyticRuleType type,
                                   DateTime captureDate, double value)
        {
            ChronologyPathNavigator navigator =
                new ChronologyPathNavigator(this);
            var parameter = new VehicleChronologicalParameter(type);

            parameter.Values.Add(new KeyValuePair <DateTime, double>(captureDate, value));
            navigator.PlaceDataByPath(path, parameter);
        }
Exemple #2
0
 public void Assimilate(VehicleChronologicalParameter source)
 {
     if (source.Type != type)
     {
         throw new Exception("Cannot assimilate another type.");
     }
     foreach (KeyValuePair <DateTime, double> pair in source.Values)
     {
         Values.Add(pair);
     }
 }
Exemple #3
0
        public void PlaceDataByPath(string path,
                                    VehicleChronologicalParameter parameter)
        {
            CheckPathAndCreateIfNotExists(path);
            IList <string> folders = path.Split('/');

            if (folders.Count == 0)
            {
                throw new Exception();
            }
            IList <VehicleChronologicalParametersGroup> currentGroupsCollection =
                chronology.Groups;

            for (int i = 0; i < folders.Count; i++)
            {
                VehicleChronologicalParametersGroup group =
                    currentGroupsCollection.FirstOrDefault(g =>
                                                           g.GroupNameKey == folders[i]);
                if (group == null) // no group yet
                {
                    throw new Exception("Group should be already here.");
                }
                if (i == folders.Count - 1) // we are at destination
                {
                    VehicleChronologicalParameter param = group.Parameters.
                                                          FirstOrDefault(p => p.Type == parameter.Type);
                    if (param == null)
                    {
                        group.Parameters.Add(parameter);
                    }
                    else
                    {
                        param.Assimilate(parameter);
                    }
                }
                currentGroupsCollection = group.Groups;
            }
        }