public void DataViewForm_ShowData() { try { SourceDataClass.isNodeTick = false; MainForm.ParseLock.WaitOne(); if (str.StartsWith("01EE")) { str = str.Substring(8); } SourceDataClass.GetData((CRCHelper.ConvertHexToChar(str))); ll = SourceDataClass.Parse(); MainForm.ParseLock.ReleaseMutex(); SourceDataClass.isNodeTick = true; InputGrid(); this.Show(); } catch (Exception e) { MainForm.ParseLock.ReleaseMutex(); SourceDataClass.isNodeTick = true; MessageBox.Show("无法解析文件:" + e.StackTrace); } //this.TopMost = true; }
public void ShowData() { SourceDataClass.GetData((CRCHelper.ConvertHexToChar(str))); ll = SourceDataClass.Parse(); InputGrid(); this.Show(); //this.TopMost = true; }
public void ParseNetworkPacket(byte[] netpacket, int length) { byte[] data = new byte[length]; Buffer.BlockCopy(netpacket, 4, data, 0, length); switch (BitConverter.ToUInt16(netpacket, 0)) { case 0xABCD: { object nodetime = new UtilityClass.UtcTime(); nodetime = UtilityClass.RawDeserialize(data, (Type)nodetime.GetType()); ShowNodeTime(nodetime.ToString()); break; } case 0xAD01: { if (ch1AdFile.adfile.writeOpened == false) { ch1AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } ch1AdFile.BinaryWrite(data); ADEventHandler handler = ADDataEvent; EventsClass.DataEventArgs e = new EventsClass.DataEventArgs("1", data, length, ""); if (handler != null) { handler(this, e); } if (ch1AdFile.FileLen > 1024 * 1024 * 100) { ch1AdFile.close(); ch1AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } break; } case 0xAD02: { if (ch2AdFile.adfile.writeOpened == false) { ch2AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } ch2AdFile.BinaryWrite(data); ADEventHandler handler = ADDataEvent; EventsClass.DataEventArgs e = new EventsClass.DataEventArgs("2", data, length, ""); if (handler != null) { handler(this, e); } if (ch2AdFile.FileLen > 1024 * 1024 * 100) { ch2AdFile.close(); ch2AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } break; } case 0xAD03: { if (ch3AdFile.adfile.writeOpened == false) { ch3AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } ch3AdFile.BinaryWrite(data); ADEventHandler handler = ADDataEvent; EventsClass.DataEventArgs e = new EventsClass.DataEventArgs("3", data, length, ""); if (handler != null) { handler(this, e); } if (ch3AdFile.FileLen > 1024 * 1024 * 100) { ch3AdFile.close(); ch3AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } break; } case 0xAD04: { if (ch4AdFile.adfile.writeOpened == false) { ch4AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } ch4AdFile.BinaryWrite(data); ADEventHandler handler = ADDataEvent; EventsClass.DataEventArgs e = new EventsClass.DataEventArgs("4", data, length, ""); if (handler != null) { handler(this, e); } if (ch4AdFile.FileLen > 1024 * 1024 * 100) { ch4AdFile.close(); ch4AdFile.OpenFile(MainForm.pMainForm.ADPathInfo); } break; } case 0xEDED: { ch1AdFile.close(); ch2AdFile.close(); ch3AdFile.close(); ch4AdFile.close(); } break; case 0xBB01: { if (!hasRecv) { WaveFile.OpenFile(MainForm.pMainForm.NetRecvDataPathInfo); hasRecv = true; } WaveFile.BinaryWrite(data); if (WaveFile.FileLen > 1024 * 1024 * 100) { WaveFile.close(); WaveFile.OpenFile(MainForm.pMainForm.NetRecvDataPathInfo); } WaveEventHandler handler = WaveDisplEvent; EventsClass.WaveEventArgs e = new EventsClass.WaveEventArgs(data, length); if (handler != null) { handler(this, e); } break; } case 0xEE01: { NetTCPFile.OpenFile(MainForm.pMainForm.NetRecvTCPPathInfo); string filename = NetTCPFile.adfile.fileName; NetTCPFile.BinaryWrite(data); NetTCPFile.close(); try { MainForm.ParseLock.WaitOne(); SourceDataClass.GetData(data); SourceDataClass.Parse(); MainForm.ParseLock.ReleaseMutex(); } catch (Exception ex) { MainForm.ParseLock.ReleaseMutex(); } DataEventHandler handler = NetDataEvent; EventsClass.DataEventArgs e = new EventsClass.DataEventArgs(Dclient.Client.RemoteEndPoint.ToString().Split(':')[0], data, length, filename); if (handler != null) { handler(this, e); } break; } case 0xACAC: { ACPacketHandle.Set(); //Debug.WriteLine("收到包号:" + BitConverter.ToUInt16(netpacket,4)); break; } //4500test case 0x45FF: { var cmd = new byte[260]; byte[] netcmd = SourceDataClass.NetPackage(cmd); MainForm.pMainForm.CommandLineWin.SendCommand("gd -n"); if (MainForm.pMainForm.CommandLineWin.SendData(netcmd)) //正确发送 { MainForm.pMainForm.mapdoc.WriteNetLog("数据已发送!"); } break; } default: break; } }