📄 helper.cs
字号:
//==========================================================================================
//
// WJ.MPR.Util.Helper
// Copyright (c) 2006, WJ Communications, Inc.
//
// A convenient file in which to store some Helper classes, enums and functions.
//
//==========================================================================================
using System;
namespace WJ.MPR.Util
{
/// <summary>
/// The MsgCmd byte for TCP/IP messages containing RFIDTag Add and Remove Tag Events.
/// </summary>
public enum TCPMsgCmd : byte
{
/// <summary>
/// A Tag has been added to the Inventory.
/// </summary>
AddTag = 0x01,
/// <summary>
/// A Tag has been removed from the Inventory.
/// </summary>
RemoveTag = 0x02
}
/// <summary>
/// Contains just a function to convert two bytes to an unsigned short (ushort in C# parlance).
/// </summary>
public class Helpers
{
/// <summary>
/// b2us = "byte to ushort" Combine two (8-bit) bytes into a single (16-bit) ushort
/// </summary>
/// <param name="a">MSB</param>
/// <param name="b">LSB</param>
/// <returns></returns>
public static ushort b2us(byte a, byte b)
{
return (ushort)(a * 256 + b);
}
/// <summary>
/// b2ui = "bytes to uint" Combine four (8-bit) bytes into a single (32-bit) uint
/// </summary>
/// <param name="a">MSB - Most significant Byte</param>
/// <param name="b">3SB - 3rd most significant Byte</param>
/// <param name="c">2SB - 2nd most significant Byte</param>
/// <param name="d">LSB - Least significant Byte</param>
/// <returns></returns>
public static uint b2ui(byte a, byte b, byte c, byte d)
{
return ((uint)a << 24) + ((uint)b << 16) + ((uint)c << 8) + (uint)d;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -