def main():
    driver.init()
    #driver.downloadPage(d,107441)
    a = node.Node(3197)
    #r=getData(1)
    #print(r)
    #print (getChildNodes(r))
    #t=getRecordTable(r)
    #print(t)
    #buildTree(a)
    #node.printTree(a,0)
    #for i in a.childNodes:
    #	print (i.id)
    #print(a.recordTable)
    #print(getChildNodes(loadData(107136)))

    #pickle.dump(a,open("pickle/informatik.p","wb"))

    while (True):
        sid = input("Enter ID: ")
        print("Searching for " + str(sid))
        n = searchNode(int(sid), a)
        if n is None:
            print("no node found for id: " + sid)
        else:
            print("ID: " + str(n.id) + " Name:" + n.name)
def handleSignal(signal):
    signal_type = signal['type']
    if signal_type == 'start':
        print('start')
        driver.init()
    elif signal_type == 'shutdown':
        print('shutdown')
        driver.destroy()
    elif signal_type == 'load':
        payload = signal['payload']
        if payload == 'load':
            print('start load balls')
            driver.loadBalls()
            driver.startLoadMotor()
        elif payload == 'unload':
            print('start unload balls')
            driver.unloadBalls()
            driver.startLoadMotor()
        elif payload == 'pause':
            print('pause load motor')
            driver.stopLoadMotor()
        else:
            print('wrong action {}'.format(payload))
    elif signal_type == 'position':
        pos = signal['payload']
        if type(pos) == int and 0 <= pos <= 9:
            print('move to position {}'.format(pos))
            driver.changeUpDutyCycle(positionTypes[pos][1])
            driver.changeDownDutyCycle(positionTypes[pos][1])
            driver.movePWM(positionTypes[pos][0])
        else:
            print('wrong position {}'.format(pos))
    else:
        print('wrong signal type {}'.format(signal_type))
def parseDataAndExecute(data):
    # 0xxxx postition:x
    # 100xx load load:0 unload:1 pause:2
    # 1010x start:0 shutdown:1
    if not data[0]:
        position = binary2Dec(booleanArray2Str(data[1:]))
        if not (0 <= position <= 9):
            print('out of bounds {}'.format(position))
            return
        driver.changeUpDutyCycle(positionTypes[position][1])
        driver.changeDownDutyCycle(positionTypes[position][1])
        driver.movePWM(positionTypes[position][0])
        print('move to position %d' % position)
    elif binary2Dec(booleanArray2Str(data[0:3])) == 4:
        loadType = binary2Dec(booleanArray2Str(data[3:]))
        if loadType == 0:
            driver.loadBalls()
            driver.startLoadMotor()
            print('start load balls')
        elif loadType == 1:
            driver.unloadBalls()
            driver.startLoadMotor()
            print('start unload balls')
        elif loadType == 2:
            driver.stopLoadMotor()
            print('pause load motor')
        else:
            print('bad action : {}'.format(loadType))
    elif binary2Dec(booleanArray2Str(data[0:4])) == 10:
        if data[4]:
            print('shutdown')
            driver.destroy()
        else:
            print('start')
            driver.init()
Example #4
0
    def __init__(self,
                 port,
                 pub=None,
                 priv=None,
                 server=DEF_AUTHSERV,
                 driv=DEF_DRIVER):
        self.port = port
        self.device = driver.init(port, driver=driv)
        self.enc = auth.SDEnc()
        self.muted = False
        self.tlog = {}
        self.serv = server

        if pub != None:
            self.enc.loadPub(pub)

        if priv != None:
            self.enc.loadPriv(priv)
Example #5
0
        b[0] != 0, b[1] != 0, b[2] != 0, b[3] != 0, b[8] != 0, b[9] != 0,
        b[10] != 0, b[11] != 0, b[16] != 0, b[17] != 0, b[18] != 0, b[19] != 0,
        b[24] != 0, b[25] != 0, b[26] != 0, b[27] != 0
    ], 4, 4)


emu = [
    2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 2, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0
]

frame = 0

k = kernel([0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1], 4, 4)

print("initing")
driver.init()

print(driver.read_all())

while 1:
    yarn = lsys_from_blocks(driver.read_all())
    #yarn = "RB"
    #k = kernel_from_blocks(driver.read_all())
    print(yarn)
    screen.fill([0, 0, 0])
    draw_weave(frame, k, yarn, yarn)
    pygame.display.flip()
    frame += 1
    if frame > weave_width: frame = 0
Example #6
0
import driver
import time
import osc

driver.init()

print(driver.read_all())

def lookup(code):
    if code==0: return " "
    if code==1: return "a"
    if code==2: return "b"
    if code==3: return "c"
    if code==4: return "d"
    if code==5: return "+"
    if code==6: return "-"
    if code==7: return ">"
    if code==8: return "<"
    if code==9: return "A"
    if code==10: return "B"
    if code==11: return "C"
    if code==12: return "D"
    if code==13: return "["
    if code==14: return "]"
    if code==15: return "."


def send_lz(blocks,last):
    conv = ""
    for block in blocks:
        conv += lookup(block)
def init():
    driver.init()
    position = read_positions()
    for ID, pos in enumerate(position):
        initial_position[ID] = int(pos)
Example #8
0
def start():
    driver.init()
    return 'OK'