private void SendPackage(ZPackage zPackage) { ZProtocolProcessObj.WriteFrame(zPackage.Frame); for (int i = 0; i < zPackage.Blocks.Length; i++) { ZProtocolProcessObj.AddBlock(zPackage.Blocks[i]); } ZProtocolProcessObj.Send(); }
private void btSend_Click(object sender, EventArgs e) { try { ZPackage zPackage = MakeZPackage(); SendPackage(zPackage); } catch (Exception ee) { MessageBox.Show(ee.Message); } }
private ZPackage MakeZPackage() { ZPackage zPackage = new ZPackage(); zPackage.Frame.PackageNum = (byte)ZBlockDescribes.Count; zPackage.Frame.Reserve = byte.Parse(tbReserve.Text); zPackage.Frame.Source = byte.Parse(tbSource.Text); zPackage.Frame.Target = byte.Parse(tbTarget.Text); zPackage.Frame.S1 = ZProtocolProcess.S1; zPackage.Frame.S2 = ZProtocolProcess.S2; zPackage.Blocks = new ZBlock[zPackage.Frame.PackageNum]; for (int i = 0; i < zPackage.Frame.PackageNum; i++) { zPackage.Blocks[i] = Converter.GetZBlock((DataBlock)flowLayoutPanel2.Controls[i], ZBlockDescribes[i]); } return(zPackage); }
//保存 private void btSave_Click(object sender, EventArgs e) { if (tbName.Text != "") { if (Packages.ContainsKey(tbName.Text) == false) { ZPackage zPackage = MakeZPackage(); Packages.Add(tbName.Text, zPackage); UpdatePackagelist(); } else { MessageBox.Show("名称重复"); } } else { MessageBox.Show("名称不能为空"); } }
private ZPackage MakeZPackage() { ZPackage zPackage = new ZPackage(); zPackage.Frame.PackageNum = (byte)ZBlockDescribes.Count; zPackage.Frame.Reserve = byte.Parse(tbReserve.Text); zPackage.Frame.Source = byte.Parse(tbSource.Text); zPackage.Frame.Target = byte.Parse(tbTarget.Text); zPackage.Frame.S1 = ZProtocolProcess.S1; zPackage.Frame.S2 = ZProtocolProcess.S2; zPackage.Blocks = new ZBlock[zPackage.Frame.PackageNum]; for (int i = 0; i < zPackage.Frame.PackageNum; i++) { zPackage.Blocks[i] = Converter.GetZBlock((DataBlock)flowLayoutPanel2.Controls[i], ZBlockDescribes[i]); } return zPackage; }