예제 #1
0
        public void NewModuleLoaded(string serialNumber, bool onList)
        {
            try
            {
                foreach (var sn in AggregateDataProvider.SerialNumbersOnTruckIncludingBuffered)
                {
                    if (sn != serialNumber && !ModulesOnTruck.Any(t => t.SerialNumber == sn))
                    {
                        ModulesOnTruck.Add(new ModuleViewModel {
                            SerialNumber = sn
                        });
                    }
                }

                if (!ModulesOnTruck.Any(t => t.SerialNumber == serialNumber))
                {
                    ModulesOnTruck.Add(new ModuleViewModel {
                        SerialNumber = serialNumber
                    });
                }

                if (!onList && !BadSerials.Any(t => t.SerialNumber == serialNumber))
                {
                    BadSerials.Add(new ModuleViewModel {
                        SerialNumber = serialNumber
                    });
                }
            }
            catch (Exception exc)
            {
                Logging.Logger.Log(exc);
            }
        }
예제 #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;
        }