Example #1
0
        public ushort[] GetUshortsFromTable(DynamicDataTable table, IMatrixValue matrixValue)
        {
            var ushortsFromTable = matrixValue.MatrixTemplate.MatrixMemoryVariables.SelectMany((variable => GetUshortsFromVariable(variable, matrixValue, table)
                                                                                                )).ToList();

            return(ushortsFromTable.ToArray());
        }
Example #2
0
        public OscilloscopeJournalViewModel(IValueViewModelFactory valueViewModelFactory,
                                            ILocalizerService localizerService, Func <IBoolValue> boolValueGettingFunc,
                                            ILoadingSequenceLoaderRegistry loadingSequenceLoaderRegistry, IJournalLoaderProvider journalLoaderProvider, OscillogramLoader oscillogramLoader)
        {
            this._valueViewModelFactory    = valueViewModelFactory;
            this._localizerService         = localizerService;
            this._boolValueGettingFunc     = boolValueGettingFunc;
            _loadingSequenceLoaderRegistry = loadingSequenceLoaderRegistry;
            _journalLoaderProvider         = journalLoaderProvider;
            _oscillogramLoader             = oscillogramLoader;
            this.LoadCommand  = new RelayCommand(this.OnLoadExecute);
            this.SelectedRows = new List <int>();
            _loaderHooks      = new LoaderHooks(() =>
            {
                Table = new DynamicDataTable(this.JournalParametersNameList, null, true);
                RaisePropertyChanged(nameof(this.Table));
                RaisePropertyChanged(nameof(this.JournalParametersNameList));
            }, list =>
            {
                List <IFormattedValueViewModel> formattedValueViewModels = new List <IFormattedValueViewModel>();
                int index                   = this.Table.GetCurrentValueCount();
                IBoolValue boolValue        = this._boolValueGettingFunc();
                boolValue.BoolValueProperty = this._oscillogramLoader.TryGetOscillogram(index, out string s, _oscilloscopeViewModel, _oscilloscopeModel, _oscilloscopeViewModel.DeviceContext);
                formattedValueViewModels.Add(this._valueViewModelFactory.CreateFormattedValueViewModel(boolValue));
                formattedValueViewModels.AddRange(list.Select((formattedValue =>
                                                               this._valueViewModelFactory.CreateFormattedValueViewModel(formattedValue))).ToList());

                this.Table.AddFormattedValueViewModel(formattedValueViewModels);
            });
Example #3
0
        public async Task <Result> Initialize(IDeviceFragment deviceFragment)
        {
            IUniconJournal uniconJournal = deviceFragment as IUniconJournal;

            _uniconJournal            = uniconJournal;
            JournalParametersNameList = new List <string>();
            foreach (IJournalParameter journalParameter in uniconJournal.RecordTemplate.JournalParameters)
            {
                if (journalParameter is IComplexJournalParameter)
                {
                    foreach (ISubJournalParameter subJournalParameter in (journalParameter as IComplexJournalParameter)
                             .ChildJournalParameters)
                    {
                        JournalParametersNameList.Add(subJournalParameter.Name);
                    }
                }
                else
                {
                    JournalParametersNameList.Add(journalParameter.Name);
                }
            }

            Table = new DynamicDataTable(JournalParametersNameList, null, true);
            RaisePropertyChanged(nameof(Table));
            RaisePropertyChanged(nameof(JournalParametersNameList));
            return(Result.Create(true));
        }
Example #4
0
        private void OnExecuteLoadJournal()
        {
            _applicationGlobalCommands.SelectFileToOpen(_localizerService.GetLocalizedString("OpenJournal"),
                                                        " UJR файл (*.ujr)|*.ujr" + "|Все файлы (*.*)|*.* ").OnSuccess(info =>
            {
                var loadedJournal = _typesContainer.Resolve <ISerializerService>()
                                    .DeserializeFromFile <IUniconJournal>(info.FullName);
                if (!JournalStructureHelper.IsJournalStructureSimilar(_uniconJournal, loadedJournal))
                {
                    if (!_applicationGlobalCommands.AskUserGlobal(
                            _localizerService.GetLocalizedString(ApplicationGlobalNames.StatusMessages
                                                                 .JOURNAL_STRUCTURE_WARNING_MESSAGE),
                            _localizerService.GetLocalizedString("Warning")))
                    {
                        return;
                    }
                }

                Table = new DynamicDataTable(JournalParametersNameList, null, true);
                RaisePropertyChanged(nameof(Table));
                RaisePropertyChanged(nameof(JournalParametersNameList));
                _journalLoaderProvider
                .GetJournalLoader(DeviceContext, _uniconJournal, _loaderHooks)
                .LoadFromReadyModelList(loadedJournal.JournalRecords);
                _wasLoadedOnce = true;
                _logService.LogMessage(_localizerService
                                       .GetLocalizedString("JournalOpened") + " " + info.FullName);
            });
        }
Example #5
0
        public async Task LoadJournal()
        {
            try
            {
                CanExecuteJournalLoading = false;
                Table = new DynamicDataTable(JournalParametersNameList, null, true);
                RaisePropertyChanged(nameof(Table));
                RaisePropertyChanged(nameof(JournalParametersNameList));
                if (_loadingTask == null)
                {
                    _loadingTask = _journalLoaderProvider
                                   .GetJournalLoader(DeviceContext, _uniconJournal, _loaderHooks)
                                   .Load();
                }

                await _loadingTask;
                _wasLoadedOnce = true;
            }
            catch (Exception e)
            {
                _applicationGlobalCommands.ShowErrorMessage(e.ToString(), this);
                _applicationGlobalCommands.ShowErrorMessage(ApplicationGlobalNames.StatusMessages.JOURNAL_READING_ERROR,
                                                            this);
            }
            finally
            {
                _loadingTask = null;
            }

            CanExecuteJournalLoading = true;
        }
Example #6
0
 public void TestItem()
 {
     DataTable table = null; // TODO: Initialize to an appropriate value
     DynamicDataTable target = new DynamicDataTable(table); // TODO: Initialize to an appropriate value
     object keyValue = null; // TODO: Initialize to an appropriate value
     DynamicDataRow actual;
     actual = target[keyValue];
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        protected override Control CreateValueControl()
        {
            var result = new DynamicDataTable();

            CreateClientControlsOn(result.LayoutGrid);
            // somewhere here i need to attach the behaviour
            CreateButtonsOn(result.ButtonPanel);
            return(result);
        }
Example #8
0
 public void TestGetEnumerator()
 {
     DataTable table = null; // TODO: Initialize to an appropriate value
     DynamicDataTable target = new DynamicDataTable(table); // TODO: Initialize to an appropriate value
     IEnumerator<DynamicDataRow> expected = null; // TODO: Initialize to an appropriate value
     IEnumerator<DynamicDataRow> actual;
     actual = target.GetEnumerator();
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        public DynamicDataContainerTableProvider(DynamicDataContainerModelProvider <T> owner, DynamicDataTable table)
            : base(owner)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            this.EntityType = table.DataType;
            this.Name       = table.Name;
            this.table      = table;
        }
        /// <summary>
        ///     Provides the implementation for operations that get member values. Classes derived from the
        ///     <see
        ///         cref="T:System.Dynamic.DynamicObject" />
        ///     class can override this method to specify dynamic behavior for operations such as getting a value for a property.
        /// </summary>
        /// <param name="binder">
        ///     Provides information about the object that called the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the Console.WriteLine(sampleObject.SampleProperty) statement, where sampleObject is an instance of the class derived from the
        ///     <see
        ///         cref="T:System.Dynamic.DynamicObject" />
        ///     class, binder.Name returns "SampleProperty". The binder.IgnoreCase property specifies whether the member name is case-sensitive.
        /// </param>
        /// <param name="result">
        ///     The result of the get operation. For example, if the method is called for a property, you can assign the property value to
        ///     <paramref
        ///         name="result" />
        ///     .
        /// </param>
        /// <returns>true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a run-time exception is thrown.)</returns>
        /// <remarks>
        ///     This gets the table for the given property name.
        ///     This attempts to cache the table instance to speed up subsequent operations.
        /// </remarks>
        public override bool TryGetMember(GetMemberBinder binder, out object result) {
            result = null;

            if (_cache.ContainsKey(binder.Name)) {
                result = _cache[binder.Name];
            } else {
                if (_dataSet.Tables.Contains(binder.Name)) {
                    result = new DynamicDataTable(_dataSet.Tables[binder.Name]);
                }
                _cache.Add(binder.Name, result);
            }
            return true;
        }
Example #11
0
 public void TestDynamicDataTableConstructor()
 {
     DataTable table = null; // TODO: Initialize to an appropriate value
     DynamicDataTable target = new DynamicDataTable(table);
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
Example #12
0
        private ushort[] GetUshortsFromVariable(IMatrixMemoryVariable variable, IMatrixValue matrixValue, DynamicDataTable dynamicDataTable)
        {
            var indexOfVariable = matrixValue.MatrixTemplate.MatrixMemoryVariables.IndexOf(variable);
            var row             = dynamicDataTable.Values[indexOfVariable];
            var boolArray       = new bool[matrixValue.MatrixTemplate.NumberOfBitsOnEachVariable];



            switch (matrixValue.MatrixTemplate.MatrixVariableOptionTemplate)
            {
            case BoolMatrixVariableOptionTemplate _:
                matrixValue.MatrixTemplate.ResultBitOptions.ForEach((option =>
                                                                     boolArray[option.NumbersOfAssotiatedBits.First()] =
                                                                         (row[matrixValue.MatrixTemplate.ResultBitOptions.IndexOf(option)] as
                                                                          EditableBoolValueViewModel)
                                                                         .BoolValueProperty));
                break;

            case ListMatrixVariableOptionTemplate _:
                row.ForEach((valueViewModel =>
                {
                    if (valueViewModel is EditableChosenFromListValueViewModel chosenFromListValueViewModel &&
                        chosenFromListValueViewModel.SelectedItem != "нет")
                    {
                        var indexOfValue = row.IndexOf(valueViewModel);
                        var signature = dynamicDataTable.ColumnNamesStrings[indexOfValue];
                        var optionSelected = matrixValue.MatrixTemplate.ResultBitOptions.FirstOrDefault((option =>
                                                                                                         option.FullSignature == signature + " " + chosenFromListValueViewModel.SelectedItem));
                        ApplySelectedListValue((ListMatrixBitOption)optionSelected, boolArray, matrixValue);
                    }
                }));
                break;
            }



            var size = variable.StartAddressBit + matrixValue.MatrixTemplate.NumberOfBitsOnEachVariable;

            var newArray = new bool[size];

            boolArray.CopyTo(newArray, variable.StartAddressBit);

            var numberOfUshorts = Math.Ceiling((double)boolArray.Length / 16);

            var ushorts = new List <ushort>();

            for (int i = 0; i < numberOfUshorts; i++)
            {
                var ushortBools = boolArray.Skip(i * 16).Take(16).ToArray();
                int resUshort   = 0;
                for (int j = 0; j < ushortBools.Count(); ++j)
                {
                    if (ushortBools[j])
                    {
                        resUshort |= 1 << j;
                    }
                }
                ushorts.Add((ushort)resUshort);
            }

            return(ushorts.ToArray());
        }