Example #1
0
        /// <summary>
        /// Parse the given string as an EVSE identification.
        /// </summary>
        /// <param name="Text">A text representation of an EVSE identification.</param>
        public static EVSE_Id Parse(String Text)
        {
            #region Initial checks

            if (Text != null)
            {
                Text = Text.Trim();
            }

            if (Text.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(Text), "The given text representation of an EVSE identification must not be null or empty!");
            }

            #endregion

            var MatchCollection = EVSEId_RegEx.Matches(Text);

            if (MatchCollection.Count != 1)
            {
                throw new ArgumentException("Illegal EVSE identification '" + Text + "'!",
                                            nameof(Text));
            }


            if (Operator_Id.TryParse(MatchCollection[0].Groups[1].Value, out Operator_Id _OperatorId))
            {
                return(new EVSE_Id(_OperatorId,
                                   MatchCollection[0].Groups[2].Value));
            }

            throw new ArgumentException("Illegal EVSE identification '" + Text + "'!",
                                        nameof(Text));
        }
Example #2
0
        /// <summary>
        /// Create a valid charging pool identification based on the given parameters.
        /// </summary>
        /// <param name="OperatorId">The identification of an Charging Station Operator.</param>
        /// <param name="Address">The address of the charging pool.</param>
        /// <param name="GeoLocation">The geo location of the charging pool.</param>
        /// <param name="Length">The maximum size of the generated charging pool identification suffix [12 &lt; n &lt; 50].</param>
        /// <param name="Mapper">A delegate to modify a generated charging pool identification suffix.</param>
        public static ChargingPool_Id Generate(Operator_Id OperatorId,
                                               Address Address,
                                               GeoCoordinate?GeoLocation = null,
                                               String HelperId           = "",
                                               Byte Length = 15,
                                               Func <String, String> Mapper = null)
        {
            if (Length < 12)
            {
                Length = 12;
            }

            if (Length > 50)
            {
                Length = 50;
            }

            var Suffíx = new SHA1CryptoServiceProvider().
                         ComputeHash(Encoding.UTF8.GetBytes(
                                         String.Concat(
                                             OperatorId.ToString(),
                                             Address.ToString(),
                                             GeoLocation?.ToString() ?? "",
                                             HelperId ?? ""
                                             )
                                         )).
                         ToHexString().
                         SubstringMax(Length).
                         ToUpper();

            return(Parse(OperatorId,
                         Mapper != null
                            ? Mapper(Suffíx)
                            : Suffíx));
        }
        public static ChargingStationOperator_Id?ToWWCP(this Operator_Id OperatorId)
        {
            if (ChargingStationOperator_Id.TryParse(OperatorId.ToString(), out ChargingStationOperator_Id ChargingStationOperatorId))
            {
                return(ChargingStationOperatorId);
            }

            return(null);
        }
Example #4
0
        /// <summary>
        /// Parse the given string as an EVSE identification.
        /// </summary>
        /// <param name="OperatorId">The unique identification of an operator.</param>
        /// <param name="Suffix">The suffix of the EVSE identification.</param>
        public static EVSE_Id Parse(Operator_Id OperatorId,
                                    String Suffix)
        {
            switch (OperatorId.Format)
            {
            case OperatorIdFormats.eMI3:
                return(Parse(OperatorId + "E" + Suffix));

            default:
                return(Parse(OperatorId + "*E" + Suffix));
            }
        }
Example #5
0
        /// <summary>
        /// Parse the given string as a charging connector identification.
        /// </summary>
        /// <param name="OperatorId">The unique identification of an operator.</param>
        /// <param name="Suffix">The suffix of the charging connector identification.</param>
        public static ChargingConnector_Id Parse(Operator_Id OperatorId,
                                                 String Suffix)
        {
            switch (OperatorId.Format)
            {
            case OperatorIdFormats.eMI3:
                return(Parse(OperatorId.ToString() + "X" + Suffix));

            default:
                return(Parse(OperatorId.ToString() + "*X" + Suffix));
            }
        }
