/// <summary> /// Registers with the correct services /// </summary> public void Register() { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // register the core as implementing the arbiter advanced remote facade objectDirectory.Rebind(this.arbiterCore, "ArbiterAdvancedRemote" + this.RemotingSuffix); // shutdown old channels this.Shutdown(); // get vehicle state channel vehicleStateChannel = channelFactory.GetChannel("ArbiterSceneEstimatorPositionChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); vehicleStateChannelToken = vehicleStateChannel.Subscribe(messagingListener); // get observed obstacle channel observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); observedObstacleChannelToken = observedObstacleChannel.Subscribe(messagingListener); // get observed vehicle channel observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); observedVehicleChannelToken = observedVehicleChannel.Subscribe(messagingListener); // get vehicle speed channel vehicleSpeedChannel = channelFactory.GetChannel("VehicleSpeedChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); vehicleSpeedChannelToken = vehicleSpeedChannel.Subscribe(messagingListener); // get side obstacle channel sideObstacleChannel = channelFactory.GetChannel("SideObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); sideObstacleChannelToken = sideObstacleChannel.Subscribe(messagingListener); // get output channel if (arbiterOutputChannel != null) { arbiterOutputChannel.Dispose(); } arbiterOutputChannel = channelFactory.GetChannel("ArbiterOutputChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); // get information channel if (arbiterInformationChannel != null) { arbiterInformationChannel.Dispose(); } arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); // get the operational layer this.operationalFacade = (OperationalFacade)objectDirectory.Resolve("OperationalService" + this.RemotingSuffix); this.operationalFacade.RegisterListener(this); this.SendProjection(); // try connecting to the test facade this.TryOperationalTestFacadeConnect(); }
/// <summary> /// Initializes communications with the outside world by means of remoting /// </summary> private void InitializeRemotingCommunications() { // Read the configuration file. RemotingConfiguration.Configure("..\\..\\App.config", false); WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Bind the operational test faceade objectDirectory.Rebind(this, "OperationalTestFacade"); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to listen to rndfChannel = channelFactory.GetChannel("RndfNetworkChannel", ChannelMode.Bytestream); mdfChannel = channelFactory.GetChannel("MdfChannel", ChannelMode.Bytestream); positionChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.Bytestream); testStringChannel = channelFactory.GetChannel("TestStringChannel", ChannelMode.Vanilla); // Create a channel listeners and listen on wanted channels channelListener = new MessagingListener(); rndfToken = rndfChannel.Subscribe(channelListener); mdfToken = mdfChannel.Subscribe(channelListener); //positionToken = positionChannel.Subscribe(channelListener); testStringToken = testStringChannel.Subscribe(new StringListener()); // Show that the navigation system is ready and waiting for input Console.WriteLine(" > Remoting Communication Initialized"); }
/// <summary> /// Registers with the correct services /// </summary> public void Register() { try { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to push to simulationMessageChannel = channelFactory.GetChannel("SimulationMessageChannel", ChannelMode.UdpMulticast); // Rebind the Simulator as the simulator remote facade server objectDirectory.Rebind(this, "SimulationServer"); // Notify user of success SimulatorOutput.WriteLine("Connection to Name Service and Registration of Simulation Server as Simulator Facade Successful"); // let clients know the sim is alive simulationMessageChannel.PublishUnreliably(SimulationMessage.Alive); } catch (Exception e) { SimulatorOutput.WriteLine("Error Registering With Remoting Services: " + e.ToString()); } }
/// <summary> /// Attempts to register with the simulation /// </summary> public void AttemptSimulationConnection() { // notify Console.WriteLine(DateTime.Now.ToString() + ": Attempting Connection To Simulation Server"); try { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Resolve the SimulationServer as the simulator remote facade server this.client.SimulationServer = (SimulatorFacade)objectDirectory.Resolve("SimulationServer"); // create the dynamics sim facade this.client.DynamicsVehicle = new DynamicsSimVehicle(new SimVehicleState(), this.objectDirectory); // register ourselves bool success = this.client.SimulationServer.Register(this.client.Name()); // notify if (success) { Console.WriteLine(DateTime.Now.ToString() + ": Attempt Succeeded"); } else { Console.WriteLine(DateTime.Now.ToString() + ": Registration Failed in Simulation"); } } catch (Exception e) { // notify Console.WriteLine(DateTime.Now.ToString() + ": Attempt Failed" + "\n" + e.ToString()); } }
/// <summary> /// Register a client with the simulation /// </summary> /// <param name="clientName"></param> /// <returns></returns> public override bool Register(string clientName) { try { // resolve the client SimulatorClientFacade scf = (SimulatorClientFacade)objectDirectory.Resolve(clientName); // client name string name = scf.Name(); // invoke changes this.simulation.BeginInvoke(new MethodInvoker(delegate() { // notify this.simulation.clientHandler.AddClient(name, scf, this.simulation.simEngine.Vehicles); this.simulation.OnClientsChanged(); })); // return success return(true); } catch (Exception e) { this.simulation.BeginInvoke(new MethodInvoker(delegate() { // notify SimulatorOutput.WriteLine("Error Registering Client: " + clientName + ". \n" + e.ToString()); })); // return error return(false); } }
public static bool Attach(string suffix, bool throwException) { operationalFacade = null; operationalUIFacade = null; if (suffix == null) { suffix = string.Empty; } try { operationalFacade = (OperationalFacade)od.Resolve("OperationalService" + suffix); operationalUIFacade = (OperationalUIFacade)od.Resolve("OperationalUIService" + suffix); DatasetSourceFacade dsfacade = operationalUIFacade.DatasetFacade; DataItemDescriptor[] dataItems = dsfacade.GetDataItems(); foreach (DataItemDescriptor item in dataItems) { if (!dataset.ContainsKey(item.Name)) { dataset.Add(item); } } dataset.AttachToSource(dsfacade); } catch (Exception) { operationalFacade = null; operationalUIFacade = null; if (throwException) { throw; } else { return(false); } } if (Attached != null) { Attached(null, new AttachEventArgs(string.IsNullOrEmpty(suffix) ? string.Empty : suffix.Substring(1))); } return(true); }
public void ResgisterWithClient() { try { // get vehicle state channel vehicleStateChannel = channelFactory.GetChannel("ArbiterSceneEstimatorPositionChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); vehicleStateChannelToken = vehicleStateChannel.Subscribe(messagingListener); // get observed obstacle channel observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); observedObstacleChannelToken = observedObstacleChannel.Subscribe(messagingListener); // get observed vehicle channel observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); observedVehicleChannelToken = observedVehicleChannel.Subscribe(messagingListener); // get vehicle speed channel vehicleSpeedChannel = channelFactory.GetChannel("VehicleSpeedChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); vehicleSpeedChannelToken = vehicleSpeedChannel.Subscribe(messagingListener); // get output channel arbiterOutputChannel = channelFactory.GetChannel("ArbiterOutputChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); arbiterOutputChannelToken = arbiterOutputChannel.Subscribe(messagingListener); // get information channel arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(messagingListener); // get side obstacle channel sideObstacleChannel = channelFactory.GetChannel("SideObstacleChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); sideObstacleChannelToken = sideObstacleChannel.Subscribe(messagingListener); // get ai this.arbiterRemote = (ArbiterAdvancedRemote)objectDirectory.Resolve("ArbiterAdvancedRemote" + this.RemotingSuffix); // get the operational layer this.operationalFacade = (OperationalFacade)objectDirectory.Resolve("OperationalService" + this.RemotingSuffix); // register RemoraOutput.WriteLine("Resgistered To Client with suffix: " + this.RemotingSuffix, OutputType.Remora); } catch (Exception e) { RemoraOutput.WriteLine("Error registering with client: " + e.ToString(), OutputType.Remora); } }
private void Connect(ObjectDirectory od) { // get the channel for the sim state IChannelFactory channelFactory = (IChannelFactory)od.Resolve("ChannelFactory"); operationalStateChannel = channelFactory.GetChannel("OperationalSimState_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // publish ourself to the object directory od.Rebind(this, "DynamicsSim_" + SimulatorClient.MachineName); }
/// <summary> /// Registers with the correct services /// </summary> public void Register() { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Notify user of success RemoraOutput.WriteLine("Connection to Name Service Successful", OutputType.Remora); // get simulation if supposed to if (global::RemoraAdvanced.Properties.Settings.Default.SimMode) { this.simulatorFacade = (SimulatorFacade)objectDirectory.Resolve("SimulationServer"); // Notify user of success RemoraOutput.WriteLine("Connection to Simulation Service Successful", OutputType.Remora); } }
/// <summary> /// Connects to the Arbiter and Sets it up for Remote Control /// </summary> public void ConnectToArbiter() { RemoraOutput.WriteLine("Connecting to Arbiter"); try { this.arbiterRemote = (ArbiterRemote)objectDirectory.Resolve("ArbiterRemote"); RemoraOutput.WriteLine("Bind Successful..."); } catch (Exception e) { RemoraOutput.WriteLine(e.ToString() + "\n\n" + "Error Binding Arbiter"); } }
public static void InitComm() { // set the machine name from the config machineName = Properties.Settings.Default.MachineName.Trim().ToUpper(); // configure remoting RemotingConfiguration.Configure("net.xml", false); // get the name service WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // get the channel factory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); }
/// <summary> /// Configures remoting /// </summary> public void Configure() { // configure RemotingConfiguration.Configure("VehicleSeparationDisplay.exe.config", false); wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Notify user of success Console.WriteLine("Connection to Name Service Successful"); // get information channel arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel" + this.RemotingSuffix, ChannelMode.UdpMulticast); arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(messagingListener); }
/// <summary> /// Try to connect to the operational facade /// </summary> public void TryOperationalTestFacadeConnect() { if (global::UrbanChallenge.Arbiter.Core.ArbiterSettings.Default.UseTestOperational) { try { // check if test facade ok bool testFacadeGood = this.operationalTestFacade != null; if (this.operationalTestFacade != null) { try { this.operationalTestFacade.Ping(); this.testComponentExists = true; } catch (Exception) { testFacadeGood = false; } } // set the operational test facade if not ok if (!testFacadeGood) { // get the operational layer this.operationalTestFacade = (OperationalTestComponentFacade)objectDirectory.Resolve("OperationalTestComponentService" + this.RemotingSuffix); this.testComponentExists = true; } // try to send road network if (CoreCommon.RoadNetwork != null) { this.operationalTestFacade.SetRoadNetwork(CoreCommon.RoadNetwork); this.testComponentNeedsRoadNetwork = false; } } catch (Exception ex) { ArbiterOutput.OutputNoLog("Error registering with operational test service: " + ex.ToString()); } } }
/// <summary> /// Initializes communications with the outside world by means of remoting /// </summary> public void InitializeRemotingCommunications() { // try to shut down in case we have already been active this.ShutDown(); try { // Read the configuration file. RemotingConfiguration.Configure("Remora.exe.config", false); WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to listen to vehicleStateChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.UdpMulticast); observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel", ChannelMode.UdpMulticast); observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel", ChannelMode.UdpMulticast); arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel", ChannelMode.UdpMulticast); carModeChannel = channelFactory.GetChannel("CarMode", ChannelMode.UdpMulticast); fakeVehicleChannel = channelFactory.GetChannel("FakeVehicleChannel", ChannelMode.UdpMulticast); // Create a channel listeners and listen on wanted channels channelListener = new MessagingListener(); vehicleStateChannelToken = vehicleStateChannel.Subscribe(channelListener); observedObstacleChannel.Subscribe(channelListener); observedVehicleChannel.Subscribe(channelListener); arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(channelListener); carModeChannelToken = carModeChannel.Subscribe(channelListener); fakeVehicleChannelToken = fakeVehicleChannel.Subscribe(channelListener); // set that remoting has been successfully initialize this.RemotingInitialized = true; RemoraOutput.WriteLine("Successfully initialized communications"); } catch (Exception e) { RemoraOutput.WriteLine(e.ToString() + "\n\n" + "Could not initialize communications, attempting to reconnect"); try { WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes(); // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to listen to vehicleStateChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.UdpMulticast); observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel", ChannelMode.UdpMulticast); observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel", ChannelMode.UdpMulticast); arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel", ChannelMode.UdpMulticast); carModeChannel = channelFactory.GetChannel("CarMode", ChannelMode.UdpMulticast); fakeVehicleChannel = channelFactory.GetChannel("FakeVehicleChannel", ChannelMode.UdpMulticast); // Create a channel listeners and listen on wanted channels channelListener = new MessagingListener(); vehicleStateChannelToken = vehicleStateChannel.Subscribe(channelListener); observedObstacleChannel.Subscribe(channelListener); observedVehicleChannel.Subscribe(channelListener); arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(channelListener); carModeChannelToken = carModeChannel.Subscribe(channelListener); fakeVehicleChannelToken = fakeVehicleChannel.Subscribe(channelListener); // set that remoting has been successfully initialize this.RemotingInitialized = true; RemoraOutput.WriteLine("Successfully initialized communications"); } catch (Exception e1) { RemoraOutput.WriteLine(e1.ToString() + "\n\n" + "Could not reinitialize nameservice communications"); try { // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to listen to vehicleStateChannel = channelFactory.GetChannel("PositionChannel", ChannelMode.UdpMulticast); observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel", ChannelMode.UdpMulticast); observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel", ChannelMode.UdpMulticast); arbiterInformationChannel = channelFactory.GetChannel("ArbiterInformationChannel", ChannelMode.UdpMulticast); carModeChannel = channelFactory.GetChannel("CarMode", ChannelMode.UdpMulticast); fakeVehicleChannel = channelFactory.GetChannel("FakeVehicleChannel", ChannelMode.UdpMulticast); // Create a channel listeners and listen on wanted channels channelListener = new MessagingListener(); vehicleStateChannelToken = vehicleStateChannel.Subscribe(channelListener); observedObstacleChannel.Subscribe(channelListener); observedVehicleChannel.Subscribe(channelListener); arbiterInformationChannelToken = arbiterInformationChannel.Subscribe(channelListener); carModeChannelToken = carModeChannel.Subscribe(channelListener); fakeVehicleChannelToken = fakeVehicleChannel.Subscribe(channelListener); // set that remoting has been successfully initialize this.RemotingInitialized = true; RemoraOutput.WriteLine("Successfully initialized communications"); } catch (Exception e2) { RemoraOutput.WriteLine(e2.ToString() + "\n\n" + "Could not reinitialize messaging communications"); } } } }
/// <summary> /// Registers with the correct services /// </summary> public void Register() { try { // "Activate" the NameService singleton. objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri); // Retreive the directory of messaging channels IChannelFactory channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory"); // Retreive the Messaging Service channels we want to interact with if (simulationMessageChannel != null) { simulationMessageChannel.Dispose(); } simulationMessageChannel = channelFactory.GetChannel("SimulationMessageChannel", ChannelMode.UdpMulticast); // Listen to channels we wish to listen to simulationMessageChannelToken = simulationMessageChannel.Subscribe(this.messagingListener); // Rebind the Simulator as the simulator remote facade server objectDirectory.Rebind(this.client, this.client.Name()); // get vehicle state channel if (vehicleStateChannel != null) { vehicleStateChannel.Dispose(); } vehicleStateChannel = channelFactory.GetChannel("ArbiterSceneEstimatorPositionChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get observed obstacle channel if (observedObstacleChannel != null) { observedObstacleChannel.Dispose(); } observedObstacleChannel = channelFactory.GetChannel("ObservedObstacleChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get observed vehicle channel if (observedVehicleChannel != null) { observedVehicleChannel.Dispose(); } observedVehicleChannel = channelFactory.GetChannel("ObservedVehicleChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get vehicle speed channel if (vehicleSpeedChannel != null) { vehicleSpeedChannel.Dispose(); } vehicleSpeedChannel = channelFactory.GetChannel("VehicleSpeedChannel_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // get the local road estimate channel if (localRoadChannel != null) { localRoadChannel.Dispose(); } localRoadChannel = channelFactory.GetChannel(LocalRoadEstimate.ChannelName + "_" + SimulatorClient.MachineName, ChannelMode.Bytestream); // Notify user of success Console.WriteLine(DateTime.Now.ToString() + ": Connection to Name Service and Registration of Simulation Client Successful"); } catch (Exception e) { // notify Console.WriteLine(DateTime.Now.ToString() + ": Error Registering With Remoting Services: " + e.ToString()); } }
public static MarshalByRefObject GetObject(string baseName) { return(objectDirectory.Resolve(BuildServiceName(baseName))); }