1722 lines · 85.6 KB · C#
RawDownload
//******************************************************************************************************//  Device.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://  ----------------------------------------------------------------------------------------------------//  04/11/2011 - Aniket Salver//       Generated original version of source code.//  04/21/2011 - Mehulbhai P Thakkar//       Added static methods for database operations.//  05/02/2011 - J. Ritchie Carroll//       Updated for coding consistency.//  05/03/2011 - Mehulbhai P Thakkar//       Guid field related changes as well as static functions update.//  05/05/2011 - Mehulbhai P Thakkar//       Added NULL value and Guid parameter handling for Save() operation.//  05/12/2011 - Aniket Salver//       Modified the way Guid is retrieved from the Data Base.//  05/13/2011 - Mehulbhai P Thakkar//       Added regular expression validation for Acronym.//  05/21/2011 - Mehulbhai P Thakkar//       Modified Save method to create or update associated measurements.//  09/23/2011 - Mehulbhai P Thakkar//       Added static method to retrieve new devices for output stream.//  09/14/2012 - Aniket Salver //       Added paging and sorting technique. //****************************************************************************************************** using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.ComponentModel;using System.ComponentModel.DataAnnotations;using System.Data;using System.Linq;using System.Text.RegularExpressions;using GSF.ComponentModel.DataAnnotations;using GSF.Configuration;using GSF.Data;using GSF.Diagnostics;using GSF.TimeSeries.UI;using PhasorProtocolAdapters;using Measurement = GSF.TimeSeries.UI.DataModels.Measurement; // ReSharper disable ConstantConditionalAccessQualifiernamespace GSF.PhasorProtocols.UI.DataModels{    #region [ Enumerations ]     /// <summary>    /// Device type enumeration.    /// </summary>    public enum DeviceType    {        /// <summary>        /// All types of devices        /// </summary>        /// <remarks>        /// Use this option to return all types of devices.        /// </remarks>        All,        /// <summary>        /// Concentrator devices such as PDC.        /// </summary>        /// <remarks>        /// Use this option just to return concentrating devices.        /// </remarks>        Concentrator,        /// <summary>        /// Direct connected devices such as field PMUs.        /// </summary>        /// <remarks>        /// Use this option to return directly connected devices.        /// </remarks>        DirectConnected    }     #endregion     /// <summary>    /// Represents a record of <see cref="Device"/> information as defined in the database.    /// </summary>    public class Device : DataModelBase    {        #region [ Members ]         // Fields        private Guid m_nodeID;        private int? m_parentID;        private Guid m_uniqueID;        private string m_acronym;        private string m_name;        private bool m_isConcentrator;        private int? m_companyID;        private int? m_historianID;        private int m_accessID;        private int? m_vendorDeviceID;        private int? m_protocolID;        private decimal? m_longitude;        private decimal? m_latitude;        private int? m_interconnectionID;        private string m_connectionString;        private string m_timeZone;        private int? m_framesPerSecond;        private long m_timeAdjustmentTicks;        private double m_dataLossInterval;        private bool m_connectOnDemand;        private string m_contactList;        private int? m_measuredLines;        private int m_loadOrder;        private bool m_enabled;        private int m_allowedParsingExceptions;        private double m_parsingExceptionWindow;        private double m_delayedConnectionInterval;        private bool m_allowUseOfCachedConfiguration;        private bool m_autoStartDataParsingSequence;        private bool m_skipDisableRealTimeData;        private int m_measurementReportingInterval;        private string m_companyAcronym;        private string m_alternateCommandChannel;         #endregion         #region [ Properties ]         /// <summary>        /// Gets or sets <see cref="Device"/> NodeID.        /// </summary>        [Required(ErrorMessage = "Device node ID is a required field, please provide value.")]        public Guid NodeID        {            get => m_nodeID;            set            {                m_nodeID = value;                OnPropertyChanged("NodeID");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> ID.        /// </summary>        // Field is populated by database via auto-increment and has no screen interaction, so no validation attributes are applied        public int ID { get; set; }         /// <summary>        /// Gets or sets <see cref="Device"/> ParentID.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? ParentID        {            get => m_parentID;            set            {                m_parentID = value;                OnPropertyChanged("ParentID");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> UniqueID.        /// </summary>        public Guid UniqueID        {            get => m_uniqueID;            set            {                m_uniqueID = value;                OnPropertyChanged("UniqueID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> Acronym.        /// </summary>        [Required(ErrorMessage = "Device acronym is a required field, please provide value.")]        [StringLength(200, ErrorMessage = "Device Acronym cannot exceed 200 characters.")]        [AcronymValidation]        public string Acronym        {            get => m_acronym;            set            {                m_acronym = value.Replace("'", "").Replace(" ", "_").ToUpper();                if (m_acronym.Length > 200)                    m_acronym = m_acronym.Substring(0, 200);                 OnPropertyChanged("Acronym");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/>  Name.        /// </summary>        [StringLength(200, ErrorMessage = "Device Name cannot exceed 200 characters.")]        public string Name        {            get => m_name;            set            {                m_name = value is null || value.Length <= 200 ? value : value.Substring(0, 200);                OnPropertyChanged("Name");            }        }         /// <summary>        /// Gets <see cref="Device"/> Original Source.        /// </summary>                public string OriginalSource { get; private set; }         /// <summary>        ///  Gets or sets <see cref="Device"/> IsConcenttrator.        /// </summary>        [DefaultValue(false)]        public bool IsConcentrator        {            get => m_isConcentrator;            set            {                m_isConcentrator = value;                OnPropertyChanged("IsConcentrator");                 if (m_isConcentrator)                    ParentID = null;            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> CompanyID.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? CompanyID        {            get => m_companyID;            set            {                m_companyID = value;                OnPropertyChanged("CompanyID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> HistrianID.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? HistorianID        {            get => m_historianID;            set            {                m_historianID = value;                OnPropertyChanged("HistorianID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> AccessID.        /// </summary>        [Required(ErrorMessage = "Device access ID is a required field, please provide value.")]        [DefaultValue(0)]        public int AccessID        {            get => m_accessID;            set            {                m_accessID = value;                OnPropertyChanged("AccessID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> VendorDeviceID.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? VendorDeviceID        {            get => m_vendorDeviceID;            set            {                m_vendorDeviceID = value;                OnPropertyChanged("VendorDeviceID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> protocolID.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? ProtocolID        {            get => m_protocolID;            set            {                m_protocolID = value;                OnPropertyChanged("ProtocolID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> Longitude.        /// </summary>        // Because of database design, no validation attributes are applied.                [RegularExpression(@"^[-]?([0-9]{1,3})?([.][0-9]{1,6})?$", ErrorMessage = "Invalid value. Please provide value in decimal(9,6) format.")]        public decimal? Longitude        {            get => m_longitude;            set            {                m_longitude = value?.Normalize();                OnPropertyChanged("Longitude");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> Latitude.        /// </summary>        // Because of database design, no validation attributes are applied.                [RegularExpression(@"^[-]?([0-9]{1,3})?([.][0-9]{1,6})?$", ErrorMessage = "Invalid value. Please provide value in decimal(9,6) format.")]        public decimal? Latitude        {            get => m_latitude;            set            {                m_latitude = value?.Normalize();                OnPropertyChanged("Latitude");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> InterconnectionID.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? InterconnectionID        {            get => m_interconnectionID;            set            {                m_interconnectionID = value;                OnPropertyChanged("InterconnectionID");            }        }         /// <summary>        ///  Gets or sets <see cref="Device"/> ConnectionString.        /// </summary>        // Because of database design, no validation attributes are applied.        public string ConnectionString        {            get => m_connectionString;            set            {                m_connectionString = value;                OnPropertyChanged("ConnectionString");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> TimeZone.        /// </summary>        [StringLength(200, ErrorMessage = "Device Time Zone cannot exceed 200 characters.")]        public string TimeZone        {            get => m_timeZone;            set            {                m_timeZone = value;                OnPropertyChanged("TimeZone");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> FramesPerSecond.        /// </summary>        [DefaultValue(30)]        public int? FramesPerSecond        {            get => m_framesPerSecond;            set            {                m_framesPerSecond = value;                OnPropertyChanged("FramesPerSecond");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> TimeAdjustmentTicks.        /// </summary>        [Required(ErrorMessage = "Device time adjustment ticks is a required field, please provide value.")]        [DefaultValue(0L)]        public long TimeAdjustmentTicks        {            get => m_timeAdjustmentTicks;            set            {                m_timeAdjustmentTicks = value;                OnPropertyChanged("TimeAdjustmentTicks");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> DataLossInterval.        /// </summary>        [Required(ErrorMessage = "Device data loss interval is a required field, please provide value.")]        [DefaultValue(typeof(double), "5")]        public double DataLossInterval        {            get => m_dataLossInterval;            set            {                m_dataLossInterval = value;                OnPropertyChanged("DataLossInterval");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/>ConnectOnDemand.        /// </summary>        [Required(ErrorMessage = "ConnectOnDemand is a required field, please provide value.")]        [DefaultValue(false)]        public bool ConnectOnDemand        {            get => m_connectOnDemand;            set            {                m_connectOnDemand = value;                OnPropertyChanged("ConnectOnDemand");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> ContactList.        /// </summary>        // Because of database design, no validation attributes are applied.        public string ContactList        {            get => m_contactList;            set            {                m_contactList = value;                OnPropertyChanged("ContactList");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> MeasuredLines.        /// </summary>        // Because of database design, no validation attributes are applied.        public int? MeasuredLines        {            get => m_measuredLines;            set            {                m_measuredLines = value;                OnPropertyChanged("MeasuredLines");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> LoadOrder.        /// </summary>        [Required(ErrorMessage = "Device load order is a required field, please provide value.")]        [DefaultValue(0)]        public int LoadOrder        {            get => m_loadOrder;            set            {                m_loadOrder = value;                OnPropertyChanged("LoadOrder");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> Enabled.        /// </summary>        [DefaultValue(false)]        public bool Enabled        {            get => m_enabled;            set            {                m_enabled = value;                OnPropertyChanged("Enabled");            }        }         /// <summary>        /// Gets or sets <see cref="Device"/> AllowedParsingExceptions.

Lines 1–500 of 1722.

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