Esempio n. 1
0
def run_program():
    # reimport module if it's already imported
    if 'program' in sys.modules:
        del sys.modules['program']
    from program import program
    # run the program, handing it telemetry capabilities through "pause" callback
    program(pause)
Esempio n. 2
0
 def __init__(self, metadataFilePath):
     metadataParser = parseMetadata(metadataFilePath)
     motionClass, (centerLongitude, centerLatitude), self.hotpointCmdList = metadataParser.parse()
     self.centerPoint = (centerLatitude, centerLongitude)
     self.absoluteAngles = motionClass.motionAngle
     self.isClockwise = motionClass.clockwiseDirect
     self.plan = program(list(zip(motionClass.motionAngle, motionClass.clockwiseDirect)))
Esempio n. 3
0
def storeProgram(action,data):
    """ Store a program in the programs list
    """
    global programs,selectedProgram

    if action == "add":
        p = program()
    else:
        p = programs[selectedProgram]

    p.startTime(data['start'])
    p.length(data['length'])
    p.line(data['line'])
    p.days(data['days'])

    if action == "add":
        programs.append(p)
    else:
        programs[selectedProgram] = p

    #Track the change to the list of programs
    global toSave, toSync
    toSave = True
    toSync = True
    loadPrograms()

    #Enable relevant buttons
    enableButton(saveButton)
    if isConnected:
        enableButton(syncButton)
Esempio n. 4
0
def decodePrograms(programs):
    """ Decode programs read from the appliance.
    Programs are stored as comma separated strings,
    each field having the following meaning:

    0 - the id
    1 - start time (four digits, two for the hour and two for the minutes)
    2 - duration in minutes
    3 - days of week (hex bitmapped)
    4 - output line

    Returns an array of program objects.
    """
    global days

    prgs = []

    for prog in programs:
        p = program()
        data = prog.split(',')
        p.startTime(data[1][:2]+':'+data[1][2:])
        p.length(int(data[2]))
        p.line(int(data[4])+1)

        d = []
        for n,i in enumerate(days):
            if (2**n) & int(data[3], 16):
                d.append(i)

        p.days(d)
        prgs.append(p)

    return prgs
Esempio n. 5
0
def start():
    r = robot.Robot()
    k = Key()
    while True:
        time.sleep(0.1)
        if k.down:
            wall.program()
            time.sleep(1)
        if k.up:
            program.program()
            time.sleep(1)
        if k.backspace:
            time.sleep(1)
            if k.backspace:
                os.system("shutdown -h 0")
        if k.left:
            subprocess.call(["aplay", "badumtss.wav"])
        if k.right:
            subprocess.call(["aplay", "drama.wav"])
Esempio n. 6
0
def parse_input():
    csv_reader = csv.reader(open('input.csv', newline=''),
                            delimiter=' ',
                            quotechar='|')
    programs = []
    for row in csv_reader:
        program_name = row[0]
        end_index = row[1].find(')')
        program_weight = int(row[1][1:end_index])
        dependant_programs = []
        if (len(row) > 2):
            depends = row[3].split(',')
            for index, item in enumerate(depends):
                if (not item == ''):
                    dependant_programs.append(item)
        programs.append(
            program(program_name, program_weight, dependant_programs))
    return programs
Esempio n. 7
0
 def get_input(self):
     dirname = os.path.dirname(__file__)
     filename = os.path.join(dirname, 'input.csv')
     print(filename)
     csv_reader = csv.reader(open(filename, newline=''),
                             delimiter=' ',
                             quotechar='|')
     programs_list = []
     for row in csv_reader:
         program_name = row[0]
         end_index = row[1].find(')')
         program_weight = int(row[1][1:end_index])
         dependant_programs = []
         if (len(row) > 2):
             depends = row[3].split(',')
             for index, item in enumerate(depends):
                 if (not item == ''):
                     dependant_programs.append(item)
         programs_list.append(
             program(program_name, program_weight, dependant_programs))
     self.programs_list = programs_list
