/// <inheritdoc /> protected override void UpdateLeds(IEnumerable <Led> ledsToUpdate) { List <Led> leds = ledsToUpdate.Where(x => x.Color.A > 0).ToList(); if (leds.Count > 0) { foreach (Led led in leds) { NovationLedId ledId = led.Id as NovationLedId; if (ledId == null) { continue; } int color = ConvertColor(led.Color); SendMessage(ledId.LedId.GetStatus(), ledId.LedId.GetId(), color); } } }
/// <summary> /// Tests whether the specified object is a <see cref="NovationLedId" /> and is equivalent to this <see cref="NovationLedId" />. /// </summary> /// <param name="obj">The object to test.</param> /// <returns><c>true</c> if <paramref name="obj" /> is a <see cref="NovationLedId" /> equivalent to this <see cref="NovationLedId" />; otherwise, <c>false</c>.</returns> public override bool Equals(object obj) { NovationLedId compareLedId = obj as NovationLedId; if (ReferenceEquals(compareLedId, null)) { return(false); } if (ReferenceEquals(this, compareLedId)) { return(true); } if (GetType() != compareLedId.GetType()) { return(false); } return(compareLedId.LedId == LedId); }
/// <inheritdoc /> protected override ShortMessage CreateMessage(KeyValuePair <object, Color> data) { NovationLedId ledId = (NovationLedId)data.Key; return(new ShortMessage(Convert.ToByte(ledId.GetStatus()), Convert.ToByte(ledId.GetId()), Convert.ToByte(ConvertColor(data.Value)))); }