/// <summary>
        /// Create an OICP AuthorizeStop XML/SOAP request.
        /// </summary>
        /// <param name="OperatorId">The unqiue identification of the charging station operator.</param>
        /// <param name="SessionId">The charging session identification.</param>
        /// <param name="Identification">An user identification.</param>
        /// <param name="EVSEId">An optional EVSE identification.</param>
        /// <param name="CPOPartnerSessionId">An optional CPO partner session identification.</param>
        /// <param name="EMPPartnerSessionId">An optional EMP partner session identification.</param>
        ///
        /// <param name="Timestamp">The optional timestamp of the request.</param>
        /// <param name="CancellationToken">An optional token to cancel this request.</param>
        /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param>
        /// <param name="RequestTimeout">An optional timeout for this request.</param>
        public AuthorizeStopRequest(Operator_Id OperatorId,
                                    Session_Id SessionId,
                                    Identification Identification,
                                    EVSE_Id?EVSEId = null,
                                    CPOPartnerSession_Id?CPOPartnerSessionId = null,
                                    EMPPartnerSession_Id?EMPPartnerSessionId = null,

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

            : base(Timestamp,
                   CancellationToken,
                   EventTrackingId,
                   RequestTimeout)

        {
            this.OperatorId          = OperatorId;
            this.SessionId           = SessionId;
            this.Identification      = Identification;
            this.EVSEId              = EVSEId;
            this.CPOPartnerSessionId = CPOPartnerSessionId;
            this.EMPPartnerSessionId = EMPPartnerSessionId;
        }
示例#2
0
        /// <summary>
        /// login kész!
        /// </summary>

        private void button1_Click(object sender, EventArgs e)
        {
            User user = new User()
            {
                Username = textBox1.Text,
                Password = textBox2.Text
            };

            guid = client.Login(user);

            if (String.IsNullOrWhiteSpace(textBox1.Text) || String.IsNullOrWhiteSpace(textBox2.Text))
            {
                MessageBox.Show(guid.Message, "Sikertelen bejelentkezés", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (guid.Id == "")
                {
                    MessageBox.Show(guid.Message, "Sikertelen bejelentkezés", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    label16.Text = "Bejelentkezve: " + textBox1.Text;
                    textBox1.Hide();
                    textBox2.Hide();
                    label3.Hide();
                    label4.Hide();
                    button1.Hide();
                    button2.Show();
                    MessageBox.Show(guid.Message, "Üdv " + textBox1.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Form1_Load(sender, e);
                }
            }
        }
示例#3
0
 override public async Task GetGames(Session_Id request, IServerStreamWriter <Game> responseStream, ServerCallContext context)
 {
     try
     {
         if (sessions.Contains(request.Id))
         {
             if (gameDatabase.IsConnect())
             {
                 string query = "SELECT * FROM games ORDER BY id";
                 if (gameDatabase.Connection.State == System.Data.ConnectionState.Closed)
                 {
                     gameDatabase.OpenConnection();
                 }
                 var cmd    = new MySqlCommand(query, gameDatabase.Connection);
                 var reader = cmd.ExecuteReader();
                 while (reader.Read())
                 {
                     Game game = new Game {
                         Gid = reader.GetInt32(0), Name = reader.GetString(1), Price = reader.GetInt32(2)
                     };
                     await responseStream.WriteAsync(game);
                 }
                 gameDatabase.Close();
                 Console.WriteLine(DateTime.Now.ToString() + ": " + "Games list asked by " + request.Id);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
            SendChargingNotificationsError(this ICPOClient        CPOClient,
                                           Session_Id             SessionId,
                                           Identification         Identification,
                                           EVSE_Id                EVSEId,
                                           ErrorClassTypes        ErrorType,

                                           CPOPartnerSession_Id?  CPOPartnerSessionId   = null,
                                           EMPPartnerSession_Id?  EMPPartnerSessionId   = null,
                                           String                 ErrorAdditionalInfo   = null,
                                           JObject                CustomData            = null,

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


                => CPOClient.SendChargingErrorNotification(
                       new ChargingErrorNotificationRequest(
                           SessionId,
                           Identification,
                           EVSEId,
                           ErrorType,

                           CPOPartnerSessionId,
                           EMPPartnerSessionId,
                           ErrorAdditionalInfo,
                           CustomData,

                           Timestamp,
                           CancellationToken,
                           EventTrackingId,
                           RequestTimeout ?? CPOClient.RequestTimeout));
        AuthorizeStop(this ICPOClient ICPOClient,
                      Operator_Id OperatorId,
                      Session_Id SessionId,
                      UID UID,
                      EVSE_Id?EVSEId = null,
                      CPOPartnerSession_Id?CPOPartnerSessionId = null,
                      EMPPartnerSession_Id?EMPPartnerSessionId = null,

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


        => ICPOClient.AuthorizeStop(new AuthorizeStopRequest(OperatorId,
                                                             SessionId,
                                                             Identification.FromUID(UID),
                                                             EVSEId,
                                                             CPOPartnerSessionId,
                                                             EMPPartnerSessionId,

                                                             Timestamp,
                                                             CancellationToken,
                                                             EventTrackingId,
                                                             RequestTimeout ?? ICPOClient.RequestTimeout));
            AuthorizeStop(this ICPOClient        CPOClient,
                          Operator_Id            OperatorId,
                          Session_Id             SessionId,
                          Identification         Identification,
                          EVSE_Id?               EVSEId                = null,
                          CPOPartnerSession_Id?  CPOPartnerSessionId   = null,
                          EMPPartnerSession_Id?  EMPPartnerSessionId   = null,
                          JObject                CustomData            = null,

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

            => CPOClient.AuthorizeStop(
                   new AuthorizeStopRequest(
                       OperatorId,
                       SessionId,
                       Identification,
                       EVSEId,
                       CPOPartnerSessionId,
                       EMPPartnerSessionId,
                       CustomData,

                       Timestamp,
                       CancellationToken,
                       EventTrackingId,
                       RequestTimeout ?? CPOClient.RequestTimeout));
示例#7
0
        AuthorizeRemoteStop(this IEMPClient EMPClient,
                            Provider_Id ProviderId,
                            EVSE_Id EVSEId,
                            Session_Id SessionId,
                            CPOPartnerSession_Id?CPOPartnerSessionId = null,
                            EMPPartnerSession_Id?EMPPartnerSessionId = null,
                            JObject CustomData = null,

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

        => EMPClient.AuthorizeRemoteStop(
            new AuthorizeRemoteStopRequest(
                ProviderId,
                EVSEId,
                SessionId,
                CPOPartnerSessionId,
                EMPPartnerSessionId,
                CustomData,

                Timestamp,
                CancellationToken,
                EventTrackingId,
                RequestTimeout ?? EMPClient.RequestTimeout));
示例#8
0
文件: Form1.cs 项目: Fdavid1017/GRPC
        private void LoginButton_Click(object sender, EventArgs e)
        {
            if (!InvalidInputs())
            {
                MessageBox.Show("Invalid inputs");
                return;
            }

            User user = new User {
                Name = userNameTextBox.Text, Passwd = userPasswordTextBox.Text
            };
            Session_Id guid = new Session_Id();

            this.guid = client.Login(user);

            if (this.guid.Id == "NOT_FOUND")
            {
                MessageBox.Show("No user found with this name and password pair!");
                return;
            }

            MessageBox.Show("Logged in\nSessiond id:\n" + this.guid.Id);
            loggedInLabel.Text       = "Logged in";
            loggedInLabel.ForeColor  = Color.Green;
            registerGroupBox.Visible = false;
        }
示例#9
0
        public static void Session_DeserializeGitHub_Test01()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":    ""NL"",
                           ""party_id"":        ""STK"",
                           ""id"":              ""101"",
                           ""start_date_time"": ""2020-03-09T10:17:09Z"",
                           ""kwh"":               0.0,
                           ""cdr_token"": {
                               ""uid"":         ""123abc"",
                               ""type"":        ""RFID"",
                               ""contract_id"": ""NL-TST-C12345678-S""
                           },
                           ""auth_method"":     ""WHITELIST"",
                           ""location_id"":     ""LOC1"",
                           ""evse_uid"":        ""3256"",
                           ""connector_id"":    ""1"",
                           ""currency"":        ""EUR"",
                           ""total_cost"": {
                               ""excl_vat"":      2.5
                           },
                           ""status"":          ""PENDING"",
                           ""last_updated"":    ""2020-03-09T10:17:09Z""
                         }";

            #endregion

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

            Assert.AreEqual(CountryCode.Parse("NL"), parsedSession.CountryCode);
            Assert.AreEqual(Party_Id.Parse("STK"), parsedSession.PartyId);
            Assert.AreEqual(Session_Id.Parse("101"), parsedSession.Id);
            //Assert.AreEqual(Session1.Start.    ToIso8601(),    parsedSession.Start.    ToIso8601());
            //Assert.AreEqual(Session1.End.Value.ToIso8601(),    parsedSession.End.Value.ToIso8601());
            //Assert.AreEqual(Session1.kWh,                      parsedSession.kWh);
            //Assert.AreEqual(Session1.CDRToken,                 parsedSession.CDRToken);
            //Assert.AreEqual(Session1.AuthMethod,               parsedSession.AuthMethod);
            //Assert.AreEqual(Session1.AuthorizationReference,   parsedSession.AuthorizationReference);
            //Assert.AreEqual(Session1.LocationId,               parsedSession.LocationId);
            //Assert.AreEqual(Session1.EVSEUId,                  parsedSession.EVSEUId);
            //Assert.AreEqual(Session1.ConnectorId,              parsedSession.ConnectorId);
            //Assert.AreEqual(Session1.MeterId,                  parsedSession.MeterId);
            //Assert.AreEqual(Session1.EnergyMeter,              parsedSession.EnergyMeter);
            //Assert.AreEqual(Session1.TransparencySoftwares,    parsedSession.TransparencySoftwares);
            //Assert.AreEqual(Session1.Currency,                 parsedSession.Currency);
            //Assert.AreEqual(Session1.ChargingPeriods,          parsedSession.ChargingPeriods);
            //Assert.AreEqual(Session1.TotalCosts,               parsedSession.TotalCosts);
            //Assert.AreEqual(Session1.Status,                   parsedSession.Status);
            //Assert.AreEqual(Session1.LastUpdated.ToIso8601(),  parsedSession.LastUpdated.ToIso8601());
        }
示例#10
0
文件: Form1.cs 项目: Fdavid1017/GRPC
        private void LogoutButton_Click(object sender, EventArgs e)
        {
            Result res = new Result();

            res = client.Logout(this.guid);
            MessageBox.Show(res.Success);
            this.guid                = new Session_Id();
            loggedInLabel.Text       = "Not logged in";
            loggedInLabel.ForeColor  = Color.Red;
            registerGroupBox.Visible = true;
            userNameTextBox.Text     = "";
            userPasswordTextBox.Text = "";
        }
            SendChargingNotificationsEnd(this ICPOClient        CPOClient,
                                         Session_Id             SessionId,
                                         Identification         Identification,
                                         EVSE_Id                EVSEId,
                                         DateTime               ChargingStart,
                                         DateTime               ChargingEnd,

                                         CPOPartnerSession_Id?  CPOPartnerSessionId      = null,
                                         EMPPartnerSession_Id?  EMPPartnerSessionId      = null,
                                         DateTime?              SessionStart             = null,
                                         DateTime?              SessionEnd               = null,
                                         Decimal?               ConsumedEnergy           = null,
                                         Decimal?               MeterValueStart          = null,
                                         Decimal?               MeterValueEnd            = null,
                                         IEnumerable<Decimal>   MeterValuesInBetween     = null,
                                         Operator_Id?           OperatorId               = null,
                                         PartnerProduct_Id?     PartnerProductId         = null,
                                         DateTime?              PenaltyTimeStart         = null,
                                         JObject                CustomData               = null,

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


                => CPOClient.SendChargingEndNotification(
                       new ChargingEndNotificationRequest(
                           SessionId,
                           Identification,
                           EVSEId,
                           ChargingStart,
                           ChargingEnd,

                           CPOPartnerSessionId,
                           EMPPartnerSessionId,
                           SessionStart,
                           SessionEnd,
                           ConsumedEnergy,
                           MeterValueStart,
                           MeterValueEnd,
                           MeterValuesInBetween,
                           OperatorId,
                           PartnerProductId,
                           PenaltyTimeStart,
                           CustomData,

                           Timestamp,
                           CancellationToken,
                           EventTrackingId,
                           RequestTimeout ?? CPOClient.RequestTimeout));
        MobileRemoteStop(this IMobileClient IMobileClient,
                         Session_Id SessionId,

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


        => IMobileClient.MobileRemoteStop(new MobileRemoteStopRequest(SessionId,

                                                                      Timestamp,
                                                                      CancellationToken,
                                                                      EventTrackingId,
                                                                      RequestTimeout ?? IMobileClient.RequestTimeout));
        /// <summary>
        /// Create a new MobileRemoteStop request.
        /// </summary>
        /// <param name="SessionId">A charging session identification.</param>
        ///
        /// <param name="Timestamp">The optional timestamp of the request.</param>
        /// <param name="CancellationToken">An optional token to cancel this request.</param>
        /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param>
        /// <param name="RequestTimeout">An optional timeout for this request.</param>
        public MobileRemoteStopRequest(Session_Id SessionId,

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

            : base(Timestamp,
                   CancellationToken,
                   EventTrackingId,
                   RequestTimeout)

        {
            this.SessionId = SessionId;
        }
示例#14
0
        /// <summary>
        /// Logout kész!
        /// </summary>

        public override Task <Result> Logout(Session_Id request, ServerCallContext context)
        {
            Result result = new Result();
            string id     = request.Id;

            if (sessions.Contains(id))
            {
                result.Success = "Sikeres kijelentkezés!";
                sessions.Remove(id);
            }
            else
            {
                result.Success = "Nem volt bejelentkezve!";
            }
            return(Task.FromResult(new Result {
                Success = result.Success
            }));
        }
示例#15
0
            override public Task <Result> Logout(Session_Id request, ServerCallContext context)
            {
                Result result = new Result();
                string idje   = request.Id;

                if (sessions.Contains(idje))
                {
                    result.Success = "Succesfully logged out!";
                    sessions.Remove(idje);
                    Console.WriteLine(DateTime.Now.ToString() + ": " + idje + " logged out");
                }
                else
                {
                    result.Success = "You are not logged in!";
                }
                return(Task.FromResult(new Result {
                    Success = result.Success
                }));
            }
            SendChargingNotificationsStart(this ICPOClient        CPOClient,
                                           Session_Id             SessionId,
                                           Identification         Identification,
                                           EVSE_Id                EVSEId,
                                           DateTime               ChargingStart,

                                           CPOPartnerSession_Id?  CPOPartnerSessionId   = null,
                                           EMPPartnerSession_Id?  EMPPartnerSessionId   = null,
                                           DateTime?              SessionStart          = null,
                                           Decimal?               MeterValueStart       = null,
                                           Operator_Id?           OperatorId            = null,
                                           PartnerProduct_Id?     PartnerProductId      = null,
                                           JObject                CustomData            = null,

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


                => CPOClient.SendChargingStartNotification(
                       new ChargingStartNotificationRequest(
                           SessionId,
                           Identification,
                           EVSEId,
                           ChargingStart,

                           CPOPartnerSessionId,
                           EMPPartnerSessionId,
                           SessionStart,
                           MeterValueStart,
                           OperatorId,
                           PartnerProductId,
                           CustomData,

                           Timestamp,
                           CancellationToken,
                           EventTrackingId,
                           RequestTimeout ?? CPOClient.RequestTimeout));
示例#17
0
        ReservationStop(this IEMPClient IEMPClient,
                        Session_Id SessionId,
                        Provider_Id ProviderId,
                        EVSE_Id EVSEId,
                        CPOPartnerSession_Id?CPOPartnerSessionId = null,
                        EMPPartnerSession_Id?EMPPartnerSessionId = null,

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


        => IEMPClient.AuthorizeRemoteReservationStop(new AuthorizeRemoteReservationStopRequest(SessionId,
                                                                                               ProviderId,
                                                                                               EVSEId,
                                                                                               CPOPartnerSessionId,
                                                                                               EMPPartnerSessionId,

                                                                                               Timestamp,
                                                                                               CancellationToken,
                                                                                               EventTrackingId,
                                                                                               RequestTimeout ?? IEMPClient.RequestTimeout));
        /// <summary>
        /// Create an OICP AuthorizeRemoteStopRequest XML/SOAP request.
        /// </summary>
        /// <param name="SessionId">A charging session identification.</param>
        /// <param name="ProviderId">An e-mobility provider identification.</param>
        /// <param name="EVSEId">The EVSE identification.</param>
        /// <param name="CPOPartnerSessionId">An optional CPO partner session identification.</param>
        /// <param name="EMPPartnerSessionId">An optional EMP partner session identification.</param>
        ///
        /// <param name="Timestamp">The optional timestamp of the request.</param>
        /// <param name="CancellationToken">An optional token to cancel this request.</param>
        /// <param name="EventTrackingId">An optional event tracking identification for correlating this request with other events.</param>
        /// <param name="RequestTimeout">An optional timeout for this request.</param>
        public AuthorizeRemoteStopRequest(Session_Id SessionId,
                                          Provider_Id ProviderId,
                                          EVSE_Id EVSEId,
                                          CPOPartnerSession_Id?CPOPartnerSessionId = null,
                                          EMPPartnerSession_Id?EMPPartnerSessionId = null,

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

            : base(Timestamp,
                   CancellationToken,
                   EventTrackingId,
                   RequestTimeout)

        {
            this.SessionId           = SessionId;
            this.ProviderId          = ProviderId;
            this.EVSEId              = EVSEId;
            this.CPOPartnerSessionId = CPOPartnerSessionId;
            this.EMPPartnerSessionId = EMPPartnerSessionId;
        }
示例#19
0
        public static void CDR_SerializeDeserialize_Test01()
        {
            #region Defined CDR1

            var CDR1 = new CDR(CountryCode.Parse("DE"),
                               Party_Id.Parse("GEF"),
                               CDR_Id.Parse("CDR0001"),
                               DateTime.Parse("2020-04-12T18:20:19Z"),
                               DateTime.Parse("2020-04-12T22:20:19Z"),
                               new CDRToken(
                                   Token_Id.Parse("1234"),
                                   TokenTypes.RFID,
                                   Contract_Id.Parse("C1234")
                                   ),
                               AuthMethods.AUTH_REQUEST,
                               new CDRLocation(
                                   Location_Id.Parse("LOC0001"),
                                   "Biberweg 18",
                                   "Jena",
                                   "Deutschland",
                                   GeoCoordinate.Parse(10, 20),
                                   EVSE_UId.Parse("DE*GEF*E*LOC0001*1"),
                                   EVSE_Id.Parse("DE*GEF*E*LOC0001*1"),
                                   Connector_Id.Parse("1"),
                                   ConnectorTypes.IEC_62196_T2,
                                   ConnectorFormats.SOCKET,
                                   PowerTypes.AC_3_PHASE,
                                   "Name?",
                                   "07749"
                                   ),
                               Currency.EUR,

                               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(
                                   10.00,
                                   11.60
                                   ),

                               // Total Energy
                               50.00M,

                               // Total time
                               TimeSpan.FromMinutes(30),

                               Session_Id.Parse("0815"),
                               AuthorizationReference.Parse("Auth0815"),
                               Meter_Id.Parse("Meter0815"),

                               // 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 Tariff[] {
                new Tariff(
                    CountryCode.Parse("DE"),
                    Party_Id.Parse("GEF"),
                    Tariff_Id.Parse("TARIFF0001"),
                    Currency.EUR,
                    new TariffElement[] {
                    new TariffElement(
                        new PriceComponent[] {
                        PriceComponent.ChargingTime(
                            TimeSpan.FromSeconds(300),
                            2.00M,
                            0.10M
                            )
                    },
                        new TariffRestrictions [] {
                        new TariffRestrictions(
                            Time.FromHourMin(08, 00),                                 // Start time
                            Time.FromHourMin(18, 00),                                 // End time
                            DateTime.Parse("2020-12-01"),                             // Start timestamp
                            DateTime.Parse("2020-12-31"),                             // End timestamp
                            1.12M,                                                    // MinkWh
                            5.67M,                                                    // MaxkWh
                            1.34M,                                                    // MinCurrent
                            8.89M,                                                    // MaxCurrent
                            1.49M,                                                    // MinPower
                            9.91M,                                                    // MaxPower
                            TimeSpan.FromMinutes(10),                                 // MinDuration
                            TimeSpan.FromMinutes(30),                                 // MaxDuration
                            new DayOfWeek[] {
                            DayOfWeek.Monday,
                            DayOfWeek.Tuesday
                        },
                            ReservationRestrictionTypes.RESERVATION
                            )
                    }
                        )
                },
                    TariffTypes.PROFILE_GREEN,
                    new DisplayText[] {
                    new DisplayText(Languages.de, "Hallo Welt!"),
                    new DisplayText(Languages.en, "Hello world!"),
                },
                    URL.Parse("https://open.charging.cloud"),
                    new Price(                    // Min Price
                        1.10,
                        1.26
                        ),
                    new Price(                    // Max Price
                        2.20,
                        2.52
                        ),
                    DateTime.Parse("2020-12-01"),                    // Start timestamp
                    DateTime.Parse("2020-12-31"),                    // End timestamp
                    new EnergyMix(
                        true,
                        new EnergySource[] {
                    new EnergySource(
                        EnergySourceCategories.SOLAR,
                        80
                        ),
                    new EnergySource(
                        EnergySourceCategories.WIND,
                        20
                        )
                },
                        new EnvironmentalImpact[] {
                    new EnvironmentalImpact(
                        EnvironmentalImpactCategories.CARBON_DIOXIDE,
                        0.1
                        )
                },
                        "Stadtwerke Jena-Ost",
                        "New Green Deal"
                        ),
                    DateTime.Parse("2020-09-22")
                    )
            },

                               new SignedData(
                                   EncodingMethod.GraphDefiened,
                                   new SignedValue[] {
                new SignedValue(
                    SignedValueNature.START,
                    "PlainStartValue",
                    "SignedStartValue"
                    ),
                new SignedValue(
                    SignedValueNature.INTERMEDIATE,
                    "PlainIntermediateValue",
                    "SignedIntermediateValue"
                    ),
                new SignedValue(
                    SignedValueNature.END,
                    "PlainEndValue",
                    "SignedEndValue"
                    )
            },
                                   1,     // Encoding method version
                                   null,  // Public key
                                   "https://open.charging.cloud/pools/1/stations/1/evse/1/publicKey"
                                   ),

                               // Total Fixed Costs
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Energy Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Time Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Parking Time
                               TimeSpan.FromMinutes(120),

                               // Total Parking Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               // Total Reservation Cost
                               new Price(
                                   20.00,
                                   23.10
                                   ),

                               "Remark!",
                               InvoiceReference_Id.Parse("Invoice:0815"),
                               true, // IsCredit
                               CreditReference_Id.Parse("Credit:0815"),

                               DateTime.Parse("2020-09-12")

                               );

            #endregion

            var JSON = CDR1.ToJSON();

            Assert.AreEqual("DE", JSON["country_code"].Value <String>());
            Assert.AreEqual("GEF", JSON["party_id"].Value <String>());
            Assert.AreEqual("CDR0001", JSON["id"].Value <String>());


            Assert.IsTrue(CDR.TryParse(JSON, out CDR CDR2, out String ErrorResponse));
            Assert.IsNull(ErrorResponse);

            Assert.AreEqual(CDR1.CountryCode, CDR2.CountryCode);
            Assert.AreEqual(CDR1.PartyId, CDR2.PartyId);
            Assert.AreEqual(CDR1.Id, CDR2.Id);

            Assert.AreEqual(CDR1.Start.ToIso8601(), CDR2.Start.ToIso8601());
            Assert.AreEqual(CDR1.End.ToIso8601(), CDR2.End.ToIso8601());
            Assert.AreEqual(CDR1.CDRToken, CDR2.CDRToken);
            Assert.AreEqual(CDR1.AuthMethod, CDR2.AuthMethod);
            Assert.AreEqual(CDR1.Location, CDR2.Location);
            Assert.AreEqual(CDR1.Currency, CDR2.Currency);
            Assert.AreEqual(CDR1.ChargingPeriods, CDR2.ChargingPeriods);
            Assert.AreEqual(CDR1.TotalCosts, CDR2.TotalCosts);
            Assert.AreEqual(CDR1.TotalEnergy, CDR2.TotalEnergy);
            Assert.AreEqual(CDR1.TotalTime, CDR2.TotalTime);

            Assert.AreEqual(CDR1.SessionId, CDR2.SessionId);
            Assert.AreEqual(CDR1.AuthorizationReference, CDR2.AuthorizationReference);
            Assert.AreEqual(CDR1.MeterId, CDR2.MeterId);
            Assert.AreEqual(CDR1.EnergyMeter, CDR2.EnergyMeter);
            Assert.AreEqual(CDR1.TransparencySoftwares, CDR2.TransparencySoftwares);
            Assert.AreEqual(CDR1.Tariffs, CDR2.Tariffs);
            Assert.AreEqual(CDR1.SignedData, CDR2.SignedData);
            Assert.AreEqual(CDR1.TotalFixedCosts, CDR2.TotalFixedCosts);
            Assert.AreEqual(CDR1.TotalEnergyCost, CDR2.TotalEnergyCost);
            Assert.AreEqual(CDR1.TotalTimeCost, CDR2.TotalTimeCost);
            Assert.AreEqual(CDR1.TotalParkingTime, CDR2.TotalParkingTime);
            Assert.AreEqual(CDR1.TotalParkingCost, CDR2.TotalParkingCost);
            Assert.AreEqual(CDR1.TotalReservationCost, CDR2.TotalReservationCost);
            Assert.AreEqual(CDR1.Remark, CDR2.Remark);
            Assert.AreEqual(CDR1.InvoiceReferenceId, CDR2.InvoiceReferenceId);
            Assert.AreEqual(CDR1.Credit, CDR2.Credit);
            Assert.AreEqual(CDR1.CreditReferenceId, CDR2.CreditReferenceId);

            Assert.AreEqual(CDR1.LastUpdated.ToIso8601(), CDR2.LastUpdated.ToIso8601());
        }
示例#20
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());
        }
示例#21
0
        public static void Session_DeserializeGitHub_Test02()
        {
            #region Define JSON

            var JSON = @"{
                           ""country_code"":        ""BE"",
                           ""party_id"":            ""BEC"",
                           ""id"":                  ""101"",
                           ""start_date_time"":     ""2015-06-29T22:39:09Z"",
                           ""end_date_time"":       ""2015-06-29T23:50:16Z"",
                           ""kwh"": 41.00,
                            ""cdr_token"": {
                                 ""uid"":           ""123abc"",
                                 ""type"":          ""RFID"",
                                 ""contract_id"":   ""NL-TST-C12345678-S""
                             },
                           ""auth_method"":         ""WHITELIST"",
                           ""location_id"":         ""LOC1"",
                           ""evse_uid"":            ""3256"",
                           ""connector_id"":        ""1"",
                           ""currency"":            ""EUR"",
                           ""charging_periods"": [{
                             ""start_date_time"":   ""2015-06-29T22:39:09Z"",
                             ""dimensions"": [{
                               ""type"":            ""ENERGY"",
                               ""volume"":            120
                             }, {
                               ""type"":            ""MAX_CURRENT"",
                               ""volume"":            30
                             }]
                           }, {
                             ""start_date_time"":   ""2015-06-29T22:40:54Z"",
                             ""dimensions"": [{
                               ""type"":            ""ENERGY"",
                               ""volume"":            41000
                             }, {
                               ""type"":            ""MIN_CURRENT"",
                               ""volume"":            34
                             }]
                           }, {
                             ""start_date_time"":   ""2015-06-29T23:07:09Z"",
                             ""dimensions"": [{
                               ""type"":            ""PARKING_TIME"",
                               ""volume"":            0.718
                             }],
                             ""tariff_id"":         ""12""
                           }],
                           ""total_cost"": {
                             ""excl_vat"":            8.50,
                             ""incl_vat"":            9.35
                           },
                           ""status"":              ""COMPLETED"",
                           ""last_updated"":        ""2015-06-29T23:50:17Z""
                         }";

            #endregion

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

            Assert.AreEqual(CountryCode.Parse("BE"), parsedSession.CountryCode);
            Assert.AreEqual(Party_Id.Parse("BEC"), parsedSession.PartyId);
            Assert.AreEqual(Session_Id.Parse("101"), parsedSession.Id);
            //Assert.AreEqual(Session1.Start.    ToIso8601(),    parsedSession.Start.    ToIso8601());
            //Assert.AreEqual(Session1.End.Value.ToIso8601(),    parsedSession.End.Value.ToIso8601());
            //Assert.AreEqual(Session1.kWh,                      parsedSession.kWh);
            //Assert.AreEqual(Session1.CDRToken,                 parsedSession.CDRToken);
            //Assert.AreEqual(Session1.AuthMethod,               parsedSession.AuthMethod);
            //Assert.AreEqual(Session1.AuthorizationReference,   parsedSession.AuthorizationReference);
            //Assert.AreEqual(Session1.LocationId,               parsedSession.LocationId);
            //Assert.AreEqual(Session1.EVSEUId,                  parsedSession.EVSEUId);
            //Assert.AreEqual(Session1.ConnectorId,              parsedSession.ConnectorId);
            //Assert.AreEqual(Session1.MeterId,                  parsedSession.MeterId);
            //Assert.AreEqual(Session1.EnergyMeter,              parsedSession.EnergyMeter);
            //Assert.AreEqual(Session1.TransparencySoftwares,    parsedSession.TransparencySoftwares);
            //Assert.AreEqual(Session1.Currency,                 parsedSession.Currency);
            //Assert.AreEqual(Session1.ChargingPeriods,          parsedSession.ChargingPeriods);
            //Assert.AreEqual(Session1.TotalCosts,               parsedSession.TotalCosts);
            //Assert.AreEqual(Session1.Status,                   parsedSession.Status);
            //Assert.AreEqual(Session1.LastUpdated.ToIso8601(),  parsedSession.LastUpdated.ToIso8601());
        }