private void ColorTriggeredHandler(Hub train, Port port, Port.Colors color) { if (hubs == null || hubs.Count == 0) { MainBoard.WriteLine("Color event received, but program is not started. Start program first"); return; } foreach (TrainProgramEvent e in Events) { if (e.TrainDeviceID == train.DeviceId) { if (e.Trigger == TrainProgramEvent.TriggerType2.Color_Change_To && color == e.TriggerColorParam && (e.TrainPort == null || e.TrainPort == port.Id)) { port.LastColorTick = Environment.TickCount; MainBoard.WriteLine("Event #" + (Events.IndexOf(e) + 1) + " triggered - " + train.Name + " sensor detected " + color.ToString(), Color.Purple); ActivateAction(e); } } } }
public override void SetLEDColor(Port.Colors color) { WriteMessage(new byte[] { 0x41, 0x34, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 }); WriteMessage(new byte[] { 0x81, 0x34, 0x11, 0x51, 0x00, (byte)color }); }
public override void SetLEDColor(Port.Colors color) { LedPattern ledPattern = (color == Port.Colors.GREEN) ? LedPattern.Green : (color == Port.Colors.RED) ? LedPattern.Red : (color == Port.Colors.ORANGE) ? LedPattern.Orange : LedPattern.Black; brick.DirectCommand.SetLedPatternAsync(ledPattern); }