Exemple #1
0
        /// <summary>
        /// Create a new StatusNotification request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The connector identification at the charge point.</param>
        /// <param name="Status">The current status of the charge point.</param>
        /// <param name="ErrorCode">The error code reported by the charge point.</param>
        ///
        /// <param name="Info">Additional free format information related to the error.</param>
        /// <param name="StatusTimestamp">The time for which the status is reported.</param>
        /// <param name="VendorId">This identifies the vendor-specific implementation.</param>
        /// <param name="VendorErrorCode">A vendor-specific error code.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public StatusNotificationRequest(ChargeBox_Id ChargeBoxId,
                                         Connector_Id ConnectorId,
                                         ChargePointStatus Status,
                                         ChargePointErrorCodes ErrorCode,

                                         String Info = null,
                                         DateTime?StatusTimestamp = null,
                                         String VendorId          = null,
                                         String VendorErrorCode   = null,

                                         Request_Id?RequestId             = null,
                                         DateTime?RequestTimestamp        = null,
                                         EventTracking_Id EventTrackingId = null)

            : base(ChargeBoxId,
                   "StatusNotification",
                   RequestId,
                   EventTrackingId,
                   RequestTimestamp)

        {
            this.ConnectorId = ConnectorId;
            this.Status      = Status;
            this.ErrorCode   = ErrorCode;

            this.Info            = Info?.Trim();             // max  50
            this.StatusTimestamp = StatusTimestamp;
            this.VendorId        = VendorId?.Trim();         // max 255
            this.VendorErrorCode = VendorErrorCode?.Trim();  // max  50
        }
Exemple #2
0
        /// <summary>
        /// Create a new MeterValues request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The connector identification at the charge point.</param>
        /// <param name="MeterValues">The sampled meter values with timestamps.</param>
        /// <param name="TransactionId">The charging transaction to which the given meter value samples are related to.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public MeterValuesRequest(ChargeBox_Id ChargeBoxId,
                                  Connector_Id ConnectorId,
                                  IEnumerable <MeterValue> MeterValues,
                                  Transaction_Id?TransactionId = null,

                                  Request_Id?RequestId             = null,
                                  DateTime?RequestTimestamp        = null,
                                  EventTracking_Id EventTrackingId = null)

            : base(ChargeBoxId,
                   "MeterValues",
                   RequestId,
                   EventTrackingId,
                   RequestTimestamp)

        {
            if (!MeterValues.SafeAny())
            {
                throw new ArgumentNullException(nameof(MeterValues), "The given MeterValues must not be null or empty!");
            }

            this.ConnectorId   = ConnectorId;
            this.TransactionId = TransactionId;
            this.MeterValues   = MeterValues;
        }
Exemple #3
0
        /// <summary>
        /// A connector is the socket or cable available for the EV to make use of.
        /// </summary>
        /// <param name="ConnectorId">Identifier of the connector within the EVSE. Two connectors may have the same id as long as they do not belong to the same EVSE object.</param>
        /// <param name="Standard">The standard of the installed connector.</param>
        /// <param name="Format">The format (socket/cable) of the installed connector.</param>
        /// <param name="PowerType">The type of powert at the connector.</param>
        /// <param name="Voltage">Voltage of the connector (line to neutral for AC_3_PHASE), in volt [V].</param>
        /// <param name="Amperage">Maximum amperage of the connector, in ampere [A].</param>
        /// <param name="TariffId">Optional identifier of the current charging tariff structure.</param>
        /// <param name="TermsAndConditions">Optional URL to the operator's terms and conditions.</param>
        public Connector(Connector_Id ConnectorId,
                         ConnectorType Standard,
                         ConnectorFormatType Format,
                         PowerType PowerType,
                         UInt16 Voltage,
                         UInt16 Amperage,
                         Tariff_Id TariffId     = null,
                         Uri TermsAndConditions = null)
        {
            #region Initial checks

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

            #endregion

            this._Id                 = ConnectorId;
            this._Standard           = Standard;
            this._Format             = Format;
            this._PowerType          = PowerType;
            this._Voltage            = Voltage;
            this._Amperage           = Amperage;
            this._TariffId           = TariffId;
            this._TermsAndConditions = TermsAndConditions;
        }
Exemple #4
0
        /// <summary>
        /// Create a reserve now request.
        /// </summary>
        /// <param name="ConnectorId">The identification of the connector to be reserved. A value of 0 means that the reservation is not for a specific connector.</param>
        /// <param name="ReservationId">The unique identification of this reservation.</param>
        /// <param name="ExpiryDate">The timestamp when the reservation ends.</param>
        /// <param name="IdTag">The identifier for which the charge point has to reserve a connector.</param>
        /// <param name="ParentIdTag">An optional ParentIdTag.</param>
        public ReserveNowRequest(Connector_Id ConnectorId,
                                 Reservation_Id ReservationId,
                                 DateTime ExpiryDate,
                                 IdToken IdTag,
                                 IdToken?ParentIdTag = null)
        {
            #region Initial checks

            if (ConnectorId.IsNullOrEmpty)
            {
                throw new ArgumentNullException(nameof(ConnectorId), "The given unique connector identification must not be null!");
            }

            if (ReservationId.IsNullOrEmpty)
            {
                throw new ArgumentNullException(nameof(ReservationId), "The given unique reservation identification must not be null!");
            }

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

            #endregion

            this.ConnectorId   = ConnectorId;
            this.ReservationId = ReservationId;
            this.ExpiryDate    = ExpiryDate;
            this.IdTag         = IdTag;
            this.ParentIdTag   = ParentIdTag ?? new IdToken?();
        }
