Esempio n. 1
0
 def __init__(self, Parent, Theme, Title, Message, **kwargs):
     super(StockPopup, self).__init__(Parent, Title, Message, **kwargs)
     self.Parent = Parent
     self.Theme = Theme
     self.engine = DbEngine(self)
     self.okButton.text = 'fertig'
     self.cancelButton.disabled = True
Esempio n. 2
0
    def __init__(self, Theme, **kwargs):

        super(HelloScreen, self).__init__(**kwargs)
        self.Theme = Theme
        self.engine = DbEngine(self)
        self.scanner = Scanner(self)
        self.orientation = 'vertical'
        self.padding = (0.5 * self.width, 30)
        self.Table.add_widget(
            Label(text='Willkommen',
                  size_hint=(1, 0.1),
                  padding_y=10,
                  bold=True))
        self.Table.add_widget(
            Button(text='',
                   background_normal='Themes/{}/Background.jpg'.format(
                       self.Theme),
                   background_down='Themes/{}/Background.jpg'.format(
                       self.Theme)))

        self.Table.add_widget(
            Label(text='Bitte scanne deine Benutzerkarte! ',
                  size_hint=(1, 0.1),
                  padding_y=10,
                  bold=True))
        self.add_widget(self.Table)
Esempio n. 3
0
 def on_open(self, *args):
     #stop timeout of Admin screen
     self.engine = DbEngine(self)
     self.Parent.timeOut.cancel()
     #Start Scanner
     self.Scan = Clock.schedule_interval(self.scanner.scan, .8)
     #set timeout
     self.timeOut = Clock.schedule_interval(self.no_input, 10)
Esempio n. 4
0
    def __init__(self, CardId, parent, **kwargs):

        super(Selection, self).__init__(**kwargs)
        self.spacing = 10
        self.cols = 4
        self.padding = (60, 10, 0, 0)
        self.size_hint_x = (.9)
        self.row_default_height = 40
        self.row_force_default = True
        self.Buttons = []
        self.engine = DbEngine(self)
        self.CardId = CardId
        self.UserGroup = 0
Esempio n. 5
0
    def __init__(self, Theme, **kwargs):

        super(AdminSelection, self).__init__(**kwargs)
        self.Theme = Theme
        self.engine = DbEngine(self)
        self.spacing = 10
        self.cols = 2
        self.padding = (60, 10, 0, 0)
        self.size_hint_x = (.9)
        self.row_default_height = 40
        self.row_force_default = True
        self.Buttons = []
        self.UserGroup = 0

        self.Buttons = []
        self.Buttons.append(
            AdminButton(Id=0, Theme=self.Theme, text='RFID Chip anlernen'))
        self.Buttons.append(
            AdminButton(Id=1, Theme=self.Theme, text='Getränkebestand'))
        self.Buttons.append(
            AdminButton(Id=2, Theme=self.Theme, text='Benutzerliste'))
        self.Buttons.append(
            AdminButton(Id=3, Theme=self.Theme, text='Freie RFID chips'))
        self.Buttons.append(
            AdminButton(Id=4, Theme=self.Theme, text='Zu den Getränken'))
        self.Buttons.append(AdminButton(Id=5, Theme=self.Theme, text=''))
        self.Buttons.append(
            AdminButton(Id=6, Theme=self.Theme, text='Programm beenden'))
        self.Buttons.append(
            AdminButton(Id=7, Theme=self.Theme, text='Pi herunterfahren'))
        self.Buttons[0].bind(on_release=self.scanMe)
        self.Buttons[1].bind(on_release=self.get_Stock)
        self.Buttons[2].bind(on_release=self.get_Users)
        self.Buttons[3].bind(on_release=self.get_freeChips)
        self.Buttons[4].bind(on_release=self.to_drinkSelection)

        self.Buttons[6].bind(on_release=self.app_exit)
        self.Buttons[7].bind(on_release=self.popup_poweroff)

        self.Buttons[5].background_color = [0, 0, 0,
                                            0]  #invisible button as spacer
        self.Buttons[6].background_color = [1, .3, 0, 1]
        self.Buttons[7].background_color = [1, .3, 0, 1]
        self.add_widget(self.Buttons[0])
        self.add_widget(self.Buttons[1])
        self.add_widget(self.Buttons[2])
        self.add_widget(self.Buttons[3])
        self.add_widget(self.Buttons[4])
        self.add_widget(self.Buttons[5])
        self.add_widget(self.Buttons[6])
        self.add_widget(self.Buttons[7])
