public ReceiveStream(signals.EType type, signals.IEPRecvFrom recv)
 {
     m_type = type;
     m_recv = recv;
     m_thread = new Thread(new ThreadStart(start));
     m_thread.IsBackground = true;
     m_thread.Start();
 }
Exemple #2
0
 private void OnChanged(signals.IAttribute attr, object value)
 {
     lock(st_screenLock)
     {
         if (value == null)
         {
             Console.Out.WriteLine(String.Format("{0}: null", attr.Name));
         }
         else
         {
             Console.Out.WriteLine(String.Format("{0}: ({1}){2}", attr.Name, value.GetType().Name, value));
         }
     }
 }
Exemple #3
0
 public Vector(signals.EType type, ITypeMarshaller inner)
 {
     enumType = type;
     innerType = inner;
 }
Exemple #4
0
 public Complex(signals.EType type)
 {
     enumType = type;
 }
Exemple #5
0
 public static ITypeMarshaller getTypeInfo(signals.EType typ)
 {
     switch (typ)
     {
         case signals.EType.String:
             return new String();
         case signals.EType.WinHdl:
             return new Handle();
         case signals.EType.Boolean:
             return new Boolean();
         case signals.EType.VecBoolean:
             return new Vector(typ, new Boolean());
         case signals.EType.Byte:
             return new Byte();
         case signals.EType.VecByte:
             return new Vector(typ, new Byte());
         case signals.EType.Short:
             return new Short();
         case signals.EType.VecShort:
             return new Vector(typ, new Short());
         case signals.EType.Long:
             return new Long();
         case signals.EType.VecLong:
             return new Vector(typ, new Long());
         case signals.EType.Int64:
             return new Int64();
         case signals.EType.VecInt64:
             return new Vector(typ, new Int64());
         case signals.EType.Single:
             return new Single();
         case signals.EType.VecSingle:
             return new Vector(typ, new Single());
         case signals.EType.Double:
             return new Double();
         case signals.EType.VecDouble:
             return new Vector(typ, new Double());
         case signals.EType.Complex:
         case signals.EType.LRSingle:
             return new Complex(typ);
         case signals.EType.VecComplex:
             return new Vector(typ, new Complex(signals.EType.Complex));
         case signals.EType.VecLRSingle:
             return new Vector(typ, new Complex(signals.EType.LRSingle));
         case signals.EType.CmplDbl:
             return new ComplexDouble();
         case signals.EType.VecCmplDbl:
             return new Vector(typ, new ComplexDouble());
         default:
             return null;
     }
 }
Exemple #6
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();
     }
 }
Exemple #7
0
 public CppProxyOutputFunction(signals.IModule module, IntPtr native)
     : base(module, native)
 {
     m_nativeSendRef = new IntPtr(native.ToInt64() + IntPtr.Size);
     m_nativeSend = (Native.IEPSendTo)CppNativeProxy.CreateCallout(m_nativeSendRef, typeof(Native.IEPSendTo));
     m_nativeSend.AddRef(IntPtr.Zero);
 }
 // Self created methods
 private void send_data_toArduino(signals signal)
 {
     serial_setup_andSend(signal);
     toolStripStatusLabel1.Text = "Signal '" + signal + "' toggle sent to Arduino"; //display actual
     statusStrip1.Refresh();   //send address "a" off signal to LED32
 }
Exemple #9
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;
        }
Exemple #10
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);
        }
Exemple #11
0
 public CppProxyInputFunction(signals.IModule module, IntPtr native)
     : base(native)
 {
     if (module == null) throw new ArgumentNullException("module");
     if (native == IntPtr.Zero) throw new ArgumentNullException("native");
     m_module = module;
     m_nativeRecvRef = new IntPtr(native.ToInt64() + IntPtr.Size);
     m_nativeRecv = (Native.IEPRecvFrom)CppNativeProxy.CreateCallout(m_nativeRecvRef, typeof(Native.IEPRecvFrom));
 }
Exemple #12
0
 public CppProxyFunction(signals.IFunctionSpec spec, IntPtr native)
 {
     if (spec == null) throw new ArgumentNullException("spec");
     if (native == IntPtr.Zero) throw new ArgumentNullException("native");
     m_nativeRef = native;
     m_spec = spec;
     Registration.storeObject(native, this);
     m_native = (Native.IFunction)CppNativeProxy.CreateCallout(native, typeof(Native.IFunction));
 }
