示例#1
0
        /// <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();
        }
示例#2
0
        /// <summary>
        /// Подписка на событие : OpenFileDialog : Нажат кнопка меню "OK".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            if (e.Cancel)
            {
                return;
            }

            List <string[]> items;

            if (CsvFile.Open(openFileDialog.FileName, '\t', out items))
            {
                tagBrowserControl.Clear();

                #region [ PARSE ROW ]

                foreach (string[] item in items)
                {
                    string deviceName     = "";
                    string tagName        = "";
                    string fragmentLength = null;
                    string readUpdateRate = null;
                    string radix          = null;
                    string writeValue     = null;

                    switch (item.Length)
                    {
                    case 1:
                        tagName = item[0];
                        break;

                    case 2:
                        deviceName = item[0];
                        tagName    = item[1];
                        break;

                    case 3:
                        deviceName     = item[0];
                        tagName        = item[1];
                        fragmentLength = item[2];
                        break;

                    case 4:
                        deviceName     = item[0];
                        tagName        = item[1];
                        fragmentLength = item[2];
                        readUpdateRate = item[3];
                        break;

                    case 6:
                        deviceName     = item[0];
                        tagName        = item[1];
                        fragmentLength = item[2];
                        readUpdateRate = item[3];
                        radix          = item[3];
                        writeValue     = item[4];
                        break;
                    }


                    LogixTagHandler tag = new LogixTagHandler(tagName);

                    if (fragmentLength != null)
                    {
                        UInt16 value;
                        if (UInt16.TryParse(fragmentLength, out value))
                        {
                            tag.Type.ArrayDimension.Value = value;
                        }
                        else
                        {
                            // TODO Message.
                        }
                    }

                    if (readUpdateRate != null)
                    {
                        UInt16 value;
                        if (UInt16.TryParse(readUpdateRate, out value))
                        {
                            tag.ReadUpdateRate = value;
                        }
                        else
                        {
                            // TODO Message.
                        }
                    }

                    if (radix != null && writeValue != null)
                    {
                        TagValueRadix tagValueRadix;
                        if (Enum.TryParse <TagValueRadix>(radix, true, out tagValueRadix))
                        {
                            //if (!tag.WriteValueControl.SetValueText(0, tagValueRadix, writeValue))
                            //{
                            //    // TODO Message.
                            //}
                        }
                        else
                        {
                            // TODO Message.
                        }
                    }

                    tagBrowserControl.Add(deviceName, tag);
                }
                #endregion
            }
            else
            {
                MessageBox.Show("Error! Can't open file!", "Registrator", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
示例#3
0
 /// <summary>
 /// Создает новый аргумент события.
 /// </summary>
 /// <param name="tag"></param>
 public TagEventArgs(LogixTagHandler tag)
 {
     this.Tag = tag;
 }