Esempio n. 1
0
 public EngineSettingsWriter(ICommandSenderHost commandSenderHost, ITargetAddressHost targerAddressHost,
                             IEngineSettingsReader engineSettingsReader)
 {
     _commandSenderHost    = commandSenderHost;
     _targerAddressHost    = targerAddressHost;
     _engineSettingsReader = engineSettingsReader;
     _writeSettingsTimeout = TimeSpan.FromMilliseconds(200.0);
 }
        public AutoSettingsReader(INotifySendingEnabled sendingEnabledNotifier,
                                  IAinsCounter ainsCounter, IAinSettingsReader ainSettingsReader,
                                  IAinSettingsStorageSettable ainSettingsStorageSettable,
                                  ILogger logger,
                                  IEngineSettingsReader engineSettingsReader, IEngineSettingsStorageSettable engineSettingsStorageSettable)
        {
            _ainsCounter                = ainsCounter;
            _ainSettingsReader          = ainSettingsReader;
            _ainSettingsStorageSettable = ainSettingsStorageSettable;
            _logger = logger;
            _engineSettingsReader          = engineSettingsReader;
            _engineSettingsStorageSettable = engineSettingsStorageSettable;
            _sendingEnabledNotifier        = sendingEnabledNotifier;

            _ainsCounter.AinsCountInSystemHasBeenChanged +=
                AinsCounterOnAinsCountInSystemHasBeenChanged;  // TODO: unsubscribe
            _sendingEnabledNotifier.SendingEnabledChanged +=
                SendingEnabledNotifierOnSendingEnabledChanged; // TODO: unsubscribe on app quit
        }
