コード例 #1
0
        /// <summary>
        /// A connector is the socket or cable available for the electric vehicle to make use of.
        /// </summary>
        /// <param name="ParentEVSE">The parent EVSE of this connector.</param>
        ///
        /// <param name="Id">Identifier of the connector within the EVSE.</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="MaxVoltage">Voltage of the connector (line to neutral for AC_3_PHASE), in volt [V].</param>
        /// <param name="MaxAmperage">Maximum amperage of the connector, in ampere [A].</param>
        ///
        /// <param name="MaxElectricPower">Maximum electric power that can be delivered by this connector, in Watts (W).</param>
        /// <param name="TariffIds">Identifiers of the currently valid charging tariffs.</param>
        /// <param name="TermsAndConditionsURL">Optional URL to the operator's terms and conditions.</param>
        ///
        /// <param name="LastUpdated">Timestamp when this connector was last updated (or created).</param>
        internal Connector(EVSE ParentEVSE,

                           Connector_Id Id,
                           ConnectorTypes Standard,
                           ConnectorFormats Format,
                           PowerTypes PowerType,
                           UInt16 MaxVoltage,
                           UInt16 MaxAmperage,

                           UInt32?MaxElectricPower           = null,
                           IEnumerable <Tariff_Id> TariffIds = null,
                           URL?TermsAndConditionsURL         = null,

                           DateTime?LastUpdated = null)

        {
            this.ParentEVSE = ParentEVSE;

            this.Id          = Id;
            this.Standard    = Standard;
            this.Format      = Format;
            this.PowerType   = PowerType;
            this.MaxVoltage  = MaxVoltage;
            this.MaxAmperage = MaxAmperage;

            this.MaxElectricPower      = MaxElectricPower;
            this.TariffIds             = TariffIds?.Distinct() ?? new Tariff_Id[0];
            this.TermsAndConditionsURL = TermsAndConditionsURL;

            this.LastUpdated = LastUpdated ?? DateTime.Now;

            CalcSHA256Hash();
        }
コード例 #2
0
        public static XDocument ToXML(this EVSE EVSE)
        {
            var _XDocument = new XDocument();



            return(_XDocument);
        }
コード例 #3
0
        public EVSEToEMIPException(EVSE EVSE,
                                   Exception InnerException)

            : base("Could not convert EVSE to an EVSERecord!",
                   InnerException)

        {
            this.EVSE = EVSE;
        }
コード例 #4
0
        public EVSEToOICPException(EVSE EVSE,
                                   Exception InnerException)

            : base("Could not convert EVSE '" + EVSE.Id + "' to an OICP " + Version.Number + " EVSEDataRecord!",
                   InnerException)

        {
            this.EVSE = EVSE;
        }
コード例 #5
0
        /// <summary>
        /// Create a new EVSE admin status update.
        /// </summary>
        /// <param name="EVSE">The updated EVSE.</param>
        /// <param name="OldStatus">The old timestamped admin status of the EVSE.</param>
        /// <param name="NewStatus">The new timestamped admin status of the EVSE.</param>
        public EVSEAdminStatusUpdate(EVSE EVSE,
                                     EVSEAdminStatus OldStatus,
                                     EVSEAdminStatus NewStatus)

        {
            this.EVSE      = EVSE;
            this.OldStatus = OldStatus.Status;
            this.NewStatus = NewStatus.Status;
        }
コード例 #6
0
        /// <summary>
        /// Create a new EVSE admin status update.
        /// </summary>
        /// <param name="EVSE">The updated EVSE.</param>
        /// <param name="OldStatus">The old timestamped admin status of the EVSE.</param>
        /// <param name="NewStatus">The new timestamped admin status of the EVSE.</param>
        public EVSEAdminStatusUpdate(EVSE EVSE,
                                     Timestamped <EVSEAdminStatusTypes> OldStatus,
                                     Timestamped <EVSEAdminStatusTypes> NewStatus)

        {
            this.EVSE      = EVSE;
            this.OldStatus = OldStatus;
            this.NewStatus = NewStatus;
        }
