mirror of
https://github.com/fbarresi/Sharp7.git
synced 2026-02-04 08:42:51 +00:00
Added Name property and override ToString
- fixed value of PLCIpAddress
This commit is contained in:
@@ -661,6 +661,13 @@ namespace Sharp7
|
||||
|
||||
#region [Class Control]
|
||||
|
||||
public S7Client(string name) : this()
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
public S7Client()
|
||||
{
|
||||
CreateSocket();
|
||||
@@ -671,6 +678,11 @@ namespace Sharp7
|
||||
Disconnect();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"PLC {Name ?? string.Empty}@{PLCIpAddress ?? "0.0.0.0"}";
|
||||
}
|
||||
|
||||
public int Connect()
|
||||
{
|
||||
_LastError = 0;
|
||||
@@ -698,7 +710,6 @@ namespace Sharp7
|
||||
|
||||
public int ConnectTo(string Address, int Rack, int Slot)
|
||||
{
|
||||
PLCIpAddress = Address;
|
||||
UInt16 RemoteTSAP = (UInt16)((ConnType << 8) + (Rack * 0x20) + Slot);
|
||||
SetConnectionParams(Address, 0x0100, RemoteTSAP);
|
||||
return Connect();
|
||||
@@ -2269,7 +2280,7 @@ namespace Sharp7
|
||||
}
|
||||
}
|
||||
|
||||
public string PLCIpAddress { get; private set; }
|
||||
public string PLCIpAddress => IPAddress;
|
||||
|
||||
public int PLCPort
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user