--- source_files: - Common/DTS.Common.Serialization/IRIGCH10/Utils/Utils.cs generated_at: "2026-04-17T16:43:36.818421+00:00" model: "zai-org/GLM-5-FP8" schema_version: 1 sha256: "2999f5bcc681631b" --- # Documentation: DTS.Serialization.IRIGCH10.Utils.Utils ## 1. Purpose This module provides low-level utility functions for IRIG Chapter 10 data serialization, including Binary Coded Decimal (BCD) encoding for date/time values, checksum computation (8-bit, 16-bit, and 32-bit variants per the CH10 specification), and bit-level manipulation of `BitArray` structures. It serves as a foundational helper class for encoding and validating binary packet data in the IRIG Chapter 10 format. --- ## 2. Public Interface ### `public static byte[] GetBCDBytes(int value)` Converts an integer value to a 2-byte Binary Coded Decimal representation. - **Parameter:** `value` — must be in range [0, 9999] - **Returns:** 2-byte array containing the BCD-encoded value - **Throws:** `ArgumentOutOfRangeException` if `value` is outside the valid range ### `public static ushort GetCheckSum8(byte[] bytes)` Computes an 8-bit checksum by summing all byte values. - **Parameter:** `bytes` — input byte array - **Returns:** `ushort` representing the sum of all bytes (wrapping at 8 bits via implicit truncation) ### `public static ushort GetCheckSum16(byte[] bytes)` Computes a 16-bit checksum per the Chapter 10 specification by treating the byte array as an array of 16-bit unsigned integers and summing them. - **Parameter:** `bytes` — input byte array (must have even length) - **Returns:** `ushort` checksum value - **Asserts:** `bytes.Length % 2 == 0` via `System.Diagnostics.Trace.Assert` ### `public static uint GetCheckSum32(byte[] bytes)` Computes a 32-bit checksum per the Chapter 10 specification by treating the byte array as an array of