コード例 #7
0
 /// <summary>
 /// Return the HashCode of this object.
 /// </summary>
 /// <returns>The HashCode of this object.</returns>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         return(EVSE.GetHashCode() * 5 ^
                OldStatus.GetHashCode() * 3 ^
                NewStatus.GetHashCode());
     }
 }
コード例 #8
0
        /// <summary>
        /// Create a charge detail record for the given charging session (identification).
        /// </summary>
        /// <param name="SessionId">The unique charging session identification.</param>
        /// <param name="ChargingReservation">An optional charging reservation used for charging.</param>
        ///
        /// <param name="EVSE">The EVSE of the EVSE used for charging.</param>
        /// <param name="ChargingStation">The charging station of the charging station used for charging.</param>
        /// <param name="ChargingPool">The charging pool of the charging pool used for charging.</param>
        /// <param name="EVSEOperator">The EVSE operator used for charging.</param>
        /// <param name="ChargingProductId">An unqiue identification for the consumed charging product.</param>
        ///
        /// <param name="ReservationTime">Optional timestamps when the reservation started and ended.</param>
        /// <param name="ParkingTime">Optional timestamps when the parking started and ended.</param>
        /// <param name="SessionTime">Optional timestamps when the charging session started and ended.</param>
        ///
        /// <param name="EnergyMeterId">An optional unique identification of the energy meter.</param>
        /// <param name="EnergyMeteringValues">An optional enumeration of intermediate energy metering values.</param>
        /// <param name="MeteringSignature">An optional signature for the metering values.</param>
        ///
        /// <param name="IdentificationStart">The identification for the start of the charging process.</param>
        /// <param name="IdentificationStop">The identification for the stop of the charging process.</param>
        public ChargeDetailRecord(ChargingSession_Id SessionId,
                                  ChargingReservation Reservation      = null,
                                  ChargingReservation_Id ReservationId = null,

                                  EVSEOperator EVSEOperator       = null,
                                  ChargingPool ChargingPool       = null,
                                  ChargingStation ChargingStation = null,
                                  EVSE EVSE      = null,
                                  EVSE_Id EVSEId = null,
                                  ChargingProduct_Id ChargingProductId = null,

                                  EVSP_Id ProviderId = null,

                                  StartEndDateTime?ReservationTime = null,
                                  StartEndDateTime?ParkingTime     = null,
                                  StartEndDateTime?SessionTime     = null,

                                  EnergyMeter_Id EnergyMeterId = null,
                                  IEnumerable <Timestamped <Double> > EnergyMeteringValues = null,
                                  String MeteringSignature = null,

                                  AuthInfo IdentificationStart = null,
                                  AuthInfo IdentificationStop  = null)

        {
            #region Initial checks

            if (SessionId == null)
            {
                throw new ArgumentNullException("Id", "The charging session identification must not be null!");
            }

            #endregion

            this._SessionId = SessionId;

            this._Reservation     = Reservation;
            this._ReservationId   = ReservationId != null ? ReservationId : Reservation != null ? Reservation.Id : null;
            this._ReservationTime = ReservationTime;

            this._EVSE              = EVSE;
            this._EVSEId            = EVSE != null ? EVSE.Id : EVSEId;
            this._ChargingStation   = ChargingStation;
            this._ChargingPool      = ChargingPool;
            this._EVSEOperator      = EVSEOperator;
            this._ChargingProductId = ChargingProductId;

            this._ParkingTime = ParkingTime;
            this._SessionTime = SessionTime;

            this._EnergyMeterId        = EnergyMeterId;
            this._EnergyMeteringValues = EnergyMeteringValues != null ? EnergyMeteringValues : new Timestamped <Double> [0];

            this._IdentificationStart = IdentificationStart;
            this._IdentificationStop  = IdentificationStop;
        }
