public ImporterForwardingInfo(Action <DateTime, ImporterForwardingInfo, RoamingNetwork_Id?, RoamingNetwork_Id?> OnChangedCallback,
                               IEnumerable <ChargingStationOperator> ChargingStationOperators,
                               ChargingStation_Id?StationId       = null,
                               String StationName                 = "",
                               String StationServiceTag           = "",
                               Address StationAddress             = null,
                               GeoCoordinate?StationGeoCoordinate = null,
                               IEnumerable <EVSE_Id> EVSEIds      = null,
                               String PhoneNumber                 = null,
                               Timestamped <ChargingStationAdminStatusTypes>?AdminStatus = null,
                               DateTime?Created     = null,
                               Boolean OutOfService = false,
                               ChargingStationOperator ForwardedToOperator = null)
 {
     this._OnForwardingChanged     = OnChangedCallback;
     this.ChargingStationOperators = ChargingStationOperators;
     this._EVSEIds             = EVSEIds != null ? new HashSet <EVSE_Id>(EVSEIds) : new HashSet <EVSE_Id>();
     this.StationId            = StationId.HasValue            ? StationId.Value               : ChargingStation_Id.Create(EVSEIds).Value;
     this.StationName          = StationName;
     this.StationServiceTag    = StationServiceTag;
     this.StationAddress       = StationAddress;
     this.StationGeoCoordinate = StationGeoCoordinate;
     this._AdminStatus         = AdminStatus != null ? AdminStatus.Value             : new Timestamped <ChargingStationAdminStatusTypes>(ChargingStationAdminStatusTypes.Operational);
     this.PhoneNumber          = PhoneNumber;
     this.Created      = Created != null ? Created.Value                 : DateTime.UtcNow;
     this.OutOfService = OutOfService;
     this.LastTimeSeen = this.Created;
     this._ForwardedToChargingStationOperator = ForwardedToOperator;
 }
        public ChargingTariffException(ChargingStationOperator ChargingStationOperator,
                                       String Message)

            : base(ChargingStationOperator.RoamingNetwork,
                   Message)

        {
        }
        public ChargingTariffAlreadyExists(ChargingStationOperator ChargingStationOperator,
                                           ChargingTariff_Id ChargingTariffId)

            : base(ChargingStationOperator.RoamingNetwork,
                   "The given charging tariff identification '" + ChargingTariffId + "' already exists within the given '" + ChargingStationOperator.Id + "' charging station operator!")

        {
        }
        public BrandAlreadyExists(ChargingStationOperator ChargingStationOperator,
                                  Brand_Id BrandId)

            : base(ChargingStationOperator.RoamingNetwork,
                   "The given brand identification '" + BrandId + "' already exists within the given '" + ChargingStationOperator.Id + "' charging station operator!")

        {
        }
        public EVSEGroupAlreadyExists(ChargingStationOperator ChargingStationOperator,
                                      EVSEGroup_Id EVSEGroupId)

            : base(ChargingStationOperator.RoamingNetwork,
                   "The given EVSE group identification '" + EVSEGroupId + "' already exists within the given '" + ChargingStationOperator.Id + "' charging station operator!")

        {
        }
        public EVSEGroupException(ChargingStationOperator ChargingStationOperator,
                                  String Message)

            : base(ChargingStationOperator.RoamingNetwork,
                   Message)

        {
        }
        /// <summary>
        /// An invalid charging pool operator identification was given.
        /// </summary>
        /// <param name="ChargingStationOperator">The charging station operator in which the exception occured.</param>
        /// <param name="InvalidChargingStationOperatorId">The invalid operator identification.</param>
        /// <param name="ValidChargingStationOperatorIds">All expected operator identifications.</param>
        public InvalidChargingPoolOperatorId(ChargingStationOperator ChargingStationOperator,
                                             ChargingStationOperator_Id InvalidChargingStationOperatorId,
                                             IEnumerable <ChargingStationOperator_Id> ValidChargingStationOperatorIds)

            : base(ChargingStationOperator,
                   "Invalid charging station operator identification '" + InvalidChargingStationOperatorId + "' where only '" + ValidChargingStationOperatorIds.AggregateWith(", ") + "' are expected!")

        {
        }
Beispiel #8
0
        public ChargingPoolException(ChargingStationOperator ChargingStationOperator,
                                     String Message,
                                     Exception InnerException)

            : base(ChargingStationOperator.RoamingNetwork,
                   Message, InnerException)

        {
        }
