zoukankan      html  css  js  c++  java
  • 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();

    版权声明:本博客所有图片、文字等版权属于虫子樱桃所有,未经许可谢绝任何形式的复制和传播。博客的图片和代码部分来自网络,本站均已注明来源和作者原来的声明。如有侵权,请使用本站联系方式告诉,我们将会在第一时间做出处理。
  • 相关阅读:
    点击链接,取得href的值,但是不转向
    启动和停止MySQL服务
    QuickText for Notepad++
    otepad++ 配置 支持jquery、html、css、javascript、php代码提示
    windows 2008+IIS7+Mysql+PHP5.5 + FastCGI环境配置
    Jquery异步请求数据实例代码
    JS读取本地文件及目录的方法
    c#.net从ftp下载文件到本地
    怎样才能充分利用SQL索引
    jQuery EasyUI Datagrid性能优化专题
  • 原文地址:https://www.cnblogs.com/czytcn/p/7646778.html
Copyright © 2011-2022 走看看