1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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;
- namespace EapClientSimulator
- {
- public class SecsMessageSendUtil
- {
- public static SecsMessage CreateS1F13Message()
- {
- SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
- {
- Stream = 0x01,
- Function = 13,
- SType = SType.DataMessage,
- TransactionId = IdGenerator.GenerateTransactionId(),
- ReplyFlag = true,
- };
- Item item = new ListItem();
- return new SecsMessage(secsMessageHeader, item, true);
- }
- /// <summary>
- /// 建立通讯S1F13
- /// </summary>
- /// <returns></returns>
- public static SecsMessage CreateS2F49Message(RemoteCommand remoteCommand)
- {
- SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
- {
- Stream = 0x02,
- Function = 49,
- SType = SType.DataMessage,
- TransactionId = IdGenerator.GenerateTransactionId(),
- ReplyFlag = true,
- };
- Item item = new ListItem();
- Item dataIdItem = new IntItem(1);
- item.AddItem(dataIdItem);
- Item objSpecItem=new IntItem(0);
- item.AddItem(objSpecItem);
- Item rmcdItem = new StringItem(DataFormat.Ascii, remoteCommand.Command);
- item.AddItem(rmcdItem);
- Item parameters = new ListItem();
- for(int i = 0; i < remoteCommand.RemoteParameters.Count; i++)
- {
- Item lstItem=new ListItem();
- Item paramNameItem = new StringItem(DataFormat.Ascii, remoteCommand.RemoteParameters[i].Name);
- lstItem.AddItem(paramNameItem);
- lstItem.AddItem(remoteCommand.RemoteParameters[i].Value);
- parameters.AddItem(lstItem);
- }
- item.AddItem(parameters);
- return new SecsMessage(secsMessageHeader, item, true);
- }
- }
- }
|