コード例 #9
0
        public EVSE GetEVSEFromCP(ChargePoint cp)
        {
            EVSE e = new EVSE();

            e.Title     = cp.AddressInfo.Title;
            e.Latitude  = cp.AddressInfo.Latitude;
            e.Longitude = cp.AddressInfo.Longitude;

            return(e);
        }
コード例 #10
0
ファイル: EVSEGroup.cs プロジェクト: rsegovia/WWCP_Core
        public EVSEGroup Add(EVSE EVSE)
        {
            if (_AllowedMemberIds.Contains(EVSE.Id) &&
                AutoIncludeEVSEs(EVSE))
            {
                _EVSEs.TryAdd(EVSE.Id, EVSE);
            }

            return(this);
        }
コード例 #11
0
 public string OutputExtendedAttribute(EVSE evse, string attributeName)
 {
     if (evse.ExtendedAttributes != null)
     {
         if (evse.ExtendedAttributes.Exists(a => a.Name == attributeName))
         {
             return(evse.ExtendedAttributes.First(a => a.Name == attributeName).Value.ToString());
         }
     }
     return("");
 }
コード例 #12
0
        /// <summary>
        /// Compares two EVSE status updates for equality.
        /// </summary>
        /// <param name="EVSEAdminStatusUpdate">An EVSE status update to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(EVSEAdminStatusUpdate EVSEAdminStatusUpdate)
        {
            if ((Object)EVSEAdminStatusUpdate == null)
            {
                return(false);
            }

            return(EVSE.Equals(EVSEAdminStatusUpdate.EVSE) &&
                   OldStatus.Equals(EVSEAdminStatusUpdate.OldStatus) &&
                   NewStatus.Equals(EVSEAdminStatusUpdate.NewStatus));
        }
コード例 #13
0
ファイル: PushDataResult.cs プロジェクト: rsegovia/WWCP_Core
 public PushSingleEVSEDataResult(EVSE EVSE,
                                 PushSingleDataResultTypes Result,
                                 IEnumerable <String> Warnings)
 {
     this.EVSE     = EVSE;
     this.Result   = Result;
     this.Warnings = Warnings != null
                          ? Warnings.Where(warning => warning != null).
                     SafeSelect(warning => warning.Trim()).
                     Where(warning => warning.IsNotNullOrEmpty())
                          : new String[0];
 }
コード例 #14
0
        /// <summary>
        /// Update an EVSE admin status.
        /// </summary>
        /// <param name="Timestamp">The timestamp when this change was detected.</param>
        /// <param name="EVSE">The updated EVSE.</param>
        /// <param name="OldStatus">The old EVSE status.</param>
        /// <param name="NewStatus">The new EVSE status.</param>
        internal void UpdateEVSEAdminStatus(DateTime Timestamp,
                                            EVSE EVSE,
                                            Timestamped <EVSEAdminStatusType> OldStatus,
                                            Timestamped <EVSEAdminStatusType> NewStatus)
        {
            var OnEVSEAdminStatusChangedLocal = OnEVSEAdminStatusChanged;

            if (OnEVSEAdminStatusChangedLocal != null)
            {
                OnEVSEAdminStatusChangedLocal(Timestamp, EVSE, OldStatus, NewStatus);
            }
        }
コード例 #15
0
        /// <summary>
        /// Update the data of an EVSE.
        /// </summary>
        /// <param name="Timestamp">The timestamp when this change was detected.</param>
        /// <param name="EVSE">The changed EVSE.</param>
        /// <param name="PropertyName">The name of the changed property.</param>
        /// <param name="OldValue">The old value of the changed property.</param>
        /// <param name="NewValue">The new value of the changed property.</param>
        internal void UpdateEVSEData(DateTime Timestamp,
                                     EVSE EVSE,
                                     String PropertyName,
                                     Object OldValue,
                                     Object NewValue)
        {
            var OnEVSEDataChangedLocal = OnEVSEDataChanged;

            if (OnEVSEDataChangedLocal != null)
            {
                OnEVSEDataChangedLocal(Timestamp, EVSE, PropertyName, OldValue, NewValue);
            }
        }
