Esempio n. 1
0
 /// <summary>
 /// 转换成数组
 /// </summary>
 /// <returns>结果数组</returns>
 public byte[] ToArray()
 {
     byte[] res = new byte[6 + (_asdu == null? 0:_asdu.ToArray().Length)];
     apci.ToArray().CopyTo(res, 0);
     if (_asdu != null)
     {
         _asdu.ToArray().CopyTo(res, 6);
     }
     return(res);
 }
Esempio n. 2
0
 /// <summary>
 /// 设置Asdu部分数据
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public bool SetAsdu(ASDUClass data)
 {
     if (data != null)
     {
         if (this.apci.UisType == APCIClass.UISFormat.I)
         {
             byte[] temp = data.ToArray();
             try
             {
                 if (temp.Length > 250)
                 {
                     (this.apci as APCIClassIFormat).APDULenth = 0x00;
                 }
                 else
                 {
                     (this.apci as APCIClassIFormat).APDULenth = Convert.ToByte(temp.Length + 4);
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.ToString() + "   " + temp.Length);
             }
             this._asdu = data;
         }
         return(true);
     }
     else
     {
         _asdu = null;
         if (this.apci.UisType == APCIClass.UISFormat.I)
         {
             (this.apci as APCIClassIFormat).APDULenth = 4;
         }
         return(false);
     }
 }