| | |
| | | using Plugin.TestResult_WPF.Model; |
| | | using SuperSocket.SocketBase.Protocol; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.ComponentModel; |
| | | using System.IO; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Windows; |
| | | using System.Windows.Controls; |
| | |
| | | private TcpServer tcpServer; |
| | | private string CountIniPath; |
| | | |
| | | // 平均温度 |
| | | public List<double> tempratures = new List<double>(); |
| | | public Dictionary<string, List<double>> detailTempratures |
| | | = new Dictionary<string, List<double>>(); |
| | | |
| | | public DataTable(TestResultView parent, int index, string title, |
| | | string countIniPath, |
| | | BaseConfig config) |
| | |
| | | public void SetTemperature(double t) |
| | | { |
| | | infoTable.temperature = t; |
| | | tempratures.Add(t); |
| | | chart.AddData(t); |
| | | } |
| | | |
| | | public void SetTemperature(string name, double t) |
| | | { |
| | | List<double> list; |
| | | if (detailTempratures.ContainsKey(name)) |
| | | { |
| | | list = detailTempratures[name]; |
| | | } |
| | | else |
| | | { |
| | | list = new List<double>(); |
| | | detailTempratures.Add(name, list); |
| | | } |
| | | list.Add(t); |
| | | multiChart.AddData(name, t); |
| | | } |
| | | |
| | |
| | | { |
| | | chart.Clear(); |
| | | multiChart.Clear(); |
| | | |
| | | tempratures.Clear(); |
| | | detailTempratures.Clear(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | StartTcpServer(); |
| | | } |
| | | |
| | | public void SaveTempFile(string filePath) |
| | | { |
| | | try |
| | | { |
| | | FileInfo fi = new FileInfo(filePath); |
| | | if (!fi.Directory.Exists) |
| | | { |
| | | fi.Directory.Create(); //文件不存在,创建文件 |
| | | } |
| | | |
| | | using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write)) |
| | | using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8)) |
| | | { |
| | | string title = string.Join(",", detailTempratures.Keys) + ",平均值"; |
| | | sw.WriteLine(title); |
| | | |
| | | for (int i = 0; i < tempratures.Count; i++) |
| | | { |
| | | string line = ""; |
| | | foreach (string key in detailTempratures.Keys) |
| | | { |
| | | if (detailTempratures[key] == null || detailTempratures[key].Count <= i) |
| | | { |
| | | line += ","; |
| | | } |
| | | else |
| | | { |
| | | line += $"{detailTempratures[key][i]},"; |
| | | } |
| | | } |
| | | line += tempratures[i]; |
| | | sw.WriteLine(line); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | } |
| | | } |
| | | } |
| | | } |