Exemple #5
0
 /// <summary>
 /// Create an OCPP GetCompositeScheduleRequest XML/SOAP request.
 /// </summary>
 /// <param name="ConnectorId">The connector identification for which the schedule is requested. Connector identification 0 will calculate the expected consumption for the grid connection.</param>
 /// <param name="Duration">The length of requested schedule.</param>
 /// <param name="ChargingRateUnit">Can optionally be used to force a power or current profile.</param>
 public GetCompositeScheduleRequest(Connector_Id ConnectorId,
                                    TimeSpan Duration,
                                    ChargingRateUnits?ChargingRateUnit = null)
 {
     this.ConnectorId      = ConnectorId;
     this.Duration         = Duration;
     this.ChargingRateUnit = ChargingRateUnit ?? new ChargingRateUnits?();
 }
 /// <summary>
 /// Create an OCPP MeterValues XML/SOAP request.
 /// </summary>
 /// <param name="ConnectorId">The connector identification at the charge point.</param>
 /// <param name="TransactionId">The charging transaction to which the given meter value samples are related to.</param>
 /// <param name="MeterValues">The sampled meter values with timestamps.</param>
 public MeterValuesRequest(Connector_Id ConnectorId,
                           Transaction_Id?TransactionId         = null,
                           IEnumerable <MeterValue> MeterValues = null)
 {
     this.ConnectorId   = ConnectorId;
     this.TransactionId = TransactionId;
     this.MeterValues   = MeterValues;
 }
 /// <summary>
 /// Create an OCPP ClearChargingProfileRequest XML/SOAP request.
 /// </summary>
 /// <param name="ChargingProfileId">The optional identification of the charging profile to clear.</param>
 /// <param name="ConnectorId">The optional connector for which to clear the charging profiles. Connector identification 0 specifies the charging profile for the overall charge point. Absence of this parameter means the clearing applies to all charging profiles that match the other criteria in the request.</param>
 /// <param name="ChargingProfilePurpose">The optional purpose of the charging profiles that will be cleared, if they meet the other criteria in the request.</param>
 /// <param name="StackLevel">The optional stack level for which charging profiles will be cleared, if they meet the other criteria in the request.</param>
 public ClearChargingProfileRequest(ChargingProfile_Id ChargingProfileId,
                                    Connector_Id ConnectorId,
                                    ChargingProfilePurposes?ChargingProfilePurpose,
                                    UInt32?StackLevel)
 {
     this.ChargingProfileId      = ChargingProfileId;
     this.ConnectorId            = ConnectorId;
     this.ChargingProfilePurpose = ChargingProfilePurpose ?? new ChargingProfilePurposes?();
     this.StackLevel             = StackLevel ?? new UInt32?();
 }