Esempio n. 6
0
class ScanPopup(AdminPopup):
    CardId = StringProperty('0')  #used to add new RFID cards to DB

    def __init__(self, Parent, Theme, Title, Message, **kwargs):
        super(ScanPopup, self).__init__(Parent, Title, Message, **kwargs)
        self.register_event_type('on_result')
        self.Parent = Parent
        self.Theme = Theme
        self.scanner = Scanner(self)
        self.okButton.text = 'fertig'
        self.cancelButton.disabled = True

    def on_open(self, *args):
        #stop timeout of Admin screen
        self.engine = DbEngine(self)
        self.Parent.timeOut.cancel()
        #Start Scanner
        self.Scan = Clock.schedule_interval(self.scanner.scan, .8)
        #set timeout
        self.timeOut = Clock.schedule_interval(self.no_input, 10)

    def on_dismiss(self, *args):
        #stop scanner
        self.Scan.cancel()
        #trigger timout on Adminscreen
        self.Parent.timeOut()

    def no_input(self, *args):
        self.dismiss()

    def on_CardId(self, *args):
        if self.CardId != '0':
            #print ('Card ', self.CardId, ' found')
            self.engine.add_RFID(self.CardId)
            self.CardId = '0'

    def on_result(self, *args):
        if args[0] != 'Erfolg':
            popup = AdminPopup(self,
                               args[0],
                               '',
                               size_hint=(None, None),
                               size=(400, 300))
            popup.innerLayout.add_widget(
                Label(text='\n\n{}'.format(args[1]), valign='bottom'))
            popup.open()
        else:
            self.innerLayout.add_widget(
                Label(text='Chip {:15} index {:5} eingefügt'.format(
                    args[1], args[2])))
Esempio n. 7
0
class StockPopup(AdminPopup):
    CardId = StringProperty('0')  #used to add new RFID cards to DB

    def __init__(self, Parent, Theme, Title, Message, **kwargs):
        super(StockPopup, self).__init__(Parent, Title, Message, **kwargs)
        self.Parent = Parent
        self.Theme = Theme
        self.engine = DbEngine(self)
        self.okButton.text = 'fertig'
        self.cancelButton.disabled = True

    def getStock(self, *args):
        label = Label(text='[b]Ean[/b]',
                      halign='left',
                      markup=True,
                      size_hint_x=None,
                      width=120)
        label.text_size = (label.width, None)
        self.innerLayout.add_widget(label)
        label = Label(text='[b]Getränk[/b]',
                      halign='left',
                      markup=True,
                      size_hint_x=None,
                      width=220)
        label.text_size = (label.width, None)
        self.innerLayout.add_widget(label)
        label = Label(text='[b]Bestand[/b]', halign='left', markup=True)
        label.text_size = (label.width, None)
        self.innerLayout.add_widget(label)

        dbResult = self.engine.getProducts(100, 100, True)
        for Product in dbResult:
            label = Label(text=Product[0],
                          halign='left',
                          size_hint_x=None,
                          width=120)
            label.text_size = (label.width, None)
            self.innerLayout.add_widget(label)
            label = Label(text=Product[1],
                          halign='left',
                          size_hint_x=None,
                          width=220)
            label.text_size = (label.width, None)
            self.innerLayout.add_widget(label)
            label = Label(text='{:5d}'.format(Product[2]), halign='right')
            label.text_size = (.5 * label.width, None)
            self.innerLayout.add_widget(label)

    # event handlers
    def on_open(self, *args):
        #stop timeout of Admin screen
        self.Parent.timeOut.cancel()
        self.getStock()

    def on_dismiss(self, *args):
        #trigger timout on Adminscreen
        self.Parent.timeOut()
