コード例 #1
0
        protected override unsafe AdsErrorCode WriteControl(AdsState adsState, short deviceState, int length, void *data, bool throwAdsException)
        {
            byte[]       buffer;
            AdsErrorCode noError = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncWriteControlReqEx(base._port, numRef, adsState, deviceState, length, data);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                return(noError);
            }
        }
コード例 #2
0
        public override unsafe AdsErrorCode DelDeviceNotification(int hNotification, bool throwAdsException)
        {
            byte[]       buffer;
            AdsErrorCode noError = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncDelDeviceNotificationReqEx(base._port, numRef, hNotification);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                return(noError);
            }
        }
コード例 #3
0
        public override unsafe AdsErrorCode Write(uint indexGroup, uint indexOffset, int length, void *data, bool throwAdsException)
        {
            byte[]       buffer;
            AdsErrorCode noError = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncWriteReqEx(base._port, numRef, indexGroup, indexOffset, length, data);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                return(noError);
            }
        }
コード例 #4
0
        protected override unsafe AdsErrorCode ReadDeviceInfo(byte *devName, byte *version, bool throwAdsException)
        {
            byte[]       buffer;
            AdsErrorCode noError = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncReadDeviceInfoReqEx(base._port, numRef, devName, version);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                return(noError);
            }
        }
コード例 #5
0
        public override unsafe AdsErrorCode ReadWrite(uint indexGroup, uint indexOffset, int readLength, void *readData, int writeLength, void *writeData, bool throwAdsException, out int dataRead)
        {
            byte[]       buffer;
            int          pcbReturn = 0;
            AdsErrorCode noError   = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncReadWriteReqEx2(base._port, numRef, indexGroup, indexOffset, readLength, readData, writeLength, writeData, &pcbReturn);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                dataRead = pcbReturn;
                return(noError);
            }
        }
コード例 #6
0
        public override unsafe AdsErrorCode ReadState(bool throwAdsException, out StateInfo stateInfo)
        {
            StateInfo info;

            byte[]       buffer;
            AdsErrorCode noError = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncReadStateReqEx(base._port, numRef, &info.adsState, &info.deviceState);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                stateInfo = info;
                return(noError);
            }
        }
コード例 #7
0
        public override unsafe AdsErrorCode AddDeviceNotification(uint indexGroup, uint indexOffset, AdsNotificationAttrib *noteAttrib, TcAdsDllWrapper.AdsNotificationDelegate noteFunc, int hUser, bool throwAdsException, out int hNotification)
        {
            byte[]       buffer;
            int          pNotification = 0;
            IntPtr       functionPointerForDelegate = Marshal.GetFunctionPointerForDelegate(noteFunc);
            AdsErrorCode noError = AdsErrorCode.NoError;

            if (((buffer = AmsAddressMarshaller.Marshal(base.address)) == null) || (buffer.Length == 0))
            {
                numRef = null;
            }
            else
            {
                numRef = buffer;
            }
            noError = TcAdsDllWrapper.UnsafeNativeMethods.AdsSyncAddDeviceNotificationReqEx(base._port, numRef, indexGroup, indexOffset, noteAttrib, functionPointerForDelegate, hUser, &pNotification);
            fixed(byte *numRef = null)
            {
                base.OnHandleCommunicationResult(noError, throwAdsException);
                hNotification = pNotification;
                return(noError);
            }
        }