Пример #1
0
def traversalclass(dirpath):
    filelist = {}

    for filename in os.listdir(dirpath):
        fname = os.path.splitext(filename)[0]
        fex = os.path.splitext(filename)[1]
        if fex == '.juggle':
            file = open(dirpath+filename, 'r')
            genfilestr = deletenote.deletenote(file.readlines())

            smc = statemachine.statemachine()
            smc.syntaxanalysis(genfilestr)
            module = smc.getmodule()
            struct = smc.getstruct()

            filelist[fname] = {}
            filelist[fname]['module'] = module
            filelist[fname]['struct'] = struct

    codegen.codegenclient(filelist)
    codegen.codegenserver(filelist)
    codegen.codegenstruct(filelist)
Пример #2
0
def traversalclass(dirpath):
    filelist = {}

    for filename in os.listdir(dirpath):
        fname = os.path.splitext(filename)[0]
        fex = os.path.splitext(filename)[1]
        if fex == '.juggle':
            file = open(dirpath+filename, 'r')
            genfilestr = deletenote.deletenote(file.readlines())

            smc = statemachine.statemachine()
            smc.syntaxanalysis(genfilestr)
            module = smc.getmodule()
            struct = smc.getstruct()

            filelist[fname] = {}
            filelist[fname]['module'] = module
            filelist[fname]['struct'] = struct

    codegencaller(filelist)
    codegenmodule(filelist)
    codegenstruct(filelist)
Пример #3
0
		data = data.split(',')
		if(abs(float(data[1])) < 100):
			x[1] = float(data[0])
			x[4] = float(data[1])
	elif(address % 10 == 3):# if the last digit of the remote IP address is 1, it means that the data is received from wireless module 3
		flag3 = 1
		data = data.split(',')
		if(abs(float(data[1])) < 100):
			x[2] = float(data[0])
			x[5] = float(data[1])
	
	if(flag1 == 1 and flag2 == 1 and flag3 == 1):	# only if data is received from all three wireless modules, do the following
		flag1 = flag2 = flag3 = 0	# reset the flags
		t = millis()	# obtain the current timestamp
		dt = t - t_prev	# calculate the difference between the timestamps
		t_prev = t		# current timestamp becomes previous timestamp for the next iteration
		curr_state = statemachine(curr_state,x)	# go through the state machine
		u = act(curr_state,x)	# compute the control signal (torque) based on the system state and state vector
		if(motor_active):	# if motor is active, then start logging the data
			append_file(x,u,curr_state)	# append the states, control signal and system state to file
			flag_graph = 1
		else:
			if(flag_graph):
				flag_graph = 0
				close_file()	# close the current file
				copyfile('states_log.txt','states_log_saved.txt')	# duplicate the current file
				import graphs	# show the graphs
				clear_file()	# clear the current file
		torque = bytes(str(u),'utf-8')+bytes('\n','utf-8')	# format the value to be sent to the microcontroller
		print(dt,x,curr_state,torque)	# show the variables on the console
		ser.write(torque)	# send the torque command to the microcontroller through serial port
Пример #4
0
def parser(str):
    machine = statemachine.statemachine()

    machine.syntaxanalysis(deletenote.deletenote(str))

    return machine.getmodule()
Пример #5
0
def parser(str):
    machine = statemachine.statemachine()

    machine.syntaxanalysis(deletenote.deletenote(str))

    return machine.getmodule(), machine.getenum()