public static void SetEncodeType(ref BigEndianUInt16 val, byte encType) { ushort v = val; v = (ushort)(v & ~(0x03 << 10) + encType << 10); val = v; }
static float DecodeUInt16(BigEndianUInt16 code, float scale, float offset) { if (code >= 2 && code <= 1023) { float value = (code - offset) / scale; return(value); } else { float value = -999; return(value); } }
private int SwitchDataBlock(BigEndianUInt16 i) { int momentCount = 0; switch (i) { case 6: momentCount = 3; break; case 7: momentCount = 4; break; case 9: momentCount = 6; break; default: break; } return(momentCount); }
/// <summary> /// 13 BIT /// </summary> /// <param name="val"></param> /// <returns></returns> public static bool IsMutliPack(this BigEndianUInt16 val) { return(((val >> 13) & 0x01) == 0x0001); }
/// <summary> /// 12-10 BIT /// </summary> /// <param name="val"></param> /// <returns></returns> public static Byte GetEncodeType(BigEndianUInt16 val) { return((Byte)((val >> 10) & 0x03)); }
/// <summary> /// 9-0 BIT /// </summary> /// <param name="val"></param> /// <returns></returns> public static void SetMessageLength(ref BigEndianUInt16 val, UInt16 length) { val = (UInt16)(((UInt16)val & (~0x03ff)) + length); }
/// <summary> /// 9-0 BIT /// </summary> /// <param name="val"></param> /// <returns></returns> public static Int16 GetMessageLength(BigEndianUInt16 val) { return((Int16)((UInt16)val & 0x03ff)); }