コード例 #16
0
        public void PopulateExtendedAttribute(EVSE evse, JToken item, string outputName, string inputName)
        {
            if (evse.ExtendedAttributes == null)
            {
                evse.ExtendedAttributes = new List <ExtendedAttribute>();
            }

            if (item[inputName] != null)
            {
                evse.ExtendedAttributes.Add(new ExtendedAttribute {
                    Name = outputName, Value = item[inputName].ToString()
                });
            }
        }
コード例 #17
0
        /// <summary>
        /// Take a snapshot of the current EVSE status.
        /// </summary>
        /// <param name="EVSE">An EVSE.</param>
        public static EVSEAdminStatusUpdate Snapshot(EVSE EVSE)

        {
            #region Initial checks

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

            #endregion

            return(new EVSEAdminStatusUpdate(EVSE,
                                             EVSE.AdminStatus,
                                             EVSE.AdminStatusSchedule().Skip(1).FirstOrDefault()));
        }
コード例 #18
0
        /// <summary>
        /// Update an EVSE status.
        /// </summary>
        /// <param name="Timestamp">The timestamp when this change was detected.</param>
        /// <param name="EventTrackingId">An event tracking identification for correlating this request with other events.</param>
        /// <param name="EVSE">The updated EVSE.</param>
        /// <param name="OldStatus">The old EVSE status.</param>
        /// <param name="NewStatus">The new EVSE status.</param>
        internal async Task UpdateEVSEStatus(DateTime Timestamp,
                                             EventTracking_Id EventTrackingId,
                                             EVSE EVSE,
                                             Timestamped <EVSEStatusTypes> OldStatus,
                                             Timestamped <EVSEStatusTypes> NewStatus)
        {
            var OnEVSEStatusChangedLocal = OnEVSEStatusChanged;

            if (OnEVSEStatusChangedLocal != null)
            {
                await OnEVSEStatusChangedLocal(Timestamp,
                                               EventTrackingId,
                                               EVSE,
                                               OldStatus,
                                               NewStatus);
            }
        }
コード例 #19
0
ファイル: GeoJSON_IO.cs プロジェクト: rsegovia/WWCP_Core
        public static JObject ToFeatureCollection(this IEnumerable <EVSE> EVSEs,
                                                  JObject Properties = null)

        {
            #region Initial checks

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

            #endregion

            return(EVSEs.
                   Select(EVSE => EVSE.ToFeature()).
                   ToFeatureCollection(Properties));
        }
コード例 #20
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="EVSEAdminStatusUpdate">An object to compare with.</param>
        public Int32 CompareTo(EVSEAdminStatusUpdate EVSEAdminStatusUpdate)
        {
            if ((Object)EVSEAdminStatusUpdate == null)
            {
                throw new ArgumentNullException(nameof(EVSEAdminStatusUpdate), "The given EVSE status update must not be null!");
            }

            // Compare EVSE Ids
            var _Result = EVSE.CompareTo(EVSEAdminStatusUpdate.EVSE);

            // If equal: Compare the new EVSE status
            if (_Result == 0)
            {
                _Result = NewStatus.CompareTo(EVSEAdminStatusUpdate.NewStatus);
            }

            // If equal: Compare the old EVSE status
            if (_Result == 0)
            {
                _Result = OldStatus.CompareTo(EVSEAdminStatusUpdate.OldStatus);
            }

            return(_Result);
        }