Esempio n. 8
0
class UserPopup(AdminPopup):
    CardId = StringProperty('0')  #used to add new RFID cards to DB

    def __init__(self, Parent, Theme, Title, Message, **kwargs):
        super(UserPopup, self).__init__(Parent, Title, Message, **kwargs)
        self.Parent = Parent
        self.Theme = Theme
        self.engine = DbEngine(self)
        self.okButton.text = 'fertig'
        self.cancelButton.disabled = True

    def getUserList(self, *args):
        label = Label(text='[b]Chip-Nr.[/b]',
                      halign='left',
                      markup=True,
                      size_hint_x=None,
                      width=100)
        label.text_size = (label.width, None)
        self.innerLayout.add_widget(label)
        label = Label(text='[b]Name[/b]',
                      halign='left',
                      markup=True,
                      size_hint_x=None,
                      width=100)
        label.text_size = (label.width, None)
        self.innerLayout.add_widget(label)
        label = Label(text='[b]Vorname[/b]', halign='left', markup=True)
        label.text_size = (label.width, None)
        self.innerLayout.add_widget(label)

        dbResult = self.engine.getUserList()
        for User in dbResult:
            label = Label(text=U'{:5d}'.format(User[0]),
                          halign='left',
                          size_hint_x=None,
                          width=120)
            label.text_size = (label.width, None)
            self.innerLayout.add_widget(label)
            label = Label(text=User[1],
                          halign='left',
                          size_hint_x=None,
                          width=100)
            label.text_size = (label.width, None)
            self.innerLayout.add_widget(label)
            label = Label(text=User[2], halign='left')
            label.text_size = (label.width, None)
            self.innerLayout.add_widget(label)

    def on_open(self, *args):
        #stop timeout of Admin screen
        self.Parent.timeOut.cancel()
        self.getUserList()

    def on_dismiss(self, *args):
        #trigger timout on Adminscreen
        self.Parent.timeOut()
Esempio n. 9
0
    def __init__(self, Theme, **kwargs):

        self.register_event_type('on_set_CardId')
        super(AdminScreen, self).__init__(**kwargs)
        self.Theme = Theme
        self.engine = DbEngine(self)
        #set idle timeout
        self.timeOut = Clock.create_trigger(self.no_input, 5)
        #add content
        self.add_widget(Image(source='Themes/{}/Background.jpg'.format(Theme),
                              size_hint=(1, 1),
                              opacity=.5),
                        index=1)
        self.Table.add_widget(
            Label(text='Administration',
                  size_hint=(1, 0.1),
                  padding_y=10,
                  bold=True))
        self.selection = AdminSelection(Theme=self.Theme)
        self.Table.add_widget(self.selection)
        self.add_widget(self.Table)
Esempio n. 10
0
class Selection(GridLayout):
    # Widget containing the list of drinks

    UserGroup = 0
    UserBalance = 0

    def __init__(self, CardId, parent, **kwargs):

        super(Selection, self).__init__(**kwargs)
        self.spacing = 10
        self.cols = 4
        self.padding = (60, 10, 0, 0)
        self.size_hint_x = (.9)
        self.row_default_height = 40
        self.row_force_default = True
        self.Buttons = []
        self.engine = DbEngine(self)
        self.CardId = CardId
        self.UserGroup = 0

    def get_product_list(self, Theme):
        #get Productlist based the user's group
        self.UserId, self.UserGroup, self.isCredit = self.engine.getUserInfo(
            self.CardId)
        if self.UserId:
            self.UserBalance = self.engine.getUserBalance(self.CardId)
        else:
            popup = Popup(
                title='Warnung',
                content=Label(
                    text='Benutzer für RFID\n {} \nnicht gefunden'.format(
                        self.CardId),
                    size_hint_x=.9,
                    halign='center'),
                size_hint=(None, None),
                size=(300, 200))

            self.timeOut = Clock.schedule_once(self.no_input, 2)
            popup.open()
            Close_me = Clock.schedule_once(popup.dismiss, 3)

        if self.UserGroup:
            if self.isCredit:
                dbResult = self.engine.getProducts(self.UserGroup, 100)
            else:
                dbResult = self.engine.getProducts(self.UserGroup,
                                                   self.UserBalance)

            #display results
            j = 0
            for Product in dbResult:

                Productlist = self.Buttons.append(
                    DrinkButton(Product[2], Product[1], self.UserId,
                                Product[3], 'Themes/{}/Button1'.format(Theme)))
                self.add_widget(self.Buttons[j])
                self.Buttons[j].bind(on_release=self.Buttons[j].callback)
                self.add_widget(
                    Label(
                        text='{:.2f}'.format(Product[3]) + ' €',
                        bold=True,
                    ))
                j = j + 1

            if (j == 0):
                self.add_widget(
                    InfoLine(text='Keine passenden Produkte gefunden'))

    def on_enter(self):
        self.timeOut = Clock.schedule_once(self.no_input, TIMEOUT)

    def on_leave(self):
        self.timeOut.cancel()

    def no_input(self, instance):
        self.parent.parent.no_input(self)
