Пример #1
0
 /// <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);
 }
Пример #2
0
 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);
 }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <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();
 }
Пример #5
0
 /// <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();
 }
Пример #6
0
 /// <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);
 }
Пример #7
0
        /// <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);
        }