Exemple #1
0
        /// <summary>
        /// Return the HashCode of this object.
        /// </summary>
        /// <returns>The HashCode of this object.</returns>
        public override Int32 GetHashCode()
        {
            unchecked
            {
                return(ChargingProfileId.GetHashCode() * 31 ^
                       StackLevel.GetHashCode() * 29 ^
                       ChargingProfilePurpose.GetHashCode() * 23 ^
                       ChargingProfileKind.GetHashCode() * 19 ^
                       ChargingSchedule.GetHashCode() * 17 ^

                       (TransactionId != null
                            ? TransactionId.GetHashCode() * 13
                            : 0) ^

                       (RecurrencyKind.HasValue
                            ? RecurrencyKind.GetHashCode() * 11
                            : 0) ^

                       (ValidFrom.HasValue
                            ? ValidFrom.GetHashCode() * 7
                            : 0) ^

                       (ValidTo.HasValue
                            ? ValidTo.GetHashCode() * 5
                            : 0));
            }
        }
Exemple #2
0
        /// <summary>
        /// Compares two id tag infos for equality.
        /// </summary>
        /// <param name="ChargingProfile">An id tag info to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(ChargingProfile ChargingProfile)
        {
            if (ChargingProfile is null)
            {
                return(false);
            }

            return(ChargingProfileId.Equals(ChargingProfile.ChargingProfileId) &&
                   StackLevel.Equals(ChargingProfile.StackLevel) &&
                   ChargingProfilePurpose.Equals(ChargingProfile.ChargingProfilePurpose) &&
                   ChargingProfileKind.Equals(ChargingProfile.ChargingProfileKind) &&
                   ChargingSchedule.Equals(ChargingProfile.ChargingSchedule) &&

                   ((!TransactionId.HasValue && !ChargingProfile.TransactionId.HasValue) ||
                    (TransactionId.HasValue && ChargingProfile.TransactionId.HasValue && TransactionId.Value.Equals(ChargingProfile.TransactionId.Value))) &&

                   ((!RecurrencyKind.HasValue && !ChargingProfile.RecurrencyKind.HasValue) ||
                    (RecurrencyKind.HasValue && ChargingProfile.RecurrencyKind.HasValue && RecurrencyKind.Value.Equals(ChargingProfile.RecurrencyKind.Value))) &&

                   ((!ValidFrom.HasValue && !ChargingProfile.ValidFrom.HasValue) ||
                    (ValidFrom.HasValue && ChargingProfile.ValidFrom.HasValue && ValidFrom.Value.Equals(ChargingProfile.ValidFrom.Value))) &&

                   ((!ValidTo.HasValue && !ChargingProfile.ValidTo.HasValue) ||
                    (ValidTo.HasValue && ChargingProfile.ValidTo.HasValue && ValidTo.Value.Equals(ChargingProfile.ValidTo.Value))));
        }
Exemple #3
0
        /// <summary>
        /// Return a XML representation of this object.
        /// </summary>
        /// <param name="XName">An alternative XML element name [default: "OCPPv1_6_CP:chargingProfile"]</param>
        public XElement ToXML(XName XName = null)

        => new XElement(XName ?? OCPPNS.OCPPv1_6_CP + "chargingProfile",

                        new XElement(OCPPNS.OCPPv1_6_CP + "chargingProfileId", ChargingProfileId.ToString()),

                        TransactionId != null
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "transactionId", TransactionId.ToString())
                       : null,

                        new XElement(OCPPNS.OCPPv1_6_CP + "stackLevel", StackLevel),
                        new XElement(OCPPNS.OCPPv1_6_CP + "chargingProfilePurpose", ChargingProfilePurpose.AsText()),
                        new XElement(OCPPNS.OCPPv1_6_CP + "chargingProfileKind", ChargingProfileKind.AsText()),

                        ValidFrom.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "validFrom", ValidFrom.Value.ToIso8601())
                       : null,

                        ValidTo.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "validTo", ValidTo.Value.ToIso8601())
                       : null,

                        RecurrencyKind.HasValue
                       ? new XElement(OCPPNS.OCPPv1_6_CP + "recurrencyKind", RecurrencyKind.Value.AsText())
                       : null,

                        ChargingSchedule.ToXML()

                        );