Esempio n. 8
0
def p_program_empty(p):
	'''program : '''
	p[0] = program()
 def test02_program(self):
     self.assertEqual(program('input/test02.in'), [(-0.3333, 1, 0, 0),
                                                   (0.3333, 0, 1, 0),
                                                   (-0.6667, 0, 0, 1)])
 def test22_program(self):
     self.assertEqual(program('input/test22.in'), [(0, 0, 1, 0),
                                                   (0, 0, 0, 1)])
 def test20_program(self):
     self.assertEqual(program('input/test20.in'), [(0, 0, -1, 1)])
 def test18_program(self):
     self.assertEqual(program('input/test18.in'),
                      [(-0.2222, 0.6667, -1, -0.7778, 1, 0, 0, 0),
                       (-0.717, 1.8667, -2.7684, -0.1778, 0, 1, 0, 0),
                       (-0.5684, 3.4, -2.0105, -1.8, 0, 0, 1, 0),
                       (-0.4865, 4.7333, -3.8526, -1.3556, 0, 0, 0, 1)])
 def test16_program(self):
     self.assertEqual(program('input/test16.in'), [(-2, 1, 0, 0),
                                                   (5, 0, -3, 1)])
 def test01_program(self):
     self.assertEqual(program('input/test01.in'),
                      [(0.1333, -0.3667, -1.4222, 1)])
 def test12_program(self):
     self.assertEqual(program('input/test12.in'), None)
#-*- coding: cp1254 -*
from program import program

p = program()

p.mainloop()
Esempio n. 17
0
#     estimator = yawErrorEstimator('DJI_0412', 'DJI_0412_corrected', plan0412, sampleParam, compressParam)

#     time_start=time.time()
#     estYawList = estimator.estimateYawErrorList(disableAutoCompression=False)
#     time_end=time.time()

#     print(estYawList)
#     print('total time consumed:',time_end-time_start)

#     print(estimator.getRunningTime())

