예제 #1
0
 public Outputs Create(Inputs inputs)
 {
   return new Outputs()
     .SetPriceLcd1(perFuel(inputs.ENozzle1, inputs.Price1))
     .SetPriceLcd2(perFuel(inputs.ENozzle2, inputs.Price2))
     .SetPriceLcd3(perFuel(inputs.ENozzle3, inputs.Price3));
 }
예제 #2
0
 public Outputs Create(Inputs inputs) 
 {
     EventLoop<Fuel> eStart = new EventLoop<Fuel>();
     Fill fi = new Fill(
                       inputs.EClearSale.Map(u => Unit.UNIT),
                       inputs.EFuelPulses, inputs.Calibration,
                       inputs.Price1, inputs.Price2, inputs.Price3,
                       eStart);
     NotifyPointOfSale np = new NotifyPointOfSale(
             new LifeCycle(inputs.ENozzle1,
                           inputs.ENozzle2,
                           inputs.ENozzle3),
             inputs.EClearSale,
             fi);
     eStart.Loop(np.EStart);
     return new Outputs()
         .SetDelivery(np.FuelFlowing.Map(
             of =>
                 of.Equals(Optional<Fuel>.Of(Fuel.ONE))   ? Delivery.FAST1 :
                 of.Equals(Optional<Fuel>.Of(Fuel.TWO))   ? Delivery.FAST2 :
                 of.Equals(Optional<Fuel>.Of(Fuel.THREE)) ? Delivery.FAST3 : 
                                                      Delivery.OFF))
         .SetSaleCostLcd(fi.DollarsDelivered.Map(
                 q => Formatters.FormatSaleCost(q)))
         .SetSaleQuantityLcd(fi.LitersDelivered.Map(
                 q => Formatters.FormatSaleQuantity(q)))
         .SetPriceLcd1(ShowDollarsPump.PriceLCD(np.FillActive, fi.Price,
                 Fuel.ONE, inputs))
         .SetPriceLcd2(ShowDollarsPump.PriceLCD(np.FillActive, fi.Price,
                 Fuel.TWO, inputs))
         .SetPriceLcd3(ShowDollarsPump.PriceLCD(np.FillActive, fi.Price,
                 Fuel.THREE, inputs))
         .SetBeep(np.EBeep)
         .SetSaleComplete(np.ESaleComplete);
 }
예제 #3
0
 public Outputs Create(Inputs inputs) 
 {
     EventLoop<Fuel> eStart = new EventLoop<Fuel>();
     Fill fi = new Fill(inputs.EClearSale.Map(u => Unit.UNIT),
                        inputs.EFuelPulses, inputs.Calibration,
                        inputs.Price1, inputs.Price2, inputs.Price3,
                        eStart);
     NotifyPointOfSale np = new NotifyPointOfSale(
             new LifeCycle(inputs.ENozzle1,
                           inputs.ENozzle2,
                           inputs.ENozzle3),
             inputs.EClearSale,
             fi);
     eStart.Loop(np.EStart);
     BehaviorLoop<bool> keypadActive = new BehaviorLoop<bool>();
     Keypad ke = new Keypad(inputs.EKeypad,
                            inputs.EClearSale,
                            keypadActive);
     Preset pr = new Preset(ke.Value,
                            fi,
                            np.FuelFlowing,
                            np.FillActive.Map(o => o.IsPresent));
     keypadActive.Loop(pr.KeypadActive);
     return new Outputs()
         .SetDelivery(pr.Delivery)
         .SetSaleCostLcd(fi.DollarsDelivered.Map(q => Formatters.FormatSaleCost(q)))
         .SetSaleQuantityLcd(fi.LitersDelivered.Map(q => Formatters.FormatSaleQuantity(q)))
         .SetPriceLcd1(ShowDollarsPump.PriceLCD(np.FillActive, fi.Price, Fuel.ONE, inputs))
         .SetPriceLcd2(ShowDollarsPump.PriceLCD(np.FillActive, fi.Price, Fuel.TWO, inputs))
         .SetPriceLcd3(ShowDollarsPump.PriceLCD(np.FillActive, fi.Price, Fuel.THREE, inputs))
         .SetSaleComplete(np.ESaleComplete)
         .SetPresetLcd(ke.Value.Map(v => Formatters.FormatSaleCost((double)v)))
         .SetBeep(np.EBeep.Merge(ke.EBeep));
 }
