Exemple #1
0
        public object Clone()
        {
            ModbusMemoryEntityViewModel memoryEntityViewModel = new ModbusMemoryEntityViewModel(_modbusConversionParametersViewModel);

            memoryEntityViewModel.SetUshortValue((ushort)_modbusMemoryEntity.DirectValue);
            memoryEntityViewModel.SetAddress(_address);
            return(memoryEntityViewModel);
        }
Exemple #2
0
        private void OnExecuteEditEntity(ModbusMemoryEntityViewModel modbusMemoryEntityViewModel)
        {
            ModbusEntityEditingViewModel modbusEntityEditingViewModel = new ModbusEntityEditingViewModel();

            modbusEntityEditingViewModel.SetEntity(modbusMemoryEntityViewModel.Clone() as ModbusMemoryEntityViewModel);

            MRNetworkingEditingViewxaml window = new MRNetworkingEditingViewxaml();

            window.DataContext = modbusEntityEditingViewModel;
            window.ShowDialog();
        }
Exemple #3
0
        public async void SetEntity(ModbusMemoryEntityViewModel modbusMemoryEntityViewModelToEdit)
        {
            _modbusMemoryEntityViewModelToEdit = modbusMemoryEntityViewModelToEdit;
            RaisePropertyChanged(nameof(ModbusMemoryEntityViewModelToEdit));
            ValueDec = ModbusMemoryEntityViewModelToEdit.DirectValueDec;
            ValueHex = ModbusMemoryEntityViewModelToEdit.DirectValueHex;
            RaisePropertyChanged(nameof(ModbusMemoryEntityViewModelToEdit.AdressDec));
            RaisePropertyChanged(nameof(ModbusMemoryEntityViewModelToEdit.AdressHex));
            _addressToWrite      = ushort.Parse(ModbusMemoryEntityViewModelToEdit.AdressDec);
            _resultedValueUshort = ushort.Parse(ModbusMemoryEntityViewModelToEdit.DirectValueDec);
            //  await WriteContext(_resultedValueUshort);



            //Querer = new Slot(ushort.Parse(ModbusMemoryEntityViewModelToEdit.AdressDec), 1, "MBNetworkQuerer");
        }
Exemple #4
0
        private void OnModbusMemorySettingsChanged(ModbusMemorySettings modbusMemorySettings)
        {
            bool isQueriesStartedBefore = IsQueriesStarted;

            if (modbusMemorySettings == null)
            {
                return;
            }
            IsQueriesStarted = false;
            if (ModbusMemoryEntityViewModels.Count != modbusMemorySettings.NumberOfPoints)
            {
                ModbusMemoryEntityViewModels.Clear();
            }
            //всякие условия вокруг - оптимизация вывода, чтобы не перерисовывать все каждый раз
            for (int i = 0; i < modbusMemorySettings.NumberOfPoints; i++)
            {
                if (_modbusConversionParametersViewModels.Count < i + 1)
                {
                    _modbusConversionParametersViewModels.Add(new ModbusConversionParametersViewModel());
                }

                if (ModbusMemoryEntityViewModels.Count <= i)
                {
                    ModbusMemoryEntityViewModel modbusMemoryEntityViewModel =
                        new ModbusMemoryEntityViewModel(_modbusConversionParametersViewModels[i]);
                    ModbusMemoryEntityViewModels.Add(modbusMemoryEntityViewModel);
                }
                ModbusMemoryEntityViewModels[i].SetAddress(modbusMemorySettings.BaseAdress + i);
                ModbusMemoryEntityViewModels[i].SetError();
            }
            if (isQueriesStartedBefore)
            {
                IsQueriesStarted = true;
            }
            else
            {
                ModbusMemoryEntityViewModels.ForEach((model => model.SetError()));
            }
        }