Inheritance: IProcessOptions
Exemplo n.º 1
0
        /// <summary>
        /// Constructs a new Router instance
        /// </summary>
        public Router(RouterOptions options)
        {
            this._options = options.Clone();

            foreach (var mapping in _options.PortNetworkMappings)
            {
                _table.AddLocalRoute(mapping.Value, mapping.Key);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an identical copy of this config object
        /// </summary>
        /// <returns>The cloned object</returns>
        public RouterOptions Clone()
        {
            RouterOptions clone = new RouterOptions()
            {
                ProcessId = this.ProcessId
            };

            clone.PortNetworkMappings.AddRange(this.PortNetworkMappings);
            return(clone);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates an identical copy of this config object
        /// </summary>
        /// <returns>The cloned object</returns>
        public RouterOptions Clone()
        {
            RouterOptions clone = new RouterOptions()
            {
                ProcessId = this.ProcessId
            };

            clone.PortNetworkMappings.AddRange(this.PortNetworkMappings);
            return clone;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a process options instance
        /// </summary>
        /// <returns>The process options instance</returns>
        public override IProcessOptions CreateOptions()
        {
            var opts = new RouterOptions()
            {
                ProcessId = this.ProcessId
            };

            opts.PortNetworkMappings.AddRange(
                this.PortMappings.Select(mapping => new KeyValuePair<byte, ushort>(mapping.PortId, mapping.Network)));

            return opts;
        }
Exemplo n.º 5
0
        public static void Main(string[] args)
        {
            /*
            ForeignDevicePortOptions options = new ForeignDevicePortOptions()
            {
                PortId = 1,
                BbmdHost = "<bbmd-ip-here>",
                BbmdPort = 47808,
                LocalHost = "0.0.0.0",
                LocalPort = 47808,
                RegistrationInterval = TimeSpan.FromSeconds(30)
            };
            */

            EthernetPortOptions ethOptions = new EthernetPortOptions()
            {
                PortId = 1
            };

            PortManagerOptions portMgrOptions = new PortManagerOptions();
            RouterOptions routerOpts = new RouterOptions();
            routerOpts.PortNetworkMappings.Add(new KeyValuePair<byte, ushort>(1, 0));
            HostOptions hostOpts = new HostOptions();
            DeviceFinderOptions finderOpts = new DeviceFinderOptions();

            //using (ForeignDevicePort port = new ForeignDevicePort(options))
            using (EthernetPort port = new EthernetPort(ethOptions))
            using (PortManager manager = new PortManager(portMgrOptions))
            using (Router router = new Router(routerOpts))
            using (Host host = new Host(hostOpts))
            using (DeviceFinder finder = new DeviceFinder(finderOpts))
            using (Session session = new Session(port, manager, router, host, finder))
            {
                var client = new BACnet.Client.Client(host);

                // as long as there is at least 1 new devices found every 10 seconds,
                // for each found device, read that devices name and print it to the console

                finder.Timeout(TimeSpan.FromSeconds(10))
                    .Catch(Observable.Empty<DeviceTableEntry>())
                    .ForEachAsync(entry =>
                    {
                        Console.WriteLine(entry.Instance);
                    })
                    .Wait();
            }
        }