Dlt645
定义
程序集:ThingsGateway.Foundation.Dlt645
一、说明
ThingsGateway.Foundation.Dlt645是对于Dlt645-2007协议的封装类库
支持多个通讯链路:Tcp/Udp/SerialPort
二、Dlt645-2007主站
1、创建Dlt645Master
        /// <summary>
        /// 新建链路
        /// </summary>
        /// <returns></returns>
        public IChannel GetChannel()
        {
            TouchSocketConfig touchSocketConfig = new TouchSocketConfig();
            return touchSocketConfig.GetSerialPortWithOption(new("COM1")); //直接获取串口对象
            //return touchSocketConfig.GetChannel(ChannelTypeEnum.SerialPortClient, null, null, new("COM1"));//通过链路枚举获取对象
        }
        /// <summary>
        /// 新建协议对象
        /// </summary>
        /// <param name="channel"></param>
        /// <returns></returns>
        public IProtocol GetProtocol(IChannel channel)
        {
            var client = new Dlt645_2007Master(channel);
            client.Station = "311111111114";//表号
            return client;
        }
2、读写操作
            Dlt645MasterTest dlt645MasterTest = new Dlt645MasterTest();
            var channel = dlt645MasterTest.GetChannel();
            var protocol = dlt645MasterTest.GetProtocol(channel);
            var data = await protocol.ReadDoubleAsync("02010100"); //读取A相电压
02010100是Dlt645中的地址表示方式,代表A相电压,请查看相关协议文档,可在源码附件中找到文档
- 基本地址
 
| 地址 | 说明 | 
|---|---|
| 02010100 | 读取02010100(A相电压) | 
参考DLT2007协议文档数据标识,可在插件源码中找到附件
- 
站号(可选)
当需要指定站号地址时可使用,举例:
 
| 地址 | 说明 | 
|---|---|
| s=111111111111;02010100 | 读取02010100 ,设备地址为111111111111 | 
- 
Dtu注册(可选)
当需要指定Dtu客户端可使用,举例:
 
| 地址 | 说明 | 
|---|---|
| id=12;40001 | 读取03功能码 ,设备地址为默认,Dtu注册包为"12",注意是UTF8格式 | 
3、其他方法
修改密码
      var result = await protocol.WritePasswordAsync(level, oldPassword, newPassword);
更改表号
      var result = await protocol.WriteDeviceStationAsync(station);