6.4 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |
|---|---|---|---|---|---|
|
2026-04-17T15:59:43.455218+00:00 | zai-org/GLM-5-FP8 | 1 | 0bdba55cc7806845 |
CalculatedChannelCreator Documentation
1. Purpose
The CalculatedChannelCreator class is a factory responsible for creating derived data channels from existing sensor input channels. It performs mathematical transformations—including 3D IR-TRACC displacement calculations, aggregate operations (SUM, AVE, Resultant, HIC), and binary operations (integration, differentiation, trigonometric functions)—on channel data and persists the results to memory-mapped files. This module exists to support post-processing of crash test data, enabling engineers to synthesize new measurement channels from raw sensor inputs.
2. Public Interface
CreateChannels (static method)
public static Test.Module.CalculatedChannel[] CreateChannels(
string testId,
string folder,
Calculation calculation,
List<Test.Module.Channel> inputChannels,
string channelName,
int startingNumber,
List<Test.Module.Channel> allChannels,
int clipLength,
out List<string> errorList,
int defaultEncoding)
Behavior: Main entry point for creating calculated channels. Dispatches to appropriate private methods based on the Calculation enum value. Returns an array of Test.Module.CalculatedChannel objects on success, or null if validation fails. Populates errorList with validation errors.
ValidateChannelName (static method)
public static bool ValidateChannelName(
string channelName,
List<Test.Module.Channel> inputChannels,
List<Test.Module.Channel> allChannels,
out List<string> errorList)
Behavior: Validates that the channel name is non-empty and unique across both input channels and all channels. Returns true if valid; false otherwise. If allChannels is null, validation is bypassed and returns true.
ThreeDIRTraccType (public enum)
public enum ThreeDIRTraccType
{
Thorax,
Abdomen,
LowerThorax
}
Behavior: Specifies the anatomical location for 3D IR-TRACC calculations, which affects the constants (δ and D0) used in the displacement formulas.
3. Invariants
- Channel Number Offset: All calculated channels use
ChannelNumberCalculationChannelIndicator(constant value100000) as a base offset for their channel numbers. - Sample Rate Compatibility: For aggregate and 3D IR-TRACC operations, the maximum sample rate among input channels must be an integer multiple of each individual channel's sample rate. Otherwise,
NotSupportedExceptionis thrown. - 3D IR-TRACC Input Count:
Create3DIRTraccChannelsasserts that exactly 3 input channels are provided. - Aggregate Operation Input Count:
CreateChannelsAggregateOperationasserts that at least 2 input channels are provided (assertion message says "at least 1" but checks1 < inputChannels.Count). - File Overwrite Safety:
CreatePersistentInformationObjectdeletes any existing file at the target filepath before creating a new persistent channel, usingGC.Collect()followed byFileUtils.DeleteFileOrMove. - Engineering Units Padding: When persisting engineering units, the string is padded to even length for word-alignment if its length is odd.
4. Dependencies
This Module Depends On:
DTS.Common.Enums.Sensors- ForSensorConstants(δ and D0 values)DTS.Common.Utilities.Logging- ForAPILogger.LogDTS.Common.Utils- ForFileUtilsDTS.Serialization- ForSliceRaw.Fileformat handlingDTS.Slice.Control- Unclear specific usage (imported but no direct reference visible)DTS.Common- ForConstants.ADC_MIDPOINT,ZeroMethodTypeDTS.Common.Events- ForPageErrorEvent,PageErrorArgDTS.Common.Calculations- ForHeadInjuryCriterionDTS.Common.Utilities.Math.Nhtsa- ForIntegration,DifferentiationPrism.Ioc- ForContainerLocatorPrism.Events- ForIEventAggregatorTest.Modulenamespace - ForChannel,CalculatedChannel,AnalogInputChannelEvent.Modulenamespace - ForChannel,AnalogInputChannel
What Depends On This Module:
- Unclear from source alone - No consumers are shown in this file.
5. Gotchas
Critical Bugs Identified:
-
Copy-Paste Error in
PerformCalculation(line ~378):var stepRPot1 = Convert.ToInt32(Math.Ceiling(indexAtCurrentTimeIRTracc) - actualIndexAtCurrentTimeIRTracc);Uses
indexAtCurrentTimeIRTraccinstead ofindexAtCurrentTimeRPot1. This causes incorrect interpolation for the R-Pot1 channel. -
Assignment Instead of Subtraction in
PerformCalculation(line ~403):incrementRPot2 = (valueRPot2AtPoint = rPot2EUData[actualIndexAtCurrentTimeRPot2 - 1]) / rateRPot2;This is an assignment (
=) inside parentheses, overwritingvalueRPot2AtPoint, when it should be a subtraction (-). -
Unused Variable in
PerformCalculationsAggregate(line ~151):var timeAtIndex =Variable is declared but never assigned or used. This is a syntax error or incomplete implementation.
Non-Obvious Behaviors:
-
Debug/Test Data Injection: The method calls
DiskUtility.ReplaceDataIfNeeded(ref irTraccEUData, "DISPLEU.txt")and similar for other channels. This appears to be a debug feature that can override channel data from disk files. Production behavior is unclear. -
Explicit
GC.Collect()Call: InCreatePersistentInformationObject,GC.Collect()is called before file deletion to handle file locks. This is a heavy operation that may cause performance issues. -
ScaleEuData Logic Appears Inverted: When
max > short.MaxValue, the scale factor calculationscaleFactor = max / short.MaxValueproduces a value ≥ 1, which would amplify data that's already too large, potentially causing overflow when casting toshort. -
HIC Unit Conversion: For HIC calculations, if engineering units are not "g", the code multiplies by
9.80665to convert from m/s² to g's. This assumes the input is in m/s², which may not always be true. -
Commented-Out Code: There is a commented-out
DeleteChannelFilemethod and associated logic for deferred file deletion, suggesting historical changes to file handling behavior.