1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using SecsGem.Core;
- using SecsGem.Core.EnumData;
- using SecsGem.Core.Hsms;
- using SecsGem.Core.ItemModel;
- using SecsGem.Core.Utility;
- 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 UAlarm : UserControl
- {
- public UAlarm()
- {
- InitializeComponent();
- }
- public event EventHandler<string> OnSendMessage;
- private void EnableAlarm(bool enable)
- {
- SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
- {
- Stream = 0x05,
- Function = 3,
- SType = SType.DataMessage,
- TransactionId = IdGenerator.GenerateTransactionId(),
- ReplyFlag = true,
- };
- Item item = new SecsGem.Core.ItemModel.ListItem();
- Item aledItem = new IntItem(enable?0x80:0x00);
- item.AddItem(aledItem);
- Item alidItem = null;
- if(string.IsNullOrEmpty(txtCeId.Text))
- {
- alidItem = ItemUtil.GetEmptyItem(SecsGem.Core.DataFormat.U4);
- }
- else
- {
- if(int.TryParse(txtCeId.Text,out var alid))
- {
- alidItem=new IntItem(alid);
- }
- else
- {
- return;
- }
- }
- item.AddItem(alidItem);
- 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)
- {
- EnableAlarm(true);
- }
- private void btnDisEnable_Click(object sender, RoutedEventArgs e)
- {
- EnableAlarm(false);
- }
- }
- }
|