Beispiel #1
0
def run(loop=True):
    boxHosts = host.cockle.prepareHosts(story, [loader.boxUid])
    boxHost = boxHosts[loader.boxUid]
    while loop and boxHost.running:
        agnostic.report_collect()
        cardUid = boxHost.gameLoop(
        )  # card value allows gameLoop to indicate idleness for future self-depower
Beispiel #2
0
def loadOther():
    report_collect()
    #report_import("faces.font_timB14")
    report_import("mfrc522")
    report_import("milecastles")
    report_import("boilerplate")
    report_import("engines")
    report_import("host")
    report_import("vault")
Beispiel #3
0
def runBox(boxUid):

    host = ConsoleHost()

    agnostic.collect()
    #TODO CH remove these test lines
    screen.clear()
    font.draw_generator(generatorFactory(), plotter)
    screen.redraw()

    agnostic.collect()

    boxUid = str(boxUid) # handle case of passing a number

    boxEngine = Engine(box=story.lookupBox(boxUid))
    boxEngine.registerStory(story)
    agnostic.collect()

    while True:
        agnostic.report_collect()
        try:
            tagUid = vault.awaitPresence()
            try:
                cardDict = vault.readJson(tagUid=tagUid)
                if "storyUid" not in cardDict or cardDict["storyUid"] is not loader.storyUid:
                    cardDict = None # existing card data incompatible
            except Exception as e:
                if type(e) is KeyboardInterrupt:
                    raise e
                else:
                    print(e)
                    cardDict = None # couldn't read card for some reason

            if cardDict is not None:
                print("JSON Good")
                card = dictToCard(tagUid, cardDict)
            else:
                print("JSON Bad")
                card = story.createBlankCard(tagUid)

            agnostic.collect()

            boxEngine.handleCard(card, host)
            print("Handled Card")
            vault.writeJson(cardToDict(card), tagUid=tagUid, unselect=True)
            print("Written JSON")
            vault.awaitAbsence()
            print("Card removed")
        except AssertionError as ae:
            print(type(ae).__name__ + str(ae))
        except KeyboardInterrupt:
            break
Beispiel #4
0
def walk(story):
    """Emulate whole museum in one box"""

    boxUids = list(story._get_table(Box).keys())
    boxHosts = prepareHosts(story, boxUids)

    while True:
        # agnostic.reboot_collect()
        report_collect()
        nextBoxUid = boxUids[randint(len(boxUids))]
        print("Visiting box {}".format(nextBoxUid))
        nextHost = boxHosts[nextBoxUid]
        nextHost.cardCache = None
        cardUid = nextHost.gameLoop(fuzz=True)
Beispiel #5
0
from st7920 import Screen

report_import("machine")
from machine import Pin

screen = Screen(slaveSelectPin=Pin(15))


def plotter(x, y):
    screen.plot(x, y)


screen.clear()
font.draw_line("Hello World", plotter)
screen.redraw()
report_collect()

report_import("milecastles")
report_import("boilerplate")
report_import("engines")
report_import("engines.console")
report_import("stories.senhouse")
from stories.senhouse import story

from regimes.console import ConsoleSiteEmulator

emulator = ConsoleSiteEmulator(story=story)
report_collect()

report_import("mfrc522")
from mfrc522 import MFRC522
Beispiel #6
0
def loadDisplay():
    report_collect()
    report_import("machine")
    report_import("st7920")
    report_import("faces.font_5x7")
Beispiel #7
0
def loadStory(name):
    report_collect()
    imp = report_import("stories." + name)
    mod = getattr(imp, name)
    return getattr(mod, 'story')
Beispiel #8
0
def fuzz(emulator):
    emulator.handleInput("a")
    while True:
        emulator.handleInput(command=str(randint(1, 4)))
        agnostic.report_collect()
        sleep(1)
Beispiel #9
0
 def run():
     while self.running:
         agnostic.report_collect()
         cardUid = self.gameLoop()