1977 lines · 87.6 KB · C#
RawDownload
//******************************************************************************************************//  InputWizardDevices.cs - Gbtc////  Copyright © 2010, Grid Protection Alliance.  All Rights Reserved.////  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See//  the NOTICE file distributed with this work for additional information regarding copyright ownership.//  The GPA licenses this file to you under the MIT License (MIT), the "License"; you may//  not use this file except in compliance with the License. You may obtain a copy of the License at:////      http://www.opensource.org/licenses/MIT////  Unless agreed to in writing, the subject software distributed under the License is distributed on an//  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the//  License for the specific language governing permissions and limitations.// //  Code Modification History://  ----------------------------------------------------------------------------------------------------//  05/24/2011 - Mehulbhai P Thakkar//       Generated original version of source code.////****************************************************************************************************** using System;using System.Collections;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.Globalization;using System.IO;using System.Linq;using System.Runtime.Serialization.Formatters;using System.Runtime.Serialization.Formatters.Soap;using System.Text;using System.Text.RegularExpressions;using System.Threading;using System.Windows;using System.Windows.Forms;using System.Windows.Input;using System.Windows.Threading;using GSF.Communication;using GSF.ComponentModel.DataAnnotations;using GSF.Data;using GSF.PhasorProtocols.BPAPDCstream;using GSF.PhasorProtocols.IEEEC37_118;using GSF.PhasorProtocols.UI.DataModels;using GSF.PhasorProtocols.UI.Modal;using GSF.PhasorProtocols.UI.UserControls;using GSF.ServiceProcess;using GSF.TimeSeries.UI;using GSF.TimeSeries.UI.Commands;using GSF.TimeSeries.UI.DataModels;using GSF.Units.EE;using PhasorProtocolAdapters;using Application = System.Windows.Application;using Cursors = System.Windows.Input.Cursors;using Phasor = GSF.PhasorProtocols.UI.DataModels.Phasor; namespace GSF.PhasorProtocols.UI.ViewModels{    /// <summary>    /// Bindable class to hold collection of <see cref="InputWizardDevice"/>.    /// </summary>    internal class InputWizardDevices : PagedViewModelBase<InputWizardDevice, string>, IDataErrorInfo    {        #region [ Members ]         // Fields        private RelayCommand m_launchWalkthroughCommand;        private RelayCommand m_browseConnectionFileCommand;        private RelayCommand m_buildConnectionStringCommand;        private RelayCommand m_buildAlternateCommandChannelCommand;        private RelayCommand m_browseIniFileCommand;        private RelayCommand m_browseConfigurationFileCommand;        private RelayCommand m_requestConfigurationCommand;        private RelayCommand m_saveConfigurationFileCommand;        private RelayCommand m_manualConfigurationCommand;        private RelayCommand m_cancelConfigurationRequestCommand;        private bool m_stepsEnabled;        private bool m_stepOneExpanded;        private bool m_stepTwoExpanded;        private bool m_stepThreeExpanded;        private string m_connectionString;        private string m_alternateCommandChannel;        private int m_accessID;        private int[] m_deviceIDs;        private string[] m_deviceAcronyms;        private int m_protocolID;        private string m_protocolAcronym;        private bool m_connectToConcentrator;        private int? m_pdcID;        private string m_pdcAcronym;        private string m_pdcName;        private int m_pdcVendorDeviceID;        private int m_pdcFrameRate;        private int m_companyID;        private int m_historianID;        private int m_interconnectionID;        private bool m_skipDisableRealTimeData;        private bool m_requestConfigurationPopupIsOpen;        private string m_requestConfigurationPopupText;        private bool m_requestConfigurationSuccess;        private readonly ObservableCollection<Protocol> m_protocolList;        private string m_connectionFileName;        private string m_configurationFileName;        private string m_iniFileName;        private string m_pdcMessage;        private string m_configurationSummary;        private IConfigurationFrame m_configurationFrame;        private string m_requestConfigurationError;        private object m_requestConfigurationAttachment;        private Device m_pdcDevice;        private bool m_newDeviceConfiguration;        private readonly Dispatcher m_dispatcher;        private readonly Dictionary<string, string> m_errorMessages;         #endregion         #region [ Constructors ]         /// <summary>        /// Creates an instance of <see cref="InputWizardDevices"/> class.        /// </summary>        /// <param name="itemsPerPage">Integer value to determine number of items per page.</param>        /// <param name="autoSave">Boolean value to determine is user changes should be saved automatically.</param>        public InputWizardDevices(int itemsPerPage, bool autoSave = true)            : base(itemsPerPage, autoSave)        {            CompanyLookupList = Company.GetLookupList(null, true);            HistorianLookupList = TimeSeries.UI.DataModels.Historian.GetLookupList(null, true, false);            InterconnectionLookupList = Interconnection.GetLookupList(null, true);            ProtocolLookupList = Protocol.GetLookupList(null);            VendorDeviceLookupList = VendorDevice.GetLookupList(null, true);            m_protocolList = Protocol.Load(null);            PdcFrameRate = 30;            StepsEnabled = true;            StepOneExpanded = true;            NewDeviceConfiguration = true;             if (CompanyLookupList.Count > 0)                CompanyID = CompanyLookupList.First().Key;             if (HistorianLookupList.Count > 1)                HistorianID = HistorianLookupList.Skip(1).First().Key;            else if (HistorianLookupList.Count > 0)                HistorianID = HistorianLookupList.First().Key;             if (InterconnectionLookupList.Count > 0)                InterconnectionID = InterconnectionLookupList.First().Key;             if (ProtocolLookupList.Count > 0)                ProtocolID = ProtocolLookupList.First().Key;             if (VendorDeviceLookupList.Count > 0)                PdcVendorDeviceID = VendorDeviceLookupList.First().Key;             m_dispatcher = Dispatcher.CurrentDispatcher;            m_errorMessages = new Dictionary<string, string>();        }         #endregion         #region [ Properties ]         /// <summary>        /// Gets flag that determines if <see cref="PagedViewModelBase{T1, T2}.CurrentItem"/> is a new record.        /// </summary>        public override bool IsNewRecord => CurrentItem.ID == 0; // string.IsNullOrEmpty(CurrentItem.Acronym);         /// <summary>        /// Gets or sets flag that determines whether the wizard steps are enabled.        /// </summary>        public bool StepsEnabled        {            get => m_stepsEnabled;            private set            {                m_stepsEnabled = value;                OnPropertyChanged(nameof(StepsEnabled));            }        }         /// <summary>        /// Gets or sets flag that determines whether step 1 is expanded.        /// </summary>        public bool StepOneExpanded        {            get => m_stepOneExpanded;            set            {                m_stepOneExpanded = value;                OnPropertyChanged(nameof(StepOneExpanded));            }        }         /// <summary>        /// Gets or sets flag that determines whether step 2 is expanded.        /// </summary>        public bool StepTwoExpanded        {            get => m_stepTwoExpanded;            set            {                m_stepTwoExpanded = value;                OnPropertyChanged(nameof(StepTwoExpanded));            }        }         /// <summary>        /// Gets or sets flag that determines whether step 3 is expanded.        /// </summary>        public bool StepThreeExpanded        {            get => m_stepThreeExpanded;            set            {                m_stepThreeExpanded = value;                OnPropertyChanged(nameof(StepThreeExpanded));            }        }         /// <summary>        /// Gets or sets name of the connection file used for configuration.        /// </summary>        public string ConnectionFileName        {            get => m_connectionFileName;            set            {                m_connectionFileName = value;                OnPropertyChanged(nameof(ConnectionFileName));            }        }         /// <summary>        /// Gets or sets name of the XML configuration file used for configuration.        /// </summary>        public string ConfigurationFileName        {            get => m_configurationFileName;            set            {                m_configurationFileName = value;                OnPropertyChanged(nameof(ConfigurationFileName));            }        }         /// <summary>        /// Gets or sets name of the INI file used for configuration.        /// </summary>        public string IniFileName        {            get => m_iniFileName;            set            {                m_iniFileName = value;                OnPropertyChanged(nameof(IniFileName));            }        }         /// <summary>        /// Gets <see cref="Dictionary{T1,T2}"/> type collection of <see cref="Company"/> defined in the database.        /// </summary>        public Dictionary<int, string> CompanyLookupList { get; }         /// <summary>        /// Gets <see cref="Dictionary{T1,T2}"/> type collection of <see cref="Historian"/> defined in the database.        /// </summary>        public Dictionary<int, string> HistorianLookupList { get; }         /// <summary>        /// Gets <see cref="Dictionary{T1,T2}"/> type collection of <see cref="Interconnection"/> defined in the database.        /// </summary>        public Dictionary<int, string> InterconnectionLookupList { get; }         /// <summary>        /// Gets <see cref="Dictionary{T1,T2}"/> type collection of <see cref="Protocol"/> defined in the database.        /// </summary>        public Dictionary<int, string> ProtocolLookupList { get; }         /// <summary>        /// Gets <see cref="Dictionary{T1,T2}"/> type collection of <see cref="VendorDevice"/> defined in the database.        /// </summary>        public Dictionary<int, string> VendorDeviceLookupList { get; }         /// <summary>        /// Gets or sets connection string to back-end service.        /// </summary>        public string ConnectionString        {            get => m_connectionString;            set            {                m_connectionString = value;                OnPropertyChanged(nameof(ConnectionString));            }        }         /// <summary>        /// Gets or sets command channel to communicate with back-end service.        /// </summary>        public string AlternateCommandChannel        {            get => m_alternateCommandChannel;            set            {                m_alternateCommandChannel = value;                OnPropertyChanged(nameof(AlternateCommandChannel));            }        }         /// <summary>        /// Gets or sets ID of the device to be configured.        /// </summary>        public int AccessID        {            get => m_accessID;            set            {                m_accessID = value;                OnPropertyChanged(nameof(AccessID));            }        }         /// <summary>        /// Gets or sets device IDs.        /// </summary>        public int[] DeviceIDs        {            get => m_deviceIDs ?? (m_deviceIDs = Array.Empty<int>());            set            {                m_deviceIDs = value;                OnPropertyChanged(nameof(DeviceIDs));            }        }         /// <summary>        /// Gets or sets device acronyms.        /// </summary>        public string[] DeviceAcronyms        {            get => m_deviceAcronyms ?? (m_deviceAcronyms = Array.Empty<string>());            set            {                m_deviceAcronyms = value;                OnPropertyChanged(nameof(DeviceAcronyms));            }        }         /// <summary>        /// Gets or sets protocol id for devices to be configured.        /// </summary>        public int ProtocolID        {            get => m_protocolID;            set            {                m_protocolID = value;                OnPropertyChanged(nameof(ProtocolID));                ProtocolAcronym = ProtocolLookupList[m_protocolID];            }        }         /// <summary>        /// Gets or sets protocol acronym for devices to be configured.        /// </summary>        public string ProtocolAcronym        {            get => m_protocolAcronym;            set            {                m_protocolAcronym = value;                OnPropertyChanged(nameof(ProtocolAcronym));                OnPropertyChanged(nameof(ProtocolIsBpaPdcStream));            }        }         /// <summary>        /// Gets a flag indicating if selected protocol is BpaPdcStream.         /// This is used to hide or display INI file selection on input wizard screen.        /// </summary>        public bool ProtocolIsBpaPdcStream => string.Equals(m_protocolAcronym, "BPAPDCstream", StringComparison.OrdinalIgnoreCase);         /// <summary>        /// Gets or sets boolean value indicating if connection is to concentrator.        /// </summary>        public bool ConnectToConcentrator        {            get => m_connectToConcentrator;            set            {                m_connectToConcentrator = value;                OnPropertyChanged(nameof(ConnectToConcentrator));                ValidatePdcAcronym();            }        }         /// <summary>        /// Gets or sets ID of the concentrator device.        /// </summary>        public int? PdcID        {            get => m_pdcID;            set            {                m_pdcID = value;                OnPropertyChanged(nameof(PdcID));            }        }         /// <summary>        /// Gets or sets acronym of the concentrator device.        /// </summary>        public string PdcAcronym        {            get => m_pdcAcronym;            set            {                m_pdcAcronym = value.Replace(" ", "_").Replace("'", "").ToUpper();                ValidatePdcAcronym();            }        }         /// <summary>        /// Gets or sets message to be displayed on the screen when PDC acronym changes.        /// </summary>        public string PdcMessage        {            get => m_pdcMessage;            set            {                m_pdcMessage = value;                OnPropertyChanged(nameof(PdcMessage));            }        }         /// <summary>        /// Gets or sets name of the concentrator device.        /// </summary>        public string PdcName        {            get => m_pdcName;            set            {                m_pdcName = value;                OnPropertyChanged(nameof(PdcName));            }        }         /// <summary>        /// Gets or sets vendor device id for this configuration.        /// </summary>        public int PdcVendorDeviceID        {            get => m_pdcVendorDeviceID;            set            {                m_pdcVendorDeviceID = value;                OnPropertyChanged(nameof(PdcVendorDeviceID));            }        }         /// <summary>        /// Gets or sets frame rate for this configuration.        /// </summary>        public int PdcFrameRate        {            get => m_pdcFrameRate;            set            {                m_pdcFrameRate = value;                OnPropertyChanged(nameof(PdcFrameRate));            }        }         /// <summary>        /// Gets or sets company ID to which devices are to be associated in this configuration.        /// </summary>        public int CompanyID        {            get => m_companyID;            set            {                m_companyID = value;                OnPropertyChanged(nameof(CompanyID));            }        }         /// <summary>        /// Gets or sets Historian ID to which devices are to be associated in this configuration.        /// </summary>        public int HistorianID        {            get => m_historianID;            set            {                m_historianID = value;                OnPropertyChanged(nameof(HistorianID));            }

Lines 1–500 of 1977.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t