Exemple #8
0
 /// <summary>
 /// Create a status notification request.
 /// </summary>
 /// <param name="Timestamp">The time for which the status is reported.</param>
 /// <param name="ConnectorStatus">The current status of the connector.</param>
 /// <param name="EVSEId">The identification of the EVSE to which the connector belongs for which the the status is reported.</param>
 /// <param name="ConnectorId">The identification of the connector within the EVSE for which the status is reported.</param>
 /// <param name="CustomData">An optional custom data object to allow to store any kind of customer specific data.</param>
 public StatusNotificationRequest(DateTime Timestamp,
                                  ConnectorStatus ConnectorStatus,
                                  EVSE_Id EVSEId,
                                  Connector_Id ConnectorId,
                                  CustomData CustomData = null)
 {
     this.Timestamp       = Timestamp;
     this.ConnectorStatus = ConnectorStatus;
     this.EVSEId          = EVSEId;
     this.ConnectorId     = ConnectorId;
     this.CustomData      = CustomData;
 }
 /// <summary>
 /// Create a start transaction request.
 /// </summary>
 /// <param name="ConnectorId">The connector identification at the charge point.</param>
 /// <param name="IdTag">The identifier for which a transaction has to be started.</param>
 /// <param name="StartTimestamp">The timestamp of the transaction start.</param>
 /// <param name="MeterStart">The energy meter value in Wh for the connector at start of the transaction.</param>
 /// <param name="ReservationId">An optional identification of the reservation that will terminate as a result of this transaction.</param>
 public StartTransactionRequest(Connector_Id ConnectorId,
                                IdToken IdTag,
                                DateTime StartTimestamp,
                                UInt64 MeterStart,
                                Reservation_Id?ReservationId = null)
 {
     this.ConnectorId    = ConnectorId;
     this.IdTag          = IdTag;
     this.StartTimestamp = StartTimestamp;
     this.MeterStart     = MeterStart;
     this.ReservationId  = ReservationId;
 }
        public static void Connector_SerializeDeserialize_Test01()
        {
            var Connector1 = new Connector(
                Connector_Id.Parse("1"),
                ConnectorTypes.IEC_62196_T2,
                ConnectorFormats.SOCKET,
                PowerTypes.AC_3_PHASE,
                400,
                30,
                12,
                new Tariff_Id[] {
                Tariff_Id.Parse("DE*GEF*T0001"),
                Tariff_Id.Parse("DE*GEF*T0002")
            },
                URL.Parse("https://open.charging.cloud/terms"),
                DateTime.Parse("2020-09-21T00:00:00Z")
                );

            var JSON = Connector1.ToJSON();

            Assert.AreEqual("1", JSON["id"].Value <String>());
            Assert.AreEqual("IEC_62196_T2", JSON["standard"].Value <String>());
            Assert.AreEqual("SOCKET", JSON["format"].Value <String>());
            Assert.AreEqual("AC_3_PHASE", JSON["power_type"].Value <String>());
            Assert.AreEqual(400, JSON["max_voltage"].Value <UInt16>());
            Assert.AreEqual(30, JSON["max_amperage"].Value <UInt16>());
            Assert.AreEqual(12, JSON["max_electric_power"].Value <UInt16>());
            Assert.AreEqual("DE*GEF*T0001", JSON["tariff_ids"][0].Value <String>());
            Assert.AreEqual("DE*GEF*T0002", JSON["tariff_ids"][1].Value <String>());
            Assert.AreEqual("https://open.charging.cloud/terms", JSON["terms_and_conditions"].Value <String>());
            Assert.AreEqual("2020-09-21T00:00:00.000Z", JSON["last_updated"].Value <String>());

            Assert.IsTrue(Connector.TryParse(JSON, out Connector Connector2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(new Tariff_Id[] {
                Tariff_Id.Parse("DE*GEF*T0001"),
                Tariff_Id.Parse("DE*GEF*T0002")
            },
                            Connector2.TariffIds);

            Assert.AreEqual(Connector1.Id, Connector2.Id);
            Assert.AreEqual(Connector1.Standard, Connector2.Standard);
            Assert.AreEqual(Connector1.Format, Connector2.Format);
            Assert.AreEqual(Connector1.PowerType, Connector2.PowerType);
            Assert.AreEqual(Connector1.MaxVoltage, Connector2.MaxVoltage);
            Assert.AreEqual(Connector1.MaxAmperage, Connector2.MaxAmperage);
            Assert.AreEqual(Connector1.MaxElectricPower, Connector2.MaxElectricPower);
            Assert.AreEqual(Connector1.TariffIds, Connector2.TariffIds);
            Assert.AreEqual(Connector1.TermsAndConditionsURL, Connector2.TermsAndConditionsURL);
            Assert.AreEqual(Connector1.LastUpdated.ToIso8601(), Connector2.LastUpdated.ToIso8601());
        }
Exemple #11
0
        /// <summary>
        /// Create a new OCPP get composite schedule response.
        /// </summary>
        /// <param name="Status">The result of the request.</param>
        /// <param name="ConnectorId">The charging schedule contained in this notification applies to a specific connector.</param>
        /// <param name="ScheduleStart">The periods contained in the charging profile are relative to this timestamp.</param>
        /// <param name="ChargingSchedule">The planned composite charging schedule, the energy consumption over time. Always relative to ScheduleStart.</param>
        public GetCompositeScheduleResponse(GetCompositeScheduleStatus Status,
                                            Connector_Id ConnectorId,
                                            DateTime?ScheduleStart,
                                            ChargingSchedule ChargingSchedule)

            : base(Result.OK())

        {
            this.Status           = Status;
            this.ConnectorId      = ConnectorId;
            this.ScheduleStart    = ScheduleStart ?? new DateTime?();
            this.ChargingSchedule = ChargingSchedule;
        }
Exemple #12
0
        public static Task <UnlockConnectorResponse> UnlockConnector(this ICentralSystemClient ICentralSystemClient,
                                                                     ChargeBox_Id ChargeBoxId,
                                                                     Connector_Id ConnectorId,

                                                                     Request_Id?RequestId      = null,
                                                                     DateTime?RequestTimestamp = null,
                                                                     TimeSpan?Timeout          = null)

        => ICentralSystemClient.UnlockConnector(new UnlockConnectorRequest(ChargeBoxId,
                                                                           ConnectorId,
                                                                           RequestId,
                                                                           RequestTimestamp),
                                                Timeout);
        /// <summary>
        /// Create a new UnlockConnector request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The identifier of the connector to be unlocked.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public UnlockConnectorRequest(ChargeBox_Id ChargeBoxId,
                                      Connector_Id ConnectorId,

                                      Request_Id?RequestId      = null,
                                      DateTime?RequestTimestamp = null)

            : base(ChargeBoxId,
                   "UnlockConnector",
                   RequestId,
                   RequestTimestamp)

        {
            this.ConnectorId = ConnectorId;
        }
Exemple #14
0
        public static Task <SetChargingProfileResponse> SetChargingProfile(this ICentralSystemClient ICentralSystemClient,
                                                                           ChargeBox_Id ChargeBoxId,
                                                                           Connector_Id ConnectorId,
                                                                           ChargingProfile ChargingProfile,

                                                                           Request_Id?RequestId      = null,
                                                                           DateTime?RequestTimestamp = null,
                                                                           TimeSpan?Timeout          = null)

        => ICentralSystemClient.SetChargingProfile(new SetChargingProfileRequest(ChargeBoxId,
                                                                                 ConnectorId,
                                                                                 ChargingProfile,
                                                                                 RequestId,
                                                                                 RequestTimestamp),
                                                   Timeout);
        /// <summary>
        /// Create an OCPP SetChargingProfileRequest XML/SOAP request.
        /// </summary>
        /// <param name="ConnectorId">The connector to which the charging profile applies. If connectorId = 0, the message contains an overall limit for the charge point.</param>
        /// <param name="ChargingProfile">The charging profile to be set.</param>
        public SetChargingProfileRequest(Connector_Id ConnectorId,
                                         ChargingProfile ChargingProfile)
        {
            #region Initial checks

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

            #endregion

            this.ConnectorId     = ConnectorId;
            this.ChargingProfile = ChargingProfile;
        }
Exemple #16
0
        public static Task <ChangeAvailabilityResponse> ChangeAvailability(this ICentralSystemClient ICentralSystemClient,
                                                                           ChargeBox_Id ChargeBoxId,
                                                                           Connector_Id ConnectorId,
                                                                           Availabilities Availability,

                                                                           Request_Id?RequestId      = null,
                                                                           DateTime?RequestTimestamp = null,
                                                                           TimeSpan?Timeout          = null)

        => ICentralSystemClient.ChangeAvailability(new ChangeAvailabilityRequest(ChargeBoxId,
                                                                                 ConnectorId,
                                                                                 Availability,
                                                                                 RequestId,
                                                                                 RequestTimestamp),
                                                   Timeout);
        /// <summary>
        /// Create a new ChangeAvailability request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The identification of the connector for which its availability should be changed. Id '0' (zero) is used if the availability of the entire charge point and all its connectors should be changed.</param>
        /// <param name="Availability">The new availability of the charge point or charge point connector.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public ChangeAvailabilityRequest(ChargeBox_Id ChargeBoxId,
                                         Connector_Id ConnectorId,
                                         Availabilities Availability,

                                         Request_Id?RequestId      = null,
                                         DateTime?RequestTimestamp = null)

            : base(ChargeBoxId,
                   "ChangeAvailability",
                   RequestId,
                   RequestTimestamp)

        {
            this.ConnectorId  = ConnectorId;
            this.Availability = Availability;
        }
