init
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
using System;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
/// <summary>
|
||||
/// the scaler is a bit different than an ordinary scaler, so the name here is inaccurate, however the idea is
|
||||
/// that we allow the user to transform collected data, primarly by allowing them to define the 0,1 value of the digital output
|
||||
/// </summary>
|
||||
public class DigitalInputScaleMultiplier
|
||||
{
|
||||
/// <summary>
|
||||
/// the format the scaler is in
|
||||
/// </summary>
|
||||
public enum Forms { ArbitraryLowAndHigh };
|
||||
|
||||
public Forms Form { get; set; } = Forms.ArbitraryLowAndHigh;
|
||||
|
||||
/// <summary>
|
||||
/// for arbirary low/high, this is the low value, the value 0 should be displayed as (OFF)
|
||||
/// </summary>
|
||||
public double DefaultValue { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// for arbitrary low/high, this is the high value, the value 1 should be displayed as (ON)
|
||||
/// </summary>
|
||||
public double ActiveValue { get; set; } = 1D;
|
||||
|
||||
/// <summary>
|
||||
/// constructor and copy constructor
|
||||
/// </summary>
|
||||
public DigitalInputScaleMultiplier()
|
||||
{
|
||||
DefaultValue = 0D;
|
||||
}
|
||||
|
||||
public DigitalInputScaleMultiplier(DigitalInputScaleMultiplier copy)
|
||||
{
|
||||
Form = copy.Form;
|
||||
DefaultValue = copy.DefaultValue;
|
||||
ActiveValue = copy.ActiveValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// deserializes an arbitrary low/high from a string
|
||||
/// </summary>
|
||||
/// <param name="tokens"></param>
|
||||
private void FromDbSerializeStringLowAndHigh(string[] tokens)
|
||||
{
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for scale multiplier"); }
|
||||
double d;
|
||||
if (double.TryParse(tokens[1], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
DefaultValue = d;
|
||||
}
|
||||
else { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for low value: " + tokens[1]); }
|
||||
|
||||
if (double.TryParse(tokens[2], System.Globalization.NumberStyles.Any, System.Globalization.CultureInfo.InvariantCulture, out d))
|
||||
{
|
||||
ActiveValue = d;
|
||||
}
|
||||
else { throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeStringLowAndHigh invalid format for high value: " + tokens[2]); }
|
||||
}
|
||||
/// <summary>
|
||||
/// deserializes a scaler from a string, regardless of format
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void FromDbSerializeString(string s)
|
||||
{
|
||||
if (null == s)
|
||||
{
|
||||
//Utilities.Logging.APILogger.Log("Unable to serialize Db. String is null.");
|
||||
|
||||
//FIXME is this the right thing to do?
|
||||
return;
|
||||
//throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString nothing to parse");
|
||||
}
|
||||
|
||||
var tokens = s.Split(new[] { System.Globalization.CultureInfo.InvariantCulture.TextInfo.ListSeparator }, StringSplitOptions.None);
|
||||
if (Enum.TryParse(tokens[0], out Forms form))
|
||||
{
|
||||
Form = form;
|
||||
switch (form)
|
||||
{
|
||||
case Forms.ArbitraryLowAndHigh: FromDbSerializeStringLowAndHigh(tokens); break;
|
||||
default: throw new NotSupportedException("DigitalInputScaleMultiplier::FromDbSerializeString unsupported form " + form);
|
||||
}
|
||||
}
|
||||
else { throw new NotSupportedException("DigitalINputScaleMultiplier::FromDbSerializeString unsupported format: " + s); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
public class LinearizationFormula
|
||||
{
|
||||
private bool _bIsValid;
|
||||
// public bool IsValid() { return _bIsValid; }
|
||||
public void MarkValid(bool bValid)
|
||||
{
|
||||
_bIsValid = bValid;
|
||||
}
|
||||
public NonLinearStyles NonLinearStyle { get; set; } = NonLinearStyles.IRTraccDiagnosticsZero;
|
||||
|
||||
public double PolynomialSensitivity { get; set; } = 1D;
|
||||
|
||||
public double LinearizationExponent { get; set; } = 1D;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// THIS IS MM/V, (UI has already been updated, we need to update the variable name)
|
||||
/// </summary>
|
||||
public double MMPerV { get; set; }
|
||||
|
||||
public double MVAt0MM { get; set; }
|
||||
|
||||
public double Slope { get; set; }
|
||||
|
||||
public double Intercept { get; set; }
|
||||
|
||||
public double CalibrationFactor { get; set; }
|
||||
|
||||
public double ZeroPositionIntercept { get; set; }
|
||||
|
||||
public LinearizationFormula()
|
||||
{
|
||||
ZeroPositionIntercept = 0D;
|
||||
CalibrationFactor = 0D;
|
||||
Intercept = 0D;
|
||||
_coefficients = new List<double>(new double[] { 0, 0, 0, 0 });
|
||||
_exponents = new List<double>(new double[] { 0, 1, 2, 3 });
|
||||
}
|
||||
|
||||
public LinearizationFormula(LinearizationFormula copy)
|
||||
{
|
||||
UsemVOverVForPolys = copy.UsemVOverVForPolys;
|
||||
_bIsValid = copy._bIsValid;
|
||||
_coefficients = new List<double>(copy._coefficients.ToArray());
|
||||
_exponents = new List<double>(copy._exponents.ToArray());
|
||||
Intercept = copy.Intercept;
|
||||
LinearizationExponent = copy.LinearizationExponent;
|
||||
MMPerV = copy.MMPerV;
|
||||
MVAt0MM = copy.MVAt0MM;
|
||||
Slope = copy.Slope;
|
||||
NonLinearStyle = copy.NonLinearStyle;
|
||||
_coefficients = new List<double>(copy._coefficients);
|
||||
_exponents = new List<double>(copy._exponents);
|
||||
PolynomialSensitivity = copy.PolynomialSensitivity;
|
||||
ZeroPositionIntercept = copy.ZeroPositionIntercept;
|
||||
CalibrationFactor = copy.CalibrationFactor;
|
||||
}
|
||||
public bool UsemVOverVForPolys { get; set; } = true;
|
||||
private List<double> _coefficients = new List<double>();
|
||||
private List<double> _exponents = new List<double>();
|
||||
public void FromIRTraccCalFactorString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("Invalid CalFactor format: " + s); }
|
||||
|
||||
CalibrationFactor = double.Parse(tokens[0], culture);
|
||||
LinearizationExponent = double.Parse(tokens[1], culture);
|
||||
ZeroPositionIntercept = double.Parse(tokens[2], culture);
|
||||
}
|
||||
public void FromIRTraccDiagnosticZeroString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 2) { throw new NotSupportedException("Invalid DiagnosticsZero format: " + s); }
|
||||
MMPerV = double.Parse(tokens[0], culture);
|
||||
LinearizationExponent = double.Parse(tokens[1], culture);
|
||||
}
|
||||
public void FromIRTraccManualString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("Invalid IRTraccManual format: " + s); }
|
||||
Slope = double.Parse(tokens[0], culture);
|
||||
Intercept = double.Parse(tokens[1], culture);
|
||||
LinearizationExponent = double.Parse(tokens[2], culture);
|
||||
}
|
||||
public void FromIRTraccAverageOverTimeString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 2) { throw new NotSupportedException("Invalid IRTRaccAverageOverTime format: " + s); }
|
||||
MMPerV = double.Parse(tokens[0], culture);
|
||||
LinearizationExponent = double.Parse(tokens[1], culture);
|
||||
}
|
||||
public void FromIRTraccZeroMMmVString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
var tokens = s.Split('x');
|
||||
if (tokens.Length < 3) { throw new NotSupportedException("Invalid IRTraccZeroMMmV format: " + s); }
|
||||
MMPerV = double.Parse(tokens[0], culture);
|
||||
MVAt0MM = double.Parse(tokens[1], culture);
|
||||
LinearizationExponent = double.Parse(tokens[2], culture);
|
||||
}
|
||||
public void FromPolynomialString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
_coefficients.Clear();
|
||||
_exponents.Clear();
|
||||
|
||||
var tokens = s.Split(',');
|
||||
foreach (var t in tokens)
|
||||
{
|
||||
var subtokens = t.Split('x');
|
||||
if (2 == subtokens.Length)
|
||||
{
|
||||
double d;
|
||||
if (double.TryParse(subtokens[0], System.Globalization.NumberStyles.Float, culture, out d))
|
||||
{
|
||||
_coefficients.Add(d);
|
||||
_exponents.Add(double.Parse(subtokens[1], culture));
|
||||
}
|
||||
else
|
||||
{
|
||||
PolynomialSensitivity = double.Parse(subtokens[1], culture);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
subtokens = t.Split('=');
|
||||
if (subtokens.Length == 2)
|
||||
{
|
||||
switch (subtokens[0])
|
||||
{
|
||||
case "S":
|
||||
PolynomialSensitivity = double.Parse(subtokens[1], culture);
|
||||
break;
|
||||
case "mV":
|
||||
UsemVOverVForPolys = Convert.ToBoolean(subtokens[1], culture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void FromSerializeString(string s, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s)) { _bIsValid = false; return; }
|
||||
if (s.Equals("1") || s.Equals("0") || s.Equals("1 ")) { _bIsValid = false; return; }
|
||||
|
||||
var tokens = s.Split('_');
|
||||
if (tokens.Length < 2) { throw new NotSupportedException("unsupported Linearization Formula Format"); }
|
||||
var style = (NonLinearStyles)Enum.Parse(typeof(NonLinearStyles), tokens[0], true);
|
||||
NonLinearStyle = style;
|
||||
switch (NonLinearStyle)
|
||||
{
|
||||
case NonLinearStyles.IRTraccDiagnosticsZero:
|
||||
FromIRTraccDiagnosticZeroString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccManual:
|
||||
FromIRTraccManualString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccZeroMMmV:
|
||||
FromIRTraccZeroMMmVString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.Polynomial:
|
||||
FromPolynomialString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccAverageOverTime:
|
||||
FromIRTraccAverageOverTimeString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
case NonLinearStyles.IRTraccCalFactor:
|
||||
FromIRTraccCalFactorString(tokens[1], culture);
|
||||
_bIsValid = true;
|
||||
break;
|
||||
default:
|
||||
throw new NotSupportedException("Unknown format: " + NonLinearStyle);
|
||||
}
|
||||
}
|
||||
public void FromSerializeString(string s)
|
||||
{
|
||||
FromSerializeString(s, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.Bridge.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
// *** see Test.cs ***
|
||||
public partial class Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for DTS generic module concepts.
|
||||
/// </summary>
|
||||
public sealed partial class Module
|
||||
{
|
||||
// *** see Test.Module.Channel.cs ***
|
||||
public partial class Channel
|
||||
{
|
||||
//*** see DTS.Common.DAS.Concepts.Test.Module.Channel.Sensor.cs ***
|
||||
public partial class Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// All available bridge types.
|
||||
/// </summary>
|
||||
public enum BridgeType
|
||||
{
|
||||
/// <summary>
|
||||
/// sensor uses IEPE setup
|
||||
/// </summary>
|
||||
[Description("IEPE")]
|
||||
IEPE = 1 << 0,
|
||||
/// <summary>
|
||||
/// sensor uses quarter bridge setup
|
||||
/// </summary>
|
||||
[Description("Quarter")]
|
||||
QuarterBridge = 1 << 1,
|
||||
/// <summary>
|
||||
/// sensor uses half bridge setup
|
||||
/// </summary>
|
||||
[Description("Bridge-Half")]
|
||||
HalfBridge = 1 << 2,
|
||||
/// <summary>
|
||||
/// sensor has a full bridge setup
|
||||
/// </summary>
|
||||
[Description("Bridge-Full")]
|
||||
FullBridge = 1 << 3,
|
||||
/// <summary>
|
||||
/// digital input setup
|
||||
/// </summary>
|
||||
[Description("DigitalInput")]
|
||||
DigitalInput = 1 << 4,
|
||||
/// <summary>
|
||||
/// squib output setup
|
||||
/// </summary>
|
||||
[Description("SQUIB")]
|
||||
SQUIB = 1 << 5,
|
||||
/// <summary>
|
||||
/// digital output setup
|
||||
/// </summary>
|
||||
[Description("TOMDigital")]
|
||||
TOMDigital = 1 << 6,
|
||||
/// <summary>
|
||||
/// sensor uses a G5 (signal plus) half bridge setup
|
||||
/// </summary>
|
||||
[Description("Bridge-Half SigPlus")]
|
||||
HalfBridge_SigPlus = 1 << 7
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Test.Module.Channel.Sensor.ExcitationVoltage.cs
|
||||
|
||||
Copyright © 2008
|
||||
Diversified Technical Systems, Inc.
|
||||
All Rights Reserved
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DatabaseImport
|
||||
{
|
||||
// *** see Test.cs ***
|
||||
public partial class Test
|
||||
{
|
||||
/// <summary>
|
||||
/// A container for DTS generic module concepts.
|
||||
/// </summary>
|
||||
public sealed partial class Module
|
||||
{
|
||||
// *** see Test.Module.Channel.cs ***
|
||||
public partial class Channel
|
||||
{
|
||||
//*** see DTS.Common.DAS.Concepts.Test.Module.Channel.Sensor.cs ***
|
||||
public partial class Sensor
|
||||
{
|
||||
/// <summary>
|
||||
/// All available Sensitivity Unit types.
|
||||
/// </summary>
|
||||
public enum SensUnits
|
||||
{
|
||||
/// <summary>
|
||||
/// No Sensitivity Units (Polynomial Sensor)
|
||||
/// </summary>
|
||||
[Description("NONE")]
|
||||
NONE = 0,
|
||||
/// <summary>
|
||||
/// Sensitivity expressed in mV with output at Capacity EU
|
||||
/// </summary>
|
||||
[Description("mV")]
|
||||
mV = 1,
|
||||
/// <summary>
|
||||
/// Excitation proportional sensitivity expressed in mV/V with output at Capacity EU
|
||||
/// </summary>
|
||||
[Description("mV/V")]
|
||||
mVperV = 2,
|
||||
/// <summary>
|
||||
/// Excitation proportional sensitivity expressed in mV/V/EU
|
||||
/// </summary>
|
||||
[Description("mV/V/EU")]
|
||||
mVperVperEU = 3,
|
||||
/// <summary>
|
||||
/// Sensitivity expressed in mV/EU
|
||||
/// </summary>
|
||||
[Description("mV/EU")]
|
||||
mVperEU = 4
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user