Beispiel #1
0
 public Outputs Create(Inputs inputs)
 {
     LifeCycle lc = new LifeCycle(inputs.SNozzle1, inputs.SNozzle2, inputs.SNozzle3);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(m =>
             m.Equals(Maybe.Just(Fuel.One)) ? Delivery.Fast1 :
                 m.Equals(Maybe.Just(Fuel.Two)) ? Delivery.Fast2 :
                     m.Equals(Maybe.Just(Fuel.Three)) ? Delivery.Fast3 :
                         Delivery.Off))
         .SetSaleQuantityLcd(lc.FillActive.Map(m =>
             m.Equals(Maybe.Just(Fuel.One)) ? "1" :
                 m.Equals(Maybe.Just(Fuel.Two)) ? "2" :
                     m.Equals(Maybe.Just(Fuel.Three)) ? "3" :
                         string.Empty));
 }
Beispiel #2
0
        public Outputs Create(Inputs inputs)
        {
            LifeCycle lc = new LifeCycle(inputs.SNozzle1, inputs.SNozzle2, inputs.SNozzle3);

            return(new Outputs()
                   .SetDelivery(lc.FillActive.Map(m =>
                                                  m.Equals(Maybe.Some(Fuel.One)) ? Delivery.Fast1 :
                                                  m.Equals(Maybe.Some(Fuel.Two)) ? Delivery.Fast2 :
                                                  m.Equals(Maybe.Some(Fuel.Three)) ? Delivery.Fast3 :
                                                  Delivery.Off))
                   .SetSaleQuantityLcd(lc.FillActive.Map(m =>
                                                         m.Equals(Maybe.Some(Fuel.One)) ? "1" :
                                                         m.Equals(Maybe.Some(Fuel.Two)) ? "2" :
                                                         m.Equals(Maybe.Some(Fuel.Three)) ? "3" :
                                                         string.Empty)));
        }
 public Outputs Create(Inputs inputs)
 {
     LifeCycle lc = new LifeCycle(inputs.SNozzle1,
         inputs.SNozzle2,
         inputs.SNozzle3);
     Cell<double> litersDelivered =
         Accumulate(lc.SStart.Map(_ => Unit.Value),
             inputs.SFuelPulses,
             inputs.Calibration);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(
             m =>
                 m.Equals(Maybe.Just(Fuel.One)) ? Delivery.Fast1 :
                     m.Equals(Maybe.Just(Fuel.Two)) ? Delivery.Fast2 :
                         m.Equals(Maybe.Just(Fuel.Three)) ? Delivery.Fast3 :
                             Delivery.Off))
         .SetSaleQuantityLcd(litersDelivered.Map(Formatters.FormatSaleQuantity));
 }
Beispiel #4
0
 public Outputs Create(Inputs inputs)
 {
     LifeCycle lc = new LifeCycle(inputs.SNozzle1,
         inputs.SNozzle2,
         inputs.SNozzle3);
     Fill fi = new Fill(lc.SStart.Map(_ => Unit.Value),
         inputs.SFuelPulses, inputs.Calibration,
         inputs.Price1, inputs.Price2, inputs.Price3,
         lc.SStart);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(
             m =>
                 m.Equals(Maybe.Just(Fuel.One)) ? Delivery.Fast1 :
                     m.Equals(Maybe.Just(Fuel.Two)) ? Delivery.Fast2 :
                         m.Equals(Maybe.Just(Fuel.Three)) ? Delivery.Fast3 :
                             Delivery.Off))
         .SetSaleCostLcd(fi.DollarsDelivered.Map(Formatters.FormatSaleCost))
         .SetSaleQuantityLcd(fi.LitersDelivered.Map(Formatters.FormatSaleQuantity))
         .SetPriceLcd1(PriceLcd(lc.FillActive, fi.Price, Fuel.One, inputs))
         .SetPriceLcd2(PriceLcd(lc.FillActive, fi.Price, Fuel.Two, inputs))
         .SetPriceLcd3(PriceLcd(lc.FillActive, fi.Price, Fuel.Three, inputs));
 }
Beispiel #5
0
 public NotifyPointOfSale(
     LifeCycle lc,
     Stream<Unit> sClearSale,
     Fill fi)
 {
     Cell<bool> locked = lc.SStart.Map(u => true).OrElse(sClearSale.Map(u => false)).Hold(false);
     this.SStart = lc.SStart.Gate(locked.Map(l => !l));
     this.SEnd = lc.SEnd.Gate(locked);
     this.FuelFlowing =
         this.SStart.Map(Maybe.Just).OrElse(
             this.SEnd.Map(f => Maybe.Nothing<Fuel>())).Hold(Maybe.Nothing<Fuel>());
     this.FillActive =
         this.SStart.Map(Maybe.Just).OrElse(
             sClearSale.Map(f => Maybe.Nothing<Fuel>())).Hold(Maybe.Nothing<Fuel>());
     this.SBeep = sClearSale;
     this.SSaleComplete = this.SEnd.Snapshot(
         this.FuelFlowing.Lift(
             fi.Price, fi.DollarsDelivered,
             fi.LitersDelivered,
             (oFuel, price, dollars, liters) =>
                 oFuel.Match(v => Maybe.Just(
                     new Sale(v, price, dollars, liters)),
                     Maybe.Nothing<Sale>))).FilterMaybe();
 }