Esempio n. 3
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            var colorsForGraphics = new List <Color>
            {
                Colors.LawnGreen,
                Colors.Red,
                Colors.Cyan,
                Colors.Yellow,
                Colors.Coral,
                Colors.LightGreen,
                Colors.HotPink,
                Colors.DeepSkyBlue,
                Colors.Gold,
                Colors.Orange,
                Colors.Violet,
                Colors.White,
                Colors.Fuchsia,
                Colors.LightSkyBlue,
                Colors.LightGray,
                Colors.Khaki,
                Colors.SpringGreen,
                Colors.Tomato,
                Colors.LightCyan,
                Colors.Goldenrod,
                Colors.SlateBlue,
                Colors.Cornsilk,
                Colors.MediumPurple,
                Colors.RoyalBlue,
                Colors.MediumVioletRed,
                Colors.MediumTurquoise
            };

            _debugLogger = new RelayMultiLoggerWithStackTraceSimple(
                new RelayLoggerWithStackTrace(
                    new RelayActionLogger(s => { }),
                    new StackTraceFormatterWithNullSuport(" > ", "[NO STACK INFO]")),
                new RelayLoggerWithStackTrace(
                    new RelayLogger(
                        new ColoredConsoleLogger(ConsoleColor.Red, ConsoleColor.Black),
                        new ChainedFormatter(new List <ITextFormatter>
            {
                new ThreadFormatter(" > ", true, false, false),
                new DateTimeFormatter(" > ")
            })),
                    new StackTraceFormatterWithNullSuport(" > ", "[NO STACK INFO]")),
                new RelayLoggerWithStackTrace(
                    new RelayLogger(
                        new ColoredConsoleLogger(ConsoleColor.Yellow, ConsoleColor.Black),
                        new ChainedFormatter(new List <ITextFormatter>
            {
                new ThreadFormatter(" > ", true, false, false),
                new DateTimeFormatter(" > ")
            })),
                    new StackTraceFormatterWithNullSuport(" > ", "[NO STACK INFO]")),
                new RelayLoggerWithStackTrace(
                    new RelayLogger(
                        new ColoredConsoleLogger(ConsoleColor.DarkCyan, ConsoleColor.Black),
                        new ChainedFormatter(new List <ITextFormatter>
            {
                new ThreadFormatter(" > ", true, false, false),
                new DateTimeFormatter(" > ")
            })),
                    new StackTraceFormatterNothing()),
                new RelayLoggerWithStackTrace(
                    new RelayLogger(
                        new ColoredConsoleLogger(ConsoleColor.Cyan, ConsoleColor.Black),
                        new ChainedFormatter(new List <ITextFormatter>
            {
                new ThreadFormatter(" > ", true, false, false),
                new DateTimeFormatter(" > ")
            })),
                    new StackTraceFormatterNothing()),
                new RelayLoggerWithStackTrace(
                    new RelayLogger(
                        new ColoredConsoleLogger(ConsoleColor.Green, ConsoleColor.Black),
                        new ChainedFormatter(new List <ITextFormatter>
            {
                new ThreadFormatter(" > ", false, true, false), new DateTimeFormatter(" > ")
            })),
                    new StackTraceFormatterWithNullSuport(" > ", string.Empty)),
                new RelayLoggerWithStackTrace(
                    new RelayLogger(
                        new ColoredConsoleLogger(ConsoleColor.White, ConsoleColor.Black),
                        new ChainedFormatter(new List <ITextFormatter>
            {
                new ThreadFormatter(" > ", true, false, false), new DateTimeFormatter(" > ")
            })),
                    new StackTraceFormatterNothing()));

            var loggerAndRegPoint = new LoggerRegistrationPointThreadSafe();

            _commonLogger   = loggerAndRegPoint;
            _loggerRegPoint = loggerAndRegPoint;

            var paramLoggerAndRegPoint = new ParamLoggerRegistrationPointThreadSafe();

            _commonParamLogger   = paramLoggerAndRegPoint;
            _paramLoggerRegPoint = paramLoggerAndRegPoint;


            var cmdSenderHost = new CommandSenderHostThreadSafe();

            _cmdSenderHostSettable = cmdSenderHost;
            _cmdSenderHost         = cmdSenderHost;

            var targetAddressHost = new TargetAddressHostThreadSafe(1);

            _targetAddressHostSettable = targetAddressHost;
            _targetAddressHost         = targetAddressHost;

            var notifySendingEnabled = new NotifySendingEnabledThreadSafe(false);

            _notifySendingEnabledRaisable = notifySendingEnabled;
            _notifySendingEnabled         = notifySendingEnabled;

            var ainsCounter = new AinsCounterThreadSafe(1);

            _ainsCounterRaisable = ainsCounter;
            _ainsCounter         = ainsCounter;

            _cycleThreadHolder = new CycleThreadHolderThreadSafe();

            var ainSettingsStorage = new AinSettingsStorageThreadSafe(_ainsCounter, _notifySendingEnabled);

            _ainSettingsStorage              = ainSettingsStorage;
            _ainSettingsStorageSettable      = ainSettingsStorage;
            _ainSettingsStorageUpdatedNotify = ainSettingsStorage;

            var ainSettingsReader = new AinSettingsReader(_cmdSenderHost, _targetAddressHost, _commonLogger,
                                                          _ainSettingsStorageSettable, _debugLogger);

            _ainSettingsReader             = ainSettingsReader;
            _ainSettingsReadNotify         = ainSettingsReader;
            _ainSettingsReadNotifyRaisable = ainSettingsReader;

            _ainSettingsWriter = new AinSettingsWriter(_cmdSenderHost, _targetAddressHost, _ainsCounterRaisable,
                                                       _ainSettingsReader);
            _autoTimeSetter =
                new AutoTimeSetter(_cmdSenderHost, _notifySendingEnabled, _targetAddressHost, _commonLogger);


            var engineSettingsStorage = new EngineSettingsStorageThreadSafe();

            _engineSettingsStorage              = engineSettingsStorage;
            _engineSettingsStorageSettable      = engineSettingsStorage;
            _engineSettingsStorageUpdatedNotify = engineSettingsStorage;

            var engineSettingsReader = new EngineSettingsReader(_cmdSenderHost, _targetAddressHost, _commonLogger,
                                                                _engineSettingsStorageSettable, _debugLogger);

            _engineSettingsReader             = engineSettingsReader;
            _engineSettingsReadNotify         = engineSettingsReader;
            _engineSettingsReadNotifyRaisable = engineSettingsReader;

            _engineSettingsWriter = new EngineSettingsWriter(_cmdSenderHost, _targetAddressHost, _engineSettingsReader);


            _autoSettingsReader = new AutoSettingsReader(
                _notifySendingEnabled,
                _ainsCounterRaisable,
                _ainSettingsReader,
                _ainSettingsStorageSettable,
                _commonLogger,
                _engineSettingsReader,
                _engineSettingsStorageSettable);



            _bsEthernetLogsReadCycleModel = new ReadCycleModel(_cmdSenderHost, targetAddressHost, notifySendingEnabled);

            var uiRoot = new SimpleUiRoot(new WpfUiNotifierAsync(Dispatcher.CurrentDispatcher));

            var ainCommandAndCommonTelemetryVm = new AinCommandAndCommonTelemetryViewModel(
                new AinCommandAndMinimalCommonTelemetryViewModel(
                    _cmdSenderHost,
                    _targetAddressHost,
                    uiRoot,
                    _commonLogger,
                    _notifySendingEnabled,
                    0,
                    _ainSettingsStorage,
                    _ainSettingsStorageUpdatedNotify),
                new TelemetryCommonViewModel(),
                _cmdSenderHost,
                _targetAddressHost,
                uiRoot,
                _notifySendingEnabled);


            // TODO: Register something but not VM?
            _cycleThreadHolder.RegisterAsCyclePart(ainCommandAndCommonTelemetryVm);


            new CommandWindow {
                DataContext = new CommandWindowViewModel(ainCommandAndCommonTelemetryVm)
            }.Show();

            new BsEthernetLogsWindow {
                DataContext = new WindowViewModel(uiRoot, _bsEthernetLogsReadCycleModel)
            }.Show();



            var mainViewModel = new MainViewModel(
                new SimpleUiRoot(new WpfUiNotifierAsync(Dispatcher.CurrentDispatcher)),
                new WpfWindowSystem(),
                colorsForGraphics,
                _cmdSenderHostSettable,
                _targetAddressHost,
                _debugLogger,
                _loggerRegPoint,
                _notifySendingEnabledRaisable,
                _commonParamLogger,
                _ainsCounterRaisable,
                _cycleThreadHolder,
                _ainSettingsReader,
                _ainSettingsReadNotify,
                _ainSettingsReadNotifyRaisable,
                _ainSettingsWriter, _ainSettingsStorage, _ainSettingsStorageSettable,
                _ainSettingsStorageUpdatedNotify, _bsEthernetLogsReadCycleModel,
                _engineSettingsReader,
                _engineSettingsWriter,
                _engineSettingsReadNotify,
                _engineSettingsReadNotifyRaisable,
                _engineSettingsStorage,
                _engineSettingsStorageSettable,
                _engineSettingsStorageUpdatedNotify);

            new MainWindow {
                DataContext = mainViewModel
            }.Show();
        }
        public Group99SettingsViewModel(IUserInterfaceRoot uiRoot, ILogger logger,
                                        IAinSettingsReaderWriter ainSettingsReaderWriter, IAinSettingsReadNotify ainSettingsReadNotify,
                                        IAinSettingsStorage ainSettingsStorage, IAinSettingsStorageUpdatedNotify ainSettingsStorageUpdatedNotify,
                                        IAinsCounter ainsCounter,
                                        IEngineSettingsReader engineSettingsReader, IEngineSettingsWriter engineSettingsWriter,
                                        IEngineSettingsReadNotify engineSettingsReadNotify, IEngineSettingsStorage engineSettingsStorage,
                                        IEngineSettingsStorageUpdatedNotify engineSettingsStorageUpdatedNotify,
                                        ImcwParameterViewModel imcwParameterVm)
        {
            _uiRoot = uiRoot;
            _logger = logger;

            _ainSettingsReaderWriter         = ainSettingsReaderWriter;
            _ainSettingsReadNotify           = ainSettingsReadNotify;
            _ainSettingsStorage              = ainSettingsStorage;
            _ainSettingsStorageUpdatedNotify = ainSettingsStorageUpdatedNotify;
            _ainsCounter = ainsCounter;

            _engineSettingsReader               = engineSettingsReader;
            _engineSettingsWriter               = engineSettingsWriter;
            _engineSettingsReadNotify           = engineSettingsReadNotify;
            _engineSettingsStorage              = engineSettingsStorage;
            _engineSettingsStorageUpdatedNotify = engineSettingsStorageUpdatedNotify;

            _imcwParameterVm = imcwParameterVm;


            Parameter01Vm =
                new ParameterDecimalEditCheckViewModel(
                    "99.01. Номинальное напряжение обмотки статора (действующее) [В]", "f0", 0, 10000);
            Parameter02Vm =
                new ParameterDecimalEditCheckViewModel("99.02. Номинальный ток обмотки статора [А]", "f0", 0, 10000);
            Parameter03Vm =
                new ParameterDecimalEditCheckViewModel("99.03. Номинальная частота напряжения питающей сети [Гц]", "f1",
                                                       8, 300);
            Parameter04Vm =
                new ParameterDecimalEditCheckViewModel("99.04. Номинальная скорость вращения двигателя [об/мин]", "f0",
                                                       0, 18000);
            Parameter05Vm =
                new ParameterDecimalEditCheckViewModel("99.05. Максимальная скорость вращения двигателя [об/мин]", "f0",
                                                       0, 18000);
            Parameter06Vm =
                new ParameterDecimalEditCheckViewModel("99.06. Номинальная мощность на валу двигателя [кВт]", "f3", 0,
                                                       9000);
            Parameter07Vm = new ParameterComboEditableViewModel <int>("99.07. Режим управления двигателем",
                                                                      new[]
            {
                new ComboItemViewModel <int> {
                    ComboText = "Скалярный", ComboValue = 0
                },
                new ComboItemViewModel <int> {
                    ComboText = "Векторный", ComboValue = 1
                }
            });
            Parameter07Vm.PropertyChanged += Parameter07VmOnPropertyChanged;

            _imcwParameterVm.PropertyChanged += ImcwParameterVmOnPropertyChanged;

            Parameter08Vm =
                new ParameterDecimalEditCheckViewModel("99.08. Номинальный коэффициент мощности cos(ϕ)", "f2", 0, 1.0m);
            Parameter09Vm =
                new ParameterDecimalEditCheckViewModel("99.09. Номинальный КПД двигателя [%]", "f1", 0, 100.0m);
            Parameter10Vm = new ParameterDecimalEditCheckViewModel("99.10. Масса двигателя [кг]", "f0", 0, 10000);
            Parameter11Vm = new ParameterDecimalEditCheckViewModel("99.11. Кратность максимального момента (Mmax/Mnom)",
                                                                   "f0", 0, 10000);
            Parameter12Vm = new ParameterDecimalEditCheckViewModel("99.12. Конструктивная высота [мм]", "f0", 0, 10000);

            ReadSettingsCmd  = new RelayCommand(ReadSettings, () => true); // TODO: read only when connected to COM
            WriteSettingsCmd =
                new RelayCommand(WriteSettings, () => IsWriteEnabled);     // TODO: read only when connected to COM

            _ainSettingsReadNotify.AinSettingsReadComplete      += AinSettingsReadNotifyOnAinSettingsReadComplete;
            _ainSettingsStorageUpdatedNotify.AinSettingsUpdated += (zbAinNuber, settings) =>
            {
                _uiRoot.Notifier.Notify(() => WriteSettingsCmd.RaiseCanExecuteChanged());
            };

            _engineSettingsReadNotify.EngineSettingsReadComplete +=
                EngineSettingsReadNotifyOnEngineSettingsReadComplete;
            _engineSettingsStorageUpdatedNotify.EngineSettingsUpdated += settings =>
            {
                _uiRoot.Notifier.Notify(() => WriteSettingsCmd.RaiseCanExecuteChanged());
            };
        }
