/// <summary> /// 载入binary显示数据 /// </summary> private void loadShowBinaryData() { try { int showLen = dataFile.BinaryData.Count;//configFile.RowSampleRateInformation.EndSampleCount; for (int index = 0; index < showLen; index++) { var binaryOrigin = new BinaryContent(dataFile.BinaryData[index], configFile.RowChannelNumType.AnalogChannelCount, configFile.RowChannelNumType.DigitalChannelCount); var ascii = new ASCIIContent(binaryOrigin); LoadCurvePoint(ascii); } foreach (var m in plotCollect) { m.MplotModel.InvalidatePlot(true); } } catch (Exception ex) { MessageBox.Show(ex.Message, "载入显示数据"); } }
void TestComtrade() { Console.WriteLine("TestComtradeManager-TestStart"); string path = @"E:\WorkProject\04-FTU终端\Comtrade\ComtradeFile"; string cfgPath = System.IO.Path.Combine(path, "binary.cfg"); string dataPath = System.IO.Path.Combine(path, "binary.dat"); Console.WriteLine("In:"); Console.WriteLine(path); Console.WriteLine(cfgPath); Console.WriteLine(dataPath); var comtradeManager = new ComtradeFileManager(); comtradeManager.ReadFile(cfgPath, dataPath); Console.WriteLine("Out:"); Console.WriteLine("配置文件内容:"); string[] cfgRow; comtradeManager.ConfigFile.MakeConfigFile(out cfgRow); for (int index = 0; index < cfgRow.Length; index++) { Console.Write(string.Format("{0}:" + cfgRow[index], index + 1)); } Console.WriteLine("数据文件内容:"); for (int i = 0; i < comtradeManager.DataFile.AsciiData.Count; i++) { var ascii = new ASCIIContent(comtradeManager.DataFile.AsciiData[i], comtradeManager.ConfigFile.RowChannelNumType.AnalogChannelCount, comtradeManager.ConfigFile.RowChannelNumType.DigitalChannelCount); Console.Write(ascii.RowToString()); } for (int j = 0; j < comtradeManager.DataFile.BinaryData.Count; j++) { var binanry = new BinaryContent(comtradeManager.DataFile.BinaryData[j], comtradeManager.ConfigFile.RowChannelNumType.AnalogChannelCount, comtradeManager.ConfigFile.RowChannelNumType.DigitalChannelCount); var assii = new ASCIIContent(binanry); Console.Write(assii.RowToString()); } Console.WriteLine("TestComtradeManager-TestEnd"); //gridRowStationRev.ItemsSource //var rowStationRev = new ObservableCollection<StationRev>(); //rowStationRev.Add(comtradeManager.ConfigFile.RowStationRev); //gridRowStationRev.ItemsSource = rowStationRev; }
static void TestASCII() { Console.WriteLine("TestASCIIContent-TestStart"); string testStr = "2, 167, -943, 1231 , 94, 37, -137 , -275, 0, 0, 0, 0, 0, 0"; // var row = new ASCIIContent(testStr,6,6); byte[] data = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFC, 0xB5, 0x04, 0x64, 0x00, 0x1D, 0x00, 0x79, 0xFF, 0x3B, 0xFF, 0x00, 0x00 }; var rowBinary = new BinaryContent(data, 6, 6); var row = new ASCIIContent(rowBinary); Console.Write(row.RowToString()); testStr = "2, 45, -943, 2322 , 94, 37, -137 , -275, 1, 1, 0, 0, 0, 0";; row.StringToRow(testStr, 6, 6); Console.Write(row.RowToString()); Console.WriteLine("TestASCIIContent-TestEnd"); while (true) { try { Console.WriteLine(); Console.Write("Input:"); var instr = Console.ReadLine(); if (instr == "q") { return; } else { row.StringToRow(instr, 6, 6); Console.WriteLine(row.RowToString()); Console.WriteLine("TestEnd"); Console.WriteLine(); } } catch (Exception ex) { Console.WriteLine("Exception:"); Console.WriteLine(ex.Message); } } }
/// <summary> /// 载入每条曲线上一个点 /// </summary> /// <param name="ascii">ASCII数据</param> private void LoadCurvePoint(ASCIIContent ascii) { for (int analogNum = 0; analogNum < configFile.RowChannelNumType.AnalogChannelCount; analogNum++) { int data = ascii.AnalogChannelData[analogNum]; var point = new DataPoint(ascii.SampleTimeStamp, data); plotCollect[analogNum].LinesCollect.ElementAt(0).Elem.Points.Add(point); } for (int digitalNum = 0; digitalNum < configFile.RowChannelNumType.DigitalChannelCount; digitalNum++) { int data = ascii.DigitalChannelData[digitalNum]; var point = new DataPoint(ascii.SampleTimeStamp, data); plotCollect[configFile.RowChannelNumType.AnalogChannelCount + digitalNum]. LinesCollect.ElementAt(0).Elem.Points.Add(point); } }
static void TestBinary() { Console.WriteLine("TestBinary-TestStart"); byte[] data = new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFC, 0xB5, 0x04, 0x64, 0x00, 0x1D, 0x00, 0x79, 0xFF, 0x3B, 0xFF, 0x00, 0x00 }; // var row = new BinaryContent(data, 6, 6); string testStr = "2, 167, -943, 1231 , 94, 37, -137 , -275, 1, 1, 0, 0, 1, 1"; var rowAssii = new ASCIIContent(testStr, 6, 6); var row = new BinaryContent(rowAssii); var rowdata = row.RowToByteArray(); foreach (var m in rowdata) { Console.Write(m.ToString("X2") + " "); } Console.WriteLine(); Console.WriteLine(row.SampleNum.ToString()); Console.WriteLine(row.TimeStamp.ToString()); foreach (var m in row.AnalogChannelData) { Console.WriteLine(m); } foreach (var m in row.DigitalChannelData) { Console.WriteLine(m); } Console.WriteLine(); byte[] data2 = new byte[] { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xFC, 0xB5, 0x04, 0x64, 0x00, 0x1D, 0x00, 0x79, 0xFF, 0x3B, 0xFF, 0x00, 0x00 }; row.ByteToRow(data2, 6, 6); rowdata = row.RowToByteArray(); foreach (var m in rowdata) { Console.Write(m.ToString("X2") + " "); } Console.WriteLine(); Console.WriteLine("TestBinary-TestEnd"); Console.ReadLine(); }
/// <summary> /// 载入ASCII显示数据 /// </summary> public void loadShowASCIIData() { try { int showLen = dataFile.AsciiData.Count;//configFile.RowSampleRateInformation.EndSampleCount; for (int index = 0; index < showLen; index++) { var ascii = new ASCIIContent(dataFile.AsciiData[index], configFile.RowChannelNumType.AnalogChannelCount, configFile.RowChannelNumType.DigitalChannelCount); LoadCurvePoint(ascii); } } catch (Exception ex) { MessageBox.Show(ex.Message, "载入显示数据"); } }
static void TestComtradeManager() { while (true) { try { Console.WriteLine("回车开始"); Console.ReadLine(); Console.WriteLine("TestComtradeManager-TestStart"); string path = @"E:\WorkProject\04-FTU终端\Comtrade\ComtradeFile"; string cfgPath = Path.Combine(path, "binary.cfg"); string dataPath = Path.Combine(path, "binary.dat"); Console.WriteLine("In:"); Console.WriteLine(path); Console.WriteLine(cfgPath); Console.WriteLine(dataPath); var comtradeManager = new ComtradeFileManager(); comtradeManager.ReadFile(cfgPath, dataPath); Console.WriteLine("Out:"); Console.WriteLine("配置文件内容:"); string[] cfgRow; comtradeManager.ConfigFile.MakeConfigFile(out cfgRow); for (int index = 0; index < cfgRow.Length; index++) { Console.Write(string.Format("{0}:" + cfgRow[index], index + 1)); } Console.WriteLine("数据文件内容:"); for (int i = 0; i < comtradeManager.DataFile.AsciiData.Count; i++) { var ascii = new ASCIIContent(comtradeManager.DataFile.AsciiData[i], comtradeManager.ConfigFile.RowChannelNumType.AnalogChannelCount, comtradeManager.ConfigFile.RowChannelNumType.DigitalChannelCount); Console.Write(ascii.RowToString()); } for (int j = 0; j < comtradeManager.DataFile.BinaryData.Count; j++) { var binanry = new BinaryContent(comtradeManager.DataFile.BinaryData[j], comtradeManager.ConfigFile.RowChannelNumType.AnalogChannelCount, comtradeManager.ConfigFile.RowChannelNumType.DigitalChannelCount); var assii = new ASCIIContent(binanry); Console.Write(assii.RowToString()); } Console.WriteLine("TestComtradeManager-TestEnd"); var instr = Console.ReadLine(); if (instr == "q") { return; } } catch (Exception ex) { Console.WriteLine(); Console.WriteLine("Exception:"); Console.WriteLine(ex.Message); var instr = Console.ReadLine(); if (instr == "q") { return; } } } }