コード例 #21
0
ファイル: EVSEs.cs プロジェクト: rsegovia/WWCP_Core
        /// <summary>
        /// Return a JSON representation of the given EVSE.
        /// </summary>
        /// <param name="EVSE">An EVSE.</param>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a charging station.</param>
        public static JObject ToJSON(this EVSE EVSE,
                                     Boolean Embedded = false,
                                     InfoStatus ExpandRoamingNetworkId          = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingStationOperatorId = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingPoolId            = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandChargingStationId         = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandBrandIds     = InfoStatus.ShowIdOnly,
                                     InfoStatus ExpandDataLicenses = InfoStatus.ShowIdOnly)

        => EVSE == null
                   ? null

                   : JSONObject.Create(

            EVSE.Id.ToJSON("@id"),

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

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

            EVSE.Brand != null
                             ? ExpandBrandIds.Switch(
                () => new JProperty("brandId", EVSE.Brand.Id.ToString()),
                () => new JProperty("brand", EVSE.Brand.ToJSON()))
                             : null,

            (!Embedded || EVSE.DataSource != EVSE.ChargingStation.DataSource)
                             ? EVSE.DataSource.ToJSON("dataSource")
                             : null,

            (!Embedded || EVSE.DataLicenses != EVSE.ChargingStation.DataLicenses)
                             ? ExpandDataLicenses.Switch(
                () => new JProperty("dataLicenseIds", new JArray(EVSE.DataLicenses.SafeSelect(license => license.Id.ToString()))),
                () => new JProperty("dataLicenses", EVSE.DataLicenses.ToJSON()))
                             : null,

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

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

            Embedded
                             ? null
                             : ExpandChargingStationOperatorId.Switch(
                () => new JProperty("chargingStationOperatorId", EVSE.Operator.Id.ToString()),
                () => new JProperty("chargingStationOperator", EVSE.Operator.ToJSON(Embedded:                          true,
                                                                                    ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                    ExpandChargingPoolIds:             InfoStatus.Hidden,
                                                                                    ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                    ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                    ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                    ExpandDataLicenses:                InfoStatus.Hidden))),

            Embedded
                             ? null
                             : ExpandChargingPoolId.Switch(
                () => new JProperty("chargingPoolId", EVSE.ChargingPool.Id.ToString()),
                () => new JProperty("chargingPool", EVSE.ChargingPool.ToJSON(Embedded:                          true,
                                                                             ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                             ExpandChargingStationOperatorId:   InfoStatus.Hidden,
                                                                             ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                             ExpandBrandIds:                    InfoStatus.Hidden,
                                                                             ExpandDataLicenses:                InfoStatus.Hidden))),

            Embedded
                             ? null
                             : ExpandChargingStationId.Switch(
                () => new JProperty("chargingStationId", EVSE.ChargingStation.Id.ToString()),
                () => new JProperty("chargingStation", EVSE.ChargingStation.ToJSON(Embedded:                          true,
                                                                                   ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                   ExpandChargingStationOperatorId:   InfoStatus.Hidden,
                                                                                   ExpandChargingPoolId:              InfoStatus.Hidden,
                                                                                   ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                   ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                   ExpandDataLicenses:                InfoStatus.Hidden))),

            #endregion

            !Embedded ? EVSE.ChargingStation.GeoLocation.Value.ToJSON("geoLocation")         : null,
            !Embedded ? EVSE.ChargingStation.Address.ToJSON("address")             : null,
            !Embedded ? EVSE.ChargingStation.AuthenticationModes.ToJSON("authenticationModes") : null,

            EVSE.ChargingModes.HasValue && EVSE.ChargingModes.Value != ChargingModes.Unspecified
                             ? new JProperty("chargingModes", new JArray(EVSE.ChargingModes.Value.ToText()))
                             : null,

            EVSE.CurrentTypes.HasValue && EVSE.CurrentTypes.Value != CurrentTypes.Unspecified
                             ? new JProperty("currentTypes", new JArray(EVSE.CurrentTypes.Value.ToText()))
                             : null,

            EVSE.AverageVoltage.HasValue && EVSE.AverageVoltage > 0     ? new JProperty("averageVoltage", String.Format("{0:0.00}", EVSE.AverageVoltage)) : null,
            EVSE.MaxCurrent.HasValue && EVSE.MaxCurrent > 0     ? new JProperty("maxCurrent", String.Format("{0:0.00}", EVSE.MaxCurrent))     : null,
            EVSE.MaxPower.HasValue && EVSE.MaxPower.HasValue ? new JProperty("maxPower", String.Format("{0:0.00}", EVSE.MaxPower))       : null,
            EVSE.MaxCapacity.HasValue && EVSE.MaxCapacity.HasValue ? new JProperty("maxCapacity", String.Format("{0:0.00}", EVSE.MaxCapacity))    : null,

            EVSE.SocketOutlets.Count > 0
                            ? new JProperty("socketOutlets", new JArray(EVSE.SocketOutlets.ToJSON()))
                            : null,

            EVSE.EnergyMeterId.HasValue ? new JProperty("energyMeterId", EVSE.EnergyMeterId) : null,

            !Embedded ? EVSE.ChargingStation.OpeningTimes.ToJSON("openingTimes") : null

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

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

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

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

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

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

                                  IReadOnlyDictionary <String, Object> CustomData = null)

            : base(CustomData)

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

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

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

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

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

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

            if (SignedMeteringValues.SafeAny() && !EnergyMeteringValues.SafeAny())
            {
                this.EnergyMeteringValues = SignedMeteringValues.Select(svalue => new Timestamped <Single>(svalue.Timestamp,
                                                                                                           (Single)svalue.MeterValue));
            }
        }
