Files
DP44/docs/ai/Common/DTS.Common.Serialization/IRIGCH10/Utils.md
2026-04-17 14:55:32 -04:00

1.8 KiB

source_files, generated_at, model, schema_version, sha256
source_files generated_at model schema_version sha256
Common/DTS.Common.Serialization/IRIGCH10/Utils/Utils.cs
2026-04-17T16:43:36.818421+00:00 zai-org/GLM-5-FP8 1 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