123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using SecsGem.Core;
- using SecsGem.Core.EnumData;
- using SecsGem.Core.Hsms;
- using SecsGem.Core.ItemModel;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace EapClientSimulator
- {
- /// <summary>
- /// UReport.xaml 的交互逻辑
- /// </summary>
- public partial class UEventReport : UserControl
- {
- public UEventReport()
- {
- InitializeComponent();
- }
- public event EventHandler<string> OnSendMessage;
- private void btnReport_Click(object sender, RoutedEventArgs e)
- {
- if(string.IsNullOrEmpty(txtCeId.Text))
- {
- MessageBox.Show("ceid is empty");
- return;
- }
- string[] strAry = txtRPID.Text.Split(';');
- SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
- {
- Stream = 0x02,
- Function = 35,
- SType = SType.DataMessage,
- TransactionId = IdGenerator.GenerateTransactionId(),
- ReplyFlag = true,
- };
- Item item = new SecsGem.Core.ItemModel.ListItem();
- Item dataIdItem = new IntItem(1);
- item.AddItem(dataIdItem);
- Item rpsItem = new SecsGem.Core.ItemModel.ListItem();
- Item vdsItem = new SecsGem.Core.ItemModel.ListItem();
- for(int i=0;i<strAry.Length;i++)
- {
- if (!string.IsNullOrEmpty(strAry[i]))
- {
- if (int.TryParse(strAry[i], out int vdValue))
- {
- Item vdItem = new IntItem(vdValue);
- vdsItem.AddItem(vdItem);
- }
- else
- {
- return;
- }
- }
- }
- Item rpItem = new SecsGem.Core.ItemModel.ListItem();
- if (int.TryParse(txtCeId.Text, out int rpid))
- {
- Item rpidItem = new IntItem(rpid);
- rpItem.AddItem(rpidItem);
- }
- else
- {
- return;
- }
- rpItem.AddItem(vdsItem);
- rpsItem.AddItem(rpItem);
- item.AddItem(rpsItem);
- SecsMessage secsMessage = new SecsMessage(secsMessageHeader, item);
- if(GlobalData.Client!=null)
- {
- GlobalData.Client.SendMessage(secsMessage);
- if (OnSendMessage != null)
- {
- OnSendMessage(this, SmlSerializationUtil.SerializeItemToString(secsMessage));
- }
- }
- }
- }
- }
|