mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
28 lines
670 B
C#
28 lines
670 B
C#
using System.Collections;
|
|
|
|
namespace S7.Net.Types
|
|
{
|
|
/// <summary>
|
|
/// Contains the conversion methods to convert Bit from S7 plc to C#.
|
|
/// </summary>
|
|
public static class Bit
|
|
{
|
|
/// <summary>
|
|
/// Converts a Bit to bool
|
|
/// </summary>
|
|
public static bool FromByte(byte v, byte bitAdr)
|
|
{
|
|
return (((int)v & (1 << bitAdr)) != 0);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts an array of bytes to a BitArray
|
|
/// </summary>
|
|
public static BitArray ToBitArray(byte[] bytes)
|
|
{
|
|
BitArray bitArr = new BitArray(bytes);
|
|
return bitArr;
|
|
}
|
|
}
|
|
}
|