예제 #1
0
파일: gui.py 프로젝트: revarbat/TikiBot
 def load_configs(self):
     try:
         with open(os.path.expanduser("~/.tikibot.yaml"), "r") as f:
             confs = yaml.safe_load(f)
     except FileNotFoundError:
         confs = yaml.load(self.get_resource("tikibot_configs.yaml"))
     self.passcode = confs.get('passcode', '8888')
     self.use_metric = confs.get('use_metric', False)
     SupplyFeed.fromDict(confs)
     Recipe.fromDict(confs)
예제 #2
0
 def _item_add_finish(self, name):
     remaining = 750
     overage = 0.25
     for lastfeed in SupplyFeed.getAllOrdered():
         remaining = lastfeed.remaining
         overage = lastfeed.pulse_overage
     feed = SupplyFeed("Misc", name, remaining=remaining, overage=overage)
     self.master.save_configs()
     self.update_listbox()
     self.master.screen_pop()
     self.master.screen_push(FeedEditScreen(self.master, feed))
예제 #3
0
 def _item_add_finish(self, name):
     flowrate = 14.2
     overage = 0.25
     for lastfeed in SupplyFeed.getAllOrdered():
         flowrate = lastfeed.flowrate
         overage = lastfeed.pulse_overage
     feed = SupplyFeed("Misc", name, flowrate=flowrate, overage=overage)
     self.master.save_configs()
     self.update_listbox()
     self.master.screen_pop()
     self.master.screen_push(FeedEditScreen(self.master, feed))
예제 #4
0
 def item_add(self):
     try:
         for n in range(99):
             name = "Feed %d" % (n + 1)
             SupplyFeed.getByName(name)
     except KeyError:
         pass
     self.master.screen_push(
         AlphaScreen(self.master,
                     label="Name für neue Zutat:",
                     defval=name,
                     callback=self._item_add_finish))
예제 #5
0
파일: gui.py 프로젝트: schuetzi99/TikiBot
 def load_configs(self):
     try:
         with open(os.path.expanduser("~/.tikibot.yaml"), "r") as f:
             confs = yaml.load(f)
     except FileNotFoundError:
         confs = yaml.load(self.get_resource("tikibot_configs.yaml"))
     self.passcode = confs.get('passcode', '8888')
     self.use_metric = confs.get('use_metric', True)
     self.stepsforml = confs.get('stepsforml', "113")
     self.serdevice = confs.get('serdevice', '/dev/ttyUSB0')
     self.bgcolor = confs.get('bgcolor', '#94F92F')
     SupplyFeed.fromDict(confs)
     Recipe.fromDict(confs)
예제 #6
0
 def add_ingredient(self, feedname, ml):
     feed = SupplyFeed.getByName(feedname)
     if feed not in Recipe.by_feed:
         Recipe.by_feed[feed] = []
     Recipe.by_feed[feed].append(self)
     self.ingredients.append(Ingredient(feed, ml))
     return self
예제 #7
0
 def __init__(self, master):
     self.master = master
     feednames = [x.getName() for x in SupplyFeed.getAll()]
     cols = max(2, math.ceil(len(feednames) / 7))
     super(ByIngredientScreen,
           self).__init__(master,
                          feednames,
                          labeltext="Find drinks by ingredient:",
                          cols=cols)
예제 #8
0
 def __init__(self, master):
     super(DumpScreen, self).__init__(master)
     self.master = master
     self.lbl = Label(self, text="Dumping all feeds")
     self.backbtn = RectButton(self, text="Stop", command=self.handle_button_back)
     self.lbl.pack(side=TOP, fill=BOTH, expand=1)
     self.backbtn.pack(side=BOTTOM, fill=X, padx=10, pady=10)
     for feed in SupplyFeed.getAll():
         feed.startFeed()
예제 #9
0
 def handle_button_ingr_add(self):
     currfeeds = [ingr.feed.name for ingr in self.recipe.ingredients]
     feeds = [
         feed for feed in SupplyFeed.getNames() if feed not in currfeeds
     ]
     self.master.screen_push(
         SelectScreen(self.master,
                      feeds,
                      labeltext="Select the ingredient:",
                      callback=self.add_ingredient_step1))
예제 #10
0
파일: gui.py 프로젝트: revarbat/TikiBot
 def save_configs(self):
     confs = {
         "conf_version": "1.0.0",
         "passcode": self.passcode,
         "use_metric": self.use_metric,
     }
     confs = SupplyFeed.toDictAll(confs)
     confs = Recipe.toDictAll(confs, metric=self.use_metric)
     with open(os.path.expanduser("~/.tikibot.yaml"), "w") as f:
         f.write(yaml.dump(confs))