if __name__ == '__main__':
    dataset_720p = [
        # ('DJI_0404', 'DJI_0404_corrected', program(((43, None), (10, False), (179, False), (281, False)))),
        ('DJI_0411', 'DJI_0411',
         program(((173, None), (65, False), (205, True), (139, False)))),
        # ('DJI_0403', 'DJI_0403_corrected', program(((214, None), (57, False), (248, False), (126, True)))),
        # ('DJI_0412', 'DJI_0412_corrected', program(((173, None), (65, False), (205, True), (139, False)))),
        # ('DJI_0410', 'DJI_0410', program(((214, None), (57, False), (248, False), (126, True)))),

        # ('DJI_0400', 'DJI_0400', program(((125, None), (39, False), (344, True), (65, True)))),
        # ('DJI_0402', 'DJI_0402', program(((56, None), (347, True), (183, False), (357, True))))
    ]

    dataset_4k = [
        # ('DJI_0447', 'DJI_0447_corrected', program(((7, None), (217, True), (327, True), (14, True))))
        # ('DJI_0488', 'DJI_0488', program(((286, None), (215, True), (310, True), (184, True), (59, False))))

        # ('DJI_0443', 'DJI_0443', program(((63, None), (346, False), (128, False), (7, False)))),
        # ('DJI_0439', 'DJI_0439', program(((125, None), (177, True), (114, False), (260, True)))),
 def test09_program(self):
     self.assertEqual(program('input/test09.in'), [(-2, 1, 0, 0),
                                                   (3.5, 0, -2.5, 1)])
Esempio n. 19
0
from program import program
from village import village
with open('input.txt', 'r') as f:
    programs = f.readlines()
programs = [x.strip() for x in programs]

my_village = village()

for idx, ind_program in enumerate(programs):
    id = int(ind_program.split("<->")[0].strip())
    pipes = ind_program.split("<->")[1].split(",")
    arr = []
    for p_idx, pipe in enumerate(pipes):
        arr.append(int(pipe.strip()))
    my_village.add_program(program(id, arr))

my_village.filter_groups()

print(my_village.get_groups()[0].get_member_size())
 def test13_program(self):
     self.assertEqual(program('input/test13.in'), [(0, 1, -2, 1)])
Esempio n. 21
0
        compressedVideoNameDict = json.load(dict_fin)

    start = int(sys.argv[1])

    confusionMatrix = {'TP': 0, 'TN': 0, 'FP': 0, 'FN': 0}

    for videoName, metadataName, videoType in zip(
            videoNameList[start:start + 1], metadataList[start:start + 1],
            videoTypeList[start:start + 1]):
        with open('log_' + videoName + '.txt', 'w') as fout:
            compressParam = compressParam_4k if videoType == '4k' else compressParam_720p
            for pp in programList:
                print('videoName:', videoName, file=fout)
                print('plan:', pp, file=fout)

                plan = program(pp)
                matcher = verifier(compressedVideoNameDict[videoName],
                                   metadataName, plan, threshold, sampleParam,
                                   compressParam)
                flag = matcher.verify(disableAutoCompression=True)
                print('result:', flag, file=fout)

                data = (videoName, metadataName, pp, videoType)
                if data in dataset:
                    # True
                    if flag == True:
                        confusionMatrix['TP'] += 1
                    else:
                        confusionMatrix['FN'] += 1
                else:
                    # False
 def test15_program(self):
     self.assertEqual(program('input/test15.in'), [(-2, 1, 0, 0),
                                                   (-3, 0, 1, 0),
                                                   (-4, 0, 0, 1)])
Esempio n. 23
0
import speak
import listen
import substructure
import info
import program

#! DİKKAT: Ses motorunda gtts çok yavaş oyüzden başka birşey araştır

while True:
    voice = listen.listen()
    print('\n' + voice)
    print(speak.speak(program.program(voice)))
 def test17_program(self):
     self.assertEqual(program('input/test17.in'), [(-2, 1, 0, 0),
                                                   (8, 0, -4, 1)])
Esempio n. 25
0
import program

if __name__ == '__main__':
    try:
        program.program()
    except Exception as e:
        print(e)
 def test19_program(self):
     self.assertEqual(program('input/test19.in'), [(-1, 1, 0, 0)])
 def test03_program(self):
     self.assertEqual(program('input/test03.in'), [(3, -2, 1)])
 def test21_program(self):
     self.assertEqual(program('input/test21.in'), [(0, -1, 1, 0)])
 def test04_program(self):
     self.assertEqual(program('input/test04.in'),
                      [(0.8, -0.44, 0.76, -1.6, 1)])
 def test23_program(self):
     self.assertEqual(program('input/test23.in'), [(0, 0, 0, 0, 0)])
 def test05_program(self):
     self.assertEqual(program('input/test05.in'), [(0, 1, 1, 0),
                                                   (-1.3333, 0.3333, 0, 1)])
Esempio n. 32
0
from program import program

program()
 def test06_program(self):
     self.assertEqual(program('input/test06.in'), [(1, -2, 1)])
Esempio n. 34
0
from program import program
with open("input.txt") as f:
    content = f.readlines()
#content = [x.strip() for x in content]
content = [x.split("=>") for x in content]
for idx, pat in enumerate(content):
    content[idx][0] = content[idx][0].strip()
    content[idx][1] = content[idx][1].strip()
my_program = program(content, ".#./..#/###")
print(my_program.get_on_pixels())
i = 0
while i < 2:
    my_program.do_iteration()
    i += 1
print(my_program.get_on_pixels())

#my_program.get_sub_grid()
g = [[1, 2, 3, 10], [4, 5, 6, 11], [7, 8, 9, 12], [13, 14, 15, 16]]
# #print(my_program.get_sub_grid(g,1,2))
# my_program.do_iteration()
# my_program.do_iteration()
#
# my_program.do_iteration()
# my_program.do_iteration()my_program.do_iteration()
# my_program.do_iteration()
print(my_program.get_pixels())
 def test08_program(self):
     self.assertEqual(program('input/test08.in'),
                      [('x[1]', 'x[2]', 'x[3]')])