예제 #4
0
 public Outputs Create(Inputs inputs) {
     LifeCycle lc = new LifeCycle(inputs.ENozzle1,
                                  inputs.ENozzle2,
                                  inputs.ENozzle3);
     Fill fi = new Fill(lc.EStart.Map(u => Unit.UNIT),
                        inputs.EFuelPulses, inputs.Calibration,
                        inputs.Price1, inputs.Price2, inputs.Price3,
                        lc.EStart);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(
             of =>
                 of.Equals(Optional<Fuel>.Of(Fuel.ONE))   ? Delivery.FAST1 :
                 of.Equals(Optional<Fuel>.Of(Fuel.TWO)) ? Delivery.FAST2 :
                 of.Equals(Optional<Fuel>.Of(Fuel.THREE)) ? Delivery.FAST3 : 
                                                      Delivery.OFF))
         .SetSaleCostLcd(fi.DollarsDelivered.Map(
             q => Formatters.FormatSaleCost(q)))
         .SetSaleQuantityLcd(fi.LitersDelivered.Map(
             q => Formatters.FormatSaleQuantity(q)))
         .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));
 }
예제 #5
0
 public Outputs Create(Inputs inputs) {
     Behavior<UpDown> nozzle1 = inputs.ENozzle1.Hold(UpDown.DOWN);
     Behavior<UpDown> nozzle2 = inputs.ENozzle2.Hold(UpDown.DOWN);
     Behavior<UpDown> nozzle3 = inputs.ENozzle3.Hold(UpDown.DOWN);
     return new Outputs()
         .SetPriceLcd1(nozzle1.Map(u =>
             u.Equals(UpDown.UP) ?  "8.8.8.8." : ""))
         .SetPriceLcd2(nozzle2.Map(u =>
             u.Equals(UpDown.UP) ?  "8.8.8.8." : ""))
         .SetPriceLcd3(nozzle3.Map(u =>
             u.Equals(UpDown.UP) ?  "8.8.8.8." : ""));
 }
예제 #6
0
 public Outputs Create(Inputs inputs) {
     Behavior<UpDown> nozzle1 = inputs.ENozzle1.Hold(UpDown.DOWN);
     Behavior<UpDown> nozzle2 = inputs.ENozzle2.Hold(UpDown.DOWN);
     Behavior<UpDown> nozzle3 = inputs.ENozzle3.Hold(UpDown.DOWN);
     Behavior<UpDown> anyNozzle = Behavior<UpDown>.Lift((n1, n2, n3) =>
         n1 == UpDown.UP || n2 == UpDown.UP || n3 == UpDown.UP ? UpDown.UP : UpDown.DOWN, 
         nozzle1, nozzle2, nozzle3);
     Behavior<Double> litersDelivered = Accumulate(inputs.EFuelPulses, inputs.Calibration);
     return new Outputs()
         .SetDelivery(anyNozzle.Map(u => u == UpDown.UP ? Delivery.FAST1 : Delivery.OFF))
         .SetSaleQuantityLcd(litersDelivered.Map(q => Formatters.FormatSaleQuantity(q)));
 }
