Esempio n. 1
0
        private void ExecuteForceUnloadCommand()
        {
            //iterate through modules and execute force unload

            foreach (var moduleVM in ModulesOnTruck.Where(m => m.Selected))
            {
                AggregateDataProvider.ForceUnload(moduleVM.SerialNumber);
            }


            _windowService.CloseModalWindow(WindowType.UnloadCorrectionWindow);
            Messenger.Default.Send <ManualUnloadCorrectionMessage>(new ManualUnloadCorrectionMessage());
        }
Esempio n. 2
0
        public void HandleRefreshTimer()
        {
            if (!_windowService.IsWindowOpen(WindowType.WaitingForUnloadWindow))
            {
                return;
            }

            _windowService.FocusLast(WindowType.WaitingForUnloadWindow);

            lock (activeList)
            {
                var snsOnTruck  = AggregateDataProvider.SerialNumbersOnTruck;
                var snsInBuffer = AggregateDataProvider.SerialNumbersInBuffer;
                System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    var modulesToRemove = ModulesOnTruck.Where(m => !snsOnTruck.Any(t => t == m.SerialNumber)).ToList();
                    foreach (var m in modulesToRemove)
                    {
                        ModulesOnTruck.Remove(m);
                    }

                    modulesToRemove = BadSerials.Where(m => !snsOnTruck.Any(t => t == m.SerialNumber)).ToList();
                    foreach (var m in modulesToRemove)
                    {
                        BadSerials.Remove(m);
                    }

                    //add all modules on truck
                    foreach (var sn in snsOnTruck)
                    {
                        if (!ModulesOnTruck.Any(m => m.SerialNumber == sn))
                        {
                            ModulesOnTruck.Add(new ViewModels.ModuleViewModel {
                                SerialNumber = sn
                            });
                        }
                    }

                    //determine modules that shouldn't be on truck
                    foreach (var sn in snsOnTruck)
                    {
                        if (!activeList.AssignedModules.Any(m => m.Name == sn) && !BadSerials.Any(m => m.SerialNumber == sn))
                        {
                            BadSerials.Add(new ModuleViewModel {
                                SerialNumber = sn, BackgroundColor = "Red", ForegroundColor = "White"
                            });
                        }
                    }

                    //set background color of modules seen
                    //TagDataProvider.GetTagsFirstSeenInTimeRange
                    foreach (var badSerial in BadSerials)
                    {
                        if (snsInBuffer.Any(m => m == badSerial.SerialNumber))
                        {
                            badSerial.BackgroundColor = "PaleVioletRed";
                            badSerial.ForegroundColor = "White";
                        }
                        else
                        {
                            badSerial.BackgroundColor = "Red";
                            badSerial.ForegroundColor = "White";
                        }
                    }

                    if (BadSerials.Count() == 0) //no incorrect serials were found
                    {
                        t.Stop();
                        _windowService.CloseModalWindow(WindowType.WaitingForUnloadWindow);
                    }
                }));
            }
            lastIntervalStart = DateTime.UtcNow;
        }