|
@@ -31,6 +31,8 @@ using EVCB_OCPP.Packet.Messages.LocalAuthListManagement;
|
|
|
using EVCB_OCPP.Packet.Messages.FirmwareManagement;
|
|
|
using EVCB_OCPP.Packet.Messages.Reservation;
|
|
|
using EVCB_OCPP.Packet.Messages.SmartCharging;
|
|
|
+using System.Threading;
|
|
|
+using System.Net.Http;
|
|
|
|
|
|
namespace TestTool.RemoteTriggerAPP
|
|
|
{
|
|
@@ -41,14 +43,18 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
{
|
|
|
string action = "";
|
|
|
List<PublishVersion> publishes = new List<PublishVersion>();
|
|
|
+ FTPClient UploadClient = new FTPClient(@"ftp://test.evsocket.phihong.com.cn", "testocpp", "testocpp");
|
|
|
+ string chargingProfilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "chargingProfile.json");
|
|
|
int selectedPublish = -1;
|
|
|
public MainWindow()
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
+ UploadClient.OnUploadProgress += UploadClient_OnUploadProgress;
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void UxSubmitBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
|
|
@@ -97,7 +103,16 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
break;
|
|
|
case "RemoteStartTransaction_ChargingProfile":
|
|
|
{
|
|
|
- SetRemoteStartTransaction(true);
|
|
|
+ var chargingProfile = VerifyChargingProfile(chargingProfilePath);
|
|
|
+ if (chargingProfile != null)
|
|
|
+ {
|
|
|
+ SetRemoteStartTransaction(chargingProfile);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ uxMsgTb.Text = "Please check chargingProfile.json exist in " + AppDomain.CurrentDomain.BaseDirectory;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
break;
|
|
|
case "RemoteStopTransaction":
|
|
@@ -139,9 +154,14 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
}
|
|
|
break;
|
|
|
#endregion
|
|
|
- case "GetDiagnostics":
|
|
|
+ case "GetDiagnostics_FTP":
|
|
|
+ {
|
|
|
+ GetDiagnostics(true);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case "GetDiagnostics_HTTP":
|
|
|
{
|
|
|
- GetDiagnostics();
|
|
|
+ GetDiagnostics(false);
|
|
|
}
|
|
|
break;
|
|
|
case "ReserveNow":
|
|
@@ -164,16 +184,21 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
GetCompositeSchedule();
|
|
|
}
|
|
|
break;
|
|
|
- case "SetChargingProfile_TxDefault":
|
|
|
- {
|
|
|
- SetChargingProfile(true);
|
|
|
- }
|
|
|
- break;
|
|
|
- case "SetChargingProfile_Tx":
|
|
|
+ case "SetChargingProfile":
|
|
|
{
|
|
|
- SetChargingProfile(false);
|
|
|
+ var chargingProfile = VerifyChargingProfile(chargingProfilePath);
|
|
|
+ if (chargingProfile != null)
|
|
|
+ {
|
|
|
+ SetChargingProfile(chargingProfile);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ uxMsgTb.Text = "Please check chargingProfile.json exist in " + AppDomain.CurrentDomain.BaseDirectory;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
#region Trigger Profile
|
|
|
case "TriggerMessage_BootNotification":
|
|
|
case "TriggerMessage_DiagnosticsStatusNotification":
|
|
@@ -192,42 +217,32 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void SetChargingProfile(bool isDefault)
|
|
|
+ private SetChargingProfileRequest VerifyChargingProfile(string path)
|
|
|
+ {
|
|
|
+ SetChargingProfileRequest request = null;
|
|
|
+
|
|
|
+ if (!File.Exists(path)) return request;
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ request = JsonConvert.DeserializeObject<SetChargingProfileRequest>(File.ReadAllText(path));
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ return request;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void SetChargingProfile(SetChargingProfileRequest csProfile)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
|
|
|
var uuid = Guid.NewGuid().ToString();
|
|
|
- var request = new SetChargingProfileRequest()
|
|
|
- {
|
|
|
- connectorId = Convert.ToInt32(uxConnectorIdTb.Text),
|
|
|
- csChargingProfiles = new csChargingProfiles()
|
|
|
- {
|
|
|
- chargingProfileId = Convert.ToInt32(DateTime.Now.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
- chargingProfileKind = ChargingProfileKindType.Absolute,
|
|
|
- chargingProfilePurpose = isDefault ? ChargingProfilePurposeType.TxDefaultProfile : ChargingProfilePurposeType.TxProfile,
|
|
|
- recurrencyKind = RecurrencyKindType.Daily,
|
|
|
- stackLevel = 1,
|
|
|
- chargingSchedule = new ChargingSchedule()
|
|
|
- {
|
|
|
- chargingRateUnit = ChargingRateUnitType.A,
|
|
|
- duration = 300,
|
|
|
- minChargingRate = 0,
|
|
|
- startSchedule = DateTime.Now.ToUniversalTime().Date,
|
|
|
- chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
|
|
|
- {
|
|
|
- new ChargingSchedulePeriod()
|
|
|
- { limit=10, startPeriod=0, numberPhases=3 },
|
|
|
- new ChargingSchedulePeriod()
|
|
|
- { limit=2, startPeriod=60, numberPhases=3 },
|
|
|
- new ChargingSchedulePeriod()
|
|
|
- { limit=8, startPeriod=120, numberPhases=3 }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
|
|
|
- WritetoDB(uuid, request);
|
|
|
+ WritetoDB(uuid, csProfile);
|
|
|
uxMsgTb.Text = string.Format("UUID:{0}", uuid);
|
|
|
}
|
|
|
catch (Exception ex)
|
|
@@ -347,7 +362,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void GetDiagnostics()
|
|
|
+ private void GetDiagnostics(bool ftp)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -356,7 +371,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
var request = new GetDiagnosticsRequest()
|
|
|
{
|
|
|
|
|
|
- location = new Uri("ftp://phihong:y42j%2f4cj84@test.evsocket.phihong.com.cn/"),
|
|
|
+ location = new Uri(ftp ? "ftp://evseocpp:evseocpp@test.evsocket.phihong.com.cn/" : "http://test.evsocket.phihong.com.cn:9003/api/file/"),
|
|
|
retries = 1,
|
|
|
retryInterval = 30,
|
|
|
startTime = DateTime.Now.AddHours(-1).ToUniversalTime(),
|
|
@@ -407,20 +422,60 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
listVersion = Convert.ToInt32(DateTime.Now.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
updateType = isFull ? UpdateType.Full : UpdateType.Differential,
|
|
|
localAuthorizationList = new List<AuthorizationData>()
|
|
|
+ //localAuthorizationList = new List<AuthorizationData>()
|
|
|
+ //{
|
|
|
+ // new AuthorizationData()
|
|
|
+ // {
|
|
|
+
|
|
|
+ // idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.ToUniversalTime().AddDays(3), status= AuthorizationStatus.Accepted},
|
|
|
+ // idTag="F5902677"
|
|
|
+ // }, new AuthorizationData()
|
|
|
+ // {
|
|
|
+ // idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.ToUniversalTime().AddDays(3), status= AuthorizationStatus.Expired},
|
|
|
+ // idTag="772690F5"
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ request.localAuthorizationList.Add(new AuthorizationData()
|
|
|
+ {
|
|
|
+ idTag="F5902677",
|
|
|
+ idTagInfo = new IdTagInfo()
|
|
|
{
|
|
|
- new AuthorizationData()
|
|
|
- {
|
|
|
-
|
|
|
- idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.ToUniversalTime().AddDays(3), status= AuthorizationStatus.Accepted},
|
|
|
- idTag="123"
|
|
|
- }, new AuthorizationData()
|
|
|
- {
|
|
|
- idTagInfo=new IdTagInfo(){ expiryDate=DateTime.Now.ToUniversalTime().AddDays(3), status= AuthorizationStatus.Expired},
|
|
|
- idTag="456"
|
|
|
- }
|
|
|
+ parentIdTag = "0000000000000000001",
|
|
|
+ expiryDate = DateTime.UtcNow.AddMonths(1),
|
|
|
+ status = AuthorizationStatus.ConcurrentTx
|
|
|
}
|
|
|
+ });
|
|
|
+
|
|
|
+ request.localAuthorizationList.Add(new AuthorizationData()
|
|
|
+ {
|
|
|
+ idTag = "772690F5",
|
|
|
+ idTagInfo = new IdTagInfo()
|
|
|
+ {
|
|
|
+ parentIdTag = "0000000000000000001",
|
|
|
+ expiryDate = DateTime.UtcNow.AddMonths(1),
|
|
|
+ status = AuthorizationStatus.Accepted
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ for (int i = 0; i < 23; i++)
|
|
|
+ {
|
|
|
+ request.localAuthorizationList.Add(new AuthorizationData()
|
|
|
+ {
|
|
|
+ idTag = DateTime.Now.ToString("yyyyMMddHHmmss" + i.ToString("00000")),
|
|
|
+ idTagInfo = new IdTagInfo()
|
|
|
+ {
|
|
|
+ parentIdTag = "0000000000000000001",
|
|
|
+ expiryDate = DateTime.UtcNow.AddMonths(1),
|
|
|
+ status = AuthorizationStatus.Accepted
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- };
|
|
|
|
|
|
WritetoDB(uuid, request);
|
|
|
uxMsgTb.Text = string.Format("UUID:{0}", uuid);
|
|
@@ -456,7 +511,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
private void SetGetConfiguration()
|
|
|
{
|
|
|
try
|
|
|
- {
|
|
|
+ {
|
|
|
string uuid = Guid.NewGuid().ToString();
|
|
|
var request = new GetConfigurationRequest()
|
|
|
{
|
|
@@ -481,7 +536,7 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void SetRemoteStartTransaction(bool hasProfile = false)
|
|
|
+ private void SetRemoteStartTransaction(SetChargingProfileRequest csProfile = null)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -492,32 +547,9 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
idTag = uxIdTagTb.Text
|
|
|
|
|
|
};
|
|
|
- if (hasProfile)
|
|
|
+ if (csProfile != null)
|
|
|
{
|
|
|
- request.chargingProfile = new csChargingProfiles()
|
|
|
- {
|
|
|
- chargingProfileId = Convert.ToInt32(DateTime.Now.ToUniversalTime().ToString("yyMMddHHmm")),
|
|
|
- chargingProfileKind = ChargingProfileKindType.Absolute,
|
|
|
- chargingProfilePurpose = ChargingProfilePurposeType.TxProfile,
|
|
|
- recurrencyKind = RecurrencyKindType.Daily,
|
|
|
- stackLevel = 1,
|
|
|
- chargingSchedule = new ChargingSchedule()
|
|
|
- {
|
|
|
- chargingRateUnit = ChargingRateUnitType.A,
|
|
|
- duration = 300,
|
|
|
- minChargingRate = 0,
|
|
|
- startSchedule = DateTime.Now.ToUniversalTime().Date,
|
|
|
- chargingSchedulePeriod = new List<ChargingSchedulePeriod>()
|
|
|
- {
|
|
|
- new ChargingSchedulePeriod()
|
|
|
- { limit=10, startPeriod=0, numberPhases=3 },
|
|
|
- new ChargingSchedulePeriod()
|
|
|
- { limit=2, startPeriod=60, numberPhases=3 },
|
|
|
- new ChargingSchedulePeriod()
|
|
|
- { limit=8, startPeriod=120, numberPhases=3 }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
+ request.chargingProfile = csProfile.csChargingProfiles;
|
|
|
}
|
|
|
|
|
|
WritetoDB(uuid, request);
|
|
@@ -759,6 +791,8 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private void uxUploadBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(uxUploadFileTb.Text))
|
|
@@ -798,7 +832,6 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
ufObj.FileUrl = new Uri(Properties.Settings.Default.FilePreUrl + ufObj.FilePath.Replace("~/", "")).ToString();
|
|
|
ufObj.IsOnline = true;
|
|
|
|
|
|
-
|
|
|
using (var db = new MainDBContext())
|
|
|
{
|
|
|
db.UploadFile.Add(ufObj);
|
|
@@ -814,15 +847,55 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
|
|
|
- FTPClient UploadClient = new FTPClient(@"ftp://test.evsocket.phihong.com.cn", "testocpp", "testocpp");
|
|
|
- bool uploadResult = UploadClient.FtpUploadBroken(uxUploadFileTb.Text, @"ftp://test.evsocket.phihong.com.cn/" + ufObj.FileName);
|
|
|
+ string filePath = uxUploadFileTb.Text;
|
|
|
+ uxMsgTb.Text = "Uploading........";
|
|
|
+
|
|
|
+ Task.Run(async () =>
|
|
|
+ {
|
|
|
+ await UploadTask(filePath, ufObj.FileName);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private async Task UploadTask(string filePath, string fileName)
|
|
|
+ {
|
|
|
+
|
|
|
+ bool uploadResult = UploadClient.FtpUploadBroken(filePath, @"ftp://test.evsocket.phihong.com.cn/" + fileName);
|
|
|
+
|
|
|
+ await Dispatcher.BeginInvoke(new Action(() =>
|
|
|
+ {
|
|
|
+ if (uploadResult)
|
|
|
+ {
|
|
|
+ uxMsgTb.Text = "Current Progress :100 %";
|
|
|
+ Thread.CurrentThread.Join(100);
|
|
|
+ }
|
|
|
+ uxMsgTb.Text = "Upload File Result :" + (uploadResult ? "Success" : "Fail");
|
|
|
+
|
|
|
+
|
|
|
+ }));
|
|
|
|
|
|
|
|
|
|
|
|
- uxMsgTb.Text = "Upload File Result :" + (uploadResult ? "Success" : "Fail");
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void UploadClient_OnUploadProgress(double percent)
|
|
|
+ {
|
|
|
+ Dispatcher.BeginInvoke(new Action(() =>
|
|
|
+ {
|
|
|
+ uxMsgTb.Text = "Current Progress :" + (int)percent + " %";
|
|
|
+
|
|
|
+ }));
|
|
|
+ }
|
|
|
|
|
|
private void uxFTPUploadBtn_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
@@ -879,12 +952,17 @@ namespace TestTool.RemoteTriggerAPP
|
|
|
db.SaveChanges();
|
|
|
}
|
|
|
|
|
|
- FTPClient UploadClient = new FTPClient(@"ftp://test.evsocket.phihong.com.cn", "testocpp", "testocpp");
|
|
|
- bool uploadResult = UploadClient.FtpUploadBroken(uxUploadFileTb.Text, @"ftp://test.evsocket.phihong.com.cn/" + ufObj.FileName);
|
|
|
|
|
|
|
|
|
+ string filePath = uxUploadFileTb.Text;
|
|
|
+ uxMsgTb.Text = "Uploading........";
|
|
|
+
|
|
|
+ Task.Run(async () =>
|
|
|
+ {
|
|
|
+ await UploadTask(filePath, ufObj.FileName);
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
- uxMsgTb.Text = "Upload File Result :" + (uploadResult ? "Success" : "Fail");
|
|
|
}
|
|
|
|
|
|
|