예제 #1
0
        /// <summary>
        /// 制造通信消息
        /// </summary>
        /// <param name="wIdent"></param>
        /// <param name="nRecog"></param>
        /// <param name="wParam"></param>
        /// <param name="wTag"></param>
        /// <param name="wSeries"></param>
        /// <param name="wSessionID"></param>
        /// <returns></returns>
        public unsafe static TDefaultMessage MakeDefaultMsg(object wIdent, object nRecog, object wParam, object wTag, object wSeries, object wSessionID)
        {
            TDefaultMessage result = new TDefaultMessage();

            result.Recog      = (int)nRecog;
            result.Ident      = Convert.ToUInt16(wIdent);
            result.Param      = Convert.ToUInt32(wParam);
            result.Tag        = Convert.ToUInt32(wTag);
            result.Series     = Convert.ToUInt32(wSeries);
            result.nSessionID = Convert.ToInt32(wSessionID);
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 加密消息
        /// </summary>
        /// <param name="sMsg"></param>
        /// <returns></returns>
        public unsafe static string EncodeMessage(TDefaultMessage sMsg)
        {
            string result = string.Empty;

            byte[] EncBuf  = new byte[BUFFERSIZE];
            byte[] TempBuf = new byte[BUFFERSIZE];
            fixed(byte *pb = TempBuf)
            {
                *(TDefaultMessage *)(pb) = sMsg;
            }

            int DestLen = Encode6BitBuf(TempBuf, EncBuf, Marshal.SizeOf(typeof(TDefaultMessage)), BUFFERSIZE);

            fixed(byte *pb = EncBuf)
            {
                result = HUtil32.SBytePtrToString((sbyte *)pb, 0, DestLen);
            }

            return(result);
        }