mirror of
https://github.com/OpenLogics/MewtocolNet.git
synced 2025-12-06 11:11:23 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a93df287d |
@@ -195,6 +195,20 @@ namespace MewtocolNet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes all permanent polling
|
||||||
|
/// </summary>
|
||||||
|
public void Disconnect () {
|
||||||
|
|
||||||
|
if (!IsConnected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
OnMajorSocketException();
|
||||||
|
|
||||||
|
PriorityTasks.Clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attaches a poller to the interface that continously
|
/// Attaches a poller to the interface that continously
|
||||||
/// polls the registered data registers and writes the values to them
|
/// polls the registered data registers and writes the values to them
|
||||||
@@ -532,7 +546,6 @@ namespace MewtocolNet {
|
|||||||
/// Calculates checksum and sends a command to the PLC then awaits results
|
/// Calculates checksum and sends a command to the PLC then awaits results
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="_msg">MEWTOCOL Formatted request string ex: %01#RT</param>
|
/// <param name="_msg">MEWTOCOL Formatted request string ex: %01#RT</param>
|
||||||
/// <param name="_close">Auto close of frame [true]%01#RT01\r [false]%01#RT</param>
|
|
||||||
/// <returns>Returns the result</returns>
|
/// <returns>Returns the result</returns>
|
||||||
public async Task<CommandResult> SendCommandAsync (string _msg) {
|
public async Task<CommandResult> SendCommandAsync (string _msg) {
|
||||||
|
|
||||||
@@ -622,6 +635,9 @@ namespace MewtocolNet {
|
|||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
Logger.Log($"Critical IO exception on send", LogLevel.Critical, this);
|
Logger.Log($"Critical IO exception on send", LogLevel.Critical, this);
|
||||||
return null;
|
return null;
|
||||||
|
} catch (SocketException) {
|
||||||
|
OnMajorSocketException();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//await result
|
//await result
|
||||||
@@ -636,6 +652,9 @@ namespace MewtocolNet {
|
|||||||
} catch (IOException) {
|
} catch (IOException) {
|
||||||
Logger.Log($"Critical IO exception on receive", LogLevel.Critical, this);
|
Logger.Log($"Critical IO exception on receive", LogLevel.Critical, this);
|
||||||
return null;
|
return null;
|
||||||
|
} catch (SocketException) {
|
||||||
|
OnMajorSocketException();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
@@ -650,16 +669,7 @@ namespace MewtocolNet {
|
|||||||
|
|
||||||
} catch (SocketException) {
|
} catch (SocketException) {
|
||||||
|
|
||||||
if (IsConnected) {
|
OnMajorSocketException();
|
||||||
|
|
||||||
Logger.Log("The PLC connection was closed", LogLevel.Error, this);
|
|
||||||
CycleTimeMs = 0;
|
|
||||||
IsConnected = false;
|
|
||||||
Disconnected?.Invoke();
|
|
||||||
KillPoller();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -668,6 +678,19 @@ namespace MewtocolNet {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMajorSocketException () {
|
||||||
|
|
||||||
|
if (IsConnected) {
|
||||||
|
|
||||||
|
Logger.Log("The PLC connection was closed", LogLevel.Error, this);
|
||||||
|
CycleTimeMs = 0;
|
||||||
|
IsConnected = false;
|
||||||
|
Disconnected?.Invoke();
|
||||||
|
KillPoller();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<PackageId>MewtocolNet</PackageId>
|
<PackageId>MewtocolNet</PackageId>
|
||||||
<Version>0.4.1</Version>
|
<Version>0.4.2</Version>
|
||||||
<Authors>Felix Weiss</Authors>
|
<Authors>Felix Weiss</Authors>
|
||||||
<Company>Womed</Company>
|
<Company>Womed</Company>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
|
|||||||
Reference in New Issue
Block a user