Ejemplo n.º 1
0
        public override void Open()
        {
            this.Close();

            if (NativeFunctions.OpenDevice(this.FDeviceType, this.FDeviceIndex, 0) != NativeFunctions.ECANStatus.STATUS_OK)
            {
                throw (new Exception(String.Format("Failed to open device type ({0}) index ({1})", this.FDeviceType, this.FDeviceIndex)));
            }

            this.FActionQueue    = new BlockingCollection <Action>();
            this.FExceptionQueue = new BlockingCollection <Exception>();

            // List Channels
            this.FChannels.Clear();
            byte channelCount = 2;             // Currently we only support devices with 2 channels

            for (byte i = 0; i < channelCount; i++)
            {
                this.FChannels.Add(i, new Channel(this, i));
            }

            // Start device thread
            this.FIsClosing   = false;
            this.FThread      = new Thread(this.ThreadedUpdate);
            this.FThread.Name = String.Format("GCAN {0}:{1}", this.FDeviceType, this.FDeviceIndex);
            this.FThread.Start();

            this.FStartTime = DateTime.Now;
        }
Ejemplo n.º 2
0
        static public void RegisterDevices()
        {
            // We only support one device type here
            UInt32 deviceType = 4;

            UInt32 deviceIndex = 0;

            while (NativeFunctions.OpenDevice(deviceType, deviceIndex, 0) == NativeFunctions.ECANStatus.STATUS_OK)
            {
                NativeFunctions.CloseDevice(deviceType, deviceIndex);
                Candle.Device.RegisterAlternativeDevice(new Device(deviceType, deviceIndex));
                deviceIndex++;
            }
        }