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]
|
#region [Class Control]
|
||||||
|
|
||||||
|
public S7Client(string name) : this()
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
public S7Client()
|
public S7Client()
|
||||||
{
|
{
|
||||||
CreateSocket();
|
CreateSocket();
|
||||||
@@ -671,6 +678,11 @@ namespace Sharp7
|
|||||||
Disconnect();
|
Disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"PLC {Name ?? string.Empty}@{PLCIpAddress ?? "0.0.0.0"}";
|
||||||
|
}
|
||||||
|
|
||||||
public int Connect()
|
public int Connect()
|
||||||
{
|
{
|
||||||
_LastError = 0;
|
_LastError = 0;
|
||||||
@@ -698,7 +710,6 @@ namespace Sharp7
|
|||||||
|
|
||||||
public int ConnectTo(string Address, int Rack, int Slot)
|
public int ConnectTo(string Address, int Rack, int Slot)
|
||||||
{
|
{
|
||||||
PLCIpAddress = Address;
|
|
||||||
UInt16 RemoteTSAP = (UInt16)((ConnType << 8) + (Rack * 0x20) + Slot);
|
UInt16 RemoteTSAP = (UInt16)((ConnType << 8) + (Rack * 0x20) + Slot);
|
||||||
SetConnectionParams(Address, 0x0100, RemoteTSAP);
|
SetConnectionParams(Address, 0x0100, RemoteTSAP);
|
||||||
return Connect();
|
return Connect();
|
||||||
@@ -2269,7 +2280,7 @@ namespace Sharp7
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string PLCIpAddress { get; private set; }
|
public string PLCIpAddress => IPAddress;
|
||||||
|
|
||||||
public int PLCPort
|
public int PLCPort
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user