Example #1
0
        /// <summary>
        /// Parse the given string as an charging station operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="Suffix">The suffix of an charging station operator identification.</param>
        /// <param name="IdFormat">The format of the charging station operator identification [old|new].</param>
        public static Operator_Id Parse(Country CountryCode,
                                        String Suffix,
                                        OperatorIdFormats IdFormat = OperatorIdFormats.ISO)
        {
            #region Initial checks

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

            Suffix = Suffix?.Trim();

            if (Suffix.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Suffix), "The given charging station operator identification suffix must not be null or empty!");
            }

            #endregion

            return(IdFormat switch {
                OperatorIdFormats.DIN => Parse("+" + CountryCode.TelefonCode.ToString() + "*" + Suffix),

                OperatorIdFormats.ISO => Parse(CountryCode.Alpha2Code + Suffix),

                _ => Parse(CountryCode.Alpha2Code + "*" + Suffix)
            });
Example #2
0
        /// <summary>
        /// Parse the given string as an charging station operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="Suffix">The suffix of an charging station operator identification.</param>
        /// <param name="IdFormat">The format of the charging station operator identification [old|new].</param>
        public static ChargingStationOperator_Id Parse(Country CountryCode,
                                                       String Suffix,
                                                       OperatorIdFormats IdFormat = OperatorIdFormats.ISO)
        {
            #region Initial checks

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

            if (Suffix.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Suffix), "The given charging station operator identification suffix must not be null or empty!");
            }

            #endregion

            switch (IdFormat)
            {
            case OperatorIdFormats.ISO:
                return(Parse(CountryCode.Alpha2Code + Suffix));

            case OperatorIdFormats.ISO_STAR:
                return(Parse(CountryCode.Alpha2Code + "*" + Suffix));

            default:     // DIN:
                return(Parse("+" + CountryCode.TelefonCode.ToString() + "*" + Suffix));
            }
        }
Example #3
0
        /// <summary>
        /// Parse the given string as an EVSE Operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="OperatorId">An Charging Station Operator identification as a string.</param>
        /// <param name="IdFormat">The format of the Charging Station Operator identification [old|new].</param>
        public static ParkingOperator_Id Parse(Country CountryCode,
                                               String OperatorId,
                                               OperatorIdFormats IdFormat = OperatorIdFormats.ISO)
        {
            #region Initial checks

            if (CountryCode == null)
            {
                throw new ArgumentException("The parameter must not be null or empty!", "CountryCode");
            }

            if (OperatorId.IsNullOrEmpty())
            {
                throw new ArgumentException("The parameter must not be null or empty!", "OperatorId");
            }

            #endregion

            var _MatchCollection = Regex.Matches(OperatorId.Trim().ToUpper(),
                                                 OperatorId_RegEx,
                                                 RegexOptions.IgnorePatternWhitespace);

            if (_MatchCollection.Count != 1)
            {
                throw new ArgumentException("Illegal EVSE Operator identification '" + CountryCode + " / " + OperatorId + "'!", "OperatorId");
            }

            return(new ParkingOperator_Id(CountryCode, _MatchCollection[0].Value, IdFormat));
        }
Example #4
0
        /// <summary>
        /// Try to parse the given text representation of an e-mobility operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="Suffix">The suffix of an e-mobility operator identification.</param>
        /// <param name="OperatorId">The parsed e-mobility operator identification.</param>
        /// <param name="IdFormat">The optional format of the e-mobility operator identification.</param>
        public static Boolean TryParse(Country CountryCode,
                                       String Suffix,
                                       out Operator_Id OperatorId,
                                       OperatorIdFormats IdFormat = OperatorIdFormats.eMI3_STAR)
        {
            #region Initial checks

            if (CountryCode == null || Suffix.IsNullOrEmpty() || Suffix.Trim().IsNullOrEmpty())
            {
                OperatorId = default;
                return(false);
            }

            #endregion

            switch (IdFormat)
            {
            case OperatorIdFormats.eMI3:
                return(TryParse(CountryCode.Alpha2Code + Suffix,
                                out OperatorId));

            default:
                return(TryParse(CountryCode.Alpha2Code + "*" + Suffix,
                                out OperatorId));
            }
        }
