Snippets

OICP 2.1 Pull EVSE Data | C#

Created by Gregor Schermuly last modified Julius Poessnecker
1
2
3
4
5
6
7
The service description can be found in the OICP 2.1 (EMP).

Section:
3.4.1 eRoamingPullEVSEData

To download the latest OICP Version, please visit our website:
https://www.hubject.com/downloads/
/// <summary>
/// Create a new task querying EVSE data from the OICP server.
/// The request might either have none, 'SearchCenter + DistanceKM' or 'LastCall' parameters.
/// Because of limitations at Hubject the SearchCenter and LastCall parameters can not be used at the same time!
/// </summary>
/// <param name="ProviderId">The unique identification of the EVSP.</param>
/// <param name="SearchCenter">An optional geo coordinate of the search center.</param>
/// <param name="DistanceKM">An optional search distance relative to the search center.</param>
/// <param name="LastCall">An optional timestamp of the last call.</param>
/// <param name="QueryTimeout">An optional timeout for this query.</param>
public async Task<HTTPResponse<IEnumerable<eRoamingEVSEData>>>

    PullEVSEData(EVSP_Id        ProviderId,
                 GeoCoordinate  SearchCenter  = null,
                 UInt64         DistanceKM    = 0,
                 DateTime?      LastCall      = null,
                 TimeSpan?      QueryTimeout  = null)

{
    [...]
}
var req = new EMPClient("api.playground.hubject.com").

              PullEVSEData(EVSP_Id.Parse("DE*GDF"),
                           SearchCenter:  new GeoCoordinate(Latitude. Parse(49.731102),
                                                            Longitude.Parse(10.142533)),
                           DistanceKM:    100,
                           QueryTimeout:  TimeSpan.FromSeconds(120)).

              ContinueWith(task => {

                  var eRoamingEVSEData = task.Result.Content;

                  if (eRoamingEVSEData.StatusCode.HasResult)
                      Console.WriteLine(eRoamingEVSEData.
                                            OperatorEVSEData.
                                            Select(evsedata => "'" + evsedata.OperatorName +
                                                               "' has " +
                                                               evsedata.EVSEDataRecords.Count() +
                                                               " EVSEs").
                                            AggregateWith(Environment.NewLine) +
                                            Environment.NewLine));

                  else
                  {
                      Console.WriteLine(eRoamingEVSEData.StatusCode.Code);
                      Console.WriteLine(eRoamingEVSEData.StatusCode.Description);
                      Console.WriteLine(eRoamingEVSEData.StatusCode.AdditionalInfo);
                  }

              });

req.Wait();

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.