12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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 UEvent : UserControl
- {
- public UEvent()
- {
- InitializeComponent();
- }
- public event EventHandler<string> OnSendMessage;
- private void EnableEvent(bool enable)
- {
-
- string[] strAry = txtCeId.Text.Split(';');
- SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
- {
- Stream = 0x02,
- Function = 37,
- SType = SType.DataMessage,
- TransactionId = IdGenerator.GenerateTransactionId(),
- ReplyFlag = true,
- };
- Item item = new SecsGem.Core.ItemModel.ListItem();
- Item ceedItem = new BooleanItem(enable);
- item.AddItem(ceedItem);
- Item ceidsItem = 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 ceidValue))
- {
- Item ceItem = new IntItem(ceidValue);
- ceidsItem.AddItem(ceItem);
- }
- else
- {
- return;
- }
- }
- }
- item.AddItem(ceidsItem);
- SecsMessage secsMessage = new SecsMessage(secsMessageHeader, item);
- if(GlobalData.Client!=null)
- {
- GlobalData.Client.SendMessage(secsMessage);
- if (OnSendMessage != null)
- {
- OnSendMessage(this, SmlSerializationUtil.SerializeItemToString(secsMessage));
- }
- }
- }
- private void btnEnable_Click(object sender, RoutedEventArgs e)
- {
- EnableEvent(true);
- }
- private void btnDisEnable_Click(object sender, RoutedEventArgs e)
- {
- EnableEvent(false);
- }
- }
- }
|