Ejemplo n.º 1
0
 internal void OnAmsReceive(IntPtr pAmsCmd)
 {
     if (pAmsCmd != IntPtr.Zero)
     {
         Marshal.Copy(pAmsCmd, this.hdrBuffer, 0, TcAmsHeaderSize.TCAMSHEADER);
         TcAmsHeader amsHeader   = new TcAmsHeader(this.hdrBuffer);
         IntPtr      source      = new IntPtr(pAmsCmd.ToInt64() + TcAmsHeaderSize.TCAMSHEADER);
         byte[]      destination = new byte[amsHeader.CbData];
         Marshal.Copy(source, destination, 0, (int)amsHeader.CbData);
         TcAmsCommand item = new TcAmsCommand(amsHeader, destination);
         if (item.AmsHeader.CommandId == 8)
         {
             object syncRoot = this._receiveQueueNotify.SyncRoot;
             lock (syncRoot)
             {
                 this._receiveQueueNotify.Enqueue(item);
             }
             this._queueEventNotify.Set();
         }
         else
         {
             object syncRoot = this._receiveQueue.SyncRoot;
             lock (syncRoot)
             {
                 this._receiveQueue.Enqueue(item);
             }
             this._queueEvent.Set();
         }
     }
 }
Ejemplo n.º 2
0
        private AdsErrorCode AdsRequest(AmsAddress rAddr, uint invokeId, ushort serviceId, uint cbLength, ITcAdsHeader adsHeader, byte[] adsData)
        {
            uint num = 0;

            if (adsHeader != null)
            {
                num = (uint)Marshal.SizeOf(adsHeader);
            }
            TcAmsHeader amsHeader = new TcAmsHeader(rAddr, this.Address, serviceId, 4, num + cbLength, 0, invokeId);

            return(this._amsServer.Send(new TcAmsCommand(amsHeader, TcAdsParser.BuildAdsBuffer(adsHeader, adsData))));
        }
Ejemplo n.º 3
0
        internal unsafe AdsErrorCode Send(TcAmsCommand amsCmd)
        {
            AdsErrorCode noError   = AdsErrorCode.NoError;
            TcAmsHeader  amsHeader = amsCmd.AmsHeader;
            IntPtr       ptr       = Marshal.AllocHGlobal((int)(Marshal.SizeOf(typeof(TcMarshallableAmsHeader)) + ((int)amsHeader.CbData)));

            Marshal.StructureToPtr(amsCmd.AmsHeader.GetMarshallableHeader(), ptr, false);
            if (amsHeader.CbData > 0)
            {
                IntPtr destination = new IntPtr(ptr.ToInt64() + Marshal.SizeOf(typeof(TcMarshallableAmsHeader)));
                Marshal.Copy(amsCmd.Data, 0, destination, (int)amsHeader.CbData);
            }
            void *pAmsCmd = ref ptr.ToPointer();

            noError = (AdsErrorCode)UnsafeNativeMethods.AmsSend(this._server.Port, pAmsCmd);
            Marshal.FreeHGlobal(ptr);
            return(noError);
        }
Ejemplo n.º 4
0
 internal TcAmsCommand(TcAmsHeader amsHeader, byte[] data)
 {
     this._amsHeader = amsHeader;
     this._data      = data;
 }
Ejemplo n.º 5
0
        private AdsErrorCode AdsResponse(AmsAddress rAddr, uint invokeId, ushort serviceId, uint cbLength, ITcAdsHeader adsHeader, byte[] adsData)
        {
            TcAmsHeader amsHeader = new TcAmsHeader(rAddr, this.Address, serviceId, 5, ((uint)Marshal.SizeOf(adsHeader)) + cbLength, 0, invokeId);

            return(this._amsServer.Send(new TcAmsCommand(amsHeader, TcAdsParser.BuildAdsBuffer(adsHeader, adsData))));
        }