예제 #11
0
 def fromArray(cls, data):
     if type(data) is dict:
         name = data['name']
         ml = data['ml']
     else:
         name, amount, unit = data
         mult = unit_measures.get(unit, 0.0)
         ml = amount * mult
     feed = SupplyFeed.getByName(name)
     return cls(feed, ml)
예제 #12
0
 def __init__(self, master):
     self.master = master
     feednames = [x.getName() for x in SupplyFeed.getAvailable()]
     cols = max(2, math.ceil(len(feednames) / 7))
     super(ByIngredientScreen,
           self).__init__(master,
                          feednames,
                          labeltext="Suche Drinks nach Zutaten:",
                          cols=cols)
     self.bgcolor = master.bgcolor
     self.configure(bg=self.bgcolor)
예제 #13
0
파일: gui.py 프로젝트: schuetzi99/TikiBot
 def save_configs(self):
     confs = {
         "conf_version": "1.0.0",
         "passcode": self.passcode,
         "use_metric": self.use_metric,
         "stepsforml": self.stepsforml,
         "serdevice": self.serdevice,
         "bgcolor": self.bgcolor,
     }
     confs = SupplyFeed.toDictAll(confs)
     confs = Recipe.toDictAll(confs, metric=self.use_metric)
     with open(os.path.expanduser("~/.tikibot.yaml"), "w") as f:
         yaml.dump(confs, f)
예제 #14
0
 def startDispensing(self, volume):
     stepsforml = self.stepsforml
     tot_vol = self.totalVolume()
     vol_mult = volume / tot_vol
     self.dispensing = []
     sercommand = ''
     self.dispenselist = [
         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         0, 0
     ]
     logging.info("Dispensing: %s, %d ml" % (self.getName(), volume))
     for ingr in self.ingredients:
         ingr.milliliters = math.ceil(ingr.milliliters * vol_mult)
         self.dispensing.append(DispensingIngredient(ingr, vol_mult))
     for ingr in self.dispensing:
         thisfeed = SupplyFeed.getByName(ingr.feed.name)
         newremaining = thisfeed.feeds[
             ingr.feed.name].remaining - ingr.milliliters
         thisfeed.feeds[ingr.feed.name].remaining = newremaining
         logging.debug("remaining neu fuer " + ingr.feed.name + ": " +
                       str(thisfeed.feeds[ingr.feed.name].remaining))
         logging.info("Zutat " + ingr.feed.name + ": " +
                      str(ingr.milliliters) + " ml")
         for pumpnumber in list(range(24)):
             if ingr.feed.motor_num == pumpnumber:
                 self.dispenselist[pumpnumber] = int(
                     math.ceil(ingr.milliliters * self.stepsforml))
     sercommand = (','.join(map(str, self.dispenselist))) + '\n'
     try:
         self.ser.readData()
     except:
         logging.debug("keine bestehende verbindung")
         try:
             self.ser = SerialConnection()
             self.ser.readData()
             logging.debug("habe verbindung")
         except:
             logging.debug("verbindung nicht moeglich")
     hwa = HardwareAction(self.mixit)
     hwa.do_dispensing(self.mixit)
     self.ser.sendData(sercommand)
     self.ser.close()
     del self.ser
     self.updateDispensing(self.mixit)
예제 #15
0
 def item_lower(self, idx, txt, feed):
     SupplyFeed.transpose(idx)
     self.master.save_configs()
예제 #16
0
 def handle_button_back(self):
     for feed in SupplyFeed.getAll():
         feed.stopFeed()
     self.master.screen_pop()
예제 #17
0
 def handle_button_select(self, item):
     feed = SupplyFeed.getByName(item)
     recipes = Recipe.getRecipesByFeed(feed)
     self.master.screen_push(
         RecipeScreen(self.master, recipes,
                      "Wähle einen Drink mit %s:" % item))
예제 #18
0
 def _get_items(self):
     return [{
         "name": "#%d %s" % (feed.motor_num, feed.getName()),
         "data": feed,
         "fgcolor": None if feed.avail else "#700",
     } for feed in SupplyFeed.getAllOrdered()]
예제 #19
0
 def handle_button_select(self, item):
     feed = SupplyFeed.getByName(item)
     recipes = Recipe.getRecipesByFeed(feed)
     self.master.screen_push(
         RecipeScreen(self.master, recipes,
                      "Select a drink with %s:" % item))
예제 #20
0
 def item_raise(self, idx, txt, feed):
     SupplyFeed.transpose(idx - 1)
     self.master.save_configs()