コード例 #23
0
 /// <summary>
 /// Check if the given EVSE is member of this charging station group.
 /// </summary>
 /// <param name="EVSE">An EVSE.</param>
 public Boolean ContainsEVSE(EVSE EVSE)
 => ChargingStations.Any(ChargingStation => ChargingStation.EVSEIds.Contains(EVSE.Id));
コード例 #24
0
ファイル: EVSEGroup.cs プロジェクト: rsegovia/WWCP_Core
 /// <summary>
 /// Check if the given EVSE is member of this EVSE group.
 /// </summary>
 /// <param name="EVSE">An EVSE.</param>
 public Boolean ContainsEVSE(EVSE EVSE)
 => _EVSEs.ContainsKey(EVSE.Id);
コード例 #25
0
ファイル: GeoJSON_IO.cs プロジェクト: rsegovia/WWCP_Core
        public static JObject ToFeature(this EVSE EVSE,
                                        InfoStatus ExpandRoamingNetworkId  = InfoStatus.ShowIdOnly,
                                        InfoStatus ExpandOperatorId        = InfoStatus.ShowIdOnly,
                                        InfoStatus ExpandChargingPoolId    = InfoStatus.ShowIdOnly,
                                        InfoStatus ExpandChargingStationId = InfoStatus.ShowIdOnly,
                                        InfoStatus ExpandBrandIds          = InfoStatus.ShowIdOnly,
                                        InfoStatus ExpandDataLicenses      = InfoStatus.ShowIdOnly,
                                        JObject Properties = null)

        {
            #region Initial checks

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

            #endregion

            #region Documentation

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

            #endregion

            return(JSONObject.Create(

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

                       new JProperty("properties", Properties ?? JSONObject.Create(

                                         new JProperty("@id", EVSE.Id.ToString()),
                                         new JProperty("@context", "https://open.charging.cloud/contexts/wwcp+geojson/EVSE"),

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

                                         EVSE.Brand != null
                               ? ExpandBrandIds.Switch(
                                             () => new JProperty("brandId", EVSE.Brand.Id.ToString()),
                                             () => new JProperty("brand", EVSE.Brand.ToJSON()))
                               : null,

                                         EVSE.DataSource.ToJSON("dataSource"),

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

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

                                         ExpandOperatorId.Switch(
                                             () => new JProperty("chargingStationOperatorId", EVSE.Operator.Id.ToString()),
                                             () => new JProperty("chargingStationOperator", EVSE.Operator.ToJSON(Embedded:                          true,
                                                                                                                 ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                                                 ExpandChargingPoolIds:             InfoStatus.Hidden,
                                                                                                                 ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                                                 ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                                                 ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                                                 ExpandDataLicenses:                InfoStatus.Hidden))),

                                         ExpandChargingPoolId.Switch(
                                             () => new JProperty("chargingPoolId", EVSE.ChargingPool.Id.ToString()),
                                             () => new JProperty("chargingPool", EVSE.ChargingPool.ToJSON(Embedded:                          true,
                                                                                                          ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                                          ExpandChargingStationOperatorId:   InfoStatus.Hidden,
                                                                                                          ExpandChargingStationIds:          InfoStatus.Hidden,
                                                                                                          ExpandEVSEIds:                     InfoStatus.Hidden,
                                                                                                          ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                                          ExpandDataLicenses:                InfoStatus.Hidden))),

                                         ExpandChargingStationId.Switch(
                                             () => new JProperty("chargingStationId", EVSE.ChargingStation.Id.ToString()),
                                             () => new JProperty("chargingStation", EVSE.ChargingStation.ToJSON(Embedded:                          true,
                                                                                                                ExpandRoamingNetworkId:            InfoStatus.Hidden,
                                                                                                                ExpandChargingStationOperatorId:   InfoStatus.Hidden,
                                                                                                                ExpandChargingPoolId:              InfoStatus.Hidden,
                                                                                                                ExpandBrandIds:                    InfoStatus.Hidden,
                                                                                                                ExpandDataLicenses:                InfoStatus.Hidden))),

                                         EVSE.ChargingStation.GeoLocation.Value.ToJSON("geoLocation"),
                                         EVSE.ChargingStation.Address.ToJSON("address"),
                                         EVSE.ChargingStation.AuthenticationModes.ToJSON("authenticationModes"),

                                         EVSE.ChargingModes != ChargingModes.Unspecified
                               ? new JProperty("chargingModes", new JArray(EVSE.ChargingModes.Value.ToText()))
                               : null,

                                         EVSE.CurrentTypes != CurrentTypes.Unspecified
                               ? new JProperty("currentTypes", new JArray(EVSE.CurrentTypes.Value.ToText()))
                               : null,

                                         EVSE.AverageVoltage.HasValue && EVSE.AverageVoltage > 0     ? new JProperty("averageVoltage", String.Format("{0:0.00}", EVSE.AverageVoltage)) : null,
                                         EVSE.MaxCurrent.HasValue && EVSE.MaxCurrent > 0     ? new JProperty("maxCurrent", String.Format("{0:0.00}", EVSE.MaxCurrent))     : null,
                                         EVSE.MaxPower.HasValue && EVSE.MaxPower.HasValue ? new JProperty("maxPower", String.Format("{0:0.00}", EVSE.MaxPower))       : null,
                                         EVSE.MaxCapacity.HasValue && EVSE.MaxCapacity.HasValue ? new JProperty("maxCapacity", String.Format("{0:0.00}", EVSE.MaxCapacity))    : null,

                                         EVSE.SocketOutlets.Count > 0
                              ? new JProperty("socketOutlets", new JArray(EVSE.SocketOutlets.ToJSON()))
                              : null,

                                         EVSE.EnergyMeterId.HasValue ? new JProperty("energyMeterId", EVSE.EnergyMeterId) : null,

                                         EVSE.ChargingStation.OpeningTimes.ToJSON("openingTimes")

                                         )),

                       new JProperty("geometry",
                                     JSONObject.Create(
                                         new JProperty("type", "Point"),
                                         new JProperty("coordinates", new JArray(
                                                           EVSE.ChargingStation.GeoLocation.Value.Longitude.Value,
                                                           EVSE.ChargingStation.GeoLocation.Value.Latitude.Value
                                                           ))
                                         ))
                       ));
        }
