示例#1
0
        private void SaveResults(CCDataPoint p)
        {
            var str  = CompileDataStr(p);
            var path = $".\\backupData\\" + $"{p.SampleName}.txt";

            if (!File.Exists(path))
            {
                using (var writer = new StreamWriter(path, true)) {
                    writer.WriteLine(U.SampleTxtHeader);
                }
            }
            using (var writer = new StreamWriter(path, true)) {
                writer.WriteLine(str);
            }
        }
示例#2
0
文件: Data.cs 项目: haiyueh/Projects
        private void SaveCSVResults(CCDataPoint p)
        {
            var str        = CompileDataStr(p);
            int cycle      = -1;
            var samplePath = U.CCDataDir + p.SampleName + "\\";

            // if no files in directory then start cycle number at start
            if (Directory.GetFiles(samplePath).Length == 0)
            {
                cycle = p.CycleNumber;
            }
            var path = samplePath + $"{p.SampleName}_Cycle_{cycle}.csv";

            // if not first sample data grab last cycle number from filename
            if (cycle == -1)
            {
                var fileArray = Directory.GetFiles(samplePath).Select(Path.GetFileNameWithoutExtension).ToList();
                var lasts     = new List <int>();
                foreach (var f in fileArray)
                {
                    lasts.Add(int.Parse(f.Split('_').Last()));
                }
                cycle = lasts.Max();
                path  = samplePath + $"{p.SampleName}_Cycle_{cycle}.csv";

                // if file size > 15mb then save new file as current cycle number
                FileInfo fi = new FileInfo(path);
                if (fi.Length > 15000000)
                {
                    cycle = p.CycleNumber;
                    path  = samplePath + $"{p.SampleName}_Cycle_{cycle}.csv";
                }
            }

            // create new csv with header if path not exists
            if (!File.Exists(path))
            {
                using (var writer = new StreamWriter(path, true)) {
                    writer.WriteLine(U.SampleTxtHeader);
                }
            }
            using (var writer = new StreamWriter(path, true)) {
                writer.WriteLine(str);
            }
        }
示例#3
0
文件: Data.cs 项目: haiyueh/Projects
 private string CompileDataStr(CCDataPoint p)
 {
     string[] str = { p.CycleNumber.ToString(),              (DateTime.UtcNow - new DateTime(1970,                                      1, 1)).TotalSeconds.ToString(),
                      p.TotalTime.ToString(),                // total time (hrs)
                      p.TimeIntoCycle.ToString(),            // time into current cycle
                      (p.CurrentBias) ? "ON" : "OFF",
                      p.SampleName,                          p.Current.ToString(),                  p.Voltage.ToString(),                  p.NumCells.ToString(),      p.CellVoc.ToString(),
                      p.TempSensor.ToString(),               p.SetCurrent.ToString(),               "-99.99",
                      $"{p.Temps[0].ToString("F2")}",        $"{p.Temps[1].ToString("F2")}",        $"{p.Temps[2].ToString("F2")}",
                      $"{p.Temps[3].ToString("F2")}",        $"{p.Temps[4].ToString("F2")}",        $"{p.Temps[5].ToString("F2")}",
                      $"{p.Temps[6].ToString("F2")}",        $"{p.Temps[7].ToString("F2")}",        $"{p.Temps[8].ToString("F2")}",
                      $"{p.Temps[9].ToString("F2")}",        $"{p.Temps[10].ToString("F2")}",       $"{p.Temps[11].ToString("F2")}",
                      $"{p.Temps[12].ToString("F2")}",       $"{p.Temps[13].ToString("F2")}",       $"{p.Temps[14].ToString("F2")}",
                      $"{p.Temps[15].ToString("F2")}",
                      $"{p.SmokeVoltage[0].ToString("F2")}", $"{p.SmokeVoltage[1].ToString("F2")}", $"{p.SmokeVoltage[2].ToString("F2")}",
                      $"{p.SmokeVoltage[3].ToString("F2")}", $"{p.SmokeVoltage[4].ToString("F2")}", $"{p.SmokeVoltage[5].ToString("F2")}",
                      $"{p.SmokeVoltage[6].ToString("F2")}", $"{p.SmokeVoltage[7].ToString("F2")}",
                      $"{p.SmokeLevel[0].ToString("F2")}",   $"{p.SmokeLevel[1].ToString("F2")}",   $"{p.SmokeLevel[2].ToString("F2")}",
                      $"{p.SmokeLevel[3].ToString("F2")}",   $"{p.SmokeLevel[4].ToString("F2")}",   $"{p.SmokeLevel[5].ToString("F2")}",
                      $"{p.SmokeLevel[6].ToString("F2")}",   $"{p.SmokeLevel[7].ToString("F2")}" };
     return(string.Join(",", str));
 }
