WSMBT Modbus & WSMBS Modbus 控件及注册机

Posted 虫子樱桃の博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WSMBT Modbus & WSMBS Modbus 控件及注册机相关的知识,希望对你有一定的参考价值。

先上注册机 点击下载
How to add the WSMBT control to the toolbox:
  1. On the Tools menu, click Choose Toolbox Items.
    Image
  2. Click browse. The open dialog appears.
    Image(1)
  3. Browse for the wsmbt.dll
    Image(2)
  4. Click ok in the "Choose toolbox Items" dialog box.
    Image(3)
  5. Now you can find the WSMBT control in the toolbox.
    Image(4)
  6. Add the WSMBTControl to your form like you add a timer.

Example code how to make a connection.

WSMBT.Result Result;

wsmbtControl1.Mode = WSMBS.Mode.TCP_IP;

wsmbtControl1.ResponseTimeout = 1000;

wsmbtControl1.ConnectTimeout = 1000;

Result = wsmbtControl1.Connect("127.0.0.1", 502);

if (Result != WSMBT.Result.SUCCESS)

  MessageBox.Show(wsmbtControl1.GetLastErrorString());

Example code to read 10 holding registers.

Int16[] Registers = new Int16[10];

WSMBT.Result Result;

Result = wsmbtControl1.ReadHoldingRegisters(1, 0, 10, Registers);

if (Result != WSMBT.Result.SUCCESS)

   MessageBox.Show(wsmbtControl1.GetLastErrorString());

bool vaild =  mbsSerial.LicenseKey("661366411818111882382891650B3");

            if (!vaild)

            {

                MessageBox.Show("您未注册成功!");

            }

            Int16[] registers = new Int16[28];

            WSMBS.Result Result;

            Result = mbsSerial.Open();

            if (Result != WSMBS.Result.SUCCESS)

            {

                return;

            }

            Result = mbsSerial.ReadHoldingRegisters(2, 2, 28, registers);

            //

            byte[] x = ParseHex("0x4481");

            MessageBox.Show(x.Length.ToString());

            //MessageBox.Show(mbsSerial.RegistersToFloat(0x4841, 0x0000).ToString());

           // MessageBox.Show(Result.ToString() + registers.Length.ToString());

            mbsSerial.Close();

以上是关于WSMBT Modbus & WSMBS Modbus 控件及注册机的主要内容,如果未能解决你的问题,请参考以下文章

Modbus设备数据采集学习工具完整资料套装&视频教程

Modbus设备数据采集学习工具完整资料套装&视频教程

Modbus总线CRC16效验算法C语言

郭博分析modbus主机模式

modbus指令读取长度

modbus tcp报文如何监听