예제 #7
0
 public Outputs Create(Inputs inputs)
 {
   Behavior<UpDown> nozzle1 = inputs.ENozzle1.Hold(UpDown.DOWN);
   Behavior<UpDown> nozzle2 = inputs.ENozzle2.Hold(UpDown.DOWN);
   Behavior<UpDown> nozzle3 = inputs.ENozzle3.Hold(UpDown.DOWN);
   Func<UpDown, Double, String> ifLiftedPrice =
     (u, price) => u.Equals(UpDown.UP)
         ? Formatters.FormatPrice(price)
         : "";
   return new Outputs()
     .SetPriceLcd1(Behavior<UpDown>.Lift(ifLiftedPrice, nozzle1, inputs.Price1))
     .SetPriceLcd2(Behavior<UpDown>.Lift(ifLiftedPrice, nozzle2, inputs.Price2))
     .SetPriceLcd3(Behavior<UpDown>.Lift(ifLiftedPrice, nozzle3, inputs.Price3));
 }
예제 #8
0
 public Outputs Create(Inputs inputs) 
 {
     LifeCycle lc = new LifeCycle(inputs.ENozzle1,
                                  inputs.ENozzle2,
                                  inputs.ENozzle3);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(
             of =>
                 of.Equals(Optional<Fuel>.Of(Fuel.ONE))   ? Delivery.FAST1 :
                 of.Equals(Optional<Fuel>.Of(Fuel.TWO))   ? Delivery.FAST2 :
                 of.Equals(Optional<Fuel>.Of(Fuel.THREE)) ? Delivery.FAST3 : 
                                                      Delivery.OFF))
         .SetSaleQuantityLcd(lc.FillActive.Map(
             of =>
                 of.Equals(Optional<Fuel>.Of(Fuel.ONE))   ? "1" :
                 of.Equals(Optional<Fuel>.Of(Fuel.TWO))   ? "2" :
                 of.Equals(Optional<Fuel>.Of(Fuel.THREE)) ? "3" : ""));
 }
 public Outputs Create(Inputs inputs) 
 {
     LifeCycle lc = new LifeCycle(inputs.ENozzle1,
                                  inputs.ENozzle2,
                                  inputs.ENozzle3);
     Behavior<Double> litersDelivered =
             Accumulate(lc.EStart.Map(u => Unit.UNIT),
                        inputs.EFuelPulses,
                        inputs.Calibration);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(
             Of =>
                 Of.Equals(Optional<Fuel>.Of(Fuel.ONE))   ? Delivery.FAST1 :
                 Of.Equals(Optional<Fuel>.Of(Fuel.TWO))   ? Delivery.FAST2 :
                 Of.Equals(Optional<Fuel>.Of(Fuel.THREE)) ? Delivery.FAST3 : 
                                                      Delivery.OFF))
         .SetSaleQuantityLcd(litersDelivered.Map(
                 q => Formatters.FormatSaleQuantity(q)));
 }
예제 #10
0
 public static Behavior<String> PriceLCD(
         Behavior<Optional<Fuel>> fillActive,
         Behavior<Double> fillPrice,
         Fuel fuel,
         Inputs inputs) {
     Behavior<Double> idlePrice;
     switch (fuel) {
         case Fuel.ONE:   idlePrice = inputs.Price1; break;
         case Fuel.TWO:   idlePrice = inputs.Price2; break;
         case Fuel.THREE: idlePrice = inputs.Price3; break;
         default:    idlePrice = null; break;
     }
     return Behavior<string>.Lift((oFuelSelected, fillPrice_, idlePrice_) =>
         oFuelSelected.IsPresent
             ? oFuelSelected.Get() == fuel
                                   ? Formatters.FormatPrice(fillPrice_)
                                   : ""
             : Formatters.FormatPrice(idlePrice_),
         fillActive,
         fillPrice,
         idlePrice);
 }
예제 #11
0
 public Outputs Create(Inputs inputs) {
     Keypad ke = new Keypad(inputs.EKeypad, new Event<Unit>());
     return new Outputs()
         .SetPresetLcd(ke.Value.Map(v => Formatters.FormatSaleCost((double)v)))
         .SetBeep(ke.EBeep);
 }
예제 #12
0
 public Outputs Create(Inputs inputs)
 {
   return new Outputs().SetBeep(inputs.EKeypad.Map(k => Unit.UNIT));
 }