Beispiel #9
0
        /// <summary>
        /// Create a new virtual charging pool.
        /// </summary>
        /// <param name="ChargingStationOperator">A charging station operator.</param>
        /// <param name="ChargingPoolId">The charging station identification for the charging station to be created.</param>
        /// <param name="ChargingPoolConfigurator">An optional delegate to configure the new (local) charging station.</param>
        /// <param name="VirtualChargingPoolConfigurator">An optional delegate to configure the new virtual charging station.</param>
        /// <param name="OnSuccess">An optional delegate for reporting success.</param>
        /// <param name="OnError">An optional delegate for reporting an error.</param>
        public static ChargingPool CreateVirtualPool(this ChargingStationOperator ChargingStationOperator,
                                                     ChargingPool_Id ChargingPoolId,
                                                     I18NString Description = null,
                                                     ChargingPoolAdminStatusTypes InitialAdminStatus = ChargingPoolAdminStatusTypes.Operational,
                                                     ChargingPoolStatusTypes InitialStatus           = ChargingPoolStatusTypes.Available,
                                                     String EllipticCurve = "P-256",
                                                     ECPrivateKeyParameters PrivateKey           = null,
                                                     PublicKeyCertificates PublicKeyCertificates = null,
                                                     TimeSpan?SelfCheckTimeSpan    = null,
                                                     UInt16 MaxAdminStatusListSize = VirtualChargingPool.DefaultMaxAdminStatusListSize,
                                                     UInt16 MaxStatusListSize      = VirtualChargingPool.DefaultMaxStatusListSize,
                                                     Action <ChargingPool> ChargingPoolConfigurator = null,
                                                     Action <VirtualChargingPool> VirtualChargingPoolConfigurator = null,
                                                     Action <ChargingPool> OnSuccess = null,
                                                     Action <ChargingStationOperator, ChargingPool_Id> OnError = null)
        {
            #region Initial checks

            if (ChargingStationOperator == null)
            {
                throw new ArgumentNullException(nameof(ChargingStationOperator), "The given charging station operator must not be null!");
            }

            #endregion

            return(ChargingStationOperator.CreateChargingPool(ChargingPoolId,
                                                              ChargingPoolConfigurator,
                                                              newstation => {
                var virtualstation = new VirtualChargingPool(newstation.Id,
                                                             ChargingStationOperator.RoamingNetwork,
                                                             Description,
                                                             InitialAdminStatus,
                                                             InitialStatus,
                                                             EllipticCurve,
                                                             PrivateKey,
                                                             PublicKeyCertificates,
                                                             SelfCheckTimeSpan,
                                                             MaxAdminStatusListSize,
                                                             MaxStatusListSize);

                VirtualChargingPoolConfigurator?.Invoke(virtualstation);

                return virtualstation;
            },

                                                              OnSuccess: OnSuccess,
                                                              OnError:   OnError));
        }
        /// <summary>
        /// Create a new charging station group.
        /// </summary>
        /// <param name="Id">The unique identification of the charing station group.</param>
        /// <param name="Operator">The charging station operator of this charging station group.</param>
        /// <param name="Description">An optional (multi-language) description of this charging station group.</param>
        internal ChargingTariffGroup(ChargingTariffGroup_Id Id,
                                     ChargingStationOperator Operator,
                                     I18NString Description = null)

            : base(Id)

        {
            this.Operator    = Operator ?? throw new ArgumentNullException(nameof(Operator), "The charging station operator must not be null!");
            this.Description = Description ?? new I18NString();

            this._ChargingTariffs = new Dictionary <ChargingTariff_Id, ChargingTariff>();


            this.ChargingTariffAddition = new VotingNotificator <DateTime, ChargingTariffGroup, ChargingTariff, Boolean>(() => new VetoVote(), true);
            this.ChargingTariffRemoval  = new VotingNotificator <DateTime, ChargingTariffGroup, ChargingTariff, Boolean>(() => new VetoVote(), true);
        }
Beispiel #11
0
        /// <summary>
        /// Create a new charging tariff having the given identification.
        /// </summary>
        /// <param name="Id">The unique identification of the charing tariff.</param>
        /// <param name="Operator">The charging station operator of this charging tariff.</param>
        /// <param name="Name">The offical (multi-language) name of this charging tariff.</param>
        /// <param name="Description">An optional (multi-language) description of this charging tariff.</param>
        public ChargingTariff(ChargingTariff_Id Id,
                              ChargingStationOperator Operator,
                              I18NString Name,
                              I18NString Description,
                              Brand Brand,

                              Uri TariffUrl,
                              Currency Currency,
                              EnergyMix EnergyMix,
                              IEnumerable <ChargingTariffElement> TariffElements)

            : base(Id)

        {
            #region Initial checks

            if (Operator == null)
            {
                throw new ArgumentNullException(nameof(Operator), "The given charging station operator must not be null!");
            }

            if (TariffElements == null || !TariffElements.Any())
            {
                throw new ArgumentNullException(nameof(TariffElements), "The given enumeration of tariff elements must not be null or empty!");
            }

            #endregion

            #region Init data and properties

            this.Operator    = Operator;
            this.Name        = Name;
            this.Description = Description ?? new I18NString();
            this.Brand       = Brand;

            this.TariffURI      = TariffUrl;
            this.Currency       = Currency;
            this.EnergyMix      = EnergyMix;
            this.TariffElements = TariffElements;

            #endregion
        }
Beispiel #12
0
        public static JObject ToFeature(this ChargingStationOperator ChargingStationOperator,
                                        Func <ChargingStationOperator, IEnumerable <JProperty> > PropertyCreator)

        {
            #region Initial checks

            if (ChargingStationOperator == null)
            {
                throw new ArgumentNullException(nameof(ChargingStationOperator), "The given charging station operator must not be null!");
            }

            if (PropertyCreator == null)
            {
                throw new ArgumentNullException(nameof(PropertyCreator), "The given JSON property creator delegate must not be null!");
            }

            #endregion

            return(ChargingStationOperator.ToFeature(new JObject(PropertyCreator(ChargingStationOperator))));
        }