示例#4
0
文件: Data.cs 项目: haiyueh/Projects
 private void SaveCCData(CCDataPoint d)
 {
     if (ComputerName != "CH-J7TMTZ1")
     {
         try {
             if (BuildTable())
             {
                 _table.InsertRow(new BigQueryInsertRow
                 {
                     { "CycleNumber", d.CycleNumber },
                     { "LogTime_Timestamp", d.LogTime },
                     { "TotalTest_Hours", d.TotalTime },
                     { "MinutesIntoCycle", d.TimeIntoCycle },
                     { "CurrentBiasIsOn", d.CurrentBias ? "ON" : "OFF" },
                     { "SampleName", d.SampleName },
                     { "Current_Amps", d.Current },
                     { "Voltage_Volts", d.Voltage },
                     { "NumCells", d.NumCells },
                     { "CellVoc_Volts", d.CellVoc },
                     { "TempSensorNumber", d.TempSensor },
                     { "SetCurrent_Amps", d.SetCurrent },
                     { "EstimatedRs_mOhms", d.EstimatedRs },
                     { "Temp1_C", d.Temps[0] },
                     { "Temp2_C", d.Temps[1] },
                     { "Temp3_C", d.Temps[2] },
                     { "Temp4_C", d.Temps[3] },
                     { "Temp5_C", d.Temps[4] },
                     { "Temp6_C", d.Temps[5] },
                     { "Temp7_C", d.Temps[6] },
                     { "Temp8_C", d.Temps[7] },
                     { "Temp9_C", d.Temps[8] },
                     { "Temp10_C", d.Temps[9] },
                     { "Temp11_C", d.Temps[10] },
                     { "Temp12_C", d.Temps[11] },
                     { "Temp13_C", d.Temps[12] },
                     { "Temp14_C", d.Temps[13] },
                     { "Temp15_C", d.Temps[14] },
                     { "Temp16_C", d.Temps[15] },
                     { "SmokeLevel1_Volts", d.SmokeLevel[0] },
                     { "SmokeLevel2_Volts", d.SmokeLevel[1] },
                     { "SmokeLevel3_Volts", d.SmokeLevel[2] },
                     { "SmokeLevel4_Volts", d.SmokeLevel[3] },
                     { "SmokeLevel5_Volts", d.SmokeLevel[4] },
                     { "SmokeLevel6_Volts", d.SmokeLevel[5] },
                     { "SmokeLevel7_Volts", d.SmokeLevel[6] },
                     { "SmokeLevel8_Volts", d.SmokeLevel[7] },
                     { "SmokeVoltage1_Volts", d.SmokeVoltage[0] },
                     { "SmokeVoltage2_Volts", d.SmokeVoltage[1] },
                     { "SmokeVoltage3_Volts", d.SmokeVoltage[2] },
                     { "SmokeVoltage4_Volts", d.SmokeVoltage[3] },
                     { "SmokeVoltage5_Volts", d.SmokeVoltage[4] },
                     { "SmokeVoltage6_Volts", d.SmokeVoltage[5] },
                     { "SmokeVoltage7_Volts", d.SmokeVoltage[6] },
                     { "SmokeVoltage8_Volts", d.SmokeVoltage[7] },
                 });
             }
             else
             {
                 U.Logger.WriteLine("Google BQ connection ERROR. Backing up via CSV");
             }
         }
         catch (Exception exc) {
             U.Logger.WriteLine(exc.ToString());
         }
     }
     try {
         SaveCSVResults(d);
     }
     catch (Exception exc) {
         U.Logger.WriteLine(exc.ToString());
     }
 }