Exemple #18
0
        /// <summary>
        /// Create a new SetChargingProfile request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The connector to which the charging profile applies. If connectorId = 0, the message contains an overall limit for the charge point.</param>
        /// <param name="ChargingProfile">The charging profile to be set.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public SetChargingProfileRequest(ChargeBox_Id ChargeBoxId,
                                         Connector_Id ConnectorId,
                                         ChargingProfile ChargingProfile,

                                         Request_Id?RequestId      = null,
                                         DateTime?RequestTimestamp = null)

            : base(ChargeBoxId,
                   "SetChargingProfile",
                   RequestId,
                   RequestTimestamp)

        {
            this.ConnectorId     = ConnectorId;
            this.ChargingProfile = ChargingProfile ?? throw new ArgumentNullException(nameof(ChargingProfile), "The given charging profile must not be null!");
        }
Exemple #19
0
        public static Task <GetCompositeScheduleResponse> GetCompositeSchedule(this ICentralSystemClient ICentralSystemClient,
                                                                               ChargeBox_Id ChargeBoxId,
                                                                               Connector_Id ConnectorId,
                                                                               TimeSpan Duration,
                                                                               ChargingRateUnits?ChargingRateUnit = null,

                                                                               Request_Id?RequestId      = null,
                                                                               DateTime?RequestTimestamp = null,
                                                                               TimeSpan?Timeout          = null)

        => ICentralSystemClient.GetCompositeSchedule(new GetCompositeScheduleRequest(ChargeBoxId,
                                                                                     ConnectorId,
                                                                                     Duration,
                                                                                     ChargingRateUnit,
                                                                                     RequestId,
                                                                                     RequestTimestamp),
                                                     Timeout);
Exemple #20
0
        /// <summary>
        /// Create a status notification request.
        /// </summary>
        /// <param name="ConnectorId">The connector identification at the charge point.</param>
        /// <param name="Status">The current status of the charge point.</param>
        /// <param name="ErrorCode">The error code reported by the charge point.</param>
        /// <param name="Info">Additional free format information related to the error.</param>
        /// <param name="StatusTimestamp">The time for which the status is reported.</param>
        /// <param name="VendorId">This identifies the vendor-specific implementation.</param>
        /// <param name="VendorErrorCode">A vendor-specific error code.</param>
        public StatusNotificationRequest(Connector_Id ConnectorId,
                                         ChargePointStatus Status,
                                         ChargePointErrorCodes ErrorCode,
                                         String Info = null,
                                         DateTime?StatusTimestamp = null,
                                         String VendorId          = null,
                                         String VendorErrorCode   = null)
        {
            this.ConnectorId = ConnectorId;
            this.Status      = Status;
            this.ErrorCode   = ErrorCode;

            this.Info            = Info?.Trim();             // max  50
            this.StatusTimestamp = StatusTimestamp;
            this.VendorId        = VendorId?.Trim();         // max 255
            this.VendorErrorCode = VendorErrorCode?.Trim();  // max  50
        }
