private void Dispose(bool disposing) { if (!_disposed) { if (disposing) { using (var blink1 = new Blink1()) { try { blink1.Open(); blink1.SetColor(0, 0, 0); } catch(InvalidOperationException) {} } } } _disposed = true; }
private void ReportStatus(IBuildDetail build, string color) { if (!ShouldDisplayNotification(build)) { return; } using (var blink1 = new Blink1()) { try { blink1.Open(); blink1.SetColor(0, 0, 0); blink1.FadeToColor(750, new HtmlHexadecimal(color), true); } catch (InvalidOperationException exception) { _logger.ErrorException(exception.Message, exception); } finally { blink1.Complete(); } } }
public uint OpenCommunication() { //try //{ if (blink == null) blink = new Blink1(); blink.Open(); blinkOpen = true; //} //catch (Exception ex) //{ // ErrorMessage.Text = "No Blink(1) device found."; // //throw new InvalidOperationException("No Blink(1) device found."); //} //var numBlinks = blink.enumerate(); //if (numBlinks > 0) //{ // if (noBlinks) // { // if (blinkOpen) blink.Close(); // blink.Open(); // blinkOpen = true; // } // noBlinks = false; // return 0; //} //else noBlinks = true; return 0; }
/// <summary> /// Sets the led status (just set, no blink) /// </summary> /// <param name="pValue"></param> private void SetStatus(byte pValue) { try { Console.WriteLine(string.Format("Send arbitrary data {0:X2} and answer is ", pValue) + TricolorUsbSignal.SendRawBuffer(new byte[] { Constants.PACKET_ID, pValue })); if (mLastSendCharWasError) { DoLogLine("SUCCESS while sending data to Blink. Reconnected?"); this.mSystrayIcon.ShowBalloonTip(2000, "Tricolor USB Signal", "Connected to USB signal.", ToolTipIcon.Info); } mLastSendCharWasError = false; } catch (Exception ex) { if (!mLastSendCharWasError) { DoLogLine("ERROR while sending data to Blink. Disconnected?"); this.mSystrayIcon.ShowBalloonTip(2000, "Tricolor USB Signal", "Connection lost to USB signal!", ToolTipIcon.Error); try { TricolorUsbSignal.Close(); } catch (Exception ex2) { DoLogLine("ERROR while closing connection to Blink. Ignore and release."); Console.WriteLine("ERROR SendChar() - Close(): " + ex.Message); } finally { mTricolorUsbSignal.Dispose(); mTricolorUsbSignal = null; } } mLastSendCharWasError = true; Console.WriteLine("ERROR SendChar(): " + ex.Message); } }