示例#5
0
 private void SaveCCData(CCDataPoint d)
 {
     try {
         //IDictionary<String, Object> dictionary = d.GetType()
         //  .GetProperties()
         //  .Where(p => p.CanRead)
         //  .ToDictionary(p => p.Name, p => p.GetValue(d, null));
         //foreach (var dd in dictionary) Console.WriteLine($"{dd}");
         if (BuildTable())
         {
             _table.InsertRow(new BigQueryInsertRow
             {
                 { "CycleNumber", d.CycleNumber },
                 { "LogTime_Timestamp", d.LogTime },
                 { "TotalTest_Hours", d.TotalTime },
                 { "MinutesIntoCycle", d.TimeIntoCycle },
                 { "CurrentBiasIsOn", d.CurrentBias ? "ON" : "OFF" },
                 { "SampleName", d.SampleName },
                 { "Current_Amps", d.Current },
                 { "Voltage_Volts", d.Voltage },
                 { "NumCells", d.NumCells },
                 { "CellVoc_Volts", d.CellVoc },
                 { "TempSensorNumber", d.TempSensor },
                 { "SetCurrent_Amps", d.SetCurrent },
                 { "EstimatedRs_mOhms", d.EstimatedRs },
                 { "Temp1_C", d.Temps[0] },
                 { "Temp2_C", d.Temps[1] },
                 { "Temp3_C", d.Temps[2] },
                 { "Temp4_C", d.Temps[3] },
                 { "Temp5_C", d.Temps[4] },
                 { "Temp6_C", d.Temps[5] },
                 { "Temp7_C", d.Temps[6] },
                 { "Temp8_C", d.Temps[7] },
                 { "Temp9_C", d.Temps[8] },
                 { "Temp10_C", d.Temps[9] },
                 { "Temp11_C", d.Temps[10] },
                 { "Temp12_C", d.Temps[11] },
                 { "Temp13_C", d.Temps[12] },
                 { "Temp14_C", d.Temps[13] },
                 { "Temp15_C", d.Temps[14] },
                 { "Temp16_C", d.Temps[15] },
                 { "SmokeLevel1_Volts", d.SmokeLevel[0] },
                 { "SmokeLevel2_Volts", d.SmokeLevel[1] },
                 { "SmokeLevel3_Volts", d.SmokeLevel[2] },
                 { "SmokeLevel4_Volts", d.SmokeLevel[3] },
                 { "SmokeLevel5_Volts", d.SmokeLevel[4] },
                 { "SmokeLevel6_Volts", d.SmokeLevel[5] },
                 { "SmokeLevel7_Volts", d.SmokeLevel[6] },
                 { "SmokeLevel8_Volts", d.SmokeLevel[7] },
                 { "SmokeVoltage1_Volts", d.SmokeVoltage[0] },
                 { "SmokeVoltage2_Volts", d.SmokeVoltage[1] },
                 { "SmokeVoltage3_Volts", d.SmokeVoltage[2] },
                 { "SmokeVoltage4_Volts", d.SmokeVoltage[3] },
                 { "SmokeVoltage5_Volts", d.SmokeVoltage[4] },
                 { "SmokeVoltage6_Volts", d.SmokeVoltage[5] },
                 { "SmokeVoltage7_Volts", d.SmokeVoltage[6] },
                 { "SmokeVoltage8_Volts", d.SmokeVoltage[7] },
             });
         }
         else
         {
             throw new Exception();
         }
     }
     catch {
         Console.WriteLine("Google BQ connection ERROR. Backing up via CSV");
         SaveResults(d);
     }
 }