コード例 #26
0
 public Task <Acknowledgement> PushEVSEData(EVSE EVSE, ActionType ActionType = ActionType.insert, EVSEOperator_Id OperatorId = null, string OperatorName = null, TimeSpan?QueryTimeout = default(TimeSpan?))
 {
     throw new NotImplementedException();
 }
コード例 #27
0
 public Task <Acknowledgement> PushEVSEStatus(EVSE EVSE, ActionType ActionType = ActionType.update, EVSEOperator_Id OperatorId = null, string OperatorName = null, Func <EVSE, bool> IncludeEVSEs = null, TimeSpan?QueryTimeout = default(TimeSpan?))
 {
     return(Task.FromResult(new Acknowledgement(true)));
 }
コード例 #28
0
        public void PopulateExtendedAttribute(EVSE evse, JToken item, string outputName, string inputName)
        {
            if (evse.ExtendedAttributes == null) evse.ExtendedAttributes = new List<ExtendedAttribute>();

            if (item[inputName] != null)
            {
                evse.ExtendedAttributes.Add(new ExtendedAttribute { Name = outputName, Value = item[inputName].ToString() });
            }
        }
コード例 #29
0
 public string OutputExtendedAttribute(EVSE evse, string attributeName)
 {
     if (evse.ExtendedAttributes != null)
     {
         if (evse.ExtendedAttributes.Exists(a => a.Name == attributeName))
         {
             return evse.ExtendedAttributes.First(a => a.Name == attributeName).Value.ToString();
         }
     }
     return "";
 }
