public void AcknowledgeAlarms(string moduleName) { try { _logger.InfoFormat("Acknowledge current alarms on {0}.", FormatModuleName(moduleName)); if (string.IsNullOrEmpty(moduleName)) { IEnumerable <IPlatformModule> modules = _platformModuleRepository.Modules; foreach (IPlatformModule module in modules) { module.AlarmManager.AcknowledgeAlarms(); } return; } IPlatformModule platformModule = GetModule(moduleName); if (platformModule == null) { throw new InvalidOperationException(new StringBuilder().AppendLine() .AppendFormat("Tried to acknowledge alarms of module '{0}'.", moduleName).AppendLine() .AppendFormat("There is no module with the specified name.").ToString()); } platformModule.AlarmManager.AcknowledgeAlarms(); } catch (Exception e) { _logger.Error(e.Message, e); throw new FaultException <AlarmServiceFault>(new AlarmServiceFault(), e.Message); } }
public void RegisterPlatform(IPlatformModule module) { if (m_player != null && module.Platform == Platform.DESKTOP) { module.Player.GameObject.SetActive(false); } if (m_player == null || module.Platform == Platform.VR) { if (m_player != null) { m_player.GameObject.SetActive(false); } m_player = module.Player; m_player.GameObject.SetActive(true); } m_uiEngine.RegisterInterface(module.UserInterface); OnModuleRegistration?.Invoke(this, new ModuleArgs() { PlatformModule = module }); if (module.Platform == Platform.VR && !XRSettings.enabled) { StartCoroutine(LoadDevice("Oculus")); } }
private void UpdateRouteIndex(PlatformItem item, IPlatformModule module) { if (item == null || item.Route == null) { return; } int index = item.Route.CurrentIndex; if (index < (item.Route.RouteItems.Count - 1)) { int nextModuleTypeId = item.Route.GetOrderedList()[index + 1].ModuleType; if (module.ModuleTypeId == nextModuleTypeId) { item.Route.CurrentIndex++; index = item.Route.CurrentIndex; if (index + 1 < item.Route.RouteItems.Count) { nextModuleTypeId = item.Route.GetOrderedList()[index + 1].ModuleType; Logger.DebugFormat("Updated Route. Next target is {0}", nextModuleTypeId); } } } if (item.Route.CurrentIndex >= item.Route.RouteItems.Count - 1) { Logger.InfoFormat("Route completed for item {0}", item.ItemId); } }
private void RecalculateRoute(PlatformItem item, IPlatformModule module) { if (!RouteCalculator.CalculateSingleItemRouting(item, module)) { module.RemoveItemRouting(item); } }
public static Alarm GetAlarm(IPlatformModule module) { var message = module.Name + " ignores downstream module"; var alarm = Alarms.GetOrAdd(module, CreateAlarm(module, message)); return(alarm); }
private async Task InitializeModule(IPlatformModule module, CancellationToken token) { if (module.State != PlatformModuleState.NotInitialized) { _logger.ErrorFormat("Module {0} cannot be initialized because it is in state '{1}', expected NotInitialized", module.Name, module.State); return; } try { _logger.InfoFormat("Initializing module {0} ", module.Name); ModuleInitializationStarted(module.Name); await module.Initialize(token); module.IsInitialized = true; if (module.State != PlatformModuleState.NotInitialized) { module.State = PlatformModuleState.Initialized; } } catch (Exception e) { module.Disable(); _logger.Error("Can't initialize module " + module.Name + ".", e); } }
void OnIsInitializedChanged(IPlatformModule sender) { if (sender.IsInitialized) { sender.ActivateModule(); } }
public void FindPlatformModule_WithDifferentModuleName_ShouldReturnModule() { IPlatformModuleRepository finder = ModuleContainer(_loa1Module, _lab1Module); IPlatformModule platformModule = finder.GetModule(Lab1()); platformModule.Should().BeSameAs(_lab1Module); }
public Alarm GetAlarm(IPlatformModule module, Func <string> message) { var alarm = _alarms.GetOrAdd(new AlarmKey { Module = module, Message = message() }, m => CreateAlarm(m.Module, m.Message)); return(alarm); }
public PlatformItemEvent(long itemId, IPlatformModule assosiatedModule, PlatformItemEventType eventType, int releasePort = -1) { ItemId = itemId; AssosiatedModule = assosiatedModule; EventType = eventType; Timestamp = DateTime.Now; ReleasePort = releasePort; }
/// <summary> /// Starts the InitializeAll method with the assumed standard values for all modules. This could also be written as a standard static method without /// making it an extension method of platform module, but it'd be hard to find a good name to describe the default retry timeout. /// </summary> /// <param name="module">The platform module where this is the extension method from.</param> /// <param name="token">A cancellation token wich is passed into <see cref="initAllFunc"/>, and which will also cancel the scheduling once it's canceled.</param> /// <param name="initAllFunc"> /// A function that will be called with the provided cancellation token, first immediately (on the next free TaskPoolThread), /// and then every 5 seconds until the timer is disposed, or the cancellation token canceled. /// </param> /// <returns>A disposable that can be used to stop the re-occurring event.</returns> public static IDisposable StartInitializeAll(this IPlatformModule module, CancellationToken token, Func <CancellationToken, Task> initAllFunc) { var timer = TaskPoolScheduler.Default.ScheduleRecurringActionWithWait(TimeSpan.FromTicks(1), TimeSpan.FromSeconds(5), async() => await initAllFunc(token)); token.Register(timer.Dispose); return(timer); }
public Alarm GetAlarm(IPlatformModule module) { var message = string.Format("Stopped {0} because {1} is not available", module.Name, GetNextModuleName(module)); var alarm = _alarms.GetOrAdd(new AlarmKey { Module = module, Message = message }, m => CreateAlarm(m.Module, m.Message)); return(alarm); }
public void Initialize(IPlatformModule module) { _module = module; _module.CurrentItemCountChangedEvent += OnCurrentItemCountChanged; _module.ModuleStateChangedEvent += OnStateChanged; _oldItemCount = _module.CurrentItemCount; CheckUpDownTime(); _refreshTimer = new Timer(OnRefreshTimeout, _timerSignalEvent, RefreshRate, RefreshRate); }
private static Alarm CreateAlarm(IPlatformModule module, string message) { return(new Alarm { Message = message, Type = AlarmType.Warning, Source = module.Name, SourceType = AlarmSourceType.LineControl, Timestamp = DateTime.Now }); }
/// <summary> /// Finds a <see cref="IPlatformModule"/> instance with the specified <paramref name="moduleName"/>. /// </summary> /// <param name="moduleName">The name of the desired module.</param> /// <returns>An <see cref="IPlatformModule"/> instance.</returns> public IPlatformModule GetModule(string moduleName) { IPlatformModule foundModule = _modules.FirstOrDefault(m => Equals(m.Name, moduleName)); if (foundModule == null) { throw new InvalidOperationException(new StringBuilder().AppendLine() .AppendFormat("Tried to get the module with name '{0}'.", moduleName).AppendLine() .AppendLine("Unfortunately that module does not exist.").ToString()); } return(foundModule); }
private string GetNextModuleName(IPlatformModule module) { try { var graph = _moduleBusManager.GraphDto; var edge = graph.Edges.LastOrDefault(e => e.Source == module.Name); return(edge == null ? "the next module" : edge.Target); } catch (Exception) { return("the next module"); } }
private void OnStateChanged(IPlatformModule sender, PlatformModuleState newState) { lock (_lock) { DelayRefreshTimer(); CheckUpDownTime(); CleanHistory(); MetricsUpdatedEvent(this, new ModuleMetricUpdateEventArgs(Availability, Performance, Quality, OverallEquipmentEfficiency)); } }
public void Setup() { _loa1Port = CreateRandom.Int(); _loa1Module = new VirtualPlatformModule { Name = Loa1(), AdsPort = _loa1Port, StreamType = 1 }; _lab1Module = new VirtualPlatformModule { Name = Lab1(), AdsPort = 113, StreamType = 1 }; _ovenModule = new VirtualPlatformModule { Name = SingleOvenModule, AdsPort = 841, StreamType = 2 }; }
private void ExecuteOnModule(string moduleName, Action <IPlatformModule> actionToExecute) { if (string.IsNullOrEmpty(moduleName)) { foreach (string platformModuleName in _platformModuleRepository.Modules.Select(m => m.Name)) { ExecuteOnModule(platformModuleName, actionToExecute); } return; } IPlatformModule platformModule = _platformModuleRepository.GetModule(moduleName); actionToExecute(platformModule); }
public void ReactOnPlatformModuleState(IPlatformModule platformModule) { platformModule.ModuleStateChangedEvent += (sender, state) => { if (state == PlatformModuleState.Run) { IsActive = true; } else { IsActive = false; } }; }
public List <AlarmDTO> GetCurrentAlarms(string moduleName) { try { IPlatformModule platformModule = GetModule(moduleName); if (platformModule == null) { throw new InvalidOperationException(new StringBuilder().AppendLine() .AppendFormat("Tried to get current alarms of module '{0}'.", moduleName).AppendLine() .AppendFormat("There is no module with the specified name.").ToString()); } return(SortAlarms(platformModule.AlarmManager.CurrentAlarms).ToDTOs()); } catch (Exception e) { _logger.Error(e.Message, e); throw new FaultException <AlarmServiceFault>(new AlarmServiceFault(), e.Message); } }
private void PlatformModuleModuleStateChangedEvent(IPlatformModule sender, PlatformModuleState newState) { _eventRaiser.Raise(ref _platformModuleStateChanged, ((PlatformModule)sender).ToDTO()); }
/// <summary> /// Should only be called by module factories during application startup. /// </summary> public void AddNewModule(IPlatformModule module) { _modules.Add(module); }
public bool IsRoutePossible(IPlatformModule sourceModule, IPlatformModule targetModule) { return(RouteCalculator.IsRoutePossible(sourceModule, targetModule)); }
public void ReleaseForcePath(IPlatformModule sourceModule, IPlatformModule targetModule, int sourcePortIndex, int targetPortIndex) { RouteForcing.ReleaseForcePath(sourceModule, targetModule, sourcePortIndex, targetPortIndex); }
private void OnModuleStateChangedEvent(IPlatformModule module, PlatformModuleState newState) { RouteForcing.RecalculateRoute(); }
private void OnModulePortFullChangedEvent(IPlatformModule sender, int inputPortIndex, bool isFull) { RouteForcing.RecalculateRoute(); }
public virtual void MoveItem(long itemId, IPlatformModule targetModule) { }
public IEnumerable <IPlatformModule> FindUpStreamModules(IPlatformModule module) { var dependingEdges = _moduleGraph.InEdges(module); return(dependingEdges.Select(edge => edge.Source)); }
public IEnumerable <IPlatformModule> FindDownStreamModules(IPlatformModule module) { var dependingEdges = _moduleGraph.OutEdges(module); return(dependingEdges.Select(edge => edge.Target)); }