Пример #1
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public P50xCommandStationState(IP50xCommandStation entity, RailwayState railwayState, string[] addressSpaces)
     : base(entity, railwayState, addressSpaces)
 {
     client.PortName = entity.ComPortName;
     client.Opened  += onClientOpened;
     client.Closed  += onClientClosed;
 }
Пример #2
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public BinkyNetCommandStationState(IBinkyNetCommandStation entity, RailwayState railwayState, string[] addressSpaces)
     : base(entity, railwayState, addressSpaces)
 {
     completionCallbacks = new Dictionary <ushort, CompletionCallback>();
     clientID            = entity.Id;
     sender      = "binkyrailways";
     topicPrefix = entity.TopicPrefix;
 }
 /// <summary>
 /// Default ctor
 /// </summary>
 public EcosCommandStationState(IEcosCommandStation entity, RailwayState railwayState, string[] addressSpaces)
     : base(entity, railwayState, addressSpaces)
 {
     connection = new EcosConnection(entity.HostName, railwayState);
     // Request to be notified
     connection.SendCommand(new Command(Constants.CmdRequest, Constants.IdEcos, Constants.OptView));
     // Get status
     connection.SendCommand(new Command(Constants.CmdGet, Constants.IdEcos, Constants.OptStatus)).ContinueWith(t => OnStatusReply(t.Result));
 }
Пример #4
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public DccOverRs232CommandStationState(IDccOverRs232CommandStation entity, RailwayState railwayState, string[] addressSpaces)
     : base(entity, railwayState, addressSpaces)
 {
     sender = new PacketSender(entity.ComPortName);
     sender.PriorityPacketsEmpty += (s, x) =>
     {
         networkIdle = true;
         RefreshIdle();
     };
 }
Пример #5
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public FeedbackModule(Client client, int id, RailwayState railwayState, int firstPortNumber)
            : base(client, id)
        {
            this.railwayState    = railwayState;
            this.firstPortNumber = firstPortNumber;

            var portCount = GetPortCount();

            this.sensorStates = new ISensorState[portCount];
            for (var i = 0; i < portCount; i++)
            {
                var portNumber = firstPortNumber + i;
                sensorStates[i] = railwayState.SensorStates.FirstOrDefault(x => (x.Address.ValueAsInt == portNumber) && (x.Address.Type == AddressType.LocoNet));
            }
        }
Пример #6
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public LocoBufferCommandStationState(ILocoBufferCommandStation entity, RailwayState railwayState, string[] addressSpaces)
            : base(entity, railwayState, addressSpaces)
        {
            var splb = new SerialPortLocoBuffer();

            splb.PortName      = entity.ComPortName;
            lb                 = splb;
            lb.PreviewMessage += MessageProcessor;
            client             = new Client(lb, railwayState, this, railwayState.Dispatcher, Log);
            client.Idle       += (s, x) =>
            {
                networkIdle = true;
                RefreshIdle();
            };
        }
Пример #7
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public BinkyNetCommandStationState(IBinkyNetCommandStation entity, RailwayState railwayState, string[] addressSpaces)
            : base(entity, railwayState, addressSpaces)
        {
            completionCallbacks = new Dictionary <ushort, CompletionCallback>();
            clientID            = entity.Id;
            sender      = "binkyrailways";
            topicPrefix = entity.TopicPrefix;
            var networkMasterInfo = new NetworkMasterInfo()
            {
                ApiVersion = "v1",
                Version    = "v0.0.0",
                ApiPort    = entity.APIPort,
                Secure     = false,
            };

            discoveryBroadcaster = new DiscoveryBroadcaster(networkMasterInfo);
        }
Пример #8
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();
 }
Пример #9
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);
 }
Пример #10
0
        /// <summary>
        /// Default ctor
        /// </summary>
        internal EcosConnection(string hostName, RailwayState railwayState)
        {
            this.railwayState = railwayState;
            // Open connection
            socket = new Client(hostName);

            locManager = new LocManager(socket, railwayState);
            var locTask = locManager.QueryObjects().ContinueWith(t => locManager.RequestView());

            feedbackManager = new FeedbackManager(socket, railwayState);
            var fbTask = feedbackManager.QueryObjects();

            switchManager = new SwitchManager(socket, railwayState);
            var swTask = switchManager.QueryObjects().ContinueWith(t => switchManager.RequestView());

            // Wait for all initialization to complete
            Task.Factory.StartNew(() => {
                Task.WaitAll(locTask, fbTask, swTask);
                initialized = true;
            });
        }
Пример #11
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public FeedbackManager(Client client, RailwayState railwayState)
     : base(client)
 {
     this.railwayState = railwayState;
 }
Пример #12
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public VirtualCommandStationState(IVirtualCommandStation entity, RailwayState railwayState)
     : base(entity, railwayState, null)
 {
 }
Пример #13
0
 /// <summary>
 /// Instantiate a new railway state.
 /// </summary>
 internal void CreateRailwayState(bool virtualMode)
 {
     RailwayState = new RailwayState(Package.Railway, virtualMode);
 }
Пример #14
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public VirtualMode(bool enabled, RailwayState railwayState)
 {
     this.enabled      = enabled;
     this.railwayState = railwayState;
     autoRunState      = new AutoRunState(railwayState);
 }