Example #1
0
        //=================================================================================================================
        static void ProcesingKey(Menu.KEY key)
        {
            switch (lcd.Screen)
            {
                // hlavni nabidka ---------------------------------------------------------------------------------
                case (int)Menu.SCREEN.mainMenu:
                    if (Card.type < (int)ROLE.SERVICE_BOTTLE)
                    {
                        error(1000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                    }
                    else
                    {
                        switch (key)
                        {
                            case Menu.KEY.changeBottle:         // change bottle
                                if (Card.type == (int)ROLE.SERVICE_BOTTLE || Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    selectedVolumeBottle = 0;
                                    selectedBottle = 0;
                                    selectedDose = 0;
                                    selectedMenu = (int)Menu.KEY.select_1;
                                    lcd.Screen = (int)Menu.SCREEN.selectBottle1;
                                    lcd.Print(20, 20, 3, 1, "Position is not selected");
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.changePrice:
                                if (Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    selectedVolumeBottle = 0;
                                    selectedBottle = 0;
                                    selectedDose = 0;
                                    selectedMenu = (int)Menu.KEY.changePrice;
                                    lcd.Screen = (int)Menu.SCREEN.selectBottle1;
                                    lcd.Print(20, 20, 3, 1, "Position is not selected");
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.changeCalibration:
                                if (Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    selectedVolumeBottle = 0;
                                    selectedBottle = 0;
                                    selectedDose = 0;
                                    selectedMenu = (int)Menu.KEY.changeCalibration;
                                    lcd.Screen = (int)Menu.SCREEN.selectBottle1;
                                    lcd.Print(20, 20, 3, 1, "Position is not selected");
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.changeDate:       // change date
                                if (Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    lcd.Screen = (int)Menu.SCREEN.setDate;
                                    Menu.GetTimeDate();
                                    lcd.PrintSettDate(Menu.dayNew, Menu.monthNew, Menu.yearNew);
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.changeTime:       // change time
                                if (Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    lcd.Screen = (int)Menu.SCREEN.setTime;
                                    Menu.GetTimeDate();
                                    lcd.PrintSettTime(Menu.hourNew, Menu.minNew);
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.systemSetting:            // system setting
                                if (Card.type > (int)ROLE.SERVICE)
                                {
                                    lcd.Screen = (int)Menu.SCREEN.service;
                                    Settings.FindIndexCurrency();
                                    PrintSettings();
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.systemLogger:         // system logger
                                if (Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    //lcd.Screen = (int)Menu.SCREEN.logger;
                                    //loggLines = Logger.ReadLogg();
                                    //cntPages = (loggLines.Count / 16);
                                    //if (loggLines.Count % 16 > 0) cntPages++;
                                    //curPage = 1;
                                    //PrintLogg(curPage);
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.cleaning:      // credit manage
                                if (Card.type > (int)ROLE.SERVICE_BOTTLE)
                                {
                                    lcd.Screen = (int)Menu.SCREEN.cleaning;
                                    lcd.Print(180, 20, 3, 1, "Cleaning", 0x81);
                                    lcd.Print(60, 55, 2, 1, "push button on selected position", 0x81);
                                    lcd.FillRectangle(touch_red, 0x0000, 180, 180, 300, 240);
                                    lcd.Print(215, 195, 2, 1, "STOP", 0x81);
                                    lcd.TouchSettings(TouchState.shut_1E);
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                            case Menu.KEY.info:              // info
                                if (Card.type > (int)ROLE.SERVICE_CREDIT)
                                {
                                    lcd.Screen = (int)Menu.SCREEN.info;
                                    Thread.Sleep(10);
                                    Info();
                                }
                                else
                                {
                                    error(2000, " Access denied ", (int)Menu.SCREEN.mainMenu);
                                }
                                break;
                        }
                        key = 0;
                    }

                    break;
                // vyber lahve ------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.selectBottle1:
                case (int)Menu.SCREEN.selectBottle2:
                    switch (key)
                    {
                        case Menu.KEY.NEXT:
                            selectedBottle = 0;
                            lcd.Screen = (int)Menu.SCREEN.selectBottle2;
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.PREV:
                            selectedBottle = 0;
                            lcd.Screen = (int)Menu.SCREEN.selectBottle1;
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.ESC:
                            selectedBottle = 0;
                            lcd.Screen = (int)Menu.SCREEN.mainMenu;
                            break;
                        default:
                            lcd.Print(10, 20, 3, 1, "Position is not selected");
                            selectedBottle = Menu.GetSelectedBottle(key);
                            if (selectedBottle > 0 && selectedBottle <= Settings.buttonNumber)
                            {
                                switch (selectedMenu)
                                {
                                    case (int)Menu.KEY.changeBottle:
                                        lcd.Screen = (int)Menu.SCREEN.selectVolumeBottle;
                                        ProcesingKey(Menu.KEY.noKey);
                                        break;
                                    case (int)Menu.KEY.changePrice:
                                        lcd.Screen = (int)Menu.SCREEN.selectDose;
                                        ProcesingKey(Menu.KEY.noKey);
                                        break;
                                    case (int)Menu.KEY.changeCalibration:
                                        lcd.Screen = (int)Menu.SCREEN.set4Number;
                                        lcd.Print(20, 5, 2, 11, "Selected position is " + selectedBottle.ToString());
                                        lcd.Print(20, 30, 2, 1, "Push button on selected position");
                                        calib c = calibration.GetCalib(selectedBottle);
                                        calibrationNew = (int)(10000 / c.coef);
                                        lcd.PrintSettings(4, calibrationNew, "ml"); // zapíše původní kalibrační hodnotu
                                        break;
                                }
                            }
                            else if (selectedBottle != 0)
                            {
                                error(1000, "Position " + (int)key + " is not occupied", lcd.Screen);
                            }
                            break;
                    }
                    break;
                // vyber objemu lahve ----------------------------------------------------------------------
                case (int)Menu.SCREEN.selectVolumeBottle:
                    Bottle svb = new Bottle(selectedBottle);
                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            selectedBottle = 0;
                            lcd.Screen = (int)Menu.SCREEN.selectBottle1;   // navrat na vyber lahve
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.select_1:
                            selectedVolumeBottle = svb.Volume;
                            lcd.Screen = (int)Menu.SCREEN.set3Number;
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.select_2:                         // zkopiruji volume
                            selectedVolumeBottle = svb.Volume;
                            int bottleResidue = svb.Residue;
                            svb.SetVolume(svb.Volume);                      // vybrany objem
                            svb.SaveBottle(selectedBottle);                 // a ulozim do stavu

                            ArrayList log = new ArrayList();

                            log.AddParam(LOG.TIME, DateTime.Now.ToString("HH:mm:ss"));
                            log.AddParam(LOG.CARD, Card.cardid);
                            log.AddParam(LOG.EVENT, EVENT.BOTTLECHANGE);
                            log.AddParam(LOG.BOTTLE, selectedBottle);
                            log.AddParam(LOG.BTLVOLUME, selectedVolumeBottle);
                            log.AddParam(LOG.RESIDUE, bottleResidue);

                            Logger.WriteLogg(log);

                            selectedBottle = 0;
                            selectedVolumeBottle = 0;

                            SucessSave(2000, (int)Menu.SCREEN.selectBottle1);
                            break;
                        default:
                            lcd.Print(20, 5, 2, 11, "Selected position is " + selectedBottle.ToString());
                            lcd.Print(20, 30, 2, 11, svb.Name);
                            lcd.Print(310, 75, 2, 5, svb.Volume.ToString() + "ml");
                            lcd.Print(20, 110, 2, 1, "Residue");
                            lcd.Print(20, 140, 2, 1, svb.Residue.ToString() + " ml");
                            lcd.Print(20, 230, 3, 1, "Select option above");
                            break;
                    }
                    break;
                // vyber davky ------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.selectDose:
                    Bottle sd = new Bottle(selectedBottle);

                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.selectBottle1;   // navrat na vyber lahve
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        default:
                            lcd.Print(20, 20, 3, 11, "Selected position is " + selectedBottle.ToString());
                            lcd.Print(20, 230, 2, 1, "Please select dose for changes");
                            selectedDose = Menu.GetSelectedDose(key);
                            if (selectedDose > 0)
                            {
                                // nactu nastaveni
                                switch (selectedDose)
                                {
                                    case 1:
                                        priceNew = sd.SmallPrice;           // cena
                                        calibrationNew = sd.SmallTime;      // doba vydeje
                                        break;
                                    case 2:
                                        priceNew = sd.MiddlePrice;
                                        calibrationNew = sd.MiddleTime;
                                        break;
                                    case 3:
                                        priceNew = sd.LargePrice;
                                        calibrationNew = sd.LargeTime;
                                        break;
                                }
                                if (selectedMenu == (int)Menu.KEY.changePrice)                 // price
                                {
                                    lcd.Screen = (int)Menu.SCREEN.set5Number;
                                    ProcesingKey(Menu.KEY.noKey);
                                }
                                else if (selectedMenu == (int)Menu.KEY.changeCalibration)  // calibration
                                {
                                    lcd.Screen = (int)Menu.SCREEN.set4Number;
                                    ProcesingKey(Menu.KEY.noKey);
                                }
                            }
                            break;
                    }
                    break;
                // nastaveni ceny ---------------------------------------------------------------------------------
                case (int)Menu.SCREEN.set5Number:
                    Bottle set5 = new Bottle(selectedBottle);
                    string sdose = (selectedDose == 1) ? "small" : (selectedDose == 2) ? "medium" : "large";
                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.selectDose;   // ESC
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.ENT:
                            set5.SetPrice(selectedDose, priceNew);             // nova cena
                            set5.SaveBottle(selectedBottle);                   // ulozim vse

                            ButtonRS485.SendSettings(selectedBottle);

                            ArrayList log = new ArrayList();

                            log.AddParam(LOG.TIME, DateTime.Now.ToString("HH:mm:ss"));
                            log.AddParam(LOG.CARD, Card.cardid);
                            log.AddParam(LOG.EVENT, EVENT.PRICECHANGE);
                            log.AddParam(LOG.BOTTLE, selectedBottle);
                            log.AddParam(LOG.DOSE, selectedDose);
                            log.AddParam(LOG.PRICE, priceNew);

                            Logger.WriteLogg(log);

                            SucessSave(2000, (int)Menu.SCREEN.selectDose);
                            break;
                        default:
                            priceNew = Menu.SetPriceNew(key, priceNew);
                            lcd.Print(20, 5, 2, 11, "Selected position is " + selectedBottle.ToString());
                            lcd.Print(20, 30, 2, 1, "Selected dose is " + sdose);
                            lcd.PrintSettings(5, priceNew, Settings.currency);
                            break;
                    }
                    break;

                // kalibrace --------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.set4Number:
                    calib set4_c = calibration.GetCalib(selectedBottle);
                    Bottle set4_b = new Bottle(selectedBottle);
                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.selectBottle1;
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.ENT:
                            set4_c.Caluclate(calibrationNew, set4_b.SmallDose, set4_b.MiddleDose, set4_b.LargeDose);

                            calibration.SaveCalib(selectedBottle, set4_c);
                            set4_b.SmallTime = set4_c.small;
                            set4_b.MiddleTime = set4_c.medium;
                            set4_b.LargeTime = set4_c.large;

                            set4_b.SaveBottle(selectedBottle);

                            calibrationNew = 0; // vynuluje calib new

                            ArrayList log = new ArrayList();

                            log.AddParam(LOG.TIME, DateTime.Now.ToString("HH:mm:ss"));
                            log.AddParam(LOG.CARD, Card.cardid);
                            log.AddParam(LOG.EVENT, EVENT.CALIBRATION);
                            log.AddParam(LOG.BOTTLE, selectedBottle);
                            log.AddParam(LOG.DOSE, "123");
                            log.AddParam(LOG.CALIBTIME, (set4_c.coef * 1000).ToString());

                            Logger.WriteLogg(log);

                            SucessSave(2000, (int)Menu.SCREEN.selectBottle1);
                            break;
                        default:
                            calibrationNew = Menu.newNum(key, calibrationNew);
                            lcd.Print(20, 5, 2, 11, "Selected position is " + selectedBottle.ToString());
                            lcd.Print(20, 30, 2, 1, new StringBuilder().Insert(0, " ", 32).ToString());
                            lcd.Print(20, 30, 2, 1, "Insert dose in ml");
                            lcd.PrintSettings(4, calibrationNew, "ml");
                            break;
                    }
                    break;
                // nastaveni vlastniho objemu ---------------------------------------------------------------------
                case (int)Menu.SCREEN.set3Number:
                    Bottle rlahev = new Bottle(selectedBottle);
                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.selectVolumeBottle;
                            ProcesingKey(Menu.KEY.noKey);
                            break;
                        case Menu.KEY.ENT:
                            if (selectedVolumeBottle > 0 && selectedVolumeBottle <= rlahev.Volume)
                            {
                                int btlresidue = rlahev.Residue;
                                rlahev.Residue = selectedVolumeBottle;
                                rlahev.SaveBottle(selectedBottle);

                                ArrayList log = new ArrayList();

                                log.AddParam(LOG.TIME, DateTime.Now.ToString("HH:mm:ss"));
                                log.AddParam(LOG.CARD, Card.cardid);
                                log.AddParam(LOG.EVENT, EVENT.BOTTLECHANGE);
                                log.AddParam(LOG.BOTTLE, selectedBottle);
                                log.AddParam(LOG.BTLVOLUME, selectedVolumeBottle);
                                log.AddParam(LOG.RESIDUE, btlresidue);

                                Logger.WriteLogg(log);

                                selectedVolumeBottle = 0;
                                selectedBottle = 0;

                                SucessSave(2000, (int)Menu.SCREEN.selectBottle1);
                            }
                            else if (selectedVolumeBottle > rlahev.Volume)
                            {
                                error(2000, " Value must be less than " + rlahev.Volume.ToString(), (int)Menu.SCREEN.set3Number);
                            }
                            else
                            {
                                error(2000, " Value must be bigger than 0 ", (int)Menu.SCREEN.set3Number);
                            }
                            break;
                        default:
                            selectedVolumeBottle = Menu.newNum(key, selectedVolumeBottle);
                            lcd.Print(20, 5, 2, 11, "Selected position is " + selectedBottle.ToString());
                            lcd.Print(20, 30, 2, 1, "Set actual residue");
                            lcd.PrintSettings(4, selectedVolumeBottle, " ml");
                            break;
                    }
                    break;
                // nastaveni datum --------------------------------------------------------------------------------
                case (int)Menu.SCREEN.setDate:
                    switch (key)
                    {
                        case Menu.KEY.ENT:
                            Utility.SetLocalTime(lcd.AdjustDateTime("date"));        // ulozim do RTCC v LCD a local
                            SucessSave(1000, (int)Menu.SCREEN.mainMenu);
                            break;
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.mainMenu;   // ESC
                            break;
                        default:
                            Menu.SetDateNew(key);
                            lcd.PrintSettDate(Menu.dayNew, Menu.monthNew, Menu.yearNew);
                            break;
                    }
                    break;
                // nastaveni hodiny -------------------------------------------------------------------------------
                case (int)Menu.SCREEN.setTime:
                    switch (key)
                    {
                        case Menu.KEY.ENT:
                            Thread.Sleep(10);
                            Utility.SetLocalTime(lcd.AdjustDateTime("time"));        // ulozim do RTCC v LCD a local
                            SucessSave(1000, (int)Menu.SCREEN.mainMenu);
                            break;
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.mainMenu;   // ESC
                            break;
                        default:
                            Menu.SetTimeNew(key);
                            lcd.PrintSettTime(Menu.hourNew, Menu.minNew);
                            break;
                    }
                    break;
                // servis ---------------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.service:

                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.mainMenu;
                            break;
                        case Menu.KEY.ENT:
                            Settings.SaveSettings();        // ulozim na SD
                            SucessSave(1000, (int)Menu.SCREEN.mainMenu);
                            break;
                        case Menu.KEY.dec_2:
                            Settings.SetPosition("sub2");
                            PrintSettings();
                            break;
                        case Menu.KEY.inc_2:
                            Settings.SetPosition("add2");
                            PrintSettings();
                            break;
                        case Menu.KEY.PREV:                 // prev
                            Settings.SetIndexCurrency("dec");
                            PrintSettings();
                            break;
                        case Menu.KEY.NEXT:                 // next
                            Settings.SetIndexCurrency("inc");
                            PrintSettings();
                            break;
                        case Menu.KEY.inc_10:         // +10
                            Settings.SetMinresidue("add10");
                            PrintSettings();
                            break;
                        case Menu.KEY.dec_10:         //
                            Settings.SetMinresidue("sub10");
                            PrintSettings();
                            break;
                    }
                    break;
                //-------------------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.cleaning:
                    if (key == Menu.KEY.stopClean)
                    {
                        Rising.Clear();
                        lcd.TouchSettings(TouchState.on);
                        lcd.Screen = (int)Menu.SCREEN.mainMenu;
                    }
                    break;
                //-------------------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.info:                     // info
                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.mainMenu;   // ESC
                            break;
                    }
                    break;

                // logger ---------------------------------------------------------------------------------------------
                case (int)Menu.SCREEN.logger:
                    switch (key)
                    {
                        case Menu.KEY.ESC:
                            lcd.Screen = (int)Menu.SCREEN.mainMenu;
                            break;
                        case Menu.KEY.NEXT:
                            if (curPage < cntPages) curPage++;
                            PrintLogg(curPage);
                            break;
                        case Menu.KEY.PREV:
                            if (curPage > 1) curPage--;
                            PrintLogg(curPage);
                            break;
                        case Menu.KEY.END:
                            curPage = cntPages;
                            PrintLogg(curPage);
                            break;
                    }
                    break;
            }
        }
Example #2
0
        // Print Price
        static void PrintPrice(int bottle, Choice choice)
        {
            int price = 0;
            Bottle lahev = new Bottle(bottle);

            string country = " " + lahev.Country;
            string grower = " " + lahev.Grower;
            string attribute = " " + lahev.Atribute;
            string priceline = "";
            //lcd.Print(0, 112, 3, 7, FillingString(country));
            //lcd.Print(0, 144, 3, 7, FillingString(grower));
            lcd.Print(0, 208, 3, 7, FillingString(" " + lahev.Name));    // 176
            //lcd.Print(0, 208, 3, 7, FillingString(attribute));
            switch (choice)
            {
                case Choice.small:
                    price = lahev.SmallPrice;
                    priceline = (bottle + ". " + lahev.SmallDose.ToString() + "ml .. " + lcd.StringFormatInt32(6, price) + " " + Settings.currency);
                    break;
                case Choice.medium:
                    price = lahev.MiddlePrice;
                    priceline = (bottle + ". " + lahev.MiddleDose.ToString() + "ml .. " + lcd.StringFormatInt32(6, price) + " " + Settings.currency);
                    break;
                case Choice.large:
                    price = lahev.LargePrice;
                    priceline = (bottle + ". " + lahev.LargeDose.ToString() + "ml .. " + lcd.StringFormatInt32(6, price) + " " + Settings.currency);
                    break;
            }
            lcd.Print(0, 240, 3, 7, FillingString(" " + priceline));
        }
Example #3
0
        //-----------------------------------------------------------------------------------------------------------
        static void Dispensing(int bottle, Choice choice)
        {
            if (!blockTouch)
            {
                Bottle lahev = new Bottle(bottle);
                int dose = 0;                       // objem v cl
                int price = 0;
                int onTime = 0;
                int pieces = 0;                     // pocet kusu
                Int64 Credit = 0;
                switch (choice)
                {
                    case Choice.small:
                        pieces = lahev.SmallPieces;
                        dose = lahev.SmallDose;
                        price = lahev.SmallPrice;
                        // je sleva ?
                        if (Card.discount > 0) { price -= (price / 100) * Card.discount; }
                        onTime = lahev.SmallTime;
                        break;
                    case Choice.medium:
                        pieces = lahev.MiddlePieces;
                        dose = lahev.MiddleDose;
                        price = lahev.MiddlePrice;
                        // je sleva ?
                        if (Card.discount > 0) { price -= (price / 100) * Card.discount; }
                        onTime = lahev.MiddleTime;
                        break;
                    case Choice.large:
                        pieces = lahev.LargePieces;
                        dose = lahev.LargeDose;
                        price = lahev.LargePrice;
                        // je sleva ?
                        if (Card.discount > 0) { price -= (price / 100) * Card.discount; }
                        onTime = lahev.LargeTime;
                        break;
                }
                if ((lahev.Residue - dose) >= Settings.minResidue)
                {
                    if (onTime > 0 && dose > 0)
                    {
                        if (Card.credit >= price)
                        {
                            Credit = Card.credit - (Int32)price;                                     // odectu kredit
                            lahev.AddTotalDose(dose);                                   // prictu do lokalni statistiky hodnotu
                            //lahev.AddTotalPrice(price);                                 // prictu do lokalni statistiky cenu
                            lahev.SetResiude(lahev.Residue - dose);                    // odectu z lahve dose
                            lahev.IncPieces((int)choice);                                    // prictu kusy
                            pieces++;
                            Bill.PurchaseAdd(price);                                    // prictu nakup
                            string txtDoseVal = dose.ToString() + "ml";
                            string billLine = (StringPad(2, Bill.RowBill.ToString()) + ". " + StringPad(2, bottle.ToString()) + " " + StringPad(5, txtDoseVal) + " " + StringPad(10, price, true));
                            Bill.BillLineAdd(billLine);

                            ButtonRS485.VentilsOnTime(FromButton.bottle, onTime);
                            BUTTON = false;
                            PARSEBUTTON = false;

                            sl031.SetCreditNew(Credit);
                            lahev.SaveBottle(bottle);

                            Thread.Sleep((onTime * 10) + 500);                  // a cekam :-)

                            lcd.PrintBill(290, billLine);
                            LcdUpdateClient("credit");

                            ArrayList log = new ArrayList();

                            log.AddParam(LOG.TIME, DateTime.Now.ToString("HH:mm:ss"));
                            log.AddParam(LOG.CARD, Card.cardid);
                            log.AddParam(LOG.EVENT, EVENT.DISPENSING);
                            log.AddParam(LOG.BOTTLE, bottle);
                            log.AddParam(LOG.RESIDUE, lahev.Residue);
                            log.AddParam(LOG.DOSE, (int)choice);
                            log.AddParam(LOG.PRICE, price);

                            Logger.WriteLogg(log);

                            dispensed = true;
                        }
                        else        // uz neni ani panak
                        {
                            dispensed = false;

                            lcd.Beep(10);
                            lcd.FillRectangle(0x0000, 0xFFFF, 5, 5, 475, 267);
                            lcd.Print(20, 80, 2, 1, ("We are sorry, but you have low credit"), 0x81);
                            lcd.Print(100, 140, 2, 1, ("Your balance: " + StringPad(2, (int)Credit, true) + " " + Settings.currency), 0x81);
                            lcd.Print(100, 170, 2, 4, ("Price for: " + StringPad(2, price, true) + " " + Settings.currency), 0x81);

                            BlockTouch(5000, (int)Menu.SCREEN.cardUser);
                        }
                    }
                    else if (dose == 0)
                    {
                        dispensed = false;

                        lcd.Beep(10);
                        lcd.FillRectangle(0x0000, 0xFFFF, 5, 5, 475, 267);
                        lcd.Print(15, 80, 2, 1, ("We are sorry, selected dose is blocked"), 0x81);
                        lcd.Print(60, 140, 2, 4, ("Reason: dose volume is 0 ml"), 0x81);

                        BlockTouch(5000, (int)Menu.SCREEN.cardUser);
                    }
                    else
                    {
                        dispensed = false;

                        lcd.Beep(10);
                        lcd.FillRectangle(0x0000, 0xFFFF, 5, 5, 475, 267);
                        lcd.Print(15, 80, 2, 1, ("We are sorry, selected dose is blocked"), 0x81);
                        lcd.Print(60, 140, 2, 4, ("Reason: wrong calibration"), 0x81);

                        BlockTouch(5000, (int)Menu.SCREEN.cardUser);
                    }
                }
                else
                {
                    dispensed = false;

                    string wineName = String.Empty;

                    lcd.Beep(10);
                    lcd.FillRectangle(0x0000, 0xFFFF, 5, 5, 475, 267);

                    if ((lahev.Residue - lahev.SmallDose) < Settings.minResidue)
                    {
                        if (lahev.Name.Length > 24)
                        {
                            wineName = "Wine: " + lahev.Name.Substring(0, 20) + " ...";
                        }
                        else
                        {
                            wineName = "Wine: " + lahev.Name;
                        }
                        string pos = "Position " + bottle + " is empty";
                        int _leftPos = 240 - ((pos.Length / 2) * 16);

                        int _left = 240 - ((wineName.Length / 2) * 12);
                        lcd.Print(_leftPos, 80, 3, 1, pos, 0x81);
                        lcd.Print(_left, 140, 2, 1, wineName, 0x81);
                    }
                    else if ((lahev.Residue - lahev.MiddleDose) < Settings.minResidue)
                    {
                        string pos = "Only small dose";
                        int _leftPos = 240 - ((pos.Length / 2) * 16);
                        lcd.Print(_leftPos, 80, 3, 1, pos, 0x81);
                    }
                    else if ((lahev.Residue - lahev.LargeDose) < Settings.minResidue)
                    {
                        string pos = "Only small and medium dose";
                        int _leftPos = 240 - ((pos.Length / 2) * 16);
                        lcd.Print(_leftPos, 80, 3, 1, pos, 0x81);
                    }

                    lcd.Print(160, 170, 2, 4, "Residue: " + lahev.Residue + " ml", 0x81);

                    BlockTouch(5000, (int)Menu.SCREEN.cardUser);
                }

                BUTTON = true;
                PARSEBUTTON = true;
            }
        }
Example #4
0
 private string GetBottle(int n)
 {
     string s = string.Empty;
     if (!File.Exists(@"SD\settings\setbottle_" + n.ToString() + ".dat"))
     {
         Bottle b = new Bottle(n);
     }
     using (FileStream fs = new FileStream(@"SD\settings\setbottle_" + n.ToString() + ".dat", FileMode.Open, FileAccess.Read))
     {
         StreamReader reader = new StreamReader(fs);
         s = reader.ReadToEnd();
         reader.Close();
     }
     return s.Trim();
 }
        public static void SendSettings(int pos)
        {
            for (int i = 1; i <= Settings.buttonNumber; i++)
            {
                if (pos != Program.ALL)
                {
                    if (i != pos)
                    {
                        continue;
                    }
                }

                Bottle b = new Bottle(i);
                Thread.Sleep(10);
                if (b.Name.IndexOfAny(new char[] { ' ' }) > 0)
                {
                    string[] split = b.Name.Split(' ');

                    string result = String.Empty;

                    foreach (string s in split)
                    {
                        result += s + "  ";
                    }

                    if (result.Length > 20)
                    {
                        result = result.Substring(0, 16);
                        result += " ...";
                    }

                    SendName(i, 1, result);
                }
                else
                {
                    SendName(i, 1, b.Name);
                }
                Thread.Sleep(10);
                if (b.Grower.IndexOfAny(new char[] { ' ' }) > 0)
                {
                    string[] split = b.Grower.Split(' ');

                    string result = String.Empty;

                    foreach (string s in split)
                    {
                        result += s + "  ";
                    }

                    if (result.Length > 20)
                    {
                        result = result.Substring(0, 16);
                        result += " ...";
                    }

                    SendName(i, 2, result);
                }
                else
                {
                    SendName(i, 2, b.Grower);
                }
                Thread.Sleep(10);
                SendResidue(i, b.Volume, b.Residue);
                Thread.Sleep(10);
                SendPrice(i, b.SmallPrice, b.MiddlePrice, b.LargePrice);
                Thread.Sleep(10);
                SendDoses(i, b.SmallDose, b.MiddleDose, b.LargeDose);
                Thread.Sleep(10);
            }
        }
        public static void IsEmpty(int pos, bool INIT = false)
        {
            for (int i = 1; i <= Settings.buttonNumber; i++)
            {
                if (pos != Program.ALL)
                {
                    if (i != pos)
                    {
                        continue;
                    }
                }

                Bottle b = new Bottle(i);
                Thread.Sleep(10);
                if (Settings.minResidue > (b.Residue - b.SmallDose) && butState[i - 1] != Screen.blank)
                {
                    ChangePicture(i, Screen.blank);
                    Print(i, 20, 1, 0, 1, "Empty bottle");
                    Print(i, 20, 33, 0, 1, "residue " + b.Residue.ToString() + " ml");
                }
                else if (toShow != Screen.service && butState[i - 1] != toShow && butState[i - 1] != Screen.blank)
                {
                    ChangePicture(i, toShow);
                }
                else if (toShow != Screen.service && butState[i - 1] == toShow && butState[i - 1] != Screen.blank)
                {
                    if (!INIT) RefreshScreen(i);
                }

                Thread.Sleep(50);
            }
        }