//******************************************************************************************************
// InputWizardDevice.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.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using GSF.ComponentModel.DataAnnotations;
using GSF.Data;
using GSF.TimeSeries.UI;
namespace GSF.PhasorProtocols.UI.DataModels
{
///
/// Represents a record from IConfigurationFrame.
///
public class InputWizardDevice : DataModelBase
{
#region [ Members ]
// Fields
private string m_acronym;
private string m_name;
private string m_configAcronym;
private string m_configName;
private decimal m_longitude;
private decimal m_latitude;
private int? m_vendorDeviceId;
private int m_accessId = 1;
private int m_parentAccessId;
private bool m_include;
private int m_digitalCount;
private int m_analogCount;
private bool m_addDigitals;
private bool m_addAnalogs;
private bool m_existing;
private string m_statusColor;
private ObservableCollection m_phasorList;
#endregion
#region [ Properties ]
///
/// Gets or sets existing device ID, if any.
///
public int ID { get; set; }
///
/// Gets or sets and provided unique ID for the device.
///
public Guid? UniqueID { get; set; }
///
/// Gets or sets acronym of the .
///
[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(nameof(Acronym));
Existing = Device.GetDevice(null, "WHERE Acronym = '" + m_acronym.ToUpper() + "'") is not null;
}
}
///
/// Gets or sets name of the .
///
[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(nameof(Name));
}
}
///
/// Gets or sets acronym from configuration frame.
///
public string ConfigAcronym
{
get => m_configAcronym;
set
{
m_configAcronym = value;
OnPropertyChanged(nameof(ConfigAcronym));
}
}
///
/// Gets or sets name from configuration frame.
///
public string ConfigName
{
get => m_configName;
set
{
m_configName = value;
OnPropertyChanged(nameof(ConfigName));
}
}
///
/// Gets or sets Longitude.
///
public decimal Longitude
{
get => m_longitude;
set
{
m_longitude = value;
OnPropertyChanged(nameof(Longitude));
}
}
///
/// Gets or sets Latitude.
///
public decimal Latitude
{
get => m_latitude;
set
{
m_latitude = value;
OnPropertyChanged(nameof(Latitude));
}
}
///
/// Gets or sets vendor device id.
///
public int? VendorDeviceID
{
get => m_vendorDeviceId;
set
{
m_vendorDeviceId = value;
OnPropertyChanged(nameof(VendorDeviceID));
}
}
///
/// Gets or sets access id.
///
public int AccessID
{
get => m_accessId;
set
{
m_accessId = value;
OnPropertyChanged(nameof(AccessID));
}
}
///
/// Gets or sets parent access id.
///
public int ParentAccessID
{
get => m_parentAccessId;
set
{
m_parentAccessId = value;
OnPropertyChanged(nameof(ParentAccessID));
}
}
///
/// Gets or sets include flag.
///
public bool Include
{
get => m_include;
set
{
m_include = value;
OnPropertyChanged(nameof(Include));
}
}
///
/// Gets or sets digital count.
///
public int DigitalCount
{
get => m_digitalCount;
set
{
m_digitalCount = value;
OnPropertyChanged(nameof(DigitalCount));
}
}
///
/// Gets or sets analog count.
///
public int AnalogCount
{
get => m_analogCount;
set
{
m_analogCount = value;
OnPropertyChanged(nameof(AnalogCount));
}
}
///
/// Gets or sets add digitals flag.
///
public bool AddDigitals
{
get => m_addDigitals;
set
{
m_addDigitals = value;
OnPropertyChanged(nameof(AddDigitals));
}
}
///
/// Gets or sets add analog flag.
///
public bool AddAnalogs
{
get => m_addAnalogs;
set
{
m_addAnalogs = value;
OnPropertyChanged(nameof(AddAnalogs));
}
}
///
/// Gets or sets existing flag.
///
public bool Existing
{
get => m_existing;
set
{
m_existing = value;
OnPropertyChanged(nameof(Existing));
StatusColor = m_existing ? "green" : "transparent";
}
}
///
/// Gets or sets status color based on existing flag.
///
public string StatusColor
{
get => m_statusColor;
set
{
m_statusColor = value;
OnPropertyChanged(nameof(StatusColor));
}
}
///
/// Gets or sets phasor list.
///
public ObservableCollection PhasorList
{
get => m_phasorList;
set
{
m_phasorList = value;
OnPropertyChanged(nameof(PhasorList));
}
}
///
/// Gets or sets DigitalLabels.
///
public List DigitalLabels { get; set; }
///
/// Gets or sets AnalogLabels.
///
public List AnalogLabels { get; set; }
///
/// Gets or sets analog scalars, i.e., adders and multipliers.
///
public Tuple[] AnalogScalars { get; set; }
#endregion
#region [ Methods ]
///
/// Retrieves type collection of .
///
/// to connection to database.
/// Collection of .
public static ObservableCollection Load(AdoDataConnection database) =>
new();
///
/// Saves information in to database.
///
/// to connection to database.
/// Information about .
/// string, indicating success for UI display.
public static string Save(AdoDataConnection database, InputWizardDevice inputWizardDevice) =>
string.Empty;
///
/// Gets a style list of information.
///
/// to connection to database.
/// Indicates if selection on UI is optional for this collection.
/// type collection.
public static Dictionary GetLookupList(AdoDataConnection database, bool isOptional = false) =>
new();
///
/// Deletes specified record from database.
///
/// to connection to database.
/// ID of the record to be deleted.
/// String, for display use, indicating success.
public static string Delete(AdoDataConnection database, int deviceID) =>
string.Empty;
#endregion
}
///
/// Represents phasor information for from IConfigurationFrame.
///
public class InputWizardDevicePhasor : DataModelBase
{
#region [ Members ]
// Fields
private string m_label;
private string m_type;
private string m_configLabel;
private string m_configType;
private string m_phase;
private string m_baseKVInput;
//private string m_destinationLabel;
private bool m_include;
#endregion
#region [ Properties ]
///
/// Gets or sets the Label.
///
[Required(ErrorMessage = "Phasor label is a required field, please provide value.")]
[StringLength(200, ErrorMessage = "Phasor label must not exceed 200 characters.")]
public string Label
{
get => m_label;
set
{
m_label = value is null || value.Length <= 200 ? value : value.Substring(0, 200);
OnPropertyChanged("Label");
}
}
///
/// Gets or sets the Type.
///
[DefaultValue("V")]
[StringLength(1, ErrorMessage = "Phasor type must be 1 character.")]
public string Type
{
get => m_type;
set
{
m_type = value;
OnPropertyChanged("Type");
}
}
///
/// Gets or sets label from configuration frame.
///
public string ConfigLabel
{
get => m_configLabel;
set
{
m_configLabel = value;
OnPropertyChanged(nameof(ConfigLabel));
}
}
///
/// Gets or sets type from configuration frame.
///
public string ConfigType
{
get => m_configType;
set
{
m_configType = value;
OnPropertyChanged(nameof(ConfigType));
}
}
///
/// Gets or sets the Phase of the current .
///
[DefaultValue("+")]
[StringLength(1, ErrorMessage = "Phasor phase must be 1 character.")]
public string Phase
{
get => m_phase;
set
{
m_phase = value;
OnPropertyChanged("Phase");
}
}
///
/// Gets base kV integer value, i.e., nominal voltage level of line/bus associated with phasor.
///
public int BaseKV { get; private set; }
///
/// Gets or sets basekV string based binding value.
///
[DefaultValue("0")]
[RegularExpression("^[0-9]*$", ErrorMessage = "Base kV must be an integer")]
public string BaseKVInput
{
get => m_baseKVInput;
set
{
BaseKV = int.TryParse(value, out int baseKV) ? baseKV : 0;
m_baseKVInput = value;
OnPropertyChanged("BaseKVInput");
}
}
//public string DestinationLabel
//{
// get
// {
// return m_destinationLabel;
// }
// set
// {
// m_destinationLabel = value;
// OnPropertyChanged("DestinationLabel");
// }
//}
///
/// Gets or sets boolean flag indicating if needs to be saved into database.
///
public bool Include
{
get => m_include;
set
{
m_include = value;
OnPropertyChanged("Include");
if (!m_include && Phase.Length > 1)
Phase = Phase.Substring(0, 1);
}
}
///
/// Gets or sets any multiplier to be applied to the phasor magnitudes.
///
public float MagnitudeMultiplier { get; set; } = 1.0F;
///
/// Gets or sets and adder to be applied to the phasor angle, in radians.
///
public float AngleAdder { get; set; }
#endregion
}
}