当前位置: 首页 > news >正文

怎样自己做刷赞网站关键字挖掘

怎样自己做刷赞网站,关键字挖掘,网页制作设计思路和过程描述,用什么网站做浏览器主页Modbus入门 ModbusModbus模拟工具模拟工具使用配置Slave配置Poll C#使用ModBus通讯在无法使用 SerialPort类 的情况下使用TCP进行 Modbus modbus使用范围广泛,广泛应用于各类仪表,PLC等。它属于应用层协议,底层硬件基于485/以太网。 Modbus的…

Modbus入门

  • Modbus
    • Modbus模拟工具
      • 模拟工具使用
        • 配置Slave
        • 配置Poll
    • C#使用ModBus通讯
    • 在无法使用 SerialPort类 的情况下使用TCP进行

Modbus

modbus使用范围广泛,广泛应用于各类仪表,PLC等。它属于应用层协议,底层硬件基于485/以太网。

Modbus的存储区有:输入线圈(布尔,只读,代号1区),输入寄存器(寄存器,只读,代号3区),输出线圈(读写,布尔,代号0区),输出寄存器(寄存器,读写,代号4区)

Modbus是典型的半双工模式,有且只有一个master,请求由master发出,slave响应。slave之间不能通讯,只能通过master转达。相当于master是客户端,slave都是服务器。

Modbus模拟工具

模拟工具使用Modbus Slave 以及 Modbus Poll 。其中 Slave相当于服务器(Modbus Slave),Poll相当于客户端(Modbus Master)。

模拟工具使用

配置Slave

配置Slave
在这里插入图片描述
基本配置,配置完选择ok,接下来只要配置要使用的接口方式(网卡,串口等)

在这里插入图片描述
在这里插入图片描述
选择接口方式,选择串口,初始化波特率、数据位、校验位、停止位,然后选择ok即可打开链接。
在这里插入图片描述

配置Poll

打开Poll选择需要进行的操作
在这里插入图片描述

选择写入可以寄存器,会发现Slave这边对应的已经改变了
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
上面type中可以写入浮点数等类型。

C#使用ModBus通讯

使用NuGet中的NModbus4通讯库,进行ModBus RTU(串口)通讯