Esempio n. 11
0
 def on_drink_selected(self, *args):
     db = DbEngine(self)
     if db:
         db.execute_order(args[0], args[1], args[2], args[3])
         del db
Esempio n. 12
0
 def get_userbalance(self):
     db = DbEngine(self)
     if db:
         UserBalance = db.getUserBalance(self.CardId)
         del db
     return UserBalance
Esempio n. 13
0
class AdminSelection(GridLayout):
    CardId = StringProperty('0')  #used to add new RFID cards to DB

    def __init__(self, Theme, **kwargs):

        super(AdminSelection, self).__init__(**kwargs)
        self.Theme = Theme
        self.engine = DbEngine(self)
        self.spacing = 10
        self.cols = 2
        self.padding = (60, 10, 0, 0)
        self.size_hint_x = (.9)
        self.row_default_height = 40
        self.row_force_default = True
        self.Buttons = []
        self.UserGroup = 0

        self.Buttons = []
        self.Buttons.append(
            AdminButton(Id=0, Theme=self.Theme, text='RFID Chip anlernen'))
        self.Buttons.append(
            AdminButton(Id=1, Theme=self.Theme, text='Getränkebestand'))
        self.Buttons.append(
            AdminButton(Id=2, Theme=self.Theme, text='Benutzerliste'))
        self.Buttons.append(
            AdminButton(Id=3, Theme=self.Theme, text='Freie RFID chips'))
        self.Buttons.append(
            AdminButton(Id=4, Theme=self.Theme, text='Zu den Getränken'))
        self.Buttons.append(AdminButton(Id=5, Theme=self.Theme, text=''))
        self.Buttons.append(
            AdminButton(Id=6, Theme=self.Theme, text='Programm beenden'))
        self.Buttons.append(
            AdminButton(Id=7, Theme=self.Theme, text='Pi herunterfahren'))
        self.Buttons[0].bind(on_release=self.scanMe)
        self.Buttons[1].bind(on_release=self.get_Stock)
        self.Buttons[2].bind(on_release=self.get_Users)
        self.Buttons[3].bind(on_release=self.get_freeChips)
        self.Buttons[4].bind(on_release=self.to_drinkSelection)

        self.Buttons[6].bind(on_release=self.app_exit)
        self.Buttons[7].bind(on_release=self.popup_poweroff)

        self.Buttons[5].background_color = [0, 0, 0,
                                            0]  #invisible button as spacer
        self.Buttons[6].background_color = [1, .3, 0, 1]
        self.Buttons[7].background_color = [1, .3, 0, 1]
        self.add_widget(self.Buttons[0])
        self.add_widget(self.Buttons[1])
        self.add_widget(self.Buttons[2])
        self.add_widget(self.Buttons[3])
        self.add_widget(self.Buttons[4])
        self.add_widget(self.Buttons[5])
        self.add_widget(self.Buttons[6])
        self.add_widget(self.Buttons[7])

    def scanMe(self, instance):
        popup = ScanPopup(
            self.parent.parent,
            self.Theme,
            'RFID anlernen',
            '',
            size_hint=(.3, .6),
        )
        popup.open()

    def get_Stock(self, instance):
        popup = StockPopup(self.parent.parent,
                           self.Theme,
                           'Getränkebestand',
                           '',
                           size_hint=(.6, .7))
        popup.open()

    def get_Users(self, instance):
        popup = UserPopup(self.parent.parent,
                          self.Theme,
                          'Benutzerliste',
                          '',
                          size_hint=(.6, .7))
        popup.open()

    def get_freeChips(self, instance):
        dbresult = self.engine.getFreeChips()
        for item in dbresult:
            popup = AdminPopup(self.parent.parent,
                               'Anzahl freier RFID Chips',
                               'Es sind {:3d} Chips unbenutzt'.format(item[0]),
                               size_hint=(.4, .4))
            popup.open()

    def to_drinkSelection(self, instance):
        # tel manager to make drinklist current and set card for selection to the Admin's card
        self.parent.parent.manager.dispatch('on_set_CardId',
                                            self.parent.parent.AdminCardId)

    def app_exit(self, instance):
        call(['sudo', 'systemctl', 'stop', 'pibar2'])

    def popup_poweroff(self, instance):
        popup = AdminPopup(self.parent.parent,
                           'System Shutdown',
                           '',
                           size_hint=(.7, .7))
        popup.innerLayout.add_widget(
            Label(text='\n\n\nDer Pi wird Heruntergefahren'))
        popup.okButton.bind(on_release=self.poweroff_pi)
        popup.open()

    def poweroff_pi(self, instance):
        call(['sudo', 'poweroff'])