Beispiel #13
0
        CreateeMIPv0_7_4_CSORoamingProvider(this RoamingNetwork RoamingNetwork,
                                            EMPRoamingProvider_Id Id,
                                            I18NString Name,
                                            I18NString Description,
                                            CPORoaming CPORoaming,

                                            eMIPv0_7_4.Partner_Id PartnerId,
                                            ChargingStationOperator DefaultOperator,

                                            WWCPChargeDetailRecord2ChargeDetailRecordDelegate WWCPChargeDetailRecord2eMIPChargeDetailRecord = null,

                                            IncludeEVSEIdDelegate IncludeEVSEIds = null,
                                            IncludeEVSEDelegate IncludeEVSEs     = null,
                                            IncludeChargingStationIdDelegate IncludeChargingStationIds = null,
                                            IncludeChargingStationDelegate IncludeChargingStations     = null,
                                            IncludeChargingPoolIdDelegate IncludeChargingPoolIds       = null,
                                            IncludeChargingPoolDelegate IncludeChargingPools           = null,
                                            ChargeDetailRecordFilterDelegate ChargeDetailRecordFilter  = null,
                                            CustomOperatorIdMapperDelegate CustomOperatorIdMapper      = null,
                                            CustomEVSEIdMapperDelegate CustomEVSEIdMapper = null,

                                            TimeSpan?SendHeartbeatsEvery = null,
                                            TimeSpan?ServiceCheckEvery   = null,
                                            TimeSpan?StatusCheckEvery    = null,
                                            TimeSpan?CDRCheckEvery       = null,

                                            Boolean DisableSendHeartbeats          = false,
                                            Boolean DisablePushData                = false,
                                            Boolean DisablePushStatus              = false,
                                            Boolean DisableAuthentication          = false,
                                            Boolean DisableSendChargeDetailRecords = false,

                                            Action <eMIPv0_7_4.CPO.WWCPCPOAdapter> eMIPConfigurator = null,
                                            Action <IEMPRoamingProvider> Configurator = null,

                                            String EllipticCurve = "P-256",
                                            ECPrivateKeyParameters PrivateKey           = null,
                                            PublicKeyCertificates PublicKeyCertificates = null,

                                            CounterValues?CPOClientSendHeartbeatCounter = null,
                                            CounterValues?CPOClientSetChargingPoolAvailabilityStatusCounter      = null,
                                            CounterValues?CPOClientSetChargingStationAvailabilityStatusCounter   = null,
                                            CounterValues?CPOClientSetEVSEAvailabilityStatusCounter              = null,
                                            CounterValues?CPOClientSetChargingConnectorAvailabilityStatusCounter = null,
                                            CounterValues?CPOClientSetEVSEBusyStatusCounter       = null,
                                            CounterValues?CPOClientSetEVSESyntheticStatusCounter  = null,
                                            CounterValues?CPOClientGetServiceAuthorisationCounter = null,
                                            CounterValues?CPOClientSetSessionEventReportCounter   = null,
                                            CounterValues?CPOClientSetChargeDetailRecordCounter   = null)

        {
            #region Initial checks

            if (RoamingNetwork == null)
            {
                throw new ArgumentNullException(nameof(RoamingNetwork), "The given roaming network must not be null!");
            }

            if (Id == null)
            {
                throw new ArgumentNullException(nameof(Id), "The given unique roaming provider identification must not be null!");
            }

            if (Name.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Name), "The given roaming provider name must not be null or empty!");
            }

            if (CPORoaming is null)
            {
                throw new ArgumentNullException(nameof(CPORoaming), "The given CPO roaming must not be null!");
            }

            #endregion

            var NewRoamingProvider = new WWCPCPOAdapter(Id,
                                                        Name,
                                                        Description,
                                                        RoamingNetwork,
                                                        CPORoaming,

                                                        PartnerId,
                                                        DefaultOperator,

                                                        IncludeEVSEIds,
                                                        IncludeEVSEs,
                                                        IncludeChargingStationIds,
                                                        IncludeChargingStations,
                                                        IncludeChargingPoolIds,
                                                        IncludeChargingPools,
                                                        ChargeDetailRecordFilter,
                                                        CustomOperatorIdMapper,
                                                        CustomEVSEIdMapper,

                                                        //EVSE2EVSEDataRecord,
                                                        //EVSEStatusUpdate2EVSEStatusRecord,
                                                        WWCPChargeDetailRecord2eMIPChargeDetailRecord,

                                                        SendHeartbeatsEvery,
                                                        ServiceCheckEvery,
                                                        StatusCheckEvery,
                                                        CDRCheckEvery,

                                                        DisableSendHeartbeats,
                                                        DisablePushData,
                                                        DisablePushStatus,
                                                        DisableAuthentication,
                                                        DisableSendChargeDetailRecords,

                                                        EllipticCurve,
                                                        PrivateKey,
                                                        PublicKeyCertificates);

            eMIPConfigurator?.Invoke(NewRoamingProvider);

            return(RoamingNetwork.
                   CreateNewRoamingProvider(NewRoamingProvider,
                                            Configurator) as WWCPCPOAdapter);
        }
        /// <summary>
        /// Take a snapshot of the current charging station operator status.
        /// </summary>
        /// <param name="ChargingStationOperator">A charging station operator.</param>
        public static ChargingStationOperatorStatus Snapshot(ChargingStationOperator ChargingStationOperator)

        => new ChargingStationOperatorStatus(ChargingStationOperator.Id,
                                             ChargingStationOperator.Status.Value,
                                             ChargingStationOperator.Status.Timestamp);
