Skip to content

Commit 4fa43c7

Browse files
OCPI: Implement imprts for EZvolt and ChargeSini
1 parent d464a33 commit 4fa43c7

File tree

9 files changed

+67511
-10
lines changed

9 files changed

+67511
-10
lines changed

API/OCM.Net/OCM.API.Core/Common/ReferenceDataManager.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using Microsoft.EntityFrameworkCore;
2-
using MongoDB.Driver;
3-
using MongoDB.Driver.Linq;
4-
using OCM.API.Common.Model;
5-
using System;
1+
using System;
62
using System.Collections.Generic;
73
using System.Linq;
84
using System.Threading.Tasks;
5+
using Microsoft.EntityFrameworkCore;
6+
using MongoDB.Driver;
7+
using MongoDB.Driver.Linq;
8+
using OCM.API.Common.Model;
99

1010
namespace OCM.API.Common
1111
{
@@ -111,7 +111,7 @@ public async Task<CoreReferenceData> GetCoreReferenceDataAsync(APIRequestParams
111111
data = new CoreReferenceData();
112112

113113
//list of Levels (ChargerTypes)
114-
data.ChargerTypes = new List<Model.ChargerType>();
114+
data.ChargerTypes = [];
115115

116116
await dataModel.ChargerTypes.ForEachAsync(cg => data.ChargerTypes.Add(Model.Extensions.ChargerType.FromDataModel(cg)));
117117

API/OCM.Net/OCM.API.Model/OCPI/OCPIDataAdapter.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,16 @@ private static EvseStatus MapOCPIStatusFromOCM(int? statusTypeId)
329329
mappedStatusId = (int)StandardStatusTypes.Operational;
330330
}
331331

332+
if (status == EvseStatus.INOPERATIVE || status == EvseStatus.OUTOFORDER)
333+
{
334+
mappedStatusId = (int)StandardStatusTypes.NotOperational;
335+
}
336+
337+
if (status == EvseStatus.PLANNED)
338+
{
339+
mappedStatusId = (int)StandardStatusTypes.PlannedForFutureDate;
340+
}
341+
332342
if (status == EvseStatus.REMOVED)
333343
{
334344
mappedStatusId = (int)StandardStatusTypes.RemovedDecomissioned;

Import/OCM.Import.Common/ImportManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ public List<IImportProvider> GetImportProviders(List<OCM.API.Common.Model.DataPr
216216
providers.Add(new ImportProvider_Voltrelli());
217217
providers.Add(new ImportProvider_PowerGo());
218218
providers.Add(new ImportProvider_Punkt());
219+
providers.Add(new ImportProvider_EzVolt());
220+
providers.Add(new ImportProvider_Chargesini());
219221

220222
//populate full data provider details for each import provider
221223
foreach (var provider in providers)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System.Collections.Generic;
2+
using OCM.API.Common.Model;
3+
4+
namespace OCM.Import.Providers.OCPI
5+
{
6+
public class ImportProvider_Chargesini : ImportProvider_OCPI, IImportProvider
7+
{
8+
public ImportProvider_Chargesini() : base()
9+
{
10+
ProviderName = "chargesini.com";
11+
OutputNamePrefix = "chargesini.com";
12+
13+
IsAutoRefreshed = true;
14+
IsProductionReady = true;
15+
16+
CredentialKey = "OCPI-CHARGESINI";
17+
18+
DefaultOperatorID = 3660; // ChargeSini
19+
Init(dataProviderId: 41, "https://web-api.chargesini.com/ocpi/cpo/2.2/locations");
20+
}
21+
22+
public override Dictionary<string, int> GetOperatorMappings()
23+
{
24+
return new Dictionary<string, int>()
25+
{
26+
{ "Chargesini",3660 }
27+
};
28+
}
29+
30+
public new List<ChargePoint> Process(CoreReferenceData coreRefData)
31+
{
32+
var outputList = base.Process(coreRefData);
33+
34+
foreach (var poi in outputList)
35+
{
36+
// chargesini is unusual in that it publishes private locations (not recommend by OCPI) with an indicator in the title, so post-process those here, leave "restricted" in the title for clarity
37+
if (poi.AddressInfo.Title.StartsWith("[public]", System.StringComparison.InvariantCultureIgnoreCase))
38+
{
39+
poi.UsageTypeID = (int)StandardUsageTypes.Public_MembershipRequired;
40+
poi.AddressInfo.Title = poi.AddressInfo.Title.Replace("[Public] ", "");
41+
}
42+
else if (poi.AddressInfo.Title.StartsWith("[restricted]", System.StringComparison.InvariantCultureIgnoreCase))
43+
{
44+
poi.UsageTypeID = (int)StandardUsageTypes.PrivateRestricted;
45+
}
46+
}
47+
return outputList;
48+
}
49+
}
50+
51+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Collections.Generic;
2+
using OCM.API.Common.Model;
3+
4+
namespace OCM.Import.Providers.OCPI
5+
{
6+
public class ImportProvider_EzVolt : ImportProvider_OCPI, IImportProvider
7+
{
8+
public ImportProvider_EzVolt() : base()
9+
{
10+
ProviderName = "ezvolt.com.br";
11+
OutputNamePrefix = "ezvolt.com.br";
12+
13+
IsAutoRefreshed = true;
14+
IsProductionReady = true;
15+
16+
CredentialKey = "OCPI-EZVOLT";
17+
18+
DefaultOperatorID = 3564; // EZVolt
19+
Init(dataProviderId: 40, "https://api3.mycharge.com.br/ocpi/2.2.1/locations");
20+
}
21+
22+
public override Dictionary<string, int> GetOperatorMappings()
23+
{
24+
return new Dictionary<string, int>()
25+
{
26+
{ "EZVolt",3564 }
27+
};
28+
}
29+
30+
public new List<ChargePoint> Process(CoreReferenceData coreRefData)
31+
{
32+
var outputList = base.Process(coreRefData);
33+
34+
return outputList;
35+
}
36+
}
37+
38+
}

0 commit comments

Comments
 (0)