/// <summary> /// /// </summary> /// <param name="recorder"></param> public FormRecordSettings(TagRecorder recorder) { InitializeComponent(); this.IsApplied = false; // Устанавливаем коллекции ComboBox из перечислений. this.comboBox_PeriodRecordingUnit.SetCollectionFromEnumeration <RecordingPeriodUnits>(); this.comboBox_SeparationFilesByPeriod.SetCollectionFromEnumeration <SeparationFilePeriodBy>(); // Присваиваем текущий редактируемый объект рекордера данных. this.CurrentRecorder = recorder; // Устанавливаем значения элементов управления. // Место расположения файла. this.textBox_FileDirectory.Text = this.CurrentRecorder.FileLocation; // Префикс названия файла. this.textBox_FileNamePrefix.Text = this.CurrentRecorder.FilePrefix; // Значения RadioButton типа записи. this.radioButton_NormalRecording.Checked = this.CurrentRecorder.RecordingType == RecordingEventType.All; this.radioButton_PeriodRecording.Checked = this.CurrentRecorder.RecordingType == RecordingEventType.ByPeriod; this.radioButton_SelectionRecording.Checked = this.CurrentRecorder.RecordingType == RecordingEventType.BySelectedTags; // Значение временного промежутка периодичной записи. this.numericUpDown_PeriodRecordingValue.Value = this.CurrentRecorder.RecordingPeriodValue; // Единица измерения временного промежутка периодичной записи. this.comboBox_PeriodRecordingUnit.SetItemFromText(Enum.GetName(typeof(RecordingPeriodUnits), this.CurrentRecorder.RecordingPeriodUnit)); // Максимальный размер файла при котором создается новая часть. this.numericUpDown_SeparationFilesBySize.Value = this.CurrentRecorder.SeparationFileSize; // Временной промежуток деления файла на части. this.comboBox_SeparationFilesByPeriod.SetItemFromText(Enum.GetName(typeof(SeparationFilePeriodBy), this.CurrentRecorder.SeparationPeriod)); // Формат временной метки одной записи. this.radioButton_TimeStampAsDateTime.Checked = !this.CurrentRecorder.TickTimeFormat; this.radioButton_TimeStampAsTicks.Checked = this.CurrentRecorder.TickTimeFormat; // Добавляем в список полный список тэгов и отмечаем выбранные. Dictionary <LogixTagHandler, LogixTagHandler> selectedTags = recorder.SelectedTags.ToDictionary(k => k, v => v); this.checkedListBox_SelectionRecording.Items.Clear(); for (int ix = 0; ix < recorder.RecordedTags.Count; ix++) { LogixTagHandler tag = recorder.RecordedTags[ix]; if (tag.OwnerTask != null) { string deviceName = tag.OwnerTask.ToString(); this.checkedListBox_SelectionRecording.Items.Add(new CheckBoxItem <LogixTagHandler>("[" + deviceName + "]" + tag.Name, tag)); if (selectedTags.ContainsKey(tag)) { this.checkedListBox_SelectionRecording.SetItemChecked(this.checkedListBox_SelectionRecording.Items.Count - 1, true); } } } DefineControlEnable(); }
/* ================================================================================================== */ #endregion /// <summary> /// /// </summary> public FormMain() { InitializeComponent(); // 1. Device Browser Control. this.deviceBrowserControl.Message += Message; this.deviceBrowserControl.TaskCollectionWasChanged += deviceBrowserControl_DeviceCollectionWasChanged; this.deviceBrowserControl.DevicePropertyWasChanged += deviceBrowserControl_DevicePropertyWasChanged; this.deviceBrowserControl.TagsValueWasChanged += deviceBrowserControl_TagsValueWasChanged; // 2. Tag Browser Control. this.tagBrowserControl.TaskCollection = deviceBrowserControl.EthernetDeviceNodes.Select(t => t.Task).ToList(); // 3. Storage of data. this.storage = new Storage(); this.storage.Message += Message; // Загружаем устройства. StorageItemInfo storageItemInfo; if (this.storage.Get(StoreOwner.AppRegistrator, StoreType.EipDevices, null, out storageItemInfo)) { this.deviceBrowserControl.SetXSettings(storageItemInfo.XContent.Element("Devices")); } // Загружаем настройки браузера тэгов. StorageItemInfo browserStorageItem; this.storage.Get(StoreOwner.AppRegistrator, StoreType.Settings, "tagbrowser", out browserStorageItem); if (browserStorageItem.IsSuccessful == true && browserStorageItem.XContent != null) { this.tagBrowserControl.SetXSettings(browserStorageItem.XContent.Element("Settings")); } // Загружаем настройки браузера сообщений. StorageItemInfo messageStorageItem; this.storage.Get(StoreOwner.AppRegistrator, StoreType.Settings, "message_control", out messageStorageItem); if (messageStorageItem.IsSuccessful == true && messageStorageItem.XContent != null) { this.messageControl.SetXSettings(messageStorageItem.XContent.Element("MessageControl")); } // 4. Recorder. this.recorder = new TagRecorder(); this.recorder.Message += Message; this.recorder.Error += Recorder_Error; StorageItemInfo recorderStorageItem; this.storage.Get(StoreOwner.AppRegistrator, StoreType.Settings, "recorder", out recorderStorageItem); if (recorderStorageItem.IsSuccessful == true && recorderStorageItem.XContent != null) { this.recorder.SetXSettings(recorderStorageItem.XContent.Element("Settings")); } // 5. Инициализация переменных. this.OnlineMode = false; this.dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromMilliseconds(500); dt.Tick += dt_Tick; dt.IsEnabled = true; }