Beispiel #15
0
        public static JObject ToFeature(this ChargingStationOperator ChargingStationOperator,
                                        JObject Properties = null)

        {
            #region Initial checks

            if (ChargingStationOperator == null)
            {
                throw new ArgumentNullException(nameof(ChargingStationOperator), "The given charging station operator must not be null!");
            }

            #endregion

            #region Documentation

            // {
            //
            //   [...]
            //
            //   {
            //     "type": "Feature",
            //     "properties": {},
            //     "geometry": {
            //       "type": "Point",
            //       "coordinates": [
            //         10.579833984375,
            //         50.48197825997291
            //       ]
            //     }
            //   }
            //
            // }

            #endregion

            return(new JObject(

                       new JProperty("type", "Feature"),

                       new JProperty("properties", Properties ?? new JObject(

                                         new JProperty("LastChange", ChargingStationOperator.LastChange),
                                         new JProperty("UserComment", ""),
                                         new JProperty("ServiceProviderComment", ""),
                                         new JProperty("Features", new JArray()),
                                         new JProperty("AuthorizationOptions", new JArray()),
                                         new JProperty("Photos", new JArray()),

                                         new JProperty("EVSEs", new JObject(
                                                           ChargingStationOperator.EVSEs.Select(evse => new JProperty(evse.Id.ToString(), "lala"))
                                                           ))

                                         )),

                       new JProperty("geometry", new JObject(
                                         new JProperty("type", "Point"),
                                         new JProperty("coordinates", new JArray(
                                                           ChargingStationOperator.GeoLocation.Longitude.Value,
                                                           ChargingStationOperator.GeoLocation.Latitude.Value
                                                           ))
                                         ))
                       ));
        }