Exemple #21
0
        /// <summary>
        /// Create an OCPP StartTransaction XML/SOAP request.
        /// </summary>
        /// <param name="ConnectorId">The connector identification at the charge point.</param>
        /// <param name="Status">The current status of the charge point.</param>
        /// <param name="ErrorCode">The error code reported by the charge point.</param>
        /// <param name="Info">Additional free format information related to the error.</param>
        /// <param name="StatusTimestamp">The time for which the status is reported.</param>
        /// <param name="VendorId">This identifies the vendor-specific implementation.</param>
        /// <param name="VendorErrorCode">A vendor-specific error code.</param>
        public StatusNotificationRequest(Connector_Id ConnectorId,
                                         ChargePointStatus Status,
                                         ChargePointErrorCodes ErrorCode,
                                         String Info = null,
                                         DateTime?StatusTimestamp = null,
                                         String VendorId          = null,
                                         String VendorErrorCode   = null)
        {
            this.ConnectorId = ConnectorId;
            this.Status      = Status;
            this.ErrorCode   = ErrorCode;

            this.Info            = Info.Trim().IsNotNullOrEmpty() ? Info.Trim() : "";
            this.StatusTimestamp = StatusTimestamp ?? new DateTime?();
            this.VendorId        = VendorId.Trim().IsNotNullOrEmpty() ? VendorId.Trim() : "";
            this.VendorErrorCode = VendorErrorCode.Trim().IsNotNullOrEmpty() ? VendorErrorCode.Trim() : "";
        }
Exemple #22
0
        /// <summary>
        /// Create a new meter values request.
        /// </summary>
        /// <param name="ConnectorId">The connector identification at the charge point.</param>
        /// <param name="TransactionId">The charging transaction to which the given meter value samples are related to.</param>
        /// <param name="MeterValues">The sampled meter values with timestamps.</param>
        public MeterValuesRequest(Connector_Id ConnectorId,
                                  Transaction_Id?TransactionId         = null,
                                  IEnumerable <MeterValue> MeterValues = null)
        {
            #region Initial checks

            if (!MeterValues.SafeAny())
            {
                throw new ArgumentNullException(nameof(MeterValues), "The given meter values must not be null or empty!");
            }

            #endregion

            this.ConnectorId   = ConnectorId;
            this.TransactionId = TransactionId;
            this.MeterValues   = MeterValues;
        }
Exemple #23
0
        /// <summary>
        /// Create a new GetCompositeSchedule request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The connector identification for which the schedule is requested. Connector identification 0 will calculate the expected consumption for the grid connection.</param>
        /// <param name="Duration">The length of requested schedule.</param>
        /// <param name="ChargingRateUnit">Can optionally be used to force a power or current profile.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public GetCompositeScheduleRequest(ChargeBox_Id ChargeBoxId,
                                           Connector_Id ConnectorId,
                                           TimeSpan Duration,
                                           ChargingRateUnits?ChargingRateUnit = null,

                                           Request_Id?RequestId      = null,
                                           DateTime?RequestTimestamp = null)

            : base(ChargeBoxId,
                   "GetCompositeSchedule",
                   RequestId,
                   RequestTimestamp)

        {
            this.ConnectorId      = ConnectorId;
            this.Duration         = Duration;
            this.ChargingRateUnit = ChargingRateUnit;
        }
        public static void Connector_PATCH_minimal()
        {
            var Connector1 = new Connector(
                Connector_Id.Parse("1"),
                ConnectorTypes.IEC_62196_T2,
                ConnectorFormats.SOCKET,
                PowerTypes.AC_3_PHASE,
                400,
                30,
                12,
                new Tariff_Id[] {
                Tariff_Id.Parse("DE*GEF*T0001"),
                Tariff_Id.Parse("DE*GEF*T0002")
            },
                URL.Parse("https://open.charging.cloud/terms"),
                DateTime.Parse("2020-09-21T00:00:00Z")
                );

            var patchResult = Connector1.TryPatch(JObject.Parse(@"{ ""standard"": ""TESLA_S"" }"));

            Assert.IsNotNull(patchResult);
            Assert.IsTrue(patchResult.IsSuccess);
            Assert.IsFalse(patchResult.IsFailed);
            Assert.IsNull(patchResult.ErrorResponse);
            Assert.IsNotNull(patchResult.PatchedData);

            Assert.AreEqual(Connector_Id.Parse("1"), patchResult.PatchedData.Id);
            Assert.AreEqual(ConnectorTypes.TESLA_S, patchResult.PatchedData.Standard);
            Assert.AreEqual(ConnectorFormats.SOCKET, patchResult.PatchedData.Format);
            Assert.AreEqual(PowerTypes.AC_3_PHASE, patchResult.PatchedData.PowerType);
            Assert.AreEqual(400, patchResult.PatchedData.MaxVoltage);
            Assert.AreEqual(30, patchResult.PatchedData.MaxAmperage);
            Assert.AreEqual(12, patchResult.PatchedData.MaxElectricPower);
            Assert.AreEqual(2, patchResult.PatchedData.TariffIds.Count());
            Assert.AreEqual(Tariff_Id.Parse("DE*GEF*T0001"), patchResult.PatchedData.TariffIds.First());
            Assert.AreEqual(Tariff_Id.Parse("DE*GEF*T0002"), patchResult.PatchedData.TariffIds.Skip(1).First());
            Assert.AreEqual(URL.Parse("https://open.charging.cloud/terms"), patchResult.PatchedData.TermsAndConditionsURL);
            Assert.AreNotEqual(DateTime.Parse("2020-09-21T00:00:00Z"), patchResult.PatchedData.LastUpdated);

            Assert.IsTrue(DateTime.UtcNow - patchResult.PatchedData.LastUpdated < TimeSpan.FromSeconds(5));
        }