Exemple #13
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();
            }
        }
Exemple #14
0
 public CppProxyEPSender(signals.IBlockDriver driver, IntPtr native)
 {
     if (driver == null) throw new ArgumentNullException("driver");
     if (native == IntPtr.Zero) throw new ArgumentNullException("native");
     m_driver = driver;
     m_nativeRef = native;
     Registration.storeObject(native, this);
     m_native = (Native.IEPSendTo)CppNativeProxy.CreateCallout(native, typeof(Native.IEPSendTo));
     m_native.AddRef(IntPtr.Zero);
 }
 private void serial_setup_andSend(signals signal)
 {
     if (!serialPort1.IsOpen)
     {
         try
         {
             serialPort1.Open();
             serialPort1.Write(signal.ToString());
             toolStripStatusLabel2.Text = serialPort1.ReadLine();
             serialPort1.Close();
         }
         catch
         {
             MessageBox.Show("There was an error. Please make sure that the correct port was selected, and the device, plugged in.");
         }
     }
 }
Exemple #16
0
 public IEnumerator<signals.IAttribute> Itemize(signals.EAttrEnumFlags flags)
 {
     uint numAttr = m_native.Itemize(IntPtr.Zero, 0, (uint)flags);
     if (numAttr == 0) return ((IList<signals.IAttribute>)new signals.IAttribute[0]).GetEnumerator();
     IntPtr[] ptrArr = new IntPtr[numAttr];
     GCHandle pin = GCHandle.Alloc(ptrArr, GCHandleType.Pinned);
     uint numObj;
     try
     {
         numObj = m_native.Itemize(pin.AddrOfPinnedObject(), numAttr, (uint)flags);
     }
     finally
     {
         pin.Free();
     }
     signals.IAttribute[] attrArray = new signals.IAttribute[numObj];
     for (int idx = 0; idx < numObj; idx++)
     {
         if (ptrArr[idx] != IntPtr.Zero)
         {
             signals.IAttribute newObj = (signals.IAttribute)Registration.retrieveObject(ptrArr[idx]);
             if (newObj == null) newObj = new CppProxyAttribute(ptrArr[idx]);
             attrArray[idx] = newObj;
         }
     }
     return ((IList<signals.IAttribute>)attrArray).GetEnumerator();
 }
Exemple #17
0
 public CppProxyBlock(signals.IBlockDriver driver, signals.IBlock parent, IntPtr native)
 {
     if (driver == null) throw new ArgumentNullException("driver");
     if (native == IntPtr.Zero) throw new ArgumentNullException("native");
     m_nativeRef = native;
     m_driver = driver;
     m_parent = parent;
     Registration.storeObject(native, this);
     m_native = (Native.IBlock)CppNativeProxy.CreateCallout(native, typeof(Native.IBlock));
     interrogate();
 }
Exemple #18
0
 public CppProxyOutEndpoint(signals.IModule module, IntPtr native)
 {
     if (module == null) throw new ArgumentNullException("module");
     if (native == IntPtr.Zero) throw new ArgumentNullException("native");
     m_module = module;
     m_nativeRef = native;
     Registration.storeObject(native, this);
     m_native = (Native.IOutEndpoint)CppNativeProxy.CreateCallout(native, typeof(Native.IOutEndpoint));
     interrogate();
 }
 private void OnAttrValueChanged(signals.IAttribute attr, object value)
 {
     if (attr == mBoundAttr)
     {
         Action action = delegate()
         {
             Value = Convert.ToInt64(value);
         };
         if (InvokeRequired)
         {
             Invoke(action);
         }
         else
         {
             action();
         }
     }
 }
Exemple #20
0
 public bool Connect(signals.IEPSendTo recv)
 {
     {
         CppProxyEPSender proxy = recv as CppProxyEPSender;
         if (proxy != null)
         {
             return m_native.Connect(proxy.Native);
         }
     }
     {
         CppProxyBuffer proxy = recv as CppProxyBuffer;
         if (proxy != null)
         {
             return m_native.Connect(proxy.NativeSender);
         }
     }
     {
         CppProxyOutputFunction proxy = recv as CppProxyOutputFunction;
         if (proxy != null)
         {
             return m_native.Connect(proxy.NativeSender);
         }
     }
     throw new NotSupportedException("Native connections not yet implemented.");
 }