Пример #1
0
 /// <summary>
 /// Create a new MaxPower tariff restriction.
 /// </summary>
 /// <param name="MaxPower">The maximum power value.</param>
 public static ChargingTariffRestriction MaxPower(Decimal MaxPower)
 => new ChargingTariffRestriction(Power: DecimalMinMax.FromMax(MaxPower));
Пример #2
0
 /// <summary>
 /// Create a new MaxkWh tariff restriction.
 /// </summary>
 /// <param name="MaxkWh">The maximum kWh value.</param>
 public static ChargingTariffRestriction MaxkWh(Decimal MaxkWh)
 => new ChargingTariffRestriction(kWh: DecimalMinMax.FromMax(MaxkWh));
Пример #3
0
 /// <summary>
 /// Create a new MaxkWh tariff restriction.
 /// </summary>
 /// <param name="MaxkWh">The maximum kWh value.</param>
 public static TariffRestriction MaxkWh(Decimal MaxkWh)
 {
     return(new TariffRestriction(kWh: DecimalMinMax.FromMax(MaxkWh)));
 }
Пример #4
0
 /// <summary>
 /// Create a new MaxPower tariff restriction.
 /// </summary>
 /// <param name="MaxPower">The maximum power value.</param>
 public static TariffRestriction MaxPower(Decimal MaxPower)
 {
     return(new TariffRestriction(Power: DecimalMinMax.FromMax(MaxPower)));
 }
Пример #5
0
        public static void Tariff0004()
        {
            var tariff = new Tariff(Tariff_Id.Parse("11"),
                                    Currency.EUR,
                                    TariffUrl:      new Uri("https://company.com/tariffs/11"),
                                    TariffElements: new List <TariffElement>()
            {
                // 2.50 euro start tariff
                new TariffElement(
                    PriceComponent.FlatRate(2.50M)
                    ),

                // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(1.00M, TimeSpan.FromSeconds(900)),
                    TariffRestriction.MaxPower(32M)
                    ),

                // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(2.00M, TimeSpan.FromSeconds(600)),
                    new TariffRestriction(Power:      DecimalMinMax.FromMin(32M),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Monday,
                                              DayOfWeek.Tuesday,
                                              DayOfWeek.Wednesday,
                                              DayOfWeek.Thursday,
                                              DayOfWeek.Friday
                                              ))
                    ),

                // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes)
                new TariffElement(
                    PriceComponent.ChargingTime(1.25M, TimeSpan.FromSeconds(600)),
                    new TariffRestriction(Power:      DecimalMinMax.FromMin(32M),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Saturday,
                                              DayOfWeek.Sunday
                                              ))
                    ),


                // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes)
                new TariffElement(
                    PriceComponent.ParkingTime(5M, TimeSpan.FromSeconds(300)),
                    new TariffRestriction(Time:       TimeRange.From(9).To(18),
                                          DayOfWeek:  Enumeration.Create(
                                              DayOfWeek.Monday,
                                              DayOfWeek.Tuesday,
                                              DayOfWeek.Wednesday,
                                              DayOfWeek.Thursday,
                                              DayOfWeek.Friday
                                              ))
                    ),

                // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes)
                new TariffElement(
                    PriceComponent.ParkingTime(6M, TimeSpan.FromSeconds(300)),
                    new TariffRestriction(Time:       TimeRange.From(10).To(17),
                                          DayOfWeek:  new DayOfWeek[] {
                    DayOfWeek.Saturday
                })
                    )
            }
                                    );

            var expected = new JObject(new JProperty("id", "11"),
                                       new JProperty("currency", "EUR"),
                                       new JProperty("tariff_alt_url", "https://company.com/tariffs/11"),
                                       new JProperty("elements", new JArray(

                                                         // 2.50 euro start tariff
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "FLAT"),
                                                                                   new JProperty("price", "2.50"),
                                                                                   new JProperty("step_size", 1)
                                                                                   )))
                                                             ),


                                                         // 1.00 euro per hour charging tariff for less than 32A (paid per 15 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "1.00"),
                                                                                   new JProperty("step_size", 900)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("max_power", "32.00")
                                                                                   )
                                                                               ))
                                                             ),

                                                         // 2.00 euro per hour charging tariff for more than 32A on weekdays (paid per 10 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "2.00"),
                                                                                   new JProperty("step_size", 600)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("min_power", "32.00"),
                                                                                   new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // 1.25 euro per hour charging tariff for more then 32A during the weekend (paid per 10 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "TIME"),
                                                                                   new JProperty("price", "1.25"),
                                                                                   new JProperty("step_size", 600)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("min_power", "32.00"),
                                                                                   new JProperty("day_of_week", new JArray("SATURDAY", "SUNDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // Parking on weekdays: between 09:00 and 18:00: 5 euro(paid per 5 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "PARKING_TIME"),
                                                                                   new JProperty("price", "5.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("start_time", "09:00"),
                                                                                   new JProperty("end_time", "18:00"),
                                                                                   new JProperty("day_of_week", new JArray("MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY"))
                                                                                   )
                                                                               ))
                                                             ),

                                                         // Parking on saturday: between 10:00 and 17:00: 6 euro (paid per 5 minutes)
                                                         new JObject(
                                                             new JProperty("price_components", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("type", "PARKING_TIME"),
                                                                                   new JProperty("price", "6.00"),
                                                                                   new JProperty("step_size", 300)
                                                                                   ))),
                                                             new JProperty("restrictions", new JArray(
                                                                               new JObject(
                                                                                   new JProperty("start_time", "10:00"),
                                                                                   new JProperty("end_time", "17:00"),
                                                                                   new JProperty("day_of_week", new JArray("SATURDAY"))
                                                                                   )
                                                                               ))
                                                             )

                                                         )));

            Assert.AreEqual(expected.ToString(), tariff.ToJSON().ToString());
        }