Esempio n. 14
0
class HelloScreen(Screen):
    CardId = StringProperty('0')
    Table = BoxLayout(orientation='vertical')
    read = True

    #    def getUserData(self,cardid):
    #        self.engine = DbEngine(self)
    #        result = self.engine.getUserId(cardid)
    #        for user in result:
    #            print (str(user[2]) +" "+str(user [3]))

    def __init__(self, Theme, **kwargs):

        super(HelloScreen, self).__init__(**kwargs)
        self.Theme = Theme
        self.engine = DbEngine(self)
        self.scanner = Scanner(self)
        self.orientation = 'vertical'
        self.padding = (0.5 * self.width, 30)
        self.Table.add_widget(
            Label(text='Willkommen',
                  size_hint=(1, 0.1),
                  padding_y=10,
                  bold=True))
        self.Table.add_widget(
            Button(text='',
                   background_normal='Themes/{}/Background.jpg'.format(
                       self.Theme),
                   background_down='Themes/{}/Background.jpg'.format(
                       self.Theme)))

        self.Table.add_widget(
            Label(text='Bitte scanne deine Benutzerkarte! ',
                  size_hint=(1, 0.1),
                  padding_y=10,
                  bold=True))
        self.add_widget(self.Table)

    # self.MIFAREReader = MFRC522.MFRC522()
    # self.init_gpio()

    def on_enter(self):
        self.read = True
        self.Scan = Clock.schedule_interval(self.scanner.scan, .8)
        self.Blank = Clock.schedule_interval(self.blank_screen, 180)

    def on_leave(self):
        self.read = False
        self.CardId = '0'
        self.Scan.cancel()
        self.Blank.cancel()

        #GPIO.cleanup()

    def on_CardId(self, *args):
        if self.CardId != '0':
            if self.engine.getAdmin(self.CardId):
                self.manager.dispatch('on_isAdmin', self.CardId)
            else:
                self.manager.dispatch('on_set_CardId', self.CardId)

    '''       
    def scan(self, *args):
        if self.read:
            #GPIO.output(16, GPIO.HIGH)  #set LED on
            (status,TagType) = self.MIFAREReader.MFRC522_Request(self.MIFAREReader.PICC_REQIDL)
            #GPIO.output(16, GPIO.LOW) #set LED off
            (status,uid) = self.MIFAREReader.MFRC522_Anticoll()
            if status == self.MIFAREReader.MI_OK:
                CardString = str(uid[0]) +str(uid[1]) +str(uid[2]) +str(uid[3]) +str(uid[4])
                self.CardId = CardString
                self.read = False
            #    if db.open:
                #        who_am_i(cardid)
                #    else:
                #        db.close
                #        cursor = db.cursor()
                #GPIO.output(12, GPIO.LOW) #LED off
                return True
    '''

    def blank_screen(self, *args):
        self.manager.current = 'black'