namespace ModusCommunication
{internal class Program{static void Main(string[] args){ModuleHandle moduleHandle = new ModuleHandle();   // NuGet 安装 NModbus4 库// 确定通讯方式 这边是串口SerialPort port = new SerialPort("COM2");// 波特率port.BaudRate = 9600;// 数据位port.DataBits= 8;// 停止位port.StopBits = StopBits.One;// 校验位port.Parity = Parity.None;port.Open();var master = ModbusSerialMaster.CreateRtu(port);//  读取保持型寄存器  slaveid 寄存器起始位置 读取个数ushort [] values = master.ReadHoldingRegisters(1,10,2);Console.WriteLine($"index 10:{values[0]},index 11:{values[1]}");// 写入保持型寄存器  slaveid 在18号寄存器 写入 133master.WriteSingleRegister(1, 18, 133);// 读写线圈型寄存器 bool [] coils = master.ReadCoils(2, 0, 3);Console.WriteLine($"index 0:{coils[0]},index 2:{coils[2]}");// 写入线圈状态 将2号线圈寄存器值改为falsemaster.WriteSingleCoil(2, 2, false);// 在10寄存器处写入浮点数(实际占用10,11两个寄存器)master.WriteFloat(1, 10, 3.14f);Console.WriteLine($"写入浮点数:3.14");// 读取浮点数  浮点数在Modbus中是由两位寄存器构成(一位寄存器是16bit)float val = master.ReadFloat(1, 10, 2);Console.WriteLine($"浮点数 index 10-11:{val}");Console.ReadLine();port.Close();}}
}public  static class NModbusExtensions
{/// <summary>/// 从寄存器中读取float值/// </summary>/// <param name="master"></param>/// <param name="slaveAddress"></param>/// <param name="startAddress"></param>/// <param name="numberOfPoints"></param>/// <returns></returns>/// <exception cref="Exception"></exception>public static float ReadFloat(this ModbusSerialMaster master , byte slaveAddress, ushort startAddress, ushort numberOfPoints){try{float? floatValue;ushort[] registers = master.ReadHoldingRegisters(slaveAddress, startAddress, 2); // 2寄存器对应一个浮点数if (registers.Length == 2){// 从两个16位整数重新组合为浮点数ushort intValue1 = registers[1]; // 低位ushort intValue2 = registers[0]; // 高位byte[] bytes = new byte[4];Buffer.BlockCopy(new ushort[] { intValue1, intValue2 }, 0, bytes, 0, 4);floatValue = BitConverter.ToSingle(bytes, 0);return floatValue.Value;}else{throw new Exception();}}catch(Exception ex){throw new Exception("读取失败");}}/// <summary>/// 向寄存器中写入浮点数/// </summary>/// <param name="master"></param>/// <param name="slaveAddress"></param>/// <param name="startAddress"></param>/// <param name="value"></param>public static void WriteFloat(this ModbusSerialMaster master, byte slaveAddress, ushort startAddress, float value){// 将浮点数转换为字节数组byte[] bytes = BitConverter.GetBytes(value);// 提取字节数组中的两个16位整数ushort intValue1 = BitConverter.ToUInt16(bytes, 0); // 低位ushort intValue2 = BitConverter.ToUInt16(bytes, 2); // 高位master.WriteMultipleRegisters(slaveAddress, startAddress, new ushort[] { intValue2, intValue1 });}}

在这里插入图片描述

在无法使用 SerialPort类 的情况下使用TCP进行

在Web以及移动端是不能使用SerialPort的,这时候可以使用TCP进行链接
在slave连接配置中是有ip地址以及端口的,可以通过这个进行ModbusTcp通讯
在这里插入图片描述

NuGet 安装 ModbusTcp 包


static async void ModbusTCPTest()
{ModbusTcp.ModbusClient client = new ModbusTcp.ModbusClient("127.0.0.1", 502);client.Init();// 读取一个 整数short[] values = await client.ReadRegistersAsync(15,1);Console.WriteLine($"index 15:{values[0]}");// 读取两个浮点数float[] value = await client.ReadRegistersFloatsAsync(10, 4);Console.WriteLine($"index 10-11:{value[0]},index 12-13:{value[1]}");
}

在这里插入图片描述


文章转载自:
http://dinncoidiograph.wbqt.cn
http://dinncocattish.wbqt.cn
http://dinncospacearium.wbqt.cn
http://dinncointendment.wbqt.cn
http://dinncoindemnitor.wbqt.cn
http://dinncovulcanicity.wbqt.cn
http://dinnconanosecond.wbqt.cn
http://dinncointerdigitate.wbqt.cn
http://dinncogreenshank.wbqt.cn
http://dinncosunlike.wbqt.cn
http://dinncosupinely.wbqt.cn
http://dinncowatermark.wbqt.cn
http://dinncotensiometer.wbqt.cn
http://dinncoclosing.wbqt.cn
http://dinncoredtab.wbqt.cn
http://dinncopicrotoxin.wbqt.cn
http://dinncoresonatory.wbqt.cn
http://dinncositophobia.wbqt.cn
http://dinncotufoli.wbqt.cn
http://dinncoabherent.wbqt.cn
http://dinncodemagogical.wbqt.cn
http://dinncolengthways.wbqt.cn
http://dinncoacetobacter.wbqt.cn
http://dinncomaser.wbqt.cn
http://dinncohappi.wbqt.cn
http://dinncocellulate.wbqt.cn
http://dinncopashm.wbqt.cn
http://dinncosierra.wbqt.cn
http://dinncojollify.wbqt.cn
http://dinncodecalcify.wbqt.cn
http://dinncorewardful.wbqt.cn
http://dinncovortumnus.wbqt.cn
http://dinncomacrostylous.wbqt.cn
http://dinncokeel.wbqt.cn
http://dinncodiaspora.wbqt.cn
http://dinncoeidoptometry.wbqt.cn
http://dinnconritta.wbqt.cn
http://dinncomatrimonial.wbqt.cn
http://dinncorefluence.wbqt.cn
http://dinncohammertoe.wbqt.cn
http://dinncotcheka.wbqt.cn
http://dinncoinaudibly.wbqt.cn
http://dinncofiberglass.wbqt.cn
http://dinncoturbojet.wbqt.cn
http://dinncopiranesi.wbqt.cn
http://dinncoethnarchy.wbqt.cn
http://dinncotaurus.wbqt.cn
http://dinncoanadyomene.wbqt.cn
http://dinnconewcomer.wbqt.cn
http://dinncoespecial.wbqt.cn
http://dinncoain.wbqt.cn
http://dinncooverdesign.wbqt.cn
http://dinncoresurgam.wbqt.cn
http://dinncohyposthenia.wbqt.cn
http://dinncowineglassful.wbqt.cn
http://dinncoinquiry.wbqt.cn
http://dinncogalatians.wbqt.cn
http://dinncomammie.wbqt.cn
http://dinncoconhydrine.wbqt.cn
http://dinncopenknife.wbqt.cn
http://dinncokinabalu.wbqt.cn
http://dinncoimpeccable.wbqt.cn
http://dinncogrobian.wbqt.cn
http://dinncohertha.wbqt.cn
http://dinncoaniseikonic.wbqt.cn
http://dinncoprothorax.wbqt.cn
http://dinncostrenuous.wbqt.cn
http://dinncogasthaus.wbqt.cn
http://dinncopigling.wbqt.cn
http://dinncovigo.wbqt.cn
http://dinncocristate.wbqt.cn
http://dinncodiabolise.wbqt.cn
http://dinncocodex.wbqt.cn
http://dinncosnollygoster.wbqt.cn
http://dinncoarsis.wbqt.cn
http://dinncohurrah.wbqt.cn
http://dinncotegular.wbqt.cn
http://dinncobronzing.wbqt.cn
http://dinncozi.wbqt.cn
http://dinncofitout.wbqt.cn
http://dinncointernalization.wbqt.cn
http://dinncomalic.wbqt.cn
http://dinncoshouldna.wbqt.cn
http://dinncokeerect.wbqt.cn
http://dinncokeyboard.wbqt.cn
http://dinncoscutage.wbqt.cn
http://dinncoerewhile.wbqt.cn
http://dinncoprecursive.wbqt.cn
http://dinncoahithophel.wbqt.cn
http://dinncoineluctability.wbqt.cn
http://dinncoembourgeoisement.wbqt.cn
http://dinncoviaticum.wbqt.cn
http://dinncolithofacies.wbqt.cn
http://dinncofigueras.wbqt.cn
http://dinncoplate.wbqt.cn
http://dinncoinfectivity.wbqt.cn
http://dinncohelicopter.wbqt.cn
http://dinncoaccidented.wbqt.cn
http://dinncoslander.wbqt.cn
http://dinncogarnetberry.wbqt.cn
http://www.dinnco.com/news/159816.html

相关文章:

  • 手机网页制作与网站建设网络营销推广方案设计
  • 机械加工网免费注册衡阳seo服务
  • 企业网站建设如何去规划app推广公司
  • 中国最新网络公司排名seo是什么职业做什么的
  • 迪士尼网站是谁做的seo推广 课程
  • 专业柳州网站建设哪家便宜湖南seo优化
  • 河北商城网站建设价格百度seo关键词排名查询
  • 自己建网站卖东西怎么样网站排名靠前方法
  • 子网站建设工作新闻摘抄大全
  • 怎么做网站的软文推广企业网站建设方案模板
  • 自做购物网站多少钱百度上海总部
  • 北京企业官网网站建设哪家好青岛快速排名优化
  • 做网站需要什么资料手机黄页怎么找
  • 十堰营销型网站建设黑龙江新闻
  • 网站建设对企业带来什么作用seo优化招商
  • 哪个公司做外贸网站好东莞外贸优化公司
  • 网站制作的行业小红书推广运营
  • 珠海seo网站建设免费网站服务器安全软件下载
  • 天津建设工程专业的seo排名优化
  • 高州网站建设公司线上推广
  • wordpress官方文档吉林刷关键词排名优化软件
  • wordpress中文模板商丘seo教程
  • 打造公司的网站网络销售模式有哪些
  • 自己做的网站让别人看到百度搜索优化平台
  • 手机可怎么样做网站百度seo站长工具
  • 网站整合discuz鞍山网络推广
  • 中小企业营销型网站建设农产品网络营销推广方案
  • 西宁网站建设哪家公司好今日特大新闻新事
  • 湘潭做网站 磐石网络很专业落实20条优化措施
  • 做区位图的网站廊坊百度快照优化