Esempio n. 5
0
        public MainViewModel(IUserInterfaceRoot uiRoot, IWindowSystem windowSystem, List <Color> colors,
                             ICommandSenderHostSettable commandSenderHostSettable, ITargetAddressHost targetAddressHost,
                             IMultiLoggerWithStackTrace <int> debugLogger, ILoggerRegistrationPoint loggerRegistrationPoint,
                             INotifySendingEnabledRaisable notifySendingEnabled, IParameterLogger paramLogger,
                             IAinsCounterRaisable ainsCounterRaisable,
                             ICycleThreadHolder cycleThreadHolder,
                             IAinSettingsReader ainSettingsReader, IAinSettingsReadNotify ainSettingsReadNotify,
                             IAinSettingsReadNotifyRaisable ainSettingsReadNotifyRaisable, IAinSettingsWriter ainSettingsWriter,
                             IAinSettingsStorage ainSettingsStorage, IAinSettingsStorageSettable ainSettingsStorageSettable,
                             IAinSettingsStorageUpdatedNotify storageUpdatedNotify,
                             ReadCycleModel bsEthernetReadCycleModel,
                             IEngineSettingsReader engineSettingsReader,
                             IEngineSettingsWriter engineSettingsWriter,
                             IEngineSettingsReadNotify engineSettingsReadNotify,
                             IEngineSettingsReadNotifyRaisable engineSettingsReadNotifyRaisable,
                             IEngineSettingsStorage engineSettingsStorage,
                             IEngineSettingsStorageSettable engineSettingsStorageSettable,
                             IEngineSettingsStorageUpdatedNotify engineSettingsStorageUpdatedNotify)
        {
            _uiRoot = uiRoot;
            _colors = colors;

            _commandSenderHostSettable = commandSenderHostSettable;
            _commandSenderHost         = commandSenderHostSettable;
            _targetAddressHost         = targetAddressHost;

            _isPortOpened = false;

            // Лог программы:
            _debugLogger             = debugLogger;
            _loggerRegistrationPoint = loggerRegistrationPoint;

            // разрешение к отправке (COM-порт открыт/закрыт)
            _notifySendingEnabled = notifySendingEnabled;

            ProgramLogVm = new ProgramLogViewModel(_uiRoot, _debugLogger, new DateTimeFormatter(" > "));
            _logger      = new RelayLogger(ProgramLogVm);
            _loggerRegistrationPoint.RegisterLoggegr(_logger);

            GetPortsAvailable();

            OpenPortCommand          = new RelayCommand(OpenPort, () => !_isPortOpened);
            ClosePortCommand         = new RelayCommand(ClosePort, () => _isPortOpened);
            GetPortsAvailableCommand = new RelayCommand(GetPortsAvailable);

            _paramLogger = paramLogger;


            _ainsCounterRaisable   = ainsCounterRaisable;
            _cycleThreadHolder     = cycleThreadHolder;
            _ainSettingsReader     = ainSettingsReader;
            _ainSettingsReadNotify = ainSettingsReadNotify;
            _ainSettingsWriter     = ainSettingsWriter;

            // Блоки АИН в системе:
            AinsCountInSystem = new List <int> {
                1, 2, 3
            };
            SelectedAinsCount = AinsCountInSystem.First();

            var ainSettingsReadedWriter = new AinSettingsReaderWriter(_ainSettingsReader, _ainSettingsWriter);

            _engineSettingsReader               = engineSettingsReader;
            _engineSettingsWriter               = engineSettingsWriter;
            _engineSettingsReadNotify           = engineSettingsReadNotify;
            _engineSettingsReadNotifyRaisable   = engineSettingsReadNotifyRaisable;
            _engineSettingsStorage              = engineSettingsStorage;
            _engineSettingsStorageSettable      = engineSettingsStorageSettable;
            _engineSettingsStorageUpdatedNotify = engineSettingsStorageUpdatedNotify;


            AinCommandAndCommonTelemetryVm = new AinCommandAndCommonTelemetryViewModel(
                new AinCommandAndMinimalCommonTelemetryViewModel(_commandSenderHost, _targetAddressHost, _uiRoot,
                                                                 _logger, _notifySendingEnabled, 0, ainSettingsStorage, storageUpdatedNotify),
                new TelemetryCommonViewModel(), _commandSenderHost, _targetAddressHost, _uiRoot, _notifySendingEnabled);

            _cycleThreadHolder.RegisterAsCyclePart(AinCommandAndCommonTelemetryVm);

            TelemtryVm = new TelemetryViewModel(_uiRoot, _commandSenderHost, _targetAddressHost, _logger,
                                                _cycleThreadHolder, _ainsCounterRaisable, _paramLogger, _notifySendingEnabled);

            SettingsVm = new SettingsViewModel(_uiRoot, _logger,
                                               ainSettingsReadedWriter, _ainSettingsReadNotify, ainSettingsReadNotifyRaisable, ainSettingsStorage,
                                               ainSettingsStorageSettable, storageUpdatedNotify, _ainsCounterRaisable,
                                               _commandSenderHost, _targetAddressHost, _notifySendingEnabled,
                                               _engineSettingsReader,
                                               _engineSettingsWriter,
                                               _engineSettingsReadNotify,
                                               _engineSettingsReadNotifyRaisable,
                                               _engineSettingsStorage,
                                               _engineSettingsStorageSettable,
                                               _engineSettingsStorageUpdatedNotify,
                                               _debugLogger); // TODO: can be moved to app.xaml.cs if needed

            ArchiveVm = new ArchivesViewModel(
                new ArchiveViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled,
                                     0),
                new ArchiveViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled,
                                     1));

            MnemonicChemeVm =
                new MnemonicChemeViewModel(Path.Combine(Environment.CurrentDirectory, "mnemoniccheme.png"));
            OldLookVm = new OldLookViewModel(_uiRoot, windowSystem, _commandSenderHost, _targetAddressHost,
                                             _notifySendingEnabled, this, _logger, _debugLogger, _cycleThreadHolder, _ainsCounterRaisable,
                                             _paramLogger, ainSettingsStorage, storageUpdatedNotify);

            _ain1StateColor = Colors.Gray;
            _ain2StateColor = Colors.Gray;
            _ain3StateColor = Colors.Gray;

            _ain1IsUsed = true;
            _ain2IsUsed = false;
            _ain3IsUsed = false;

            _ainsCounterRaisable.AinsCountInSystemHasBeenChanged += ainsCount =>
            {
                switch (ainsCount)
                {
                case 1:
                    Ain1IsUsed = true;
                    Ain2IsUsed = false;
                    Ain3IsUsed = false;
                    break;

                case 2:
                    Ain1IsUsed = true;
                    Ain2IsUsed = true;
                    Ain3IsUsed = false;
                    break;

                case 3:
                    Ain1IsUsed = true;
                    Ain2IsUsed = true;
                    Ain3IsUsed = true;
                    break;

                default:
                    throw new Exception("Такое число АИН в системе не поддерживается");
                }
            };

            AinCommandAndCommonTelemetryVm.AinsLinkInformationHasBeenUpdated += (ain1Error, ain2Error, ain3Error) =>
            {
                Ain1StateColor = ain1Error.HasValue ? ain1Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray;
                Ain2StateColor = ain2Error.HasValue ? ain2Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray;
                Ain3StateColor = ain3Error.HasValue ? ain3Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray;
            };

            _notifySendingEnabled.SendingEnabledChanged += isEnabled =>
            {
                // TODO: execution in ui thread
                Ain1StateColor = Colors.Gray;
                Ain2StateColor = Colors.Gray;
                Ain3StateColor = Colors.Gray;
            };

            EngineAutoSetupVm = new EngineAutoSetupViewModel(
                new TableViewModel("Начальные значения:", _logger),
                new TableViewModel("После тестирования:", _logger),
                _notifySendingEnabled, _ainSettingsReader, _ainSettingsReadNotify, _ainSettingsWriter, _uiRoot, _logger,
                _commandSenderHost, _targetAddressHost, bsEthernetReadCycleModel);

            _logger.Log("Программа загружена");
        }
        public Group20SettingsViewModel(IUserInterfaceRoot uiRoot, ILogger logger,
                                        IAinSettingsReaderWriter ainSettingsReaderWriter, IAinSettingsReadNotify ainSettingsReadNotify,
                                        IAinSettingsStorage ainSettingsStorage, IAinSettingsStorageUpdatedNotify ainSettingsStorageUpdatedNotify,
                                        IAinsCounter ainsCounter,
                                        IEngineSettingsReader engineSettingsReader, IEngineSettingsWriter engineSettingsWriter,
                                        IEngineSettingsReadNotify engineSettingsReadNotify, IEngineSettingsStorage engineSettingsStorage,
                                        IEngineSettingsStorageUpdatedNotify engineSettingsStorageUpdatedNotify)
        {
            _uiRoot = uiRoot;
            _logger = logger;

            _ainSettingsReaderWriter         = ainSettingsReaderWriter;
            _ainSettingsReadNotify           = ainSettingsReadNotify;
            _ainSettingsStorage              = ainSettingsStorage;
            _ainSettingsStorageUpdatedNotify = ainSettingsStorageUpdatedNotify;
            _ainsCounter = ainsCounter;

            _engineSettingsReader               = engineSettingsReader;
            _engineSettingsWriter               = engineSettingsWriter;
            _engineSettingsReadNotify           = engineSettingsReadNotify;
            _engineSettingsStorage              = engineSettingsStorage;
            _engineSettingsStorageUpdatedNotify = engineSettingsStorageUpdatedNotify;

            Parameter01Vm =
                new ParameterDecimalEditCheckViewModel("20.01. Максимальная частота [Гц]", "f1", 0, 6553.5m);

            Parameter02Vm =
                new ParameterDecimalEditCheckViewModel("20.02. Ограничение тока (амплитуда) [А]", "f0", -10000, 10000);
            Parameter03Vm = new ParameterDecimalEditCheckViewModel("20.03. Минимальная частота (электрическая) [Гц]",
                                                                   "f1", -3276.8m, 3276.7m);

            Parameter04Vm = new ParameterDecimalEditCheckViewModel("20.04. Максимальный ток (амплитуда) для защиты [А]",
                                                                   "f0", -32768, 32767);
            Parameter05Vm =
                new ParameterDecimalEditCheckViewModel("20.05. Максимальное напряжение шины DC для защиты [В]", "f0",
                                                       -1000, 1000);
            Parameter06Vm =
                new ParameterDecimalEditCheckViewModel("20.06. Минимальное напряжение шины DC [В]", "f0", -1000, 1000);
            Parameter07Vm = new ParameterDecimalEditCheckViewModel("20.07. Порог защиты по внешней температуре [⁰С]",
                                                                   "f0", -32768, 32767);


            Parameter08Vm =
                new ParameterDecimalEditCheckViewModel("20.08. Тепловая защита: граница перегрева [А² × 0.1сек]", "f0",
                                                       -10000, 10000);
            Parameter09Vm =
                new ParameterDecimalEditCheckViewModel("20.09. Тепловая защита: I(RMS) [А]", "f0", -10000, 10000);
            Parameter10Vm = new ParameterDecimalEditCheckViewModel(
                "20.10. Скорость вращения двигателя (электрическая) ниже нулевого предела (ZERO_SPEED) [Гц]", "f0",
                -10000, 10000);

            Parameter11Vm =
                new ParameterDecimalEditCheckViewModel("20.11. Минимальный момент", "f0", -10000, 10000);  // TODO: WTF?
            Parameter12Vm =
                new ParameterDecimalEditCheckViewModel("20.12. Максимальный момент", "f0", -10000, 10000); // TODO: WTF?

            ReadSettingsCmd  = new RelayCommand(ReadSettings, () => true);                                 // TODO: read only when connected to COM
            WriteSettingsCmd =
                new RelayCommand(WriteSettings, () => IsWriteEnabled);                                     // TODO: read only when connected to COM

            _ainSettingsReadNotify.AinSettingsReadComplete      += AinSettingsReadNotifyOnAinSettingsReadComplete;
            _ainSettingsStorageUpdatedNotify.AinSettingsUpdated += (zbAinNuber, settings) =>
            {
                _uiRoot.Notifier.Notify(() => WriteSettingsCmd.RaiseCanExecuteChanged());
            };

            _engineSettingsReadNotify.EngineSettingsReadComplete +=
                EngineSettingsReadNotifyOnEngineSettingsReadComplete;
            _engineSettingsStorageUpdatedNotify.EngineSettingsUpdated += settings =>
            {
                _uiRoot.Notifier.Notify(() => WriteSettingsCmd.RaiseCanExecuteChanged());
            };
        }
