public static LoggerData GetLoggerData(string path) { var t = new LoggerData(); var enc = System.Text.Encoding.GetEncoding("shift-jis"); string str = System.IO.File.ReadAllText(path, enc); var p = GetChString(str); var u = GetBodyStrings(str); UInt16 cnt = 0; SetInitial(ref t, str); foreach (var f in p) { var w = new LoggerData.LoggerOneData(); string[] g = f.Split(','); g[0] = g[0].Replace("CH", ""); w.CHNo = UInt16.Parse(g[0]); w.Name = g[1]; switch (g[2]) { case "TEMP": w.Unit = LoggerData.LoggerOneData.TypeUnit.TEMP; break; case "DC": w.Unit = LoggerData.LoggerOneData.TypeUnit.DC; break; default: break; } foreach (var y in u) { string[] q = y.Split(','); var v = new LoggerData.LoggerOneData.PointData(); v.No = ulong.Parse(q[0]); v.DateTime = DateTime.Parse(q[1]); v.Value = double.Parse(q[cnt + 3]); v.SamplingMillisSecond = ((v.No - 1) * t.SamplingMillisSecond); w._DataValue.Add(v); } t._Data.Add(w); cnt++; } SetInitial(ref t, str); return(t); }
private static void SetInitial(ref LoggerData data, string text) { string[] del = { "\r\n" }; string[] arr = text.Split(del, StringSplitOptions.None); foreach (var f in arr) { try { string[] s = f.Split(','); switch (s[0]) { case "ベンダ": data.Vendor = s[1]; break; case "モデル": data.Model = s[1]; break; case "バージョン": data.Version = s[1]; break; case "開始時刻": data.StartDateTime = DateTime.Parse(s[1] + " " + s[2]); break; case "終了時刻": data.EndDateTime = DateTime.Parse(s[1] + " " + s[2]); break; case "測定間隔": switch (s[1]) { case "100ms": data.SamplingMillisSecond = 100; break; case "250ms": data.SamplingMillisSecond = 250; break; case "1s": data.SamplingMillisSecond = 1000; break; default: data.SamplingMillisSecond = 0; break; } break; default: break; } } catch (Exception) { } } }