Exemple #25
0
        public static Task <ReserveNowResponse> ReserveNow(this ICentralSystemClient ICentralSystemClient,
                                                           ChargeBox_Id ChargeBoxId,
                                                           Connector_Id ConnectorId,
                                                           Reservation_Id ReservationId,
                                                           DateTime ExpiryDate,
                                                           IdToken IdTag,
                                                           IdToken?ParentIdTag = null,

                                                           Request_Id?RequestId      = null,
                                                           DateTime?RequestTimestamp = null,
                                                           TimeSpan?Timeout          = null)

        => ICentralSystemClient.ReserveNow(new ReserveNowRequest(ChargeBoxId,
                                                                 ConnectorId,
                                                                 ReservationId,
                                                                 ExpiryDate,
                                                                 IdTag,
                                                                 ParentIdTag,
                                                                 RequestId,
                                                                 RequestTimestamp),
                                           Timeout);
Exemple #26
0
        /// <summary>
        /// Create a new StartTransaction request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The connector identification at the charge point.</param>
        /// <param name="IdTag">The identifier for which a transaction has to be started.</param>
        /// <param name="StartTimestamp">The timestamp of the transaction start.</param>
        /// <param name="MeterStart">The energy meter value in Wh for the connector at start of the transaction.</param>
        /// <param name="ReservationId">An optional identification of the reservation that will terminate as a result of this transaction.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public StartTransactionRequest(ChargeBox_Id ChargeBoxId,
                                       Connector_Id ConnectorId,
                                       IdToken IdTag,
                                       DateTime StartTimestamp,
                                       UInt64 MeterStart,
                                       Reservation_Id?ReservationId = null,
                                       Request_Id?RequestId         = null,
                                       DateTime?RequestTimestamp    = null)

            : base(ChargeBoxId,
                   "StartTransaction",
                   RequestId,
                   RequestTimestamp)

        {
            this.ConnectorId    = ConnectorId;
            this.IdTag          = IdTag;
            this.StartTimestamp = StartTimestamp;
            this.MeterStart     = MeterStart;
            this.ReservationId  = ReservationId;
        }
        public static void Connector_PATCH_InvalidLastUpdatedPatch()
        {
            var Connector1 = new Connector(
                Connector_Id.Parse("1"),
                ConnectorTypes.IEC_62196_T2,
                ConnectorFormats.SOCKET,
                PowerTypes.AC_3_PHASE,
                400,
                30,
                12,
                new Tariff_Id[] {
                Tariff_Id.Parse("DE*GEF*T0001"),
                Tariff_Id.Parse("DE*GEF*T0002")
            },
                URL.Parse("https://open.charging.cloud/terms"),
                DateTime.Parse("2020-09-21T00:00:00Z")
                );

            var patchResult = Connector1.TryPatch(JObject.Parse(@"{ ""last_updated"": ""I-N-V-A-L-I-D!"" }"));

            Assert.IsNotNull(patchResult);
            Assert.IsFalse(patchResult.IsSuccess);
            Assert.IsTrue(patchResult.IsFailed);
            Assert.IsNotNull(patchResult.ErrorResponse);
            Assert.AreEqual("Invalid JSON merge patch of a connector: Invalid 'last updated'!", patchResult.ErrorResponse);
            Assert.IsNotNull(patchResult.PatchedData);

            Assert.AreEqual(Connector_Id.Parse("1"), patchResult.PatchedData.Id);
            Assert.AreEqual(ConnectorTypes.IEC_62196_T2, patchResult.PatchedData.Standard);
            Assert.AreEqual(ConnectorFormats.SOCKET, patchResult.PatchedData.Format);
            Assert.AreEqual(PowerTypes.AC_3_PHASE, patchResult.PatchedData.PowerType);
            Assert.AreEqual(400, patchResult.PatchedData.MaxVoltage);
            Assert.AreEqual(30, patchResult.PatchedData.MaxAmperage);
            Assert.AreEqual(12, patchResult.PatchedData.MaxElectricPower);
            Assert.AreEqual(2, patchResult.PatchedData.TariffIds.Count());
            Assert.AreEqual(Tariff_Id.Parse("DE*GEF*T0001"), patchResult.PatchedData.TariffIds.First());
            Assert.AreEqual(Tariff_Id.Parse("DE*GEF*T0002"), patchResult.PatchedData.TariffIds.Skip(1).First());
            Assert.AreEqual(URL.Parse("https://open.charging.cloud/terms"), patchResult.PatchedData.TermsAndConditionsURL);
            Assert.AreEqual("2020-09-21T00:00:00.000Z", patchResult.PatchedData.LastUpdated.ToIso8601());
        }
