public void BoolTest( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetBool(true, 1234); Assert.IsTrue(softBuffer.GetBool(1234)); softBuffer.SetBool(true, 2234); Assert.IsTrue(softBuffer.GetBool(2234)); softBuffer.SetBool(false, 2234); Assert.IsTrue(!softBuffer.GetBool(2234)); softBuffer.SetBool(true, 8); Assert.IsTrue(softBuffer.GetByte(1) == 0x01); softBuffer.SetBool(new bool[] { true, true, false, false, true, false, true }, 3451); bool[] data = softBuffer.GetBool(3451, 7); Assert.IsTrue(data[0]); Assert.IsTrue(data[1]); Assert.IsFalse(data[2]); Assert.IsFalse(data[3]); Assert.IsTrue(data[4]); Assert.IsFalse(data[5]); Assert.IsTrue(data[6]); }
public void Int64Test( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetValue(new long[] { 123456, -12345, 231412 }, 328); long[] read = softBuffer.GetInt64(328, 3); Assert.IsTrue(read[0] == 123456 && read[1] == -12345 && read[2] == 231412); }
public void UInt32Test( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetValue(new uint[] { 123, 42123, 24567 }, 328); uint[] read = softBuffer.GetUInt32(328, 3); Assert.IsTrue(read[0] == 123 && read[1] == 42123 && read[2] == 24567); }
public void Int16Test( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetValue(new short[] { 123, -123, 24567 }, 328); short[] read = softBuffer.GetInt16(328, 3); Assert.IsTrue(read[0] == 123 && read[1] == -123 && read[2] == 24567); }
public void DoubleTest( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetValue(new double[] { 123456d, -12345d, 231412d }, 328); double[] read = softBuffer.GetDouble(328, 3); Assert.IsTrue(read[0] == 123456d && read[1] == -12345d && read[2] == 231412d); }
public void SingleTest( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetValue(new float[] { 123456f, -12345f, 231412f }, 328); float[] read = softBuffer.GetSingle(328, 3); Assert.IsTrue(read[0] == 123456f && read[1] == -12345f && read[2] == 231412f); }
/// <summary> /// LSisServer /// </summary> public LSisServer() { inputBuffer = new SoftBuffer(DataPoolLength); outputBuffer = new SoftBuffer(DataPoolLength); memeryBuffer = new SoftBuffer(DataPoolLength); dbBlockBuffer = new SoftBuffer(DataPoolLength); WordLength = 2; ByteTransform = new ReverseBytesTransform(); }
/// <summary> /// 实例化一个S7协议的服务器,支持I,Q,M,DB1.X 数据区块的读写操作 /// </summary> public LSisServer( ) { // 四个数据池初始化,输入寄存器,输出寄存器,中间寄存器,DB块寄存器 inputBuffer = new SoftBuffer(DataPoolLength); outputBuffer = new SoftBuffer(DataPoolLength); memeryBuffer = new SoftBuffer(DataPoolLength); dbBlockBuffer = new SoftBuffer(DataPoolLength); WordLength = 2; ByteTransform = new ReverseBytesTransform( ); }
/// <summary> /// 实例化一个mc协议的服务器 /// </summary> public MelsecMcServer( ) { // 共计使用了五个数据池 xBuffer = new SoftBuffer(DataPoolLength); yBuffer = new SoftBuffer(DataPoolLength); mBuffer = new SoftBuffer(DataPoolLength); dBuffer = new SoftBuffer(DataPoolLength * 2); wBuffer = new SoftBuffer(DataPoolLength * 2); WordLength = 1; ByteTransform = new RegularByteTransform( ); }
/// <summary> /// LSisServer /// </summary> public LSisServer() { pBuffer = new SoftBuffer(DataPoolLength); qBuffer = new SoftBuffer(DataPoolLength); mBuffer = new SoftBuffer(DataPoolLength); dBuffer = new SoftBuffer(DataPoolLength); WordLength = 2; ByteTransform = new RegularByteTransform(); serialPort = new SerialPort(); }
/// <summary> /// 实例化一个S7协议的服务器,支持I,Q,M,DB1.X 数据区块的读写操作 /// </summary> public SiemensS7Server( ) { // 四个数据池初始化,输入寄存器,输出寄存器,中间寄存器,DB块寄存器 inputBuffer = new SoftBuffer(DataPoolLength); outputBuffer = new SoftBuffer(DataPoolLength); memeryBuffer = new SoftBuffer(DataPoolLength); dbBlockBuffer = new SoftBuffer(DataPoolLength); WordLength = 2; ByteTransform = new ReverseBytesTransform( ); lockOnlineClient = new SimpleHybirdLock( ); listsOnlineClient = new List <AppSession>( ); }
/// <summary> /// LSisServer /// </summary> public LSisServer() { pBuffer = new SoftBuffer(DataPoolLength); qBuffer = new SoftBuffer(DataPoolLength); mBuffer = new SoftBuffer(DataPoolLength); dBuffer = new SoftBuffer(DataPoolLength); WordLength = 2; ByteTransform = new RegularByteTransform(); #if !NETSTANDARD2_0 serialPort = new SerialPort(); #endif }
/// <summary> /// LSisServer /// </summary> public LSisServer() { inputBuffer = new SoftBuffer(DataPoolLength); outputBuffer = new SoftBuffer(DataPoolLength); memeryBuffer = new SoftBuffer(DataPoolLength); dbBlockBuffer = new SoftBuffer(DataPoolLength); WordLength = 2; ByteTransform = new ReverseBytesTransform(); #if !NETSTANDARD2_0 serialPort = new SerialPort(); #endif }
/// <summary> /// 实例化一个Modbus Tcp的服务器,支持数据读写操作 /// </summary> public ModbusTcpServer( ) { // 四个数据池初始化,线圈,输入线圈,寄存器,只读寄存器 coilBuffer = new SoftBuffer(DataPoolLength); inputBuffer = new SoftBuffer(DataPoolLength); registerBuffer = new SoftBuffer(DataPoolLength * 2); inputRegisterBuffer = new SoftBuffer(DataPoolLength * 2); subscriptions = new List <ModBusMonitorAddress>( ); subcriptionHybirdLock = new SimpleHybirdLock( ); ByteTransform = new ReverseWordTransform( ); WordLength = 1; serialPort = new SerialPort( ); }
public void BoolTest( ) { SoftBuffer softBuffer = new SoftBuffer(1000); softBuffer.SetBool(true, 1234); Assert.IsTrue(softBuffer.GetBool(1234)); softBuffer.SetBool(true, 2234); Assert.IsTrue(softBuffer.GetBool(2234)); softBuffer.SetBool(false, 2234); Assert.IsTrue(!softBuffer.GetBool(2234)); softBuffer.SetBool(true, 8); Assert.IsTrue(softBuffer.GetByte(1) == 0x01); }
public void SoftBuffer1( ) { SoftBuffer softBuffer = new SoftBuffer(1000); byte[] b1 = new byte[] { 0x13, 0xA6, 0x15, 0x85, 0x5B, 0x05, 0x12, 0x36, 0xF2, 0x27 }; softBuffer.SetBytes(b1, 367); byte[] b2 = softBuffer.GetBytes(367, b1.Length); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(b1, b2), "第一次" + SoftBasic.ByteToHexString(b2)); byte[] b3 = new byte[] { 0x12, 0xC6, 0x25, 0x3C, 0x42, 0x85, 0x5B, 0x05, 0x12, 0x87 }; softBuffer.SetBytes(b3, 367 + b1.Length); byte[] b4 = softBuffer.GetBytes(367 + b1.Length, b3.Length); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(b3, b4), "第二次"); byte[] b5 = SoftBasic.SpliceTwoByteArray(b1, b3); byte[] b6 = softBuffer.GetBytes(367, b1.Length + b3.Length); Assert.IsTrue(SoftBasic.IsTwoBytesEquel(b5, b6), "第三次"); }