public virtual void Open() { this.Close(); if (!NativeFunctions.candle_dev_open(this.FDeviceHandle)) { NativeFunctions.throwError(this.FDeviceHandle); } // Create queues this.FActionQueue = new BlockingCollection <Action>(); this.FExceptionQueue = new BlockingCollection <Exception>(); // Flush Rx on device { NativeFunctions.candle_frame_t nativeFrame; while (NativeFunctions.candle_frame_read(this.FDeviceHandle , out nativeFrame , 0)) { } } // Setup device thread this.FIsClosing = false; this.FThread = new Thread(this.ThreadedUpdate); this.FThread.Name = String.Format("Candle {0}", this.FInstanceIndex); // List Channels this.FChannels.Clear(); byte channelCount; if (!NativeFunctions.candle_channel_count(this.FDeviceHandle, out channelCount)) { NativeFunctions.throwError(this.FDeviceHandle); } for (byte i = 0; i < channelCount; i++) { this.FChannels.Add(i, new Channel(this, i)); } // Start device thread this.FThread.Start(); }
public void Open() { this.Close(); if (!NativeFunctions.candle_dev_open(this.FDeviceHandle)) { NativeFunctions.throwError(this.FDeviceHandle); } // Create queues this.FActionQueue = new BlockingCollection <Action>(); this.FExceptionQueue = new BlockingCollection <Exception>(); // Start device thread this.FIsClosing = false; this.FThread = new Thread(this.ThreadedUpdate); this.FThread.Name = "Candle"; this.FThread.Start(); // List Channels this.FChannels.Clear(); byte channelCount; if (!NativeFunctions.candle_channel_count(this.FDeviceHandle, out channelCount)) { NativeFunctions.throwError(this.FDeviceHandle); } for (byte i = 0; i < channelCount; i++) { this.FChannels.Add(i, new Channel(this, i)); } this.FCounterLastTime = DateTime.Now; this.FCounterRxBits = 0; this.FCounterTxBits = 0; }