protected void SetModel(object value) { if (value == null) { return; } this._recordTemplate = value as IRecordTemplate; this.AllJournalParameterEditorViewModels.Clear(); foreach (IJournalParameter journalParameter in this._recordTemplate.JournalParameters) { if (journalParameter is IComplexJournalParameter) { this.AllJournalParameterEditorViewModels.Add(this._journalParametersEditorViewModelFactory .CreateComplexJournalParameterEditorViewModel(journalParameter as IComplexJournalParameter)); } else if (journalParameter is IDependentJournalParameter) { this.AllJournalParameterEditorViewModels.Add(this._journalParametersEditorViewModelFactory .CreateDependentJournalParameterEditorViewModel(journalParameter as IDependentJournalParameter, this.GetAllJournalParameters())); } else { this.AllJournalParameterEditorViewModels.Add(this._journalParametersEditorViewModelFactory .CreateJournalParameterEditorViewModel(journalParameter)); } } }
public async Task <IJournalRecord> CreateJournalRecord(ushort[] values, IRecordTemplate recordTemplate, DeviceContext deviceContext) { if (values.All(o => o == 0)) { return(null); } IJournalRecord journalRecord = _container.Resolve <IJournalRecord>(); foreach (IJournalParameter journalParameter in recordTemplate.JournalParameters) { journalRecord.FormattedValues.AddRange( await GetValuesForRecord(journalParameter, values, deviceContext)); } return(journalRecord); }
public void Initialize(List <IFormattedValue> formattedValues, IRecordTemplate recordTemplate) { this._formattedValues = formattedValues; this._recordTemplate = recordTemplate; int numberOfValue = 0; numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.LEN)).RelatedJournalParameter); this._oscillogramCountingsNumber = (int)Math.Ceiling((this._formattedValues[numberOfValue] as INumericValue).NumValue); numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.REZ)).RelatedJournalParameter); this._sizeOfCountingInWords = (int)Math.Ceiling((this._formattedValues[numberOfValue] as INumericValue).NumValue); numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.POINT)).RelatedJournalParameter); this._pointOfStart = (int)Math.Ceiling((this._formattedValues[numberOfValue] as INumericValue).NumValue); numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.AFTER)).RelatedJournalParameter); this._sizeAfter = (int)Math.Ceiling((this._formattedValues[numberOfValue] as INumericValue).NumValue); numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.BEGIN)).RelatedJournalParameter); this._beginAddresInData = (int)Math.Ceiling((this._formattedValues[numberOfValue] as INumericValue).NumValue); numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.DATATIME)).RelatedJournalParameter); if (!(this._formattedValues[numberOfValue] is ITimeValue)) { throw new ArgumentException("Time value not on right place"); } this._dataTimeJournalValue = (this._formattedValues[numberOfValue] as ITimeValue); numberOfValue = this._recordTemplate.JournalParameters.IndexOf(this.OscilloscopeTags .First((tag => tag.TagKey == OscilloscopeKeys.ALM)).RelatedJournalParameter); this._alarm = (this._formattedValues[numberOfValue]).AsString(); }
public RecordTemplateEditorViewModel(IJournalParametersEditorViewModelFactory journalParametersEditorViewModelFactory, IFormatterEditorFactory formatterEditorFactory, IRecordTemplate recordTemplate ) { this._recordTemplate = recordTemplate; this.AllJournalParameterEditorViewModels = new ObservableCollection <IJournalParameterEditorViewModel>(); this._journalParametersEditorViewModelFactory = journalParametersEditorViewModelFactory; this._formatterEditorFactory = formatterEditorFactory; this.AddRecordParameterCommand = new RelayCommand(this.OnAddRecordParameterExecute); this.AddComplexRecordParameterCommand = new RelayCommand(this.OnAddComplexRecordParameterExecute); this.EditElementCommand = new RelayCommand(this.OnEditElementExecute, this.CanExecuteEditElement); this.SetElementUpCommand = new RelayCommand(this.OnSetElementUpExecute, this.CanExecuteSetElementUp); this.SetElementDownCommand = new RelayCommand(this.OnSetElementDownExecute, this.CanExecuteSetElementDown); this.DeleteElementCommand = new RelayCommand(this.OnDeleteElementExecute, this.CanDeleteElementDown); this.AddDependentParameterCommand = new RelayCommand(this.OnAddDependentParameterExecute); this.ShowFormatterParametersCommand = new RelayCommand(this.OnShowFormatterParametersExecute, this.CanShowFormatterParametersExecute); }
private static bool CheckRecordByTemplate(IRecordTemplate recordTemplate, IJournalRecord journalRecord) { var recordTemplateCounter = 0; foreach (var journalParameter in recordTemplate.JournalParameters) { var res = CheckRecordByParameter(journalRecord, journalParameter, recordTemplateCounter); recordTemplateCounter = res.Item2; if (!res.Item1) { return(false); } } if (journalRecord.FormattedValues.Count != recordTemplateCounter) { return(false); } return(true); }
private static bool CheckRecordTemplateCorrespondsValues(IRecordTemplate recordTemplate, List <IJournalRecord> journalRecords) { return(journalRecords.All(record => CheckRecordByTemplate(recordTemplate, record))); }
public UniconJournal(IRecordTemplate recordTemplate) { RecordTemplate = recordTemplate; JournalRecords = new List <IJournalRecord>(); }