Example #6
0
        /// <summary>
        /// Create a new Electric Vehicle Supply Equipment (EVSE) identification based on the given
        /// operator identification and identification suffix.
        /// </summary>
        /// <param name="OperatorId">The unique identification of an operator.</param>
        /// <param name="Suffix">The suffix of the EVSE identification.</param>
        private EVSE_Id(Operator_Id OperatorId,
                        String Suffix)
        {
            #region Initial checks

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

            #endregion

            this.OperatorId = OperatorId;
            this.Suffix     = Suffix;
            this.MinSuffix  = Suffix.Replace("*", "");
        }
Example #7
0
        /// <summary>
        /// Parse the given string as a charging connector identification.
        /// </summary>
        /// <param name="Text">A text representation of a charging connector identification.</param>
        /// <param name="ChargingConnectorId">The parsed charging connector identification.</param>
        public static Boolean TryParse(String Text, out ChargingConnector_Id ChargingConnectorId)
        {
            #region Initial checks

            if (Text != null)
            {
                Text = Text.Trim();
            }

            if (Text.IsNullOrEmpty())
            {
                ChargingConnectorId = default;
                return(false);
            }

            #endregion

            try
            {
                ChargingConnectorId = default;

                var MatchCollection = ChargingConnectorId_RegEx.Matches(Text);

                if (MatchCollection.Count != 1)
                {
                    return(false);
                }

                if (Operator_Id.TryParse(MatchCollection[0].Groups[1].Value, out Operator_Id OperatorId))
                {
                    ChargingConnectorId = new ChargingConnector_Id(OperatorId,
                                                                   MatchCollection[0].Groups[2].Value);

                    return(true);
                }
            }
            catch (Exception)
            { }

            ChargingConnectorId = default;
            return(false);
        }
Example #8
0
        /// <summary>
        /// Generate a new unique identification of an EVSE identification.
        /// </summary>
        /// <param name="OperatorId">The unique identification of an operator.</param>
        /// <param name="Length">The desired length of the identification suffix.</param>
        /// <param name="Mapper">A delegate to modify the newly generated EVSE identification.</param>
        public static EVSE_Id Random(Operator_Id OperatorId,
                                     Byte Length = 10,
                                     Func <String, String> Mapper = null)

        => new EVSE_Id(OperatorId,
                       (Mapper ?? (_ => _))(_Random.RandomString((UInt16)(Length < 10 ? 10 : Length > 50 ? 50 : Length))));
        public static Operator_Id ToEMIP(this ChargingStationOperator_Id OperatorId,
                                         CustomOperatorIdMapperDelegate CustomOperatorIdMapper = null)

        => Operator_Id.Parse(CustomOperatorIdMapper != null
                                     ? CustomOperatorIdMapper(OperatorId.ToString())
                                     : OperatorId.ToString());
Example #10
0
        /// <summary>
        /// Generate a new unique identification of a charging connector identification.
        /// </summary>
        /// <param name="OperatorId">The unique identification of an operator.</param>
        /// <param name="Length">The desired length of the identification suffix.</param>
        /// <param name="Mapper">A delegate to modify the newly generated charging connector identification.</param>
        public static ChargingConnector_Id Random(Operator_Id OperatorId,
                                                  Byte Length = 12,
                                                  Func <String, String> Mapper = null)

        => new ChargingConnector_Id(OperatorId,
                                    (Mapper ?? (_ => _))(_Random.RandomString((UInt16)(Length < 12 ? 12 : Length > 50 ? 50 : Length))));
Example #11
0
        /// <summary>
        /// Generate a new unique identification of a charging station identification.
        /// </summary>
        /// <param name="OperatorId">The unique identification of an operator.</param>
        /// <param name="Length">The desired length of the identification suffix.</param>
        /// <param name="Mapper">A delegate to modify the newly generated charging station identification.</param>
        public static ChargingStation_Id Random(Operator_Id OperatorId,
                                                Byte Length = 8,
                                                Func <String, String> Mapper = null)

        => new ChargingStation_Id(OperatorId,
                                  (Mapper ?? (_ => _))(_Random.RandomString((UInt16)(Length < 8 ? 8 : Length > 50 ? 50 : Length))));