Example #1
0
        private void interrogate()
        {
            m_name = Utilities.getString(m_native.Name());
            m_descr = Utilities.getString(m_native.Description());
            m_type = m_native.Type();
            m_typeInfo = ProxyTypes.getTypeInfo(m_type);
            m_readOnly = m_native.isReadOnly();

            m_callbackRef = false;
            CppNativeProxy.Callback callback = CppNativeProxy.CreateCallin(m_catcher, typeof(Native.IAttributeObserver));
            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            try { }
            finally
            {
                m_callback = callback;
                m_callback.DangerousAddRef(ref m_callbackRef);
                m_native.Observe(m_callback.DangerousGetHandle());
            }
        }
Example #2
0
 public bool WriteOne(signals.EType type, object val, int msTimeout)
 {
     if (val == null) throw new ArgumentNullException("val");
     if (type != m_sendType || m_sendTypeInfo == null)
     {
         m_sendType = type;
         m_sendTypeInfo = ProxyTypes.getTypeInfo(type);
         if (m_sendTypeInfo == null) throw new NotSupportedException("Cannot retrieve value for this type.");
     }
     Array pinArray = m_sendTypeInfo.toPinnableArray(new object[] { val });
     GCHandle pin = GCHandle.Alloc(pinArray, GCHandleType.Pinned);
     try
     {
         return m_nativeSend.WriteOne(type, pin.AddrOfPinnedObject(), (uint)msTimeout);
     }
     finally
     {
         pin.Free();
     }
 }
Example #3
0
        public object ReadOne(signals.EType type, int msTimeout)
        {
            if (type != m_recvType || m_recvTypeInfo == null)
            {
                m_recvType = type;
                m_recvTypeInfo = ProxyTypes.getTypeInfo(type);
                if (m_recvTypeInfo == null) throw new NotSupportedException("Cannot retrieve value for this type.");
            }

            Array pinArray = m_recvTypeInfo.makePinnableArray(1);
            GCHandle pin = GCHandle.Alloc(pinArray, GCHandleType.Pinned);
            bool read;
            try
            {
                read = m_nativeRecv.ReadOne(type, pin.AddrOfPinnedObject(), (uint)msTimeout);
            }
            finally
            {
                pin.Free();
            }
            return read ? m_recvTypeInfo.fromPinnableArray(pinArray, 1).GetValue(0) : null;
        }
Example #4
0
        public void Read(signals.EType type, out Array values, bool bReadAll, int msTimeout)
        {
            if (type != m_recvType || m_recvTypeInfo == null)
            {
                m_recvType = type;
                m_recvTypeInfo = ProxyTypes.getTypeInfo(type);
                if (m_recvTypeInfo == null) throw new NotSupportedException("Cannot retrieve value for this type.");
            }

            Array pinArray = m_recvTypeInfo.makePinnableArray(BufferSize);
            GCHandle pin = GCHandle.Alloc(pinArray, GCHandleType.Pinned);
            uint read;
            try
            {
                read = m_nativeRecv.Read(type, pin.AddrOfPinnedObject(), (uint)BufferSize, bReadAll, (uint)msTimeout);
            }
            finally
            {
                pin.Free();
            }
            values = m_recvTypeInfo.fromPinnableArray(pinArray, (int)read);
        }
Example #5
0
        public int Write(signals.EType type, Array values, int msTimeout)
        {
            if (values == null) throw new ArgumentNullException("values");
            if (type != m_type || m_typeInfo == null)
            {
                m_type = type;
                m_typeInfo = ProxyTypes.getTypeInfo(type);
                if (m_typeInfo == null) throw new NotSupportedException("Cannot retrieve value for this type.");
            }

            Array pinArray = m_typeInfo.toPinnableArray(values);
            GCHandle pin = GCHandle.Alloc(pinArray, GCHandleType.Pinned);
            try
            {
                return (int)m_native.Write(type, pin.AddrOfPinnedObject(), (uint)values.Length, (uint)msTimeout);
            }
            finally
            {
                pin.Free();
            }
        }
Example #6
0
 private void interrogate()
 {
     m_type = m_native.Type();
     m_typeInfo = ProxyTypes.getTypeInfo(m_type);
 }