mirror of
https://github.com/ThingsGateway/ThingsGateway.git
synced 2026-10-23 08:48:59 +08:00
整理代码
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TargetFrameworks>net6.0;net8.0;</TargetFrameworks>
|
||||
<Version>4.0.0.7</Version>
|
||||
<Version>4.0.0.8</Version>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Authors>Diego</Authors>
|
||||
<Product>ThingsGateway</Product>
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@
|
||||
namespace ThingsGateway.Foundation.Demo;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public partial class SerialSessionPage : IDisposable
|
||||
public partial class SerialPortClientPage : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志输出
|
||||
@@ -36,7 +36,7 @@ public partial class SerialSessionPage : IDisposable
|
||||
/// 获取对象
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public SerialPortClient GetSerialSession()
|
||||
public SerialPortClient GetSerialPortClient()
|
||||
{
|
||||
_config ??= new TouchSocketConfig();
|
||||
var LogMessage = new LoggerGroup() { LogLevel = LogLevel.Trace };
|
||||
@@ -81,7 +81,7 @@ public partial class SerialSessionPage : IDisposable
|
||||
try
|
||||
{
|
||||
_serialPortClient.Close();
|
||||
await GetSerialSession().ConnectAsync();
|
||||
await GetSerialPortClient().ConnectAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
@using Masa.Blazor;
|
||||
@namespace ThingsGateway.Foundation.Demo
|
||||
|
||||
<SerialSessionPage @ref=_serialSessionPage></SerialSessionPage>
|
||||
<SerialPortClientPage @ref=_serialPortClientPage></SerialPortClientPage>
|
||||
|
||||
<MCard Flat Class="pa-2 my-1" Style="width:100%">
|
||||
<div class="mb-4">驱动配置</div>
|
||||
|
||||
+5
-5
@@ -17,9 +17,9 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class DLT645_2007DebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private SerialSessionPage _serialSessionPage;
|
||||
private SerialPortClientPage _serialPortClientPage;
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
private ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007 _plc;
|
||||
/// <summary>
|
||||
@@ -69,9 +69,9 @@ public partial class DLT645_2007DebugPage
|
||||
""", "csharp"));
|
||||
|
||||
|
||||
if (_serialSessionPage != null)
|
||||
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
|
||||
_plc = new ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007(_serialSessionPage.GetSerialSession());
|
||||
if (_serialPortClientPage != null)
|
||||
_serialPortClientPage.LogAction = _driverDebugUIPage.LogOut;
|
||||
_plc = new ThingsGateway.Foundation.Adapter.DLT645.DLT645_2007(_serialPortClientPage.GetSerialPortClient());
|
||||
_driverDebugUIPage.Plc = _plc;
|
||||
|
||||
//初始化
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class DLT645_2007OverTcpDebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private TcpClientPage _tcpClientPage;
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
@using Masa.Blazor;
|
||||
@namespace ThingsGateway.Foundation.Demo
|
||||
|
||||
<SerialSessionPage @ref=_serialSessionPage></SerialSessionPage>
|
||||
<SerialPortClientPage @ref=_serialPortClientPage></SerialPortClientPage>
|
||||
|
||||
<MCard Flat Class="pa-2 my-1" Style="width:100%">
|
||||
<div class="mb-4">驱动配置</div>
|
||||
|
||||
+5
-5
@@ -19,9 +19,9 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class ModbusRtuDebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private SerialSessionPage _serialSessionPage;
|
||||
private SerialPortClientPage _serialPortClientPage;
|
||||
private readonly List<(string Code, string Language)> _sections = new();
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
|
||||
@@ -72,9 +72,9 @@ public partial class ModbusRtuDebugPage
|
||||
""", "csharp"));
|
||||
|
||||
|
||||
if (_serialSessionPage != null)
|
||||
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
|
||||
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu(_serialSessionPage.GetSerialSession());
|
||||
if (_serialPortClientPage != null)
|
||||
_serialPortClientPage.LogAction = _driverDebugUIPage.LogOut;
|
||||
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusRtu(_serialPortClientPage.GetSerialPortClient());
|
||||
_driverDebugUIPage.Plc = _plc;
|
||||
//载入配置
|
||||
StateHasChanged();
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class ModbusRtuOverTcpDebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private TcpClientPage _tcpClientPage;
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class ModbusRtuOverUdpDebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private UdpSessionPage _udpSessionPage;
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
@using Masa.Blazor;
|
||||
@namespace ThingsGateway.Foundation.Demo
|
||||
|
||||
<SerialSessionPage @ref=_serialSessionPage></SerialSessionPage>
|
||||
<SerialPortClientPage @ref=_serialPortClientPage></SerialPortClientPage>
|
||||
|
||||
<MCard Flat Class="pa-2 my-1" Style="width:100%">
|
||||
<div class="mb-4">驱动配置</div>
|
||||
|
||||
+5
-5
@@ -17,9 +17,9 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class ModbusSerialServerDebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private SerialSessionPage _serialSessionPage;
|
||||
private SerialPortClientPage _serialPortClientPage;
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
|
||||
private ThingsGateway.Foundation.Adapter.Modbus.ModbusSerialServer _plc;
|
||||
@@ -70,9 +70,9 @@ public partial class ModbusSerialServerDebugPage
|
||||
""", "csharp"));
|
||||
|
||||
|
||||
if (_serialSessionPage != null)
|
||||
_serialSessionPage.LogAction = _driverDebugUIPage.LogOut;
|
||||
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusSerialServer(_serialSessionPage.GetSerialSession());
|
||||
if (_serialPortClientPage != null)
|
||||
_serialPortClientPage.LogAction = _driverDebugUIPage.LogOut;
|
||||
_plc = new ThingsGateway.Foundation.Adapter.Modbus.ModbusSerialServer(_serialPortClientPage.GetSerialPortClient());
|
||||
_driverDebugUIPage.Plc = _plc;
|
||||
//载入配置
|
||||
StateHasChanged();
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public partial class ModbusTcpDebugPage
|
||||
private ThingsGateway.Foundation.Adapter.Modbus.ModbusTcp _plc;
|
||||
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private TcpClientPage _tcpClientPage;
|
||||
/// <summary>
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ namespace ThingsGateway.Foundation.Demo;
|
||||
public partial class ModbusUdpDebugPage
|
||||
{
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private UdpSessionPage _udpSessionPage;
|
||||
private DriverDebugUIPage _driverDebugUIPage;
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public partial class SiemensDebugPage
|
||||
private ThingsGateway.Foundation.Adapter.Siemens.SiemensS7PLC _plc;
|
||||
|
||||
/// <summary>
|
||||
/// SerialSessionPage
|
||||
/// SerialPortClientPage
|
||||
/// </summary>
|
||||
private TcpClientPage _tcpClientPage;
|
||||
/// <summary>
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace ThingsGateway.Foundation.Adapter.DLT645;
|
||||
/// <summary>
|
||||
/// DLT645_2007
|
||||
/// </summary>
|
||||
public class DLT645_2007 : ReadWriteDevicesSerialSessionBase, IDLT645_2007
|
||||
public class DLT645_2007 : ReadWriteDevicesSerialPortClientBase, IDLT645_2007
|
||||
{
|
||||
/// <summary>
|
||||
/// DLT645_2007
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace ThingsGateway.Foundation.Adapter.Modbus;
|
||||
/// <summary>
|
||||
/// ModbusRtu
|
||||
/// </summary>
|
||||
public class ModbusRtu : ReadWriteDevicesSerialSessionBase
|
||||
public class ModbusRtu : ReadWriteDevicesSerialPortClientBase
|
||||
{
|
||||
/// <summary>
|
||||
/// ModbusRtu
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace ThingsGateway.Foundation.Adapter.Modbus;
|
||||
/// <summary>
|
||||
/// <inheritdoc/>
|
||||
/// </summary>
|
||||
public class ModbusSerialServer : ReadWriteDevicesSerialSessionBase, IModbusServer
|
||||
public class ModbusSerialServer : ReadWriteDevicesSerialPortClientBase, IModbusServer
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public ModbusSerialServer(SerialPortClient serialPortClient) : base(serialPortClient)
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@ namespace ThingsGateway.Foundation.Core;
|
||||
/// <summary>
|
||||
/// 串口读写设备
|
||||
/// </summary>
|
||||
public abstract class ReadWriteDevicesSerialSessionBase : ReadWriteDevicesBase
|
||||
public abstract class ReadWriteDevicesSerialPortClientBase : ReadWriteDevicesBase
|
||||
{
|
||||
/// <summary>
|
||||
/// <inheritdoc cref="ReadWriteDevicesSerialSessionBase"/>
|
||||
/// <inheritdoc cref="ReadWriteDevicesSerialPortClientBase"/>
|
||||
/// </summary>
|
||||
/// <param name="serialPortClient"></param>
|
||||
public ReadWriteDevicesSerialSessionBase(SerialPortClient serialPortClient)
|
||||
public ReadWriteDevicesSerialPortClientBase(SerialPortClient serialPortClient)
|
||||
{
|
||||
SerialPortClient = serialPortClient;
|
||||
WaitingClientEx = SerialPortClient.CreateWaitingClient(new() { });
|
||||
|
||||
+4
-5
@@ -232,8 +232,7 @@ namespace ThingsGateway.Foundation.SerialPorts
|
||||
{
|
||||
if (this.m_online)
|
||||
{
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, msg));
|
||||
this.MainSerialPort.TryClose();
|
||||
this.PrivateOnDisconnecting(new DisconnectEventArgs(true, msg)).GetFalseAwaitResult();
|
||||
this.BreakOut(true, msg);
|
||||
}
|
||||
}
|
||||
@@ -249,7 +248,7 @@ namespace ThingsGateway.Foundation.SerialPorts
|
||||
{
|
||||
if (this.m_online)
|
||||
{
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开"));
|
||||
this.PrivateOnDisconnecting(new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开")).GetFalseAwaitResult();
|
||||
this.BreakOut(true, $"{nameof(Dispose)}主动断开");
|
||||
}
|
||||
}
|
||||
@@ -357,7 +356,7 @@ namespace ThingsGateway.Foundation.SerialPorts
|
||||
this.MainSerialPort.SafeDispose();
|
||||
this.m_delaySender.SafeDispose();
|
||||
this.DataHandlingAdapter.SafeDispose();
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnected, new DisconnectEventArgs(manual, msg));
|
||||
this.PrivateOnDisconnected(new DisconnectEventArgs(manual, msg)).GetFalseAwaitResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,7 +429,7 @@ namespace ThingsGateway.Foundation.SerialPorts
|
||||
}
|
||||
private SerialPort CreateSerial(SerialPortOption serialPortOption)
|
||||
{
|
||||
SerialPortOption = serialPortOption;
|
||||
SerialPortOption = serialPortOption.Map<SerialPortOption>();
|
||||
var serialPort = new SerialPort(serialPortOption.PortName, serialPortOption.BaudRate, serialPortOption.Parity, serialPortOption.DataBits, serialPortOption.StopBits);
|
||||
return serialPort;
|
||||
}
|
||||
|
||||
+3
-3
@@ -233,7 +233,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
this.MainSocket.SafeDispose();
|
||||
this.m_delaySender.SafeDispose();
|
||||
this.DataHandlingAdapter.SafeDispose();
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnected, new DisconnectEventArgs(manual, msg));
|
||||
this.PrivateOnDisconnected(new DisconnectEventArgs(manual, msg)).GetFalseAwaitResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
{
|
||||
if (this.Online)
|
||||
{
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, msg));
|
||||
this.PrivateOnDisconnecting(new DisconnectEventArgs(true, msg)).GetFalseAwaitResult();
|
||||
this.MainSocket.TryClose();
|
||||
this.BreakOut(true, msg);
|
||||
}
|
||||
@@ -479,7 +479,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
{
|
||||
if (this.Online)
|
||||
{
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开"));
|
||||
this.PrivateOnDisconnecting(new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开")).GetFalseAwaitResult();
|
||||
this.BreakOut(true, $"{nameof(Dispose)}主动断开");
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -267,7 +267,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
{
|
||||
if (this.m_online)
|
||||
{
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, msg));
|
||||
this.PrivateOnDisconnecting(new DisconnectEventArgs(true, msg)).GetFalseAwaitResult();
|
||||
this.MainSocket.TryClose();
|
||||
this.BreakOut(true, msg);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
{
|
||||
if (this.m_online)
|
||||
{
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnecting, new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开"));
|
||||
this.PrivateOnDisconnecting(new DisconnectEventArgs(true, $"{nameof(Dispose)}主动断开")).GetFalseAwaitResult();
|
||||
this.BreakOut(true, $"{nameof(Dispose)}主动断开");
|
||||
}
|
||||
}
|
||||
@@ -498,7 +498,7 @@ namespace ThingsGateway.Foundation.Sockets
|
||||
this.MainSocket.SafeDispose();
|
||||
this.m_delaySender.SafeDispose();
|
||||
this.DataHandlingAdapter.SafeDispose();
|
||||
Task.Factory.StartNew(this.PrivateOnDisconnected, new DisconnectEventArgs(manual, msg));
|
||||
this.PrivateOnDisconnected(new DisconnectEventArgs(manual, msg)).GetFalseAwaitResult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\DriverDebugUIBase.cs" Link="DebugPage\DriverDebugUIBase.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\DriverDebugUIPage.razor.cs" Link="DebugPage\DriverDebugUIPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialSessionPage.razor.cs" Link="DebugPage\SerialSessionPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialPortClientPage.razor.cs" Link="DebugPage\SerialPortClientPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\TcpClientPage.razor.cs" Link="DebugPage\TcpClientPage.razor.cs" />
|
||||
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\DriverDebugUIPage.razor" Link="DebugPage\DriverDebugUIPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialSessionPage.razor" Link="DebugPage\SerialSessionPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialPortClientPage.razor" Link="DebugPage\SerialPortClientPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\TcpClientPage.razor" Link="DebugPage\TcpClientPage.razor" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\DriverDebugUIBase.cs" Link="DebugPage\DriverDebugUIBase.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\DriverDebugUIPage.razor.cs" Link="DebugPage\DriverDebugUIPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialSessionPage.razor.cs" Link="DebugPage\SerialSessionPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialPortClientPage.razor.cs" Link="DebugPage\SerialPortClientPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\TcpClientPage.razor.cs" Link="DebugPage\TcpClientPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\TcpServerPage.razor.cs" Link="DebugPage\TcpServerPage.razor.cs" />
|
||||
<Compile Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\UdpSessionPage.razor.cs" Link="DebugPage\UdpSessionPage.razor.cs" />
|
||||
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\DriverDebugUIPage.razor" Link="DebugPage\DriverDebugUIPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialSessionPage.razor" Link="DebugPage\SerialSessionPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\SerialPortClientPage.razor" Link="DebugPage\SerialPortClientPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\TcpClientPage.razor" Link="DebugPage\TcpClientPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\TcpServerPage.razor" Link="DebugPage\TcpServerPage.razor" />
|
||||
<Content Include="..\..\Demo\ThingsGateway.Foundation.Demo.Rcl\Components\DebugPage\UdpSessionPage.razor" Link="DebugPage\UdpSessionPage.razor" />
|
||||
|
||||
Reference in New Issue
Block a user