C3DeviceController - prop. IPAddress to field.
This commit is contained in:
parent
4ee2507055
commit
e72f365013
|
@ -9,7 +9,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
public class C3DeviceController
|
public class C3DeviceController
|
||||||
{
|
{
|
||||||
public string IPAddress { get; }
|
private string ipAddress;
|
||||||
private int port;
|
private int port;
|
||||||
private IntPtr oneTimeConnectedParamHandler;
|
private IntPtr oneTimeConnectedParamHandler;
|
||||||
private string connectionString;
|
private string connectionString;
|
||||||
|
@ -20,9 +20,9 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
public C3DeviceController(string ipAddress, int port = C3Constant.DEFAULT_C3_PORT)
|
public C3DeviceController(string ipAddress, int port = C3Constant.DEFAULT_C3_PORT)
|
||||||
{
|
{
|
||||||
IPAddress = ipAddress;
|
this.ipAddress = ipAddress;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
connectionString = $"protocol=TCP,ipaddress={this.IPAddress},port={this.port},timeout=2000,passwd=";
|
connectionString = $"protocol=TCP,ipaddress={this.ipAddress},port={this.port},timeout=2000,passwd=";
|
||||||
oneTimeConnectedParamHandler = IntPtr.Zero;
|
oneTimeConnectedParamHandler = IntPtr.Zero;
|
||||||
isReconnected = true;
|
isReconnected = true;
|
||||||
reconnectCounter = 0;
|
reconnectCounter = 0;
|
||||||
|
@ -50,7 +50,7 @@ namespace AIParkingApplication
|
||||||
|
|
||||||
public ActionResult Connect()
|
public ActionResult Connect()
|
||||||
{
|
{
|
||||||
if (Util.IsPingable(IPAddress, out long replyTime))
|
if (Util.IsPingable(ipAddress, out long replyTime))
|
||||||
{
|
{
|
||||||
oneTimeConnectedParamHandler = Connect(connectionString);
|
oneTimeConnectedParamHandler = Connect(connectionString);
|
||||||
if (oneTimeConnectedParamHandler != IntPtr.Zero)
|
if (oneTimeConnectedParamHandler != IntPtr.Zero)
|
||||||
|
@ -58,7 +58,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = false,
|
HasError = false,
|
||||||
Message = string.Format(C3Constant.CONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.CONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.FAILED_TO_CONNECT, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress, PullLastError())
|
Message = string.Format(C3Constant.FAILED_TO_CONNECT, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress, PullLastError())
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = false,
|
HasError = false,
|
||||||
Message = string.Format(C3Constant.OPENNED_DOOR_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.OPENNED_DOOR_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.FAILED_TO_OPEN_DOOR, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.FAILED_TO_OPEN_DOOR, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.NOT_CONNECTTED, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.NOT_CONNECTTED, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -136,13 +136,13 @@ namespace AIParkingApplication
|
||||||
doorId = C3Constant.DEFAULT_DOOR_ID;
|
doorId = C3Constant.DEFAULT_DOOR_ID;
|
||||||
cardNumber = C3Constant.DEFAULT_CARD_NUMBER;
|
cardNumber = C3Constant.DEFAULT_CARD_NUMBER;
|
||||||
|
|
||||||
if (!Util.IsPingable(IPAddress, out long replyTime))
|
if (!Util.IsPingable(ipAddress, out long replyTime))
|
||||||
{
|
{
|
||||||
isReconnected = false;
|
isReconnected = false;
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.FAILED_TO_PING, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ namespace AIParkingApplication
|
||||||
{
|
{
|
||||||
isReconnected = true;
|
isReconnected = true;
|
||||||
reconnectCounter = 0;
|
reconnectCounter = 0;
|
||||||
reconnectResult.Message = string.Format(C3Constant.RECONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress);
|
reconnectResult.Message = string.Format(C3Constant.RECONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress);
|
||||||
}
|
}
|
||||||
return reconnectResult;
|
return reconnectResult;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.FAILED_TO_READ_LOG, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.FAILED_TO_READ_LOG, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = true,
|
HasError = true,
|
||||||
Message = string.Format(C3Constant.WRONG_FORMAT_DATA, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress, ex.Message)
|
Message = string.Format(C3Constant.WRONG_FORMAT_DATA, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress, ex.Message)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ namespace AIParkingApplication
|
||||||
var result = new ActionResult
|
var result = new ActionResult
|
||||||
{
|
{
|
||||||
HasError = false,
|
HasError = false,
|
||||||
Message = string.Format(C3Constant.DISCONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), IPAddress)
|
Message = string.Format(C3Constant.DISCONNECTED_SUCCESSFULLY, DateTime.Now.ToString(AppConstant.DATETIME_FORMAT), ipAddress)
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user