[Console]::OutputEncoding = [Text.Encoding]::UTF8 $lines = [IO.File]::ReadAllLines("$env:TEMP\opencode\ss123.tsv") $n = 0; $guardHit = 0; $msbZero = 0; $msbZero2 = 0; $first = $null foreach ($ln in $lines) { $p = $ln -split "`t" if ($p.Count -lt 5 -or $p[4].Length -lt 100) { continue } $hex = $p[4] -replace '[^0-9a-fA-F]','' if ($hex.Length -ne 2168) { continue } # 1084B = 2168 hex chars $b = New-Object byte[] 1084 for ($i = 0; $i -lt 1084; $i++) { $b[$i] = [Convert]::ToByte($hex.Substring($i*2,2),16) } if ($b[0x20] -ne 1 -or $b[0x21] -ne 1) { continue } # DMX subtype $n++ if ($null -eq $first) { $first = $b } $ch1 = $b[0x3C]; $ch513 = $b[0x23C] if ($b[0x22] -eq (($ch1 - 1) -bxor 0x70)) { $guardHit++ } if ($b[0x25] -lt 0x80) { $msbZero++ } if ($b[0x29] -lt 0x80) { $msbZero2++ } } echo "DMX frames: $n" echo "g1==(CH1-1)^0x70: $guardHit/$n" echo "byte0x25<0x80 (MSB=0, Random.Next 特征): $msbZero/$n" echo "byte0x29<0x80: $msbZero2/$n" if ($first) { $hdr = ($first[0x18..0x3F] | ForEach-Object { $_.ToString("x2") }) -join ' ' echo "首帧 0x18-0x3F: $hdr" echo "首帧 CH1-8: $(($first[0x3C..0x43] | ForEach-Object { $_.ToString('x2') }) -join ' ')" }