/// <summary> /// Shuts down the communicator and unsubscribes from channels, whatnot /// </summary> public void Shutdown() { try { if (vehicleStateChannel != null) { // unsubscribe from channels vehicleStateChannel.Unsubscribe(vehicleStateChannelToken); observedObstacleChannel.Unsubscribe(observedObstacleChannelToken); observedVehicleChannel.Unsubscribe(observedVehicleChannelToken); vehicleSpeedChannel.Unsubscribe(vehicleSpeedChannelToken); arbiterOutputChannel.Unsubscribe(arbiterOutputChannelToken); arbiterInformationChannel.Unsubscribe(arbiterInformationChannelToken); sideObstacleChannel.Unsubscribe(sideObstacleChannelToken); this.arbiterRemote = null; this.operationalFacade = null; // notify RemoraOutput.WriteLine("Unsubscribed from channels", OutputType.Remora); } } catch (Exception e) { // notify RemoraOutput.WriteLine("Error in shutting down registered channels", OutputType.Remora); Console.WriteLine(e.ToString()); } }
/// <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(); }
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); } }