Exemple #28
0
        /// <summary>
        /// Create a new ReserveNow request.
        /// </summary>
        /// <param name="ChargeBoxId">The charge box identification.</param>
        /// <param name="ConnectorId">The identification of the connector to be reserved. A value of 0 means that the reservation is not for a specific connector.</param>
        /// <param name="ReservationId">The unique identification of this reservation.</param>
        /// <param name="ExpiryDate">The timestamp when the reservation ends.</param>
        /// <param name="IdTag">The identifier for which the charge point has to reserve a connector.</param>
        /// <param name="ParentIdTag">An optional ParentIdTag.</param>
        ///
        /// <param name="RequestId">An optional request identification.</param>
        /// <param name="RequestTimestamp">An optional request timestamp.</param>
        public ReserveNowRequest(ChargeBox_Id ChargeBoxId,
                                 Connector_Id ConnectorId,
                                 Reservation_Id ReservationId,
                                 DateTime ExpiryDate,
                                 IdToken IdTag,
                                 IdToken?ParentIdTag = null,

                                 Request_Id?RequestId      = null,
                                 DateTime?RequestTimestamp = null)

            : base(ChargeBoxId,
                   "ReserveNow",
                   RequestId,
                   RequestTimestamp)

        {
            this.ConnectorId   = ConnectorId;
            this.ReservationId = ReservationId;
            this.ExpiryDate    = ExpiryDate;
            this.IdTag         = IdTag;
            this.ParentIdTag   = ParentIdTag ?? new IdToken?();
        }