コード例 #30
0
        public EVSE GetEVSEFromCP(ChargePoint cp)
        {
            EVSE e = new EVSE();
            e.Title = cp.AddressInfo.Title;
            e.Latitude = cp.AddressInfo.Latitude;
            e.Longitude = cp.AddressInfo.Longitude;

            return e;
        }
コード例 #31
0
 /// <summary>
 /// Take a snapshot of the current EVSE status.
 /// </summary>
 /// <param name="EVSE">An EVSE.</param>
 public static EVSEStatus Snapshot(EVSE EVSE)
 {
     return(new EVSEStatus(EVSE.Id,
                           EVSE.Status.Value,
                           EVSE.Status.Timestamp));
 }
コード例 #32
0
        /// <summary>
        /// Take a snapshot of the current EVSE status.
        /// </summary>
        /// <param name="EVSE">An EVSE.</param>
        public static EVSEStatus Snapshot(EVSE EVSE)

        => new EVSEStatus(EVSE.Id,
                          EVSE.Status);
コード例 #33
0
        AddStaticData(ISendData Sender,
                      EVSE EVSE,

                      DateTime?Timestamp,
                      CancellationToken?CancellationToken,
                      EventTracking_Id EventTrackingId,
                      TimeSpan?RequestTimeout)

        {
            #region Initial checks

            if (EVSE == null)
            {
                return(PushEVSEDataResult.NoOperation(Id,
                                                      Sender));
            }

            if (DisablePushData)
            {
                return(PushEVSEDataResult.AdminDown(Id,
                                                    Sender,
                                                    new EVSE[] { EVSE }));
            }

            #endregion

            #region Send OnEnqueueSendCDRRequest event

            //try
            //{

            //    OnEnqueueSendCDRRequest?.Invoke(StartTime,
            //                                    Timestamp.Value,
            //                                    this,
            //                                    EventTrackingId,
            //                                    RoamingNetwork.Id,
            //                                    ChargeDetailRecord,
            //                                    RequestTimeout);

            //}
            //catch (Exception e)
            //{
            //    e.Log(nameof(WWCPCPOAdapter) + "." + nameof(OnSendCDRRequest));
            //}

            #endregion

            await DataAndStatusLock.WaitAsync();

            try
            {
                if (_IncludeEVSEs == null ||
                    (_IncludeEVSEs != null && _IncludeEVSEs(EVSE)))
                {
                    EVSEsToAddQueue.Add(EVSE);

                    FlushEVSEDataAndStatusTimer.Change(FlushEVSEDataAndStatusEvery, TimeSpan.FromMilliseconds(-1));
                }
            }
            finally
            {
                DataAndStatusLock.Release();
            }

            return(PushEVSEDataResult.Enqueued(Id, Sender));
        }