Example #5
0
        /// <summary>
        /// Return the identification in the given format.
        /// </summary>
        /// <param name="Format">The format of the identification.</param>
        public String ToString(OperatorIdFormats Format)
        {
            switch (OperatorId.Format)
            {
            case OperatorIdFormats.ISO:
                return(String.Concat(OperatorId.CountryCode.Alpha2Code,
                                     OperatorId.Suffix,
                                     "S",
                                     Suffix));

            case OperatorIdFormats.ISO_STAR:
                return(String.Concat(OperatorId.CountryCode.Alpha2Code,
                                     "*",
                                     OperatorId.Suffix,
                                     "*S",
                                     Suffix));

            default:     // DIN
                return(String.Concat("+",
                                     OperatorId.CountryCode.TelefonCode,
                                     "*",
                                     OperatorId.Suffix,
                                     "*S",
                                     Suffix));
            }
        }
Example #6
0
 /// <summary>
 /// Create a new Charging Station Operator identification.
 /// </summary>
 /// <param name="CountryCode">The Alpha-2-CountryCode.</param>
 /// <param name="OperatorId">The EVSE Operator identification.</param>
 /// <param name="IdFormat">The format of the Charging Station Operator identification [old|new].</param>
 private ParkingOperator_Id(Country CountryCode,
                            String OperatorId,
                            OperatorIdFormats IdFormat = OperatorIdFormats.ISO)
 {
     this.CountryCode = CountryCode;
     this.OperatorId  = OperatorId;
     this.Format      = IdFormat;
 }
Example #7
0
 /// <summary>
 /// Create a new charging operator identification.
 /// </summary>
 /// <param name="CountryCode">The country code.</param>
 /// <param name="Suffix">The suffix of the charging operator identification.</param>
 /// <param name="Format">The format of the charging operator identification.</param>
 private Operator_Id(Country CountryCode,
                     String Suffix,
                     OperatorIdFormats Format = OperatorIdFormats.eMI3_STAR)
 {
     this.CountryCode = CountryCode;
     this.Suffix      = Suffix;
     this.Format      = Format;
 }
Example #8
0
        /// <summary>
        /// Try to parse the given text representation of an e-mobility operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="Suffix">The suffix of an e-mobility operator identification.</param>
        /// <param name="IdFormat">The optional format of the e-mobility operator identification.</param>
        public static Operator_Id?TryParse(Country CountryCode,
                                           String Suffix,
                                           OperatorIdFormats IdFormat = OperatorIdFormats.eMI3_STAR)
        {
            if (TryParse(CountryCode, Suffix, out Operator_Id _OperatorId, IdFormat))
            {
                return(_OperatorId);
            }

            return(new Operator_Id?());
        }
Example #9
0
        /// <summary>
        /// Return a text representation of the given operator identification format.
        /// </summary>
        /// <param name="OperatorIdFormat">A operator identification format.</param>
        public static String AsText(this OperatorIdFormats OperatorIdFormat)
        {
            switch (OperatorIdFormat)
            {
            case OperatorIdFormats.eMI3:
            case OperatorIdFormats.eMI3_STAR:
                return("eMI3");

            default:
                return("Gireve");
            }
        }
Example #10
0
        /// <summary>
        /// Create a new operator identification.
        /// </summary>
        /// <param name="CountryCode">The country code.</param>
        /// <param name="Suffix">The suffix of the charging station operator identification.</param>
        /// <param name="Format">The format of the charging station operator identification.</param>
        private Operator_Id(Country CountryCode,
                            String Suffix,
                            OperatorIdFormats Format = OperatorIdFormats.ISO)
        {
            if (Suffix.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Suffix), "The charging station operator identification suffix must not be null or empty!");
            }

            this.CountryCode = CountryCode;
            this.Suffix      = Suffix;
            this.Format      = Format;
        }