Beispiel #16
0
        /// <summary>
        /// Return a JSON representation for the given charging station operator.
        /// </summary>
        /// <param name="ChargingStationOperator">A charging station operator.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a roaming network.</param>
        public static JObject ToJSON(this ChargingStationOperator ChargingStationOperator,
                                     Boolean Embedded = false,
                                     InfoStatus ExpandRoamingNetworkId   = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingPoolIds    = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingStationIds = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandEVSEIds            = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandBrandIds           = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandDataLicenses       = InfoStatus.ShowIdOnly)


        => ChargingStationOperator == null

                   ? null

                   : JSONObject.Create(

            new JProperty("@id", ChargingStationOperator.Id.ToString()),

            !Embedded
                             ? new JProperty("@context", "https://open.charging.cloud/contexts/wwcp+json/ChargingStationOperator")
                             : null,

            new JProperty("name", ChargingStationOperator.Name.ToJSON()),

            ChargingStationOperator.Description.IsNeitherNullNorEmpty()
                             ? ChargingStationOperator.Description.ToJSON("description")
                             : null,

            ChargingStationOperator.DataSource.ToJSON("DataSource"),

            ExpandDataLicenses.Switch(
                () => new JProperty("dataLicenseIds", new JArray(ChargingStationOperator.DataLicenses.SafeSelect(license => license.Id.ToString()))),
                () => new JProperty("dataLicenses", ChargingStationOperator.DataLicenses.ToJSON())),

            #region Embedded means it is served as a substructure of e.g. a charging station operator

            Embedded
                             ? null
                             : ExpandRoamingNetworkId.Switch(
                () => new JProperty("roamingNetworkId", ChargingStationOperator.RoamingNetwork.Id.ToString()),
                () => new JProperty("roamingNetwork", ChargingStationOperator.RoamingNetwork.ToJSON(Embedded:                          true,
                                                                                                    ExpandChargingStationOperatorIds:  InfoStatus.Hidden,
                                                                                                    ExpandChargingPoolIds:             InfoStatus.Hidden,
                                                                                                    ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                                    ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                                    ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                                    ExpandDataLicenses:                InfoStatus.Hidden))),

            #endregion

            ChargingStationOperator.Address != null
                             ? ChargingStationOperator.Address.ToJSON("address")
                             : null,

            // API
            // MainKeys
            // RobotKeys
            // Endpoints
            // DNS SRV

            ChargingStationOperator.Logo.IsNotNullOrEmpty()
                             ? new JProperty("logos", JSONArray.Create(
                                                 JSONObject.Create(
                                                     new JProperty("uri", ChargingStationOperator.Logo),
                                                     new JProperty("description", I18NString.Empty.ToJSON())
                                                     )
                                                 ))
                             : null,

            ChargingStationOperator.Homepage.IsNotNullOrEmpty()
                             ? new JProperty("homepage", ChargingStationOperator.Homepage)
                             : null,

            ChargingStationOperator.HotlinePhoneNumber.IsNotNullOrEmpty()
                             ? new JProperty("hotline", ChargingStationOperator.HotlinePhoneNumber)
                             : null,


            ChargingStationOperator.ChargingPools.Any()
                             ? ExpandChargingPoolIds.Switch(

                () => new JProperty("chargingPoolIds",
                                    new JArray(ChargingStationOperator.ChargingPoolIds().
                                               OrderBy(poolId => poolId).
                                               Select(poolId => poolId.ToString()))),

                () => new JProperty("chargingPools",
                                    new JArray(ChargingStationOperator.ChargingPools.
                                               OrderBy(poolId => poolId).
                                               ToJSON(Embedded:                         true,
                                                      ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                      ExpandChargingStationOperatorId:  InfoStatus.Hidden,
                                                      ExpandChargingStationIds:         InfoStatus.Hidden,
                                                      ExpandEVSEIds:                    InfoStatus.Hidden,
                                                      ExpandBrandIds:                   InfoStatus.Hidden,
                                                      ExpandDataLicenses:               InfoStatus.Hidden))))
                             : null,

            ChargingStationOperator.ChargingPools.Any() && ExpandChargingPoolIds == InfoStatus.Expand
                             ? null
                             : ExpandChargingStationIds.Switch(
                () => new JProperty("chargingStationIds",
                                    new JArray(ChargingStationOperator.ChargingStationIds().
                                               OrderBy(stationid => stationid).
                                               Select(stationid => stationid.ToString()))),

                () => new JProperty("chargingStations",
                                    new JArray(ChargingStationOperator.ChargingStations.
                                               OrderBy(station => station).
                                               ToJSON(Embedded:                         true,
                                                      ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                      ExpandChargingStationOperatorId:  InfoStatus.Hidden,
                                                      ExpandChargingPoolId:             InfoStatus.Hidden,
                                                      ExpandEVSEIds:                    InfoStatus.Hidden,
                                                      ExpandBrandIds:                   InfoStatus.Hidden,
                                                      ExpandDataLicenses:               InfoStatus.Hidden)))),

            ChargingStationOperator.ChargingPools.Any() && (ExpandChargingPoolIds == InfoStatus.Expand || ExpandChargingStationIds == InfoStatus.Expand)
                             ? null
                             : ExpandEVSEIds.Switch(
                () => new JProperty("EVSEIds",
                                    new JArray(ChargingStationOperator.EVSEIds().
                                               OrderBy(evseId => evseId).
                                               Select(evseId => evseId.ToString()))),

                () => new JProperty("EVSEs",
                                    new JArray(ChargingStationOperator.EVSEs.
                                               OrderBy(evse => evse).
                                               ToJSON(Embedded:                         true,
                                                      ExpandRoamingNetworkId:           InfoStatus.Hidden,
                                                      ExpandChargingStationOperatorId:  InfoStatus.Hidden,
                                                      ExpandChargingPoolId:             InfoStatus.Hidden,
                                                      ExpandChargingStationId:          InfoStatus.Hidden,
                                                      ExpandBrandIds:                   InfoStatus.Hidden,
                                                      ExpandDataLicenses:               InfoStatus.Hidden)))),


            ChargingStationOperator.Brands.Any()
                             ? ExpandBrandIds.Switch(

                () => new JProperty("brandIds",
                                    new JArray(ChargingStationOperator.BrandIds.
                                               OrderBy(brandId => brandId).
                                               Select(brandId => brandId.ToString()))),

                () => new JProperty("brands",
                                    new JArray(ChargingStationOperator.Brands.
                                               OrderBy(brand => brand).
                                               ToJSON(Embedded:                         true,
                                                      ExpandChargingPoolIds:            InfoStatus.Hidden,
                                                      ExpandChargingStationIds:         InfoStatus.Hidden,
                                                      ExpandEVSEIds:                    InfoStatus.Hidden,
                                                      ExpandDataLicenses:               InfoStatus.ShowIdOnly))))
                             : null

            );
 public Task <PushEVSEDataResult> UpdateStaticData(ChargingStationOperator ChargingStationOperator, DateTime?Timestamp = null, CancellationToken?CancellationToken = null, EventTracking_Id EventTrackingId = null, TimeSpan?RequestTimeout = null)
 {
     throw new NotImplementedException();
 }
        CreateOICPv2_3_EMPRoamingProvider(this RoamingNetwork RoamingNetwork,
                                          EMPRoamingProvider_Id Id,
                                          I18NString Name,
                                          I18NString Description,
                                          OICPv2_3.CPO.CPORoaming CPORoaming,

                                          OICPv2_3.EVSE2EVSEDataRecordDelegate EVSE2EVSEDataRecord = null,
                                          OICPv2_3.EVSEStatusUpdate2EVSEStatusRecordDelegate EVSEStatusUpdate2EVSEStatusRecord = null,
                                          OICPv2_3.WWCPChargeDetailRecord2ChargeDetailRecordDelegate WWCPChargeDetailRecord2OICPChargeDetailRecord = null,

                                          ChargingStationOperator DefaultOperator   = null,
                                          OperatorIdFormats DefaultOperatorIdFormat = OperatorIdFormats.ISO_STAR,
                                          ChargingStationOperatorNameSelectorDelegate OperatorNameSelector = null,

                                          IncludeEVSEIdDelegate IncludeEVSEIds = null,
                                          IncludeEVSEDelegate IncludeEVSEs     = null,
                                          ChargeDetailRecordFilterDelegate ChargeDetailRecordFilter = null,
                                          //CustomEVSEIdMapperDelegate                                  CustomEVSEIdMapper                              = null,

                                          TimeSpan?ServiceCheckEvery = null,
                                          TimeSpan?StatusCheckEvery  = null,
                                          TimeSpan?CDRCheckEvery     = null,

                                          Boolean DisablePushData                = false,
                                          Boolean DisablePushStatus              = false,
                                          Boolean DisableAuthentication          = false,
                                          Boolean DisableSendChargeDetailRecords = false,

                                          Action <OICPv2_3.CPO.WWCPEMPAdapter> OICPConfigurator = null,
                                          Action <IEMPRoamingProvider> Configurator             = null,

                                          String EllipticCurve = "P-256",
                                          ECPrivateKeyParameters PrivateKey           = null,
                                          PublicKeyCertificates PublicKeyCertificates = null)

        {
            #region Initial checks

            if (Id == null)
            {
                throw new ArgumentNullException(nameof(Id), "The given unique roaming provider identification must not be null!");
            }

            if (Name.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Name), "The given roaming provider name must not be null or empty!");
            }

            if (RoamingNetwork == null)
            {
                throw new ArgumentNullException(nameof(RoamingNetwork), "The given roaming network must not be null!");
            }

            if (CPORoaming == null)
            {
                throw new ArgumentNullException(nameof(CPORoaming), "The given CPORoaming must not be null!");
            }

            #endregion

            var NewRoamingProvider = new OICPv2_3.CPO.WWCPEMPAdapter(Id,
                                                                     Name,
                                                                     Description,
                                                                     RoamingNetwork,
                                                                     CPORoaming,

                                                                     EVSE2EVSEDataRecord,
                                                                     EVSEStatusUpdate2EVSEStatusRecord,
                                                                     WWCPChargeDetailRecord2OICPChargeDetailRecord,

                                                                     DefaultOperator,
                                                                     DefaultOperatorIdFormat,
                                                                     OperatorNameSelector,

                                                                     IncludeEVSEIds,
                                                                     IncludeEVSEs,
                                                                     ChargeDetailRecordFilter,
                                                                     //CustomEVSEIdMapper,

                                                                     ServiceCheckEvery,
                                                                     StatusCheckEvery,
                                                                     CDRCheckEvery,

                                                                     DisablePushData,
                                                                     DisablePushStatus,
                                                                     DisableAuthentication,
                                                                     DisableSendChargeDetailRecords,

                                                                     EllipticCurve,
                                                                     PrivateKey,
                                                                     PublicKeyCertificates);

            OICPConfigurator?.Invoke(NewRoamingProvider);

            return(RoamingNetwork.
                   CreateNewRoamingProvider(NewRoamingProvider,
                                            Configurator) as OICPv2_3.CPO.WWCPEMPAdapter);
        }
        /// <summary>
        /// Take a snapshot of the current charging station operator status.
        /// </summary>
        /// <param name="ChargingStationOperator">A charging station operator.</param>
        public static ChargingStationOperatorStatusUpdate Snapshot(ChargingStationOperator ChargingStationOperator)

        => new ChargingStationOperatorStatusUpdate(ChargingStationOperator.Id,
                                                   ChargingStationOperator.Status,
                                                   ChargingStationOperator.StatusSchedule().Skip(1).FirstOrDefault());
