/// <summary>
        /// 使用指定的S字节,F字节,函数名称,是否期待响应,Item实例,初始化SecsMessage类的新实例
        /// </summary>
        /// <param name="s">message stream number</param>
        /// <param name="f">message function number</param>
        /// <param name="name">Stream function name</param>
        /// <param name="replyExpected">expect reply message</param>
        /// <param name="item">the root item of message</param>
        public SecsMessage(short deviceID, byte s, byte f, string name, bool replyExpected, int systembyte = -1, Item item = null)
        {
            if (s > 0x7F)
            {
                throw new ArgumentOutOfRangeException("s", s, "Stream number不能超過127");
            }

            this.S             = s;
            this.F             = f;
            this.Name          = name;
            this.ReplyExpected = replyExpected;
            this.SecsItem      = item;
            this.SystenBytes   = systembyte == -1 ? SecsGem.NewSystemByte() : systembyte;
            this.DeviceID      = deviceID;
            this._rawDatas     = item == null ? emptyMsgDatas : Lazy.Create(() =>
            {
                var result = new List <RawData> {
                    null, dummyHeaderDatas
                };
                uint length          = 10 + SecsItem.Encode(result);
                byte[] msgLengthByte = BitConverter.GetBytes(length);
                Array.Reverse(msgLengthByte);
                result[0] = new RawData(msgLengthByte);
                return(result.AsReadOnly());
            });
        }
Beispiel #2
0
 internal PrimaryMessageWrapper(SecsGem secsGem, MessageHeader header, SecsMessage msg)
 {
     _secsGem = new WeakReference <SecsGem>(secsGem);
     _header  = header;
     Message  = msg;
 }
 internal PrimaryMessageWrapper(SecsGem secsGem, MessageHeader header, SecsMessage msg)
 {
     _secsGem = secsGem;
     _header  = header;
     Message  = msg;
 }
 internal PrimaryMessageWrapper(SecsGem secsGem, in MessageHeader header, SecsMessage msg)
Beispiel #5
0
 internal PrimaryMessageWrapper(SecsGem secsGem, MessageHeader header, SecsMessage message)
 {
     this.weakReferenceSecsGem = new WeakReference <SecsGem>(secsGem);
     this.header  = header;
     this.Message = message;
 }