9.8 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | ||
|---|---|---|---|---|---|---|
|
2026-04-16T11:39:41.280506+00:00 | zai-org/GLM-5-FP8 | 1 | d40daed59089dfb4 |
Documentation: DTS.Common.DAS.Concepts.Test.Module
1. Purpose
This module provides utilities for handling tilt sensor data and recording mode configurations within the DTS data acquisition system. It contains classes and methods for converting raw ADC tilt sensor readings into engineering units (degrees), managing tilt axis configurations and polarities, and parsing string representations of enumeration values. The module serves as a bridge between hardware-level sensor data and application-level tilt calculations, supporting multiple axis orientations and calibration parameters.
2. Public Interface
Classes
Test.Module.TiltAxis
A data container class representing a single tilt axis configuration.
| Property | Type | Default | Description |
|---|---|---|---|
AxisNumber |
int |
- | The axis identifier number |
CurrentTilt |
double |
- | The current tilt value |
Label |
string |
- | The axis label (e.g., "X", "Y", "Z") |
Inversion |
int |
1 |
Polarity multiplier (-1 or 1) |
IsIgnored |
bool |
false |
Whether this axis is excluded from calculations |
MountedOffset |
double |
0.0 |
Mount offset in degrees |
TargetOffset |
double |
0.0 |
Target offset in degrees |
Test.Module.TiltAxesHelper
A helper class for managing tilt axis configurations parsed from firmware attributes.
| Property | Type | Default | Description |
|---|---|---|---|
AxisConfigurations |
Dictionary<int, TiltAxis> |
Empty dict with keys 0,1,2 | Collection of axis configurations |
AxisOne |
TiltAxis |
- | Reference to the first active axis |
AxisTwo |
TiltAxis |
- | Reference to the second active axis |
LevelTolerance |
double |
0.5 |
Tolerance for level detection |
Constructors:
TiltAxesHelper()- Default constructor initializing 3 axis configurationsTiltAxesHelper(string TiltAxes, double MountOffsetAxisOne, double MountOffsetAxisTwo, double TargetAxisOne, double TargetAxisTwo, double LevelTolerance, int AxisIgnored, bool UseForTiltCalculation)- Constructs from firmware attributes
Methods:
string AxesToString()- Returns a string representation of axis labels with polarity indicators (e.g., "IXPYP")
Enumerations
Test.Module.TiltAxesSimple
Simplified tilt axis orderings (6 permutations).
| Value | Name |
|---|---|
| 0 | XYZ |
| 1 | XZY |
| 2 | YXZ |
| 3 | YZX |
| 4 | ZXY |
| 5 | ZYX |
Test.Module.TiltAxesPolarity
Polarity combinations for three axes (8 combinations).
| Value | Name |
|---|---|
| 0 | PPP |
| 1 | PPN |
| 2 | PNP |
| 3 | PNN |
| 4 | NPP |
| 5 | NPN |
| 6 | NNP |
| 7 | NNN |
Test.Module.TiltSensorCalAttributes
18 calibration attribute indices for tilt sensor calibration data.
| Value | Name |
|---|---|
| 0 | TILTSENSOR_CAL_1_GainAxis1 |
| 1 | TILTSENSOR_CAL_2_ZeroAxis1 |
| 2 | TILTSENSOR_CAL_3_ZeroDomAxis2PosAxis1 |
| 3 | TILTSENSOR_CAL_4_ZeroDomAxis2NegAxis1 |
| ... | (continues through index 17) |
| 17 | TILTSENSOR_CAL_18_ZeroDomAxis2NegAxis3 |
Test.Module.AxisLabel
| Value | Name |
|---|---|
| 0 | X |
| 1 | Y |
| 2 | Z |
Static Methods
Recording Mode Methods
public static DFConstantsAndEnums.RecordingMode GetRecordingModeFromString(string recordingMode)
Converts a string representation to a DFConstantsAndEnums.RecordingMode enum value. Throws Exception with descriptive message if parsing fails.
Tilt Axes Parsing Methods
public static TiltAxes GetTiltAxesFromString(string tiltAxes)
Converts a string representation to a TiltAxes enum value. Throws Exception with descriptive message if parsing fails.
public static TiltAxesSimple SimplifyTiltAxes(TiltAxes axes)
Converts a TiltAxes enum to its simplified form by removing "I" (inversion) prefixes.
public static int[] GetPolaritiesFromTiltAxes(TiltAxes ta)
Returns an array of polarity values (-1 or 1) for each axis based on the TiltAxes enum.
public static bool[] GetBoolPolaritiesFromTiltAxes(TiltAxes tiltAxes)
Returns a boolean array indicating inversion state for each axis. true indicates inverted.
public static AxisLabel[] GetAxisLabelFromTiltAxes(TiltAxes tiltAxes)
public static AxisLabel[] GetAxisLabelFromTiltAxes(string tiltAxes)
Extracts axis labels from a TiltAxes enum or string representation.
Tilt Calculation Methods
public static double[] GetTiltDegreesEU(short[] tiltSensorADC, double[] tiltSensorCals)
Overload that uses default parameters: TiltAxes.IXYZ, ignored axis 3, and zero mount offsets.
public static double[] GetTiltDegreesEU(short[] tiltSensorADC, double[] tiltSensorCals, TiltAxes axes, int ignoredAxis, float[] mountOffsetAxis)
Converts raw ADC tilt sensor readings to engineering units (degrees). Returns a double[3] containing X, Y, Z tilt values in degrees. The ignored axis value is set to double.NaN.
public static double[] GetTiltZeroData(short[] tiltSensorADC, double[] tiltSensorCals, int dominantAxis)
Calculates zero offset data based on the dominant axis and its polarity.
public static int GetDominantTiltAxis(short[] tiltSensorADC)
Returns the index of the axis with the largest absolute ADC value.
public static double[] GetTiltGains(double[] tiltSensorCals)
Extracts gain values from calibration data. Returns 1.0 for any gain that is 0.0.
Utility Methods
public static string ConvertBoolToInvertString(bool isInverted)
Returns "I" if isInverted is true, otherwise empty string.
public static string GetOrientationLabelFromAxisInfo(string[] axisLabels, bool[] invertAxis)
Builds an orientation label string from axis labels and inversion flags.
public static TiltAxes GetTiltAxesFromAxisInfo(string[] axisLabels, bool[] invertAxis)
Constructs a TiltAxes enum from axis labels and inversion flags.
public static float[] GetMountOffsetsOrTargetsFromAxisInfo(float[] perAxisValue, int axisToIgnore)
Extracts a 2-element array of values for the non-ignored axes (1-indexed: 1, 2, or 3).
3. Invariants
-
Array Size Requirements:
tiltSensorADCmust be a 3-element array (indices 0, 1, 2 correspond to axes)tiltSensorCalsmust be an 18-element array (indexed byTiltSensorCalAttributes)mountOffsetAxismust be a 2-element arrayperAxisValueinGetMountOffsetsOrTargetsFromAxisInfomust be a 3-element array
-
Ignored Axis Values:
- Valid values are 1, 2, or 3 (1-indexed)
- A value of 0 is silently converted to 3 in
GetTiltDegreesEU
-
Gain Default Behavior:
- Any gain value of
0.0is replaced with1.0inGetTiltGains
- Any gain value of
-
Output Format:
GetTiltDegreesEUreturns degrees rounded to 3 decimal places (viaSIGNIFICANT_DIGITS = 1000)- Ignored axis values are set to
double.NaN
-
TiltAxesHelper Dictionary Keys:
- The default constructor initializes
AxisConfigurationswith keys 0, 1, 2 (not 1, 2, 3)
- The default constructor initializes
4. Dependencies
External Dependencies (Imports)
DTS.Common.Enums.DASFactory- ProvidesDFConstantsAndEnums.RecordingModeandTiltAxesenumerationsDTS.Common.Utilities- ProvidesDegreesFromADC.GetDegrees()methodSystem- Core .NET typesSystem.Collections.Generic-Dictionary<TKey, TValue>,List<T>System.ComponentModel- Component model infrastructureSystem.Linq- LINQ extension methods (Max(),Min(),IndexOf())System.Text-StringBuilder
Consumers
- Unknown from source alone. The partial class structure (
Test.cs,Test.Module) suggests this is part of a larger test configuration system.
5. Gotchas
Critical Bugs in TiltAxesHelper Constructor
-
Dictionary Key Mismatch: The constructor parses
TiltAxesstring using indices 0, 1, 2:for (int i = 0; i < 3; i++) { AxisConfigurations[i].Label = TiltAxes[i * 2].ToString(); }However, the conditional logic references keys 1, 2, 3:
AxisOne = AxisConfigurations[2]; AxisTwo = AxisConfigurations[3]; // Key 3 does not exist!This will throw a
KeyNotFoundExceptionat runtime whenAxisIgnored == 1. -
Duplicate Assignment Bug: In the
elsebranch (whenAxisIgnoredis not 1 or 2):AxisOne = AxisConfigurations[1]; AxisOne = AxisConfigurations[2]; // Overwrites previous lineAxisOneis assigned twice andAxisTwois never assigned (remainsnull). -
TargetOffset Assignment Bug:
AxisOne.TargetOffset = TargetAxisOne; AxisOne.TargetOffset = TargetAxisTwo; // Overwrites previous lineTargetAxisTwooverwritesTargetAxisOne, andAxisTwo.TargetOffsetis never set.
Other Issues
-
Misleading Comments: Comments in
GetTiltDegreesEUstate "1 decimal place" but the code usesSIGNIFICANT_DIGITS = 1000which provides 3 decimal places. -
Inconsistent Mount Offset Usage: In
GetTiltDegreesEU, some switch cases usemountOffsetAxisOnetwice for different axes (e.g., case 2 in XYZ usesmountOffsetAxisOnefor both X and Z calculations). This may be intentional but appears inconsistent. -
Silent Normalization:
ignoredAxis == 0is silently converted to3without documentation or validation of other invalid values. -
Unused Property:
UseForTiltCalculationproperty inTiltAxesHelperis set in the constructor but never used elsewhere in the visible code.