Beispiel #20
0
        /// <summary>
        /// Create a charge detail record for the given charging session (identification).
        /// </summary>
        /// <param name="SessionId">The unique charging session identification.</param>
        /// <param name="SessionTime">The timestamps when the charging session started and ended.</param>
        /// <param name="Duration">The duration of the charging session, whenever it is more than the time span between its start- and endtime, e.g. caused by a tariff granularity of 15 minutes.</param>
        ///
        /// <param name="EVSE">The EVSE used for charging.</param>
        /// <param name="EVSEId">The identification of the EVSE used for charging.</param>
        /// <param name="ChargingStation">The charging station of the charging station used for charging.</param>
        /// <param name="ChargingStationId">The identification of the charging station used for charging.</param>
        /// <param name="ChargingPool">The charging pool of the charging pool used for charging.</param>
        /// <param name="ChargingPoolId">The identification of the charging pool used for charging.</param>
        /// <param name="ChargingStationOperator">The charging station operator used for charging.</param>
        /// <param name="ChargingStationOperatorId">The identification of the charging station operator used for charging.</param>
        /// <param name="ChargingProduct">The consumed charging product.</param>
        /// <param name="ChargingPrice">The charging price.</param>
        ///
        /// <param name="AuthenticationStart">The authentication used for starting this charging process.</param>
        /// <param name="AuthenticationStop">The authentication used for stopping this charging process.</param>
        /// <param name="ProviderIdStart">The identification of the e-mobility provider used for starting this charging process.</param>
        /// <param name="ProviderIdStop">The identification of the e-mobility provider used for stopping this charging process.</param>
        ///
        /// <param name="Reservation">The optional charging reservation used before charging.</param>
        /// <param name="ReservationId">The optional charging reservation identification used before charging.</param>
        /// <param name="ReservationTime">Optional timestamps when the reservation started and ended.</param>
        ///
        /// <param name="ParkingSpaceId">The optional identification of the parkging space.</param>
        /// <param name="ParkingTime">Optional timestamps when the parking started and ended.</param>
        /// <param name="ParkingFee">The optional fee for parking.</param>
        ///
        /// <param name="EnergyMeterId">An optional unique identification of the energy meter.</param>
        /// <param name="EnergyMeteringValues">An optional enumeration of intermediate energy metering values.</param>
        ///
        /// <param name="CustomData">An optional dictionary of customer-specific data.</param>
        public ChargeDetailRecord(ChargingSession_Id SessionId,
                                  StartEndDateTime?SessionTime,
                                  TimeSpan?Duration = null,

                                  EVSE EVSE      = null,
                                  EVSE_Id?EVSEId = null,
                                  ChargingStation ChargingStation                      = null,
                                  ChargingStation_Id?ChargingStationId                 = null,
                                  ChargingPool ChargingPool                            = null,
                                  ChargingPool_Id?ChargingPoolId                       = null,
                                  ChargingStationOperator ChargingStationOperator      = null,
                                  ChargingStationOperator_Id?ChargingStationOperatorId = null,
                                  ChargingProduct ChargingProduct                      = null,
                                  Decimal?ChargingPrice = null,

                                  AAuthentication AuthenticationStart  = null,
                                  AAuthentication AuthenticationStop   = null,
                                  eMobilityProvider_Id?ProviderIdStart = null,
                                  eMobilityProvider_Id?ProviderIdStop  = null,

                                  ChargingReservation Reservation      = null,
                                  ChargingReservation_Id?ReservationId = null,
                                  StartEndDateTime?ReservationTime     = null,

                                  ParkingSpace_Id?ParkingSpaceId = null,
                                  StartEndDateTime?ParkingTime   = null,
                                  Decimal?ParkingFee             = null,

                                  EnergyMeter_Id?EnergyMeterId = null,
                                  IEnumerable <Timestamped <Single> > EnergyMeteringValues = null,
                                  IEnumerable <SignedMeteringValue> SignedMeteringValues   = null,
                                  IEnumerable <String> Signatures = null,

                                  IReadOnlyDictionary <String, Object> CustomData = null)

            : base(CustomData)

        {
            this.SessionId   = SessionId;
            this.SessionTime = SessionTime;
            this.Duration    = Duration;

            this.EVSE                      = EVSE;
            this.EVSEId                    = EVSEId ?? EVSE?.Id;
            this.ChargingStation           = ChargingStation;
            this.ChargingStationId         = ChargingStationId ?? ChargingStation?.Id;
            this.ChargingPool              = ChargingPool;
            this.ChargingPoolId            = ChargingPoolId ?? ChargingPool?.Id;
            this.ChargingStationOperator   = ChargingStationOperator;
            this.ChargingStationOperatorId = ChargingStationOperatorId ?? ChargingStationOperator?.Id;
            this.ChargingProduct           = ChargingProduct;
            this.ChargingPrice             = ChargingPrice;

            this.IdentificationStart = AuthenticationStart;
            this.IdentificationStop  = AuthenticationStop;
            this.ProviderIdStart     = ProviderIdStart;
            this.ProviderIdStop      = ProviderIdStop;

            this.Reservation     = Reservation;
            this.ReservationId   = ReservationId ?? Reservation?.Id;
            this.ReservationTime = ReservationTime;

            this.ParkingSpaceId = ParkingSpaceId;
            this.ParkingTime    = ParkingTime;
            this.ParkingFee     = ParkingFee;

            this.EnergyMeterId        = EnergyMeterId;
            this.EnergyMeteringValues = EnergyMeteringValues ?? new Timestamped <Single> [0];
            this.SignedMeteringValues = SignedMeteringValues ?? new SignedMeteringValue[0];
            this._Signatures          = Signatures.SafeAny()  ? new HashSet <String>(Signatures) : new HashSet <String>();

            if (SignedMeteringValues.SafeAny() && !EnergyMeteringValues.SafeAny())
            {
                this.EnergyMeteringValues = SignedMeteringValues.Select(svalue => new Timestamped <Single>(svalue.Timestamp,
                                                                                                           (Single)svalue.MeterValue));
            }
        }