Exemple #4
0
        /// <summary>
        /// Create a new charging profile.
        /// </summary>
        /// <param name="ChargingProfileId">The unique identification of this profile.</param>
        /// <param name="StackLevel">Value determining level in hierarchy stack of profiles. Higher values have precedence over lower values. Lowest level is 0.</param>
        /// <param name="ChargingProfilePurpose">Defines the purpose of the schedule transferred by this message.</param>
        /// <param name="ChargingProfileKind">Indicates the kind of schedule.</param>
        /// <param name="ChargingSchedule">Contains limits for the available power or current over time.</param>
        ///
        /// <param name="TransactionId">When the ChargingProfilePurpose is set to TxProfile, this value MAY be used to match the profile to a specific charging transaction.</param>
        /// <param name="RecurrencyKind">An optional indication of the start point of a recurrence.</param>
        /// <param name="ValidFrom">An optional timestamp at which the profile starts to be valid. If absent, the profile is valid as soon as it is received by the charge point. Not allowed to be used when ChargingProfilePurpose is TxProfile.</param>
        /// <param name="ValidTo">An optional timestamp at which the profile stops to be valid. If absent, the profile is valid until it is replaced by another profile. Not allowed to be used when ChargingProfilePurpose is TxProfile.</param>
        public ChargingProfile(ChargingProfile_Id ChargingProfileId,
                               UInt32 StackLevel,
                               ChargingProfilePurposes ChargingProfilePurpose,
                               ChargingProfileKinds ChargingProfileKind,
                               ChargingSchedule ChargingSchedule,

                               Transaction_Id?TransactionId   = null,
                               RecurrencyKinds?RecurrencyKind = null,
                               DateTime?ValidFrom             = null,
                               DateTime?ValidTo = null)

        {
            this.ChargingProfileId      = ChargingProfileId;
            this.StackLevel             = StackLevel;
            this.ChargingProfilePurpose = ChargingProfilePurpose;
            this.ChargingProfileKind    = ChargingProfileKind;
            this.ChargingSchedule       = ChargingSchedule ?? throw new ArgumentNullException(nameof(ChargingSchedule), "The given charging schedule must not be null!");

            this.TransactionId  = TransactionId ?? new Transaction_Id?();
            this.RecurrencyKind = RecurrencyKind ?? new RecurrencyKinds?();
            this.ValidFrom      = ValidFrom ?? new DateTime?();
            this.ValidTo        = ValidTo ?? new DateTime?();
        }
Exemple #5
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomChargingProfileSerializer">A delegate to serialize custom charging profiles.</param>
        /// <param name="CustomChargingScheduleSerializer">A delegate to serialize custom charging schedule requests.</param>
        /// <param name="CustomChargingSchedulePeriodSerializer">A delegate to serialize custom charging schedule periods.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <ChargingProfile> CustomChargingProfileSerializer               = null,
                              CustomJObjectSerializerDelegate <ChargingSchedule> CustomChargingScheduleSerializer             = null,
                              CustomJObjectSerializerDelegate <ChargingSchedulePeriod> CustomChargingSchedulePeriodSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("chargingProfileId", ChargingProfileId.ToString()),

                TransactionId != null
                               ? new JProperty("transactionId", TransactionId.ToString())
                               : null,

                new JProperty("stackLevel", StackLevel),
                new JProperty("chargingProfilePurpose", ChargingProfilePurpose.AsText()),
                new JProperty("chargingProfileKind", ChargingProfileKind.AsText()),

                ValidFrom.HasValue
                               ? new JProperty("validFrom", ValidFrom.Value.ToIso8601())
                               : null,

                ValidTo.HasValue
                               ? new JProperty("validTo", ValidTo.Value.ToIso8601())
                               : null,

                RecurrencyKind.HasValue
                               ? new JProperty("recurrencyKind", RecurrencyKind.Value.AsText())
                               : null,

                new JProperty("chargingSchedule", ChargingSchedule.ToJSON(CustomChargingScheduleSerializer,
                                                                          CustomChargingSchedulePeriodSerializer))

                );

            return(CustomChargingProfileSerializer != null
                       ? CustomChargingProfileSerializer(this, JSON)
                       : JSON);
        }