12 KiB
12 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T02:05:00.800450+00:00 | Qwen/Qwen3-Coder-Next-FP8 | 1 | d40daed59089dfb4 |
Module
Documentation: DTS.Common.DAS.Concepts.Test.Module
1. Purpose
This module provides utility types and methods for handling tilt sensor configuration and computation within the DTS DAS (Data Acquisition System) framework. It encapsulates domain-specific concepts such as axis labeling, polarity inversion, mounting offsets, and calibration-aware conversion of raw ADC values to tilt angles in degrees. The module supports dynamic axis ordering (e.g., IXYIZ, ZYX) and ignored axes, enabling flexible tilt sensor mounting configurations. It also includes string ↔ enumeration conversion helpers and core tilt calculation logic used in calibration and real-time data processing.
2. Public Interface
All public members reside within the nested Test.Module class.
GetRecordingModeFromString(string recordingMode)
public static DFConstantsAndEnums.RecordingMode GetRecordingModeFromString(string recordingMode)
- Behavior: Parses the input string into a
DFConstantsAndEnums.RecordingModeenum value usingEnum.Parse. Throws anException(wrapping the original) if parsing fails or input isnull.
TiltAxis class
public class TiltAxis
{
public int AxisNumber { get; set; }
public double CurrentTilt { get; set; }
public string Label { get; set; }
public int Inversion { get; set; } = 1;
public bool IsIgnored { get; set; } = false;
public double MountedOffset { get; set; } = 0.0;
public double TargetOffset { get; set; } = 0.0;
}
- Purpose: Represents a single tilt sensor axis configuration. Properties define axis identity, current measurement, label (
X,Y,Z), inversion factor (+1or-1), ignore flag, and offset values (in degrees).
TiltAxesHelper class
public class TiltAxesHelper
{
public Dictionary<int, TiltAxis> AxisConfigurations { get; set; }
public TiltAxis AxisOne { get; set; }
public TiltAxis AxisTwo { get; set; }
public double LevelTolerance { get; set; } = 0.5;
public TiltAxesHelper();
public TiltAxesHelper(string TiltAxes, double MountOffsetAxisOne, double MountOffsetAxisTwo,
double TargetAxisOne, double TargetAxisTwo, double LevelTolerance,
int AxisIgnored, bool UseForTiltCalculation);
public string AxesToString();
}
- Behavior:
- Default constructor initializes
AxisConfigurationswith keys1,2,3, each containing a newTiltAxis. - Parameterized constructor parses a
TiltAxesstring (e.g.,"IXIYIZ") to populateAxisConfigurations[i].LabelandInversion, setsIsIgnoredfor the specified axis, and assignsAxisOne/AxisTworeferences to the non-ignored axes. - Bug Note: In the constructor,
AxisOne = AxisConfigurations[2];is assigned twice whenAxisIgnored == 2(should likely beAxisTwo = AxisConfigurations[3];). AxesToString(): Reconstructs the orientation string fromAxisConfigurations(e.g.,"IXIYIZ"→"IXIYIZ").
- Default constructor initializes
TiltAxesSimple enum
public enum TiltAxesSimple
{
XYZ = 0, XZY = 1, YXZ = 2, YZX = 3, ZXY = 4, ZYX = 5
}
- Represents the simplified axis ordering (ignoring inversion markers
I).
SimplifyTiltAxes(TiltAxes axes)
public static TiltAxesSimple SimplifyTiltAxes(TiltAxes axes)
- Behavior: Strips
Icharacters fromaxes.ToString()and parses the result intoTiltAxesSimple.
GetTiltAxesFromString(string tiltAxes)
public static TiltAxes GetTiltAxesFromString(string tiltAxes)
- Behavior: Parses the input string into a
TiltAxesenum value usingEnum.Parse. Throws anException(wrapping the original) on failure.
GetPolaritiesFromTiltAxes(TiltAxes ta)
public static int[] GetPolaritiesFromTiltAxes(TiltAxes ta)
- Behavior: Returns an array of
+1or-1for each axis, where-1corresponds to anI(inverted) axis in theTiltAxesstring.
GetBoolPolaritiesFromTiltAxes(TiltAxes tiltAxes)
public static bool[] GetBoolPolaritiesFromTiltAxes(TiltAxes tiltAxes)
- Behavior: Returns a
bool[3]wheretrueindicates an inverted axis (I),falseindicates non-inverted (P). Iterates over the string representation, settingrv[ax] = truewhen encountering'I', and incrementsaxonly on non-Icharacters.
TiltSensorCalAttributes enum
public enum TiltSensorCalAttributes
{
TILTSENSOR_CAL_1_GainAxis1 = 0,
TILTSENSOR_CAL_2_ZeroAxis1 = 1,
TILTSENSOR_CAL_3_ZeroDomAxis2PosAxis1 = 2,
TILTSENSOR_CAL_4_ZeroDomAxis2NegAxis1 = 3,
TILTSENSOR_CAL_5_ZeroDomAxis3PosAxis1 = 4,
TILTSENSOR_CAL_6_ZeroDomAxis3NegAxis1 = 5,
TILTSENSOR_CAL_7_GainAxis2 = 6,
TILTSENSOR_CAL_8_ZeroAxis2 = 7,
TILTSENSOR_CAL_9_ZeroDomAxis1PosAxis2 = 8,
TILTSENSOR_CAL_10_ZeroDomAxis1NegAxis2 = 9,
TILTSENSOR_CAL_11_ZeroDomAxis3PosAxis2 = 10,
TILTSENSOR_CAL_12_ZeroDomAxis3NegAxis2 = 11,
TILTSENSOR_CAL_13_GainAxis3 = 12,
TILTSENSOR_CAL_14_ZeroAxis3 = 13,
TILTSENSOR_CAL_15_ZeroDomAxis1PosAxis3 = 14,
TILTSENSOR_CAL_16_ZeroDomAxis1NegAxis3 = 15,
TILTSENSOR_CAL_17_ZeroDomAxis2PosAxis3 = 16,
TILTSENSOR_CAL_18_ZeroDomAxis3NegAxis3 = 17,
}
- Defines indices into the
tiltSensorCalsarray for calibration parameters.
GetTiltDegreesEU(...) overloads
public static double[] GetTiltDegreesEU(short[] tiltSensorADC, double[] tiltSensorCals);
public static double[] GetTiltDegreesEU(short[] tiltSensorADC, double[] tiltSensorCals,
TiltAxes axes, int ignoredAxis, float[] mountOffsetAxis);
- Behavior: Converts raw ADC values (
tiltSensorADC, length ≥ 3) to tilt angles (degrees) using calibration data (tiltSensorCals, length ≥ 18). Returns adouble[3]where the ignored axis isdouble.NaN, and the other two axes are computed and rounded to 3 decimal places (viaSIGNIFICANT_DIGITS = 1000).- Uses
GetDominantTiltAxis,GetTiltGains,GetTiltZeroData, and axis-specific scaling factors (xFactor,yFactor,zFactor) derived fromaxes. - Applies mounting offsets from
mountOffsetAxis[0]andmountOffsetAxis[1]to the non-ignored axes.
- Uses
GetTiltZeroData(...)
public static double[] GetTiltZeroData(short[] tiltSensorADC, double[] tiltSensorCals, int dominantAxis)
- Behavior: Returns a
double[3]of zero-point offsets. Uses base zero values (TILTSENSOR_CAL_2/8/14) and conditionally overrides them with dominant-axis-specific values (TILTSENSOR_CAL_3/4,9/10,15/16, etc.) based on the sign oftiltSensorADC[dominantAxis].
GetDominantTiltAxis(...)
public static int GetDominantTiltAxis(short[] tiltSensorADC)
- Behavior: Returns the index (
0,1, or2) of the axis with the largest absolute ADC value.
GetTiltGains(...)
public static double[] GetTiltGains(double[] tiltSensorCals)
- Behavior: Returns a
double[3]of gain values (TILTSENSOR_CAL_1/7/13). Uses1.0if a gain is0.0.
AxisLabel enum
public enum AxisLabel { X = 0, Y = 1, Z = 2 }
GetAxisLabelFromTiltAxes(...) overloads
public static AxisLabel[] GetAxisLabelFromTiltAxes(TiltAxes tiltAxes);
public static AxisLabel[] GetAxisLabelFromTiltAxes(string tiltAxes);
- Behavior: Returns an
AxisLabel[3]array corresponding to the non-Icharacters in theTiltAxesstring (e.g.,"IXYIZ"→[Y, Z, X]).
ConvertBoolToInvertString(bool isInverted)
public static string ConvertBoolToInvertString(bool isInverted)
- Behavior: Returns
"I"ifisInvertedistrue, else"".
GetOrientationLabelFromAxisInfo(...)
public static string GetOrientationLabelFromAxisInfo(string[] axisLabels, bool[] invertAxis)
- Behavior: Concatenates
invertAxis[i] ? "I" : ""+axisLabels[i]for each axis (e.g.,["X","Y","Z"],[true,false,false]→"IXYZ").
GetTiltAxesFromAxisInfo(...)
public static TiltAxes GetTiltAxesFromAxisInfo(string[] axisLabels, bool[] invertAxis)
- Behavior: Calls
GetOrientationLabelFromAxisInfo, thenGetTiltAxesFromString.
GetMountOffsetsOrTargetsFromAxisInfo(...)
public static float[] GetMountOffsetsOrTargetsFromAxisInfo(float[] perAxisValue, int axisToIgnore)
- Behavior: Returns a
float[2]containing the values for the two non-ignored axes.axisToIgnoreis1,2, or3(1-indexed).- Example:
axisToIgnore=1→[perAxisValue[1], perAxisValue[2]].
- Example:
3. Invariants
TiltAxesstring format: Must be 6 characters long, alternating axis label (X,Y,Z) and polarity (PorN). Inversion is represented byI(e.g.,IX), butIis not a label—it is a polarity marker.- Valid examples:
"IXIYIZ","IXYZ","ZYX","IXZIY". - Invalid:
"IXIY"(length ≠ 6),"IXIXIX"(repeated labels),"IXIYIP"(invalid polarity).
- Valid examples:
TiltAxesSimplevalues: Derived by removing allIcharacters fromTiltAxes.ToString(). Must be a permutation of"XYZ".GetTiltDegreesEUoutput: The ignored axis is alwaysdouble.NaN; the other two axes are rounded to 3 decimal places.- Calibration array indexing:
tiltSensorCalsmust have ≥ 18 elements; indices correspond strictly toTiltSensorCalAttributes. GetDominantTiltAxis: Uses the axis with the largest absolute value (handles negative ADCs correctly).
4. Dependencies
- Imports/Usings:
DTS.Common.Enums.DASFactory.DFConstantsAndEnums(forRecordingMode,TiltAxes)DTS.Common.Utilities(likely containsDegreesFromADC)System,System.Collections.Generic,System.Linq,System.Text,System.ComponentModel
- External Types Used:
DFConstantsAndEnums.RecordingMode(enum)DTS.Common.Enums.DASFactory.DFConstantsAndEnums.TiltAxes(enum, defined elsewhere)DTS.Common.Utilities.DegreesFromADC.GetDegrees(...)(used inGetTiltDegreesEU)
- Depended Upon By:
- Likely used by tilt sensor drivers, calibration tools, and data processing pipelines (e.g.,
DataPRO—per comment inSIGNIFICANT_DIGITS).
- Likely used by tilt sensor drivers, calibration tools, and data processing pipelines (e.g.,
5. Gotchas
- Constructor Bug in
TiltAxesHelper: WhenAxisIgnored == 2,AxisOneis assigned twice (AxisConfigurations[1]), andAxisTwois never set. Likely should be:However,AxisOne = AxisConfigurations[1]; AxisTwo = AxisConfigurations[3]; // but note: AxisConfigurations is 1-indexed!AxisConfigurationsuses keys1,2,3, butTiltAxis.AxisNumberis not initialized in the constructor—this may cause off-by-one errors ifAxisNumberis expected to match the dictionary key. TiltAxesEnum Values: The source file does not define theTiltAxesenum itself (only uses it). Its members (e.g.,IXYIZ,ZYX) are assumed to exist inDFConstantsAndEnums. The code assumes all permutations with optionalIare valid enum values.GetTiltZeroDataLogic: UsesdominantAxisto select dominant-axis-specific zero points. This is non-trivial: zero points differ based on which axis is dominant (e.g.,ZeroDomAxis1PosAxis2vsZeroDomAxis1NegAxis2).SIGNIFICANT_DIGITS = 1000: Hardcoded to enforce 3 decimal places (0.001 precision). This is a legacy design choice (see internal case 34373).GetTiltDegreesEUADC Indexing: AssumestiltSensorADC[0],[1],[2]correspond to the physical axes in the order they appear in the calibration array, not theTiltAxeslabel order. Theaxesparameter only affects sign and axis assignment in the output array.GetBoolPolaritiesFromTiltAxes: The loop incrementsaxonly on non-Icharacters, so the resultingbool[]is not aligned with the original axis order ifIis present. For"IXYIZ",rv[0]corresponds toY,rv[1]toZ,rv[2]toX—this may be counterintuitive.GetPolaritiesFromTiltAxes: Returns+1forP,-1forI, but the mapping is based on the same non-I-indexed logic asGetBoolPolaritiesFromTiltAxes.