/// <summary> /// The COM port for the given command station is invalid. /// Choose a new one. /// </summary> string IStateUserInterface.ChooseComPortName(ICommandStationState cs) { using (var dialog = new ChooseComPortForm(cs)) { if (dialog.ShowDialog(this) == DialogResult.OK) { return(dialog.SelectedPortName); } } return(null); }
private static Bitmap getPowerImage(ICommandStationState cs) { if (!cs.Power.IsConsistent) { return(Strings.loc_state_error); } if (cs.Power.Actual) { return(Strings.loc_state_ok); } return(Strings.loc_state_unassigned); }
/// <summary> /// Prepare this state for use in a live railway. /// Make sure all relevant connections to other state objects are resolved. /// </summary> /// <returns>True if the entity is now ready for use in a live railway, false otherwise.</returns> protected override bool TryPrepareForUse(IStateUserInterface ui, IStatePersistence statePersistence) { var cs = RailwayState.SelectCommandStation(Entity); if (cs == null) { return(false); } this.statePersistence = statePersistence; cs.AddLoc(this); commandStation = cs; return(true); }
/// <summary> /// Default ctor /// </summary> public ChooseComPortForm(ICommandStationState cs) { this.cs = cs; InitializeComponent(); if (cs != null) { lbInfo.Text = string.Format(lbInfo.Text, cs.Description); lbPortNames.Items.AddRange(SerialPort.GetPortNames()); if (lbPortNames.Items.Count > 0) { lbPortNames.SelectedIndex = 0; } } UpdateControls(); }
/// <summary> /// Default ctor /// </summary> public Client(LocoBuffer lb, RailwayState railwayState, ICommandStationState cs, IStateDispatcher stateDispatcher, Logger log) { if (lb == null) { throw new ArgumentNullException("lb"); } if (cs == null) { throw new ArgumentNullException("cs"); } if (stateDispatcher == null) { throw new ArgumentNullException("stateDispatcher"); } this.railwayState = railwayState; this.lb = lb; this.log = log; this.stateDispatcher = stateDispatcher; this.cs = cs; StartIdleDetection(); }
/// <summary> /// Default ctor /// </summary> public Master(LocoBuffer lb, RailwayState railwayState, ICommandStationState cs, IStateDispatcher stateDispatcher, Logger log) { if (lb == null) { throw new ArgumentNullException("lb"); } if (cs == null) { throw new ArgumentNullException("cs"); } if (stateDispatcher == null) { throw new ArgumentNullException("stateDispatcher"); } this.railwayState = railwayState; this.lb = lb; this.log = log; this.stateDispatcher = stateDispatcher; this.cs = cs; slotTable = new SlotTable(cs); }
/// <summary> /// Does the given command station support the given network exact? /// </summary> public static bool SupportsExact(this ICommandStationState cs, IAddressEntity entity, Network network) { bool exact; return(cs.Supports(entity, network, out exact) && exact); }