public EvaluatorRuntime( ContextManager contextManager, IHeartBeatManager heartBeatManager, PIDStoreHandler pidStoreHelper, EvaluatorExitLogger evaluatorExitLogger) { using (Logger.LogFunction("EvaluatorRuntime::EvaluatorRuntime")) { _heartBeatManager = heartBeatManager; _clock = _heartBeatManager.EvaluatorSettings.RuntimeClock; _contextManager = contextManager; _evaluatorId = _heartBeatManager.EvaluatorSettings.EvalutorId; _pidStoreHelper = pidStoreHelper; _evaluatorExitLogger = evaluatorExitLogger; var remoteManager = _heartBeatManager.EvaluatorSettings.RemoteManager; ReefMessageProtoObserver driverObserver = new ReefMessageProtoObserver(); // subscribe to driver proto message driverObserver.Subscribe(o => OnNext(o.Message)); // register the driver observer _evaluatorControlChannel = remoteManager.RegisterObserver(driverObserver); AppDomain.CurrentDomain.UnhandledException += EvaluatorRuntimeUnhandledException; DefaultUnhandledExceptionHandler.Unregister(); // start the heart beat _clock.ScheduleAlarm(0, _heartBeatManager); } }
public TaskStatus(IHeartBeatManager heartBeatManager, string contextId, string taskId, Optional<ISet<ITaskMessageSource>> evaluatorMessageSources) { _heartBeatManager = heartBeatManager; _taskLifeCycle = new TaskLifeCycle(); _evaluatorMessageSources = evaluatorMessageSources; State = TaskState.Init; _taskId = taskId; _contextId = contextId; }
public RootContextLauncher(string id, IConfiguration contextConfiguration, Optional<ServiceConfiguration> rootServiceConfig, Optional<IConfiguration> rootTaskConfig, IHeartBeatManager heartbeatManager) { Id = id; _rootContextConfiguration = contextConfiguration; _rootServiceInjector = InjectServices(rootServiceConfig); _rootServiceInjector.BindVolatileInstance(GenericType<IHeartBeatManager>.Class, heartbeatManager); RootTaskConfig = rootTaskConfig; }
private ContextManager( AvroConfigurationSerializer serializer, IHeartBeatManager heartBeatManager, RootContextLauncher rootContextLauncher) { _rootContextLauncher = rootContextLauncher; _heartBeatManager = heartBeatManager; _serializer = serializer; }
private TaskStatus( [Parameter(typeof(ContextConfigurationOptions.ContextIdentifier))] string contextId, [Parameter(typeof(TaskConfigurationOptions.Identifier))] string taskId, [Parameter(typeof(TaskConfigurationOptions.TaskMessageSources))] ISet<ITaskMessageSource> taskMessageSources, IHeartBeatManager heartBeatManager) { _heartBeatManager = heartBeatManager; _taskLifeCycle = new TaskLifeCycle(); _evaluatorMessageSources = Optional<ISet<ITaskMessageSource>>.OfNullable(taskMessageSources); State = TaskState.Init; _taskId = taskId; _contextId = contextId; }
private TaskStatus( [Parameter(typeof(ContextConfigurationOptions.ContextIdentifier))] string contextId, [Parameter(typeof(TaskConfigurationOptions.Identifier))] string taskId, [Parameter(typeof(TaskConfigurationOptions.TaskMessageSources))] ISet <ITaskMessageSource> taskMessageSources, TaskLifeCycle taskLifeCycle, IHeartBeatManager heartBeatManager) { _heartBeatManager = heartBeatManager; _taskLifeCycle = taskLifeCycle; _evaluatorMessageSources = Optional <ISet <ITaskMessageSource> > .OfNullable(taskMessageSources); State = TaskState.Init; _taskId = taskId; _contextId = contextId; }
/// <summary> /// Launches an Task on this context. /// TODO[JIRA REEF-217]: Remove heartBeatManager from argument. /// </summary> /// <param name="taskConfiguration"></param> /// <param name="heartBeatManager"></param> public void StartTask(IConfiguration taskConfiguration, IHeartBeatManager heartBeatManager) { lock (_contextLifeCycle) { LOGGER.Log(Level.Info, "ContextRuntime::StartTask(TaskConfiguration) task is present: " + _task.IsPresent()); if (_task.IsPresent()) { LOGGER.Log(Level.Info, "Task state: " + _task.Value.GetTaskState()); LOGGER.Log(Level.Info, "ContextRuntime::StartTask(TaskConfiguration) task has ended: " + _task.Value.HasEnded()); if (_task.Value.HasEnded()) { // clean up state _task = Optional <TaskRuntime> .Empty(); } else { // note: java code is putting thread id here var e = new InvalidOperationException( string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId)); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } } AssertChildContextNotPresent("Attempting to instantiate a child context on a context that is not the topmost active context."); var taskInjector = _contextInjector.ForkInjector(taskConfiguration); var taskRuntime = taskInjector.GetInstance <TaskRuntime>(); try { _task = Optional <TaskRuntime> .Of(taskRuntime); taskRuntime.RunTask(); } catch (Exception e) { var ex = new TaskClientCodeException(string.Empty, Id, "Unable to run the new task", e); Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, "Task start error.", LOGGER); } } }
private ContextManager( IHeartBeatManager heartBeatManager, EvaluatorSettings evaluatorSettings, AvroConfigurationSerializer serializer) { // TODO[JIRA REEF-217]: Inject base Injector and pass Injector to RootContextLauncher using (LOGGER.LogFunction("ContextManager::ContextManager")) { _heartBeatManager = heartBeatManager; _serializer = serializer; _rootContextLauncher = new RootContextLauncher( evaluatorSettings.RootContextId, evaluatorSettings.RootContextConfig, evaluatorSettings.RootServiceConfiguration, evaluatorSettings.RootTaskConfiguration, heartBeatManager); } }
public EvaluatorRuntime( ContextManager contextManager, IHeartBeatManager heartBeatManager) { using (Logger.LogFunction("EvaluatorRuntime::EvaluatorRuntime")) { _heartBeatManager = heartBeatManager; _clock = _heartBeatManager.EvaluatorSettings.RuntimeClock; _contextManager = contextManager; _evaluatorId = _heartBeatManager.EvaluatorSettings.EvalutorId; var remoteManager = _heartBeatManager.EvaluatorSettings.RemoteManager; ReefMessageProtoObserver driverObserver = new ReefMessageProtoObserver(); // subscribe to driver proto message driverObserver.Subscribe(o => OnNext(o.Message)); // register the driver observer _evaluatorControlChannel = remoteManager.RegisterObserver(driverObserver); // start the heart beat _clock.ScheduleAlarm(0, _heartBeatManager); } }
public MainViewModel(IMissionPlanner planner, IHeartBeatManager heartBeatManager, ITelemetryService telemetryService, IConnectedUasManager connectedUasManager) { _telemetryService = telemetryService; _heartBeatManager = heartBeatManager; Connections = connectedUasManager; Connections.ActiveDroneChanged += Connections_ActiveDroneChanged; var transport = new SerialPortTransport(DispatcherServices); //Connections.Active = new ConnectedUas(new APM(null), transport); //Connections.All.Add(Connections.Active); //Connections.Active.Transport.OnMessageReceived += _telemeteryLink_MessageParsed; //TelemetryLink.MessageParsed += _telemeteryLink_MessageParsed; OpenSerialPortCommand = new RelayCommand(HandleConnectClick, CanPressConnect); ShowMissionPlannerCommand = new RelayCommand(() => ViewModelNavigation.NavigateAsync <Missions.MissionPlannerViewModel>(this), CanDoConnectedStuff); StartDataStreamsCommand = new RelayCommand(() => _telemetryService.Start(Connections.Active.Uas, Connections.Active.Transport), CanDoConnectedStuff); StopDataStreamsCommand = new RelayCommand(() => _telemetryService.Stop(Connections.Active.Transport), CanDoConnectedStuff); BeginCalibrationCommand = new RelayCommand(() => ViewModelNavigation.NavigateAsync <Calibration.AccCalibrationViewModel>(this), CanDoConnectedStuff); FlyNowCommand = new RelayCommand(() => ViewModelNavigation.NavigateAsync <HudViewModel>(this), CanDoConnectedStuff); MotorTestCommand = new RelayCommand(() => ViewModelNavigation.NavigateAsync <Testing.MotorsTestViewModel>(this), CanDoConnectedStuff); Title = "UAS NuvIoT Connector"; _planner = planner; MenuItems = new List <MenuItem>() { new MenuItem() { Command = new RelayCommand(() => ViewModelNavigation.NavigateAsync <UasTypeManagerViewModel>(this)), Name = "Settings", FontIconKey = "fa-users" }, new MenuItem() { Command = new RelayCommand(() => ViewModelNavigation.NavigateAsync <UserOrgsViewModel>(this)), Name = ClientResources.MainMenu_SwitchOrgs, FontIconKey = "fa-users" }, new MenuItem() { Command = new RelayCommand(() => ViewModelNavigation.NavigateAsync <ChangePasswordViewModel>(this)), Name = ClientResources.MainMenu_ChangePassword, FontIconKey = "fa-key" }, new MenuItem() { Command = new RelayCommand(() => ViewModelNavigation.NavigateAsync <InviteUserViewModel>(this)), Name = ClientResources.MainMenu_InviteUser, FontIconKey = "fa-user" }, new MenuItem() { Command = new RelayCommand(() => ViewModelNavigation.NavigateAsync <AboutViewModel>(this)), Name = "About", FontIconKey = "fa-info" }, new MenuItem() { Command = new RelayCommand(() => Logout()), Name = ClientResources.Common_Logout, FontIconKey = "fa-sign-out" } }; this.RefreshUI(); }
private TaskRuntime GetDeprecatedTaskRuntime( IInjector taskInjector, string contextId, IConfiguration taskConfiguration, IHeartBeatManager heartBeatManager) { var taskId = string.Empty; try { taskId = taskInjector.GetNamedInstance<TaskConfigurationOptions.Identifier, string>(); } catch (Exception e) { var ex = new TaskClientCodeException(string.Empty, Id, "Unable to instantiate the new task", e); Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, "Cannot get instance of Task ID: " + e.StackTrace, LOGGER); } LOGGER.Log(Level.Info, "Trying to inject task with configuration" + taskConfiguration); return new TaskRuntime(taskInjector, contextId, taskId, heartBeatManager); }
/// <summary> /// Launches an Task on this context. /// </summary> /// <param name="taskConfiguration"></param> /// <param name="contextId"></param> /// <param name="heartBeatManager"></param> public void StartTask(IConfiguration taskConfiguration, string contextId, IHeartBeatManager heartBeatManager) { lock (_contextLifeCycle) { LOGGER.Log(Level.Info, "ContextRuntime::StartTask(TaskConfiguration) task is present: " + _task.IsPresent()); if (_task.IsPresent()) { LOGGER.Log(Level.Info, "Task state: " + _task.Value.GetTaskState()); LOGGER.Log(Level.Info, "ContextRuntime::StartTask(TaskConfiguration) task has ended: " + _task.Value.HasEnded()); if (_task.Value.HasEnded()) { // clean up state _task = Optional<TaskRuntime>.Empty(); } else { // note: java code is putting thread id here var e = new InvalidOperationException( string.Format(CultureInfo.InvariantCulture, "Attempting to spawn a child context when an Task with id '{0}' is running", _task.Value.TaskId)); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } } if (_childContext.IsPresent()) { var e = new InvalidOperationException("Attempting to instantiate a child context on a context that is not the topmost active context."); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } var taskInjector = _contextInjector.ForkInjector(taskConfiguration); var taskRuntime = _deprecatedTaskStart ? GetDeprecatedTaskRuntime(taskInjector, contextId, taskConfiguration, heartBeatManager) : taskInjector.GetInstance<TaskRuntime>(); try { _task = Optional<TaskRuntime>.Of(taskRuntime); taskRuntime.RunTask(); } catch (Exception e) { var ex = new TaskClientCodeException(string.Empty, Id, "Unable to run the new task", e); Utilities.Diagnostics.Exceptions.CaughtAndThrow(ex, Level.Error, "Task start error.", LOGGER); } } }
public RootContextLauncher(string id, IConfiguration contextConfiguration, Optional <IConfiguration> rootServiceConfig, Optional <IConfiguration> rootTaskConfig, IHeartBeatManager heartbeatManager) { Id = id; _rootContextConfiguration = contextConfiguration; _rootServiceInjector = InjectServices(rootServiceConfig); _rootServiceInjector.BindVolatileInstance(GenericType <IHeartBeatManager> .Class, heartbeatManager); RootTaskConfig = rootTaskConfig; }