Exemple #29
0
        public static void Session_SerializeDeserialize_Test01()
        {
            #region Define Session1

            var Session1 = new Session(
                CountryCode.Parse("DE"),
                Party_Id.Parse("GEF"),
                Session_Id.Parse("Session0001"),
                DateTime.Parse("2020-08-21T00:00:00.000Z"), // Start
                1.11M,                                      // KWh
                new CDRToken(
                    Token_Id.Parse("1234"),
                    TokenTypes.RFID,
                    Contract_Id.Parse("Contract0815")
                    ),
                AuthMethods.AUTH_REQUEST,
                Location_Id.Parse("LOC0001"),
                EVSE_UId.Parse("EVSE0001"),
                Connector_Id.Parse("C1"),
                Currency.EUR,
                SessionStatusTypes.ACTIVE,
                DateTime.Parse("2020-08-22T00:00:00.000Z"),                // End
                AuthorizationReference.Parse("Auth1234"),

                Meter_Id.Parse("Meter0001"),

                // OCPI Computer Science Extentions
                new EnergyMeter(
                    Meter_Id.Parse("Meter0815"),
                    "EnergyMeter Model #1",
                    "hw. v1.80",
                    "fw. v1.20",
                    "Energy Metering Services",
                    null,
                    null
                    ),

                // OCPI Computer Science Extentions
                new TransparencySoftware[] {
                new TransparencySoftware(
                    "Chargy Transparency Software Desktop Application",
                    "v1.00",
                    LegalStatus.LegallyBinding,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyDesktopApp")
                    ),
                new TransparencySoftware(
                    "Chargy Transparency Software Mobile Application",
                    "v1.00",
                    LegalStatus.ForInformationOnly,
                    OpenSourceLicenses.GPL3,
                    "GraphDefined GmbH",
                    URL.Parse("https://open.charging.cloud/logo.svg"),
                    URL.Parse("https://open.charging.cloud/Chargy/howto"),
                    URL.Parse("https://open.charging.cloud/Chargy"),
                    URL.Parse("https://github.com/OpenChargingCloud/ChargyMobileApp")
                    )
            },

                new ChargingPeriod[] {
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:49Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.ENERGY,
                        1.33M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0001")
                    ),
                new ChargingPeriod(
                    DateTime.Parse("2020-04-12T18:21:50Z"),
                    new CDRDimension[] {
                    new CDRDimension(
                        CDRDimensions.TIME,
                        5.12M
                        )
                },
                    Tariff_Id.Parse("DE*GEF*T0002")
                    )
            },

                // Total Costs
                new Price(
                    1.12,
                    2.24
                    ),

                DateTime.Parse("2020-09-21T00:00:00.000Z")
                );

            #endregion

            var JSON = Session1.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("Session0001", JSON["id"].Value <String>());
            Assert.AreEqual("2020-08-21T00:00:00.000Z", JSON["start_date_time"].Value <String>());
            Assert.AreEqual("2020-08-22T00:00:00.000Z", JSON["end_date_time"].Value <String>());
            Assert.AreEqual(1.11, JSON["kwh"].Value <Decimal>());
            Assert.AreEqual("1234", JSON["cdr_token"]["uid"].Value <String>());
            Assert.AreEqual("RFID", JSON["cdr_token"]["type"].Value <String>());
            Assert.AreEqual("Contract0815", JSON["cdr_token"]["contract_id"].Value <String>());
            Assert.AreEqual("AUTH_REQUEST", JSON["auth_method"].Value <String>());
            Assert.AreEqual("Auth1234", JSON["authorization_reference"].Value <String>());
            Assert.AreEqual("LOC0001", JSON["location_id"].Value <String>());
            Assert.AreEqual("EVSE0001", JSON["evse_uid"].Value <String>());
            Assert.AreEqual("C1", JSON["connector_id"].Value <String>());
            Assert.AreEqual("Meter0001", JSON["meter_id"].Value <String>());
            Assert.AreEqual("EUR", JSON["currency"].Value <String>());
            //Assert.AreEqual("Stadtwerke Jena-Ost",             JSON["charging_periods"]["xxx"].Value<String>());
            Assert.AreEqual(1.12, JSON["total_cost"]["excl_vat"].Value <Decimal>());
            Assert.AreEqual(2.24, JSON["total_cost"]["incl_vat"].Value <Decimal>());
            Assert.AreEqual("ACTIVE", JSON["status"].Value <String>());
            Assert.AreEqual("2020-09-21T00:00:00.000Z", JSON["last_updated"].Value <String>());

            Assert.IsTrue(Session.TryParse(JSON, out Session Session2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(Session1.CountryCode, Session2.CountryCode);
            Assert.AreEqual(Session1.PartyId, Session2.PartyId);
            Assert.AreEqual(Session1.Id, Session2.Id);
            Assert.AreEqual(Session1.Start.ToIso8601(), Session2.Start.ToIso8601());
            Assert.AreEqual(Session1.End.Value.ToIso8601(), Session2.End.Value.ToIso8601());
            Assert.AreEqual(Session1.kWh, Session2.kWh);
            Assert.AreEqual(Session1.CDRToken, Session2.CDRToken);
            Assert.AreEqual(Session1.AuthMethod, Session2.AuthMethod);
            Assert.AreEqual(Session1.AuthorizationReference, Session2.AuthorizationReference);
            Assert.AreEqual(Session1.LocationId, Session2.LocationId);
            Assert.AreEqual(Session1.EVSEUId, Session2.EVSEUId);
            Assert.AreEqual(Session1.ConnectorId, Session2.ConnectorId);
            Assert.AreEqual(Session1.MeterId, Session2.MeterId);
            Assert.AreEqual(Session1.EnergyMeter, Session2.EnergyMeter);
            Assert.AreEqual(Session1.TransparencySoftwares, Session2.TransparencySoftwares);
            Assert.AreEqual(Session1.Currency, Session2.Currency);
            Assert.AreEqual(Session1.ChargingPeriods, Session2.ChargingPeriods);
            Assert.AreEqual(Session1.TotalCosts, Session2.TotalCosts);
            Assert.AreEqual(Session1.Status, Session2.Status);
            Assert.AreEqual(Session1.LastUpdated.ToIso8601(), Session2.LastUpdated.ToIso8601());
        }
Exemple #30
0
        /// <summary>
        /// The Session object describes the Session and its properties
        /// where a group of EVSEs that belong together are installed.
        /// </summary>
        /// <param name="Id">Uniquely identifies the Session within the CPOs platform (and suboperator platforms).</param>
        /// <param name="Start">The time when the session became active.</param>
        /// <param name="End">The time when the session is completed.</param>
        /// <param name="kWh">How many kWh are charged.</param>
        /// <param name="AuthId">An id provided by the authentication used so that the eMSP knows to which driver the session belongs.</param>
        /// <param name="AuthMethod">Method used for authentication.</param>
        /// <param name="Location">The location where this session took place.</param>
        /// <param name="EVSE">The EVSE that was used for this session.</param>
        /// <param name="ConnectorId">Connector ID of the connector used at the EVSE.</param>
        /// <param name="MeterId">Optional identification of the kWh meter.</param>
        /// <param name="Currency">ISO 4217 code of the currency used for this session.</param>
        /// <param name="ChargingPeriods">An optional enumeration of charging periods that can be used to calculate and verify the total cost.</param>
        /// <param name="TotalCosts">The total cost (excluding VAT) of the session in the specified currency. This is the price that the eMSP will have to pay to the CPO.</param>
        /// <param name="Status">The status of the session.</param>
        public Session(Session_Id Id,
                       DateTime Start,
                       DateTime?End,
                       Decimal kWh,
                       Auth_Id AuthId,
                       AuthMethodType AuthMethod,
                       Location Location,
                       EVSE EVSE,
                       Connector_Id ConnectorId,
                       Meter_Id MeterId,
                       Currency Currency,
                       IEnumerable <ChargingPeriod> ChargingPeriods,
                       Decimal TotalCosts,
                       SessionStatusType Status)

            : base(Id)

        {
            #region Initial checks

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

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

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

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

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

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

            #endregion

            #region Init data and properties

            this._Start           = Start;
            this._End             = End;
            this._kWh             = kWh;
            this._AuthId          = AuthId;
            this._AuthMethod      = AuthMethod;
            this._Location        = Location;
            this._EVSE            = EVSE;
            this._ConnectorId     = ConnectorId;
            this._MeterId         = MeterId;
            this._Currency        = Currency;
            this._ChargingPeriods = ChargingPeriods;
            this._TotalCosts      = TotalCosts;
            this._Status          = Status;

            #endregion
        }