/// <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); } }
/// <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); }
/// <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; }
/// <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; }
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(); } }