Files
ThingsGateway/framework/demo/ThingsGateway.Foundation.Demo.Rcl/Pages/DLT645/DLT645_2007DebugPage.razor.cs
Kimdiego2098 e1c492f238 整理文件
2023-11-18 23:02:28 +08:00

88 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
namespace ThingsGateway.Foundation.Demo;
/// <inheritdoc/>
public partial class DLT645_2007DebugPage
{
/// <summary>
/// SerialSessionPage
/// </summary>
private SerialSessionPage _serialSessionPage;
private DriverDebugUIPage _driverDebugUIPage;
private ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007 _plc;
/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="firstRender"></param>
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
_sections.Add((
"""
private static async Task ModbusClientAsync()
{
//链路基础配置项
var config = new TouchSocketConfig();
config
.SetSerialProperty(new SerialProperty() //串口链路才需要
{
PortName = "COM1"
});
var serialSession = new SerialSession();//链路对象
serialSession.Setup(config);
//创建协议对象,构造函数需要传入对应链路对象
DLT645_2007 plc = new(serialSession)//传入链路
{
//协议配置
DataFormat = DataFormat.ABCD,
FrameTime = 0,
CacheTimeout = 1000,
ConnectTimeOut = 3000,
Station = 1,
TimeOut = 3000,
Crc16CheckEnable = true
};
#region
var result = await plc.ReadStringAsync("00000000", 1);
#endregion
}
""", "csharp"));
if (_serialSessionPage != null)
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
_plc = new ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007(_serialSessionPage.GetSerialSession());
_driverDebugUIPage.Plc = _plc;
//初始化
_driverDebugUIPage.Address = "02010100";
_driverDebugUIPage.DeviceVariableRunTimes.ForEach(a => a.Address = "02010100");
//载入配置
StateHasChanged();
}
base.OnAfterRender(firstRender);
}
}