Example #11
0
        /// <summary>
        /// Parse the given string as an EVSE Operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="OperatorId">An Charging Station Operator identification as a string.</param>
        /// <param name="EVSEOperatorId">The parsed EVSE Operator identification.</param>
        /// <param name="IdFormat">The format of the Charging Station Operator identification [old|new].</param>
        public static Boolean TryParse(Country CountryCode,
                                       String OperatorId,
                                       out ParkingOperator_Id EVSEOperatorId,
                                       OperatorIdFormats IdFormat = OperatorIdFormats.ISO)
        {
            #region Initial checks

            if (CountryCode == null || OperatorId.IsNullOrEmpty())
            {
                EVSEOperatorId = null;
                return(false);
            }

            #endregion

            try
            {
                var _MatchCollection = Regex.Matches(OperatorId.Trim().ToUpper(),
                                                     OperatorId_RegEx,
                                                     RegexOptions.IgnorePatternWhitespace);

                if (_MatchCollection.Count != 1)
                {
                    EVSEOperatorId = null;
                    return(false);
                }

                EVSEOperatorId = new ParkingOperator_Id(CountryCode, _MatchCollection[0].Value, IdFormat);
                return(true);
            }

            catch (Exception e)
            {
                EVSEOperatorId = null;
                return(false);
            }
        }
Example #12
0
        /// <summary>
        /// Return a new charging station operator identification in the given format.
        /// </summary>
        /// <param name="NewFormat">The new charging station operator identification format.</param>
        public ChargingStationOperator_Id ChangeFormat(OperatorIdFormats NewFormat)

        => new ChargingStationOperator_Id(CountryCode,
                                          Suffix,
                                          NewFormat);
Example #13
0
        /// <summary>
        /// Return the identification in the given format.
        /// </summary>
        /// <param name="IdFormat">The format.</param>
        public String ToFormat(OperatorIdFormats IdFormat)

        => IdFormat == OperatorIdFormats.ISO
                   ? String.Concat(CountryCode.Alpha2Code, "*", OperatorId)
                   : String.Concat("+", CountryCode.TelefonCode, "*", OperatorId);
Example #14
0
        /// <summary>
        /// Return the identification in the given format.
        /// </summary>
        /// <param name="IdFormat">The format.</param>
        public String ToFormat(OperatorIdFormats IdFormat)

        => IdFormat == OperatorIdFormats.ISO
                   ? String.Concat(OperatorId.ToString(IdFormat), "*E", Suffix)
                   : String.Concat(OperatorId.ToString(IdFormat), "*", Suffix);
Example #15
0
        /// <summary>
        /// Return a new charging station operator identification in the given format.
        /// </summary>
        /// <param name="NewFormat">The new charging station operator identification format.</param>
        public GridOperator_Id ChangeFormat(OperatorIdFormats NewFormat)

        => new GridOperator_Id(CountryCode,
                               Suffix,
                               NewFormat);
        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);
        }
Example #17
0
 /// <summary>
 /// Return a new Charging Station Operator identification in the given format.
 /// </summary>
 /// <param name="Format">An Charging Station Operator identification format.</param>
 public ParkingOperator_Id ChangeFormat(OperatorIdFormats Format)
 {
     return(new ParkingOperator_Id(this.CountryCode, this.OperatorId, Format));
 }
Example #18
0
        /// <summary>
        /// Return a new EVSE identification in the given format.
        /// </summary>
        /// <param name="NewFormat">An EVSE identification format.</param>
        public EVSE_Id ChangeFormat(OperatorIdFormats NewFormat)

        => new EVSE_Id(OperatorId.ChangeFormat(NewFormat),
                       Suffix);