init
This commit is contained in:
84
DataPRO/SensorDB/StreamOutputSetting.cs
Normal file
84
DataPRO/SensorDB/StreamOutputSetting.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using DTS.Common.Classes;
|
||||
using DTS.Common.Classes.Sensors;
|
||||
using DTS.Common.Enums;
|
||||
using DTS.Common.Enums.Sensors;
|
||||
using DTS.Common.Interface.Sensors;
|
||||
using DTS.Common.Storage;
|
||||
using DTS.Common.Utilities.Logging;
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace DTS.SensorDB
|
||||
{
|
||||
public class StreamOutputSetting : SensorData
|
||||
{
|
||||
///<summary>
|
||||
///</summary>
|
||||
public StreamOutputSetting() : base()
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
public StreamOutputSetting(StreamOutputSetting copy) : base(copy)
|
||||
{
|
||||
SetDefaults(this);
|
||||
}
|
||||
|
||||
public StreamOutputSetting(IStreamOutputRecord record)
|
||||
{
|
||||
SetDefaults(this);
|
||||
try
|
||||
{
|
||||
DatabaseId = record.Id;
|
||||
SerialNumber = record.SerialNumber;
|
||||
|
||||
StreamOutUDPProfile = record.StreamOutUDPProfile;
|
||||
StreamOutUDPAddress = record.StreamOutUDPAddress;
|
||||
StreamOutUDPTimeChannelId = record.StreamOutUDPTimeChannelId;
|
||||
StreamOutUDPDataChannelId = record.StreamOutUDPDataChannelId;
|
||||
StreamOutUDPTmNSConfig = record.StreamOutUDPTmNSConfig;
|
||||
StreamOutIRIGTimeDataPacketIntervalMs = record.StreamOutIRIGTimeDataPacketIntervalMs;
|
||||
StreamOutTMATSIntervalMs = record.StreamOutTMATSIntervalMs;
|
||||
Broken = record.Broken;
|
||||
DoNotUse = record.DoNotUse;
|
||||
LastModified = record.LastModified;
|
||||
LastUpdatedBy = record.LastUpdatedBy;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APILogger.Log("Failed to process: ", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetDefaults(SensorData sd)
|
||||
{
|
||||
sd.SupportedExcitation = new Common.Enums.ExcitationVoltageOptions.ExcitationVoltageOption[] { ExcitationVoltageOptions.ExcitationVoltageOption.Undefined };
|
||||
sd.Bridge = SensorConstants.BridgeType.StreamOut;
|
||||
sd.AxisNumber = 0;
|
||||
sd.NumberOfAxes = 1;
|
||||
sd.Capacity = 1;
|
||||
sd.DisplayUnit = "";
|
||||
sd.BridgeResistance = double.NaN;
|
||||
sd.CheckOffset = false;
|
||||
sd.Manufacturer = "Generic";
|
||||
sd.OffsetToleranceHigh = 0;
|
||||
sd.OffsetToleranceLow = 0;
|
||||
sd.Model = "Stream Output Setting";
|
||||
sd.Shunt = ShuntMode.None;
|
||||
sd.MeasureExcitation = false;
|
||||
sd.MeasureNoise = false;
|
||||
}
|
||||
|
||||
public static void Commit(SensorData setting)
|
||||
{
|
||||
SetDefaults(setting);
|
||||
|
||||
IStreamOutputRecord record = new StreamOutputRecord(setting);
|
||||
var hr = DbOperations.SensorsStreamOutputUpdateInsert(ref record);
|
||||
if (0 == hr)
|
||||
{
|
||||
setting.DatabaseId = record.Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user