Esempio n. 7
0
        public SettingsViewModel(
            IUserInterfaceRoot userInterfaceRoot,
            ILogger logger,
            IAinSettingsReaderWriter ainSettingsReadedWriter,
            IAinSettingsReadNotify ainSettingsReadNotify,
            IAinSettingsReadNotifyRaisable ainSettingsReadNotifyRaisable,
            IAinSettingsStorage ainSettingsStorage,
            IAinSettingsStorageSettable ainSettingsStorageSettable,
            IAinSettingsStorageUpdatedNotify storageUpdatedNotify,
            IAinsCounter ainsCounter,
            ICommandSenderHost commandSenderHost,
            ITargetAddressHost targetAddressHost,
            INotifySendingEnabled notifySendingEnabled,
            IEngineSettingsReader engineSettingsReader,
            IEngineSettingsWriter engineSettingsWriter,
            IEngineSettingsReadNotify engineSettingsReadNotify,
            IEngineSettingsReadNotifyRaisable engineSettingsReadNotifyRaisable,
            IEngineSettingsStorage engineSettingsStorage,
            IEngineSettingsStorageSettable engineSettingsStorageSettable,
            IEngineSettingsStorageUpdatedNotify engineSettingsStorageUpdatedNotify,
            IMultiLoggerWithStackTrace <int> debugLogger)
        {
            Group20SettingsVm = new Group20SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter,
                                                             engineSettingsReader, engineSettingsWriter, engineSettingsReadNotify, engineSettingsStorage,
                                                             engineSettingsStorageUpdatedNotify);

            Group22SettingsVm = new Group22SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group23SettingsVm = new Group23SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group24SettingsVm = new Group24SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group25SettingsVm = new Group25SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group26SettingsVm = new Group26SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group27SettingsVm = new Group27SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);

            var imcwParamViewModel = new ImcwParameterViewModel();

            Group99SettingsVm = new Group99SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                             ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter,
                                                             engineSettingsReader, engineSettingsWriter, engineSettingsReadNotify, engineSettingsStorage,
                                                             engineSettingsStorageUpdatedNotify,
                                                             imcwParamViewModel);

            Group100SettingsVm = new Group100SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                               ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group101SettingsVm = new Group101SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                               ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group102SettingsVm = new Group102SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                               ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group103SettingsVm = new Group103SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                               ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            //Group104SettingsVm = new Group104SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter, ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter);
            Group105SettingsVm = new Group105SettingsViewModel(userInterfaceRoot, logger,
                                                               ainSettingsReadedWriter, /*ainSettingsReadNotify, */ ainSettingsStorage, storageUpdatedNotify,
                                                               ainsCounter);
            Group106SettingsVm = new Group106SettingsViewModel(userInterfaceRoot, logger, ainSettingsReadedWriter,
                                                               ainSettingsReadNotify, ainSettingsStorage, storageUpdatedNotify, ainsCounter, imcwParamViewModel);
            Group107SettingsVm = new Group107SettingsViewModel(userInterfaceRoot, logger,
                                                               ainSettingsReadedWriter, /*ainSettingsReadNotify, */ ainSettingsStorage, storageUpdatedNotify,
                                                               ainsCounter);

            ImportExportVm = new ImportExportViewModel(ainSettingsStorageSettable, ainSettingsReadNotifyRaisable,
                                                       engineSettingsStorageSettable, engineSettingsReadNotifyRaisable, debugLogger);
        }