Exemple #1
0
 public static void ApplyDeltas(ref TCompData template, ref Dictionary <string, List <double> > deltas)
 {
     for (int i = 5; i < 91; i++)
     {
         template.TempData[i] = template.TempData[i - 1] + deltas["temp"][i - 5]; //Apply delta to previous value to get current value
         foreach (string key in template.MeasurementData.Keys)
         {
             template.MeasurementData[key][i] = template.MeasurementData[key][i - 1] + deltas[key][i - 5];
         }
     }
 }
Exemple #2
0
        public static void Template(string model, int months)
        {
            Tuple <TCompData, int> templateData = GenerateTemplate(model, months);
            TCompData     template       = templateData.Item1;
            List <string> lines          = template.GetLines();
            string        templateFolder = Path.Join(Config.ResultsDir, "\\TComp_Templates\\GenericTemplates");

            Directory.CreateDirectory(templateFolder);
            WriteFile(templateFolder, Path.Join(templateFolder, $"{DateTime.UtcNow:yyyy-MM-dd-HH-mm-ss}_{model}_Template.txt"), lines);
            MessageBox.Show($"{model} template generated using the data from {templateData.Item2} sensors from the past {months} months.",
                            "Template Generated", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemple #3
0
 public static void FillTemplate(ref TCompData template)
 {
     //Fill template up to count 91 with 0.0 values
     while (template.TempData.Count < 91)
     {
         template.TempData.Add(0.0);
     }
     foreach (string key in template.MeasurementData.Keys)
     {
         while (template.MeasurementData[key].Count < 91)
         {
             template.MeasurementData[key].Add(0.0);
         }
     }
 }
Exemple #4
0
        public static void ApplyTemplate(string serialNumber, int months)
        {
            HelixEvoSensor         sensor       = AllEvoDataSingle(new() { SerialNumber = serialNumber });
            Tuple <TCompData, int> templateData = GenerateTemplate(sensor.PartNumber.Substring(0, 8), months); //Only get 920-0201 portion of PN
            TCompData     template      = templateData.Item1;
            List <string> lines         = template.GetLines();
            string        snGroupFolder = GetGroupFolder(Config.TcompDir, sensor.SerialNumber);

            string tcompPath = Path.Join(snGroupFolder, $"SN{sensor.SerialNumber}.txt");

            if (File.Exists(tcompPath))
            {
                TCompBackup(tcompPath);
            }
            WriteFile(snGroupFolder, tcompPath, lines, false);
            LogTemplateApplication(sensor, templateData.Item2, months);
            MessageBox.Show($"Template generated for SN{sensor.SerialNumber}, model {sensor.PartNumber}. Used data from {templateData.Item2} sensors" +
                            $" from the past {months} months.", "Template Applied", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemple #5
0
        public static void TrimTemplate(ref TCompData template, bool reference = false)
        {
            int trimTo = reference ? 5 : 91;

            //Trim all data columns to length of 91
            while (template.TimeData.Count > 91) //Ensure count is 91
            {
                template.TimeData.RemoveAt(template.TimeData.Count - 1);
            }
            while (template.TempData.Count > trimTo)
            {
                template.TempData.RemoveAt(template.TempData.Count - 1);
            }
            foreach (string key in template.MeasurementData.Keys)
            {
                while (template.MeasurementData[key].Count > trimTo)
                {
                    template.MeasurementData[key].RemoveAt(template.MeasurementData[key].Count - 1);
                }
            }
        }