Beispiel #21
0
        /// <summary>
        /// Create a new charging station group.
        /// </summary>
        /// <param name="Id">The unique identification of the charing station group.</param>
        /// <param name="Operator">The charging station operator of this charging station group.</param>
        /// <param name="Name">The offical (multi-language) name of this charging station group.</param>
        /// <param name="Description">An optional (multi-language) description of this charging station group.</param>
        ///
        /// <param name="Members">An enumeration of charging stations member building this charging station group.</param>
        /// <param name="MemberIds">An enumeration of charging station identifications which are building this charging station group.</param>
        /// <param name="AutoIncludeStations">A delegate deciding whether to include new charging stations automatically into this group.</param>
        ///
        /// <param name="StatusAggregationDelegate">A delegate called to aggregate the dynamic status of all subordinated charging stations.</param>
        /// <param name="MaxGroupStatusListSize">The default size of the charging station group status list.</param>
        /// <param name="MaxGroupAdminStatusListSize">The default size of the charging station group admin status list.</param>
        internal ChargingStationGroup(ChargingStationGroup_Id Id,
                                      ChargingStationOperator Operator,
                                      I18NString Name,
                                      I18NString Description = null,

                                      Brand Brand           = null,
                                      Priority?Priority     = null,
                                      ChargingTariff Tariff = null,
                                      IEnumerable <DataLicense> DataLicenses = null,

                                      IEnumerable <ChargingStation> Members               = null,
                                      IEnumerable <ChargingStation_Id> MemberIds          = null,
                                      Func <ChargingStation, Boolean> AutoIncludeStations = null,

                                      Func <ChargingStationStatusReport, ChargingStationGroupStatusTypes> StatusAggregationDelegate = null,
                                      UInt16 MaxGroupStatusListSize      = DefaultMaxGroupStatusListSize,
                                      UInt16 MaxGroupAdminStatusListSize = DefaultMaxGroupAdminStatusListSize)

            : base(Id)

        {
            #region Initial checks

            if (Operator == null)
            {
                throw new ArgumentNullException(nameof(Operator), "The charging station operator must not be null!");
            }

            if (IEnumerableExtensions.IsNullOrEmpty(Name))
            {
                throw new ArgumentNullException(nameof(Name), "The name of the charging station group must not be null or empty!");
            }

            #endregion

            #region Init data and properties

            this.Operator    = Operator;
            this.Name        = Name;
            this.Description = Description ?? new I18NString();

            this.Brand        = Brand;
            this.Priority     = Priority;
            this.Tariff       = Tariff;
            this.DataLicenses = DataLicenses?.Any() == true ? new ReactiveSet <DataLicense>(DataLicenses) : new ReactiveSet <DataLicense>();

            this._AllowedMemberIds   = MemberIds != null ? new HashSet <ChargingStation_Id>(MemberIds) : new HashSet <ChargingStation_Id>();
            this.AutoIncludeStations = AutoIncludeStations ?? (MemberIds == null ? (Func <ChargingStation, Boolean>)(station => true) : station => false);
            this._ChargingStations   = new ConcurrentDictionary <ChargingStation_Id, ChargingStation>();

            this.StatusAggregationDelegate = StatusAggregationDelegate;

            this._AdminStatusSchedule = new StatusSchedule <ChargingStationGroupAdminStatusTypes>(MaxGroupAdminStatusListSize);
            this._AdminStatusSchedule.Insert(ChargingStationGroupAdminStatusTypes.Unknown);

            this._StatusSchedule = new StatusSchedule <ChargingStationGroupStatusTypes>     (MaxGroupStatusListSize);
            this._StatusSchedule.Insert(ChargingStationGroupStatusTypes.Unknown);

            #endregion

            #region Init events

            // ChargingStationGroup events
            this.ChargingStationAddition = new VotingNotificator <DateTime, ChargingStationGroup, ChargingStation, Boolean>(() => new VetoVote(), true);
            this.ChargingStationRemoval  = new VotingNotificator <DateTime, ChargingStationGroup, ChargingStation, Boolean>(() => new VetoVote(), true);

            // ChargingStation events
            this.EVSEAddition = new VotingNotificator <DateTime, ChargingStation, EVSE, Boolean>(() => new VetoVote(), true);
            this.EVSERemoval  = new VotingNotificator <DateTime, ChargingStation, EVSE, Boolean>(() => new VetoVote(), true);

            // EVSE events

            #endregion

            #region Link events

            this._AdminStatusSchedule.OnStatusChanged += (Timestamp, EventTrackingId, StatusSchedule, OldStatus, NewStatus)
                                                         => UpdateAdminStatus(Timestamp, EventTrackingId, OldStatus, NewStatus);

            // ChargingStationGroup events
            //this.OnChargingStationAddition.OnVoting       += (timestamp, evseoperator, pool, vote) => EVSEOperator.ChargingStationAddition.SendVoting      (timestamp, evseoperator, pool, vote);
            //this.OnChargingStationAddition.OnNotification += (timestamp, evseoperator, pool)       => EVSEOperator.ChargingStationAddition.SendNotification(timestamp, evseoperator, pool);
            //
            //this.OnChargingStationRemoval. OnVoting       += (timestamp, evseoperator, pool, vote) => EVSEOperator.ChargingStationRemoval. SendVoting      (timestamp, evseoperator, pool, vote);
            //this.OnChargingStationRemoval. OnNotification += (timestamp, evseoperator, pool)       => EVSEOperator.ChargingStationRemoval. SendNotification(timestamp, evseoperator, pool);

            // ChargingStation events
            this.OnEVSEAddition.OnVoting       += (timestamp, station, evse, vote) => Operator.EVSEAddition.SendVoting(timestamp, station, evse, vote);
            this.OnEVSEAddition.OnNotification += (timestamp, station, evse) => Operator.EVSEAddition.SendNotification(timestamp, station, evse);

            this.OnEVSERemoval.OnVoting       += (timestamp, station, evse, vote) => Operator.EVSERemoval.SendVoting(timestamp, station, evse, vote);
            this.OnEVSERemoval.OnNotification += (timestamp, station, evse) => Operator.EVSERemoval.SendNotification(timestamp, station, evse);

            #endregion


            if (Members?.Any() == true)
            {
                Members.ForEach(station => Add(station));
            }
        }