Beispiel #1
0
def on_new_stream(data):
    video = mux.mux()
    stream_key = video.stream_key
    stream_link = video.link
    socketio.emit('stream_data', {
        'streamKey': stream_key,
        'link': stream_link
    })
def muxed_block_gens(mux_out, reset, clock):

    mux_sel, bg0_en, bg1_en = [Signal(bool(0)) for i in range(3)]
    bg0_out, bg1_out = [Signal(intbv(0)[2:]) for i in range(2)]

    bg0 = block_gen(bg0_out, bg0_en, clock, reset, n=4)
    bg1 = block_gen(bg1_out, bg1_en, clock, reset, n=4)
    my_mux = mux(mux_out, bg0_out, bg1_out, mux_sel)

    return bg0, bg1, my_mux
Beispiel #3
0
def test_mux():

    z, a, b, sel = [Signal(intbv(0)) for i in range(4)]

    mux_1 = mux(z, a, b, sel)

    @instance
    def stimulus():
        print("z a b sel")
        for i in range(12):
            a.next, b.next, sel.next = randrange(8), randrange(8), randrange(2)
            yield delay(10)
            print("%s %s %s %s" % (z, a, b, sel))

    return mux_1, stimulus
Beispiel #4
0
def test_mux():

    z, a, b, sel = [Signal(intbv(0)) for i in range(4)]

    mux_1 = mux(z, a, b, sel)

    @instance
    def stimulus():
        print("z a b sel")
        for i in range(12):
            a.next, b.next, sel.next = randrange(8), randrange(8), randrange(2)
            yield delay(10)
            print("%s %s %s %s" % (z, a, b, sel))

    return mux_1, stimulus
Beispiel #5
0
from myhdl import Signal, Simulation, delay, always_comb
from mux import mux
from random import randrange

z, a, b, sel = [Signal(0) for i in range(4)]

mux_1 = mux(z, a, b, sel)

def test():
    print "z a b sel"
    for i in range(8):
        a.next, b.next, sel.next = randrange(8), randrange(8), randrange(2)
        yield delay(10)
        print "%s %s %s %s" % (z, a, b, sel)

test_1 = test()

sim = Simulation(mux_1, test_1)
sim.run()
Beispiel #6
0
fn = args['file']
if not os.path.isdir(fn):
    if not os.path.isfile(fn):
        print("{0} does not exist".format(fn))
        sys.exit(-2)

if args['output'] == None:
    outname = "out.mkv"
else:
    outname = args['output']

mode = args['mode']
if mode == "audio":
    extract_audio(fn)
elif mode == "subs":
    extract_subs(fn)
elif mode == "mux":
    mux(fn, outname)
elif mode == "shader":
    shader(fn, args['width'], args['height'], args['shader_dir'], args['bit'],
           outname)
elif mode == "encode":
    encode_to_hevc(fn, outname)
elif mode == "split":
    length = get_video_length(fn)
    split_by_seconds(filename=fn,
                     split_length=args['split_length'],
                     video_length=length,
                     split_dir=args['output'])
else:
    print("Unknown option: {0}".format(mode))
Beispiel #7
0
def measure():
	aqi_dict = {-1:"#FFFFFF", 0:"#1CC88A", 1:"#FFD700", 2:"#FFA500", 3:"#FF0000", 4:"#800080", 5:"#800000", 6:"#800000"}
	con = sqlite3.connect("Measure.db")
	c = con.cursor()
	
	aon = sqlite3.connect("Aqi.db")
	a = aon.cursor()
	
	"""
	#productTable
	try:
		sql = "DROP TABLE IF EXISTS productTable"
		c.execute(sql)
		sql= "CREATE TABLE productTable(time text primary key not null, temp text, NO2 text, O3 text, CO text, SO2 text, PM25 text)"
		c.execute(sql)
	except:
		print("product Table create error")
	
	
	# aqiTable
	try:
		sql = "DROP TABLE IF EXISTS aqiTable"
		a.execute(sql)
		sql= "CREATE TABLE aqiTable(time text primary key not null, no2c text, no2 int, o3c text, o3 int, coc text, co int, so2c text, so2 int, pm25c text, pm25 int)"
		a.execute(sql)
	except:
		print("AQI Table create error")
	"""


	for i in range(24, 29):
		pin_direction = open("/gpio/pin" + str(i) + "/direction", 'w')
		pin_direction.write("out")
		pin_direction.close()

	avg = 24

	ms = mux.mux(16, 28, 0, [24, 25, 26, 27])
	ms.enable()

	ms.select_channel(udoo_pin.p_TMP())
	t = ms.oversampling(avg)
	temp = round(mux.temperature(t),1)

	ms.select_channel(udoo_pin.p_NO2_WE())
	WE = ms.oversampling(avg)
	ms.select_channel(udoo_pin.p_NO2_AE())
	AE = ms.oversampling(avg)
	NO2 = round(mux.NO2(WE, AE, temp),-1)

	ms.select_channel(udoo_pin.p_O3_WE())
	WE = ms.oversampling(avg)
	ms.select_channel(udoo_pin.p_O3_AE())
	AE = ms.oversampling(avg)
	O3 = round(mux.O3(WE, AE, temp),3)

	ms.select_channel(udoo_pin.p_CO_WE())
	WE = ms.oversampling(avg)
	ms.select_channel(udoo_pin.p_CO_AE())
	AE = ms.oversampling(avg)
	CO = round(mux.CO(WE, AE, temp),1)

	ms.select_channel(udoo_pin.p_SO2_WE())
	WE = ms.oversampling(avg)
	ms.select_channel(udoo_pin.p_SO2_AE())
	AE = ms.oversampling(avg)
	SO2 = round(mux.SO2(WE, AE, temp),-1)

	ms.select_channel(udoo_pin.p_PM25())
	V = ms.oversampling(avg)
	PM25 = round(mux.PM25(V),1)

	timestamp = str(datetime.now())[:-7]
	try:
		c.execute("INSERT INTO productTable VALUES(?, ?, ?, ?, ?, ?, ?)", (timestamp, temp, NO2, O3, CO, SO2, PM25))
	except:
		print("Data insert error")
		exit()
	con.commit()

#-----------------------------------------------------------------------------------------------------------------------------------------

	c.execute("SELECT avg(NO2) FROM productTable ORDER BY time DESC LIMIT 3600")
	no2 = c.fetchall()
	no2 = int(no2[0][0])
	no2 = aqi.no2(no2)
	no2c = aqi_dict[no2[0]]

	c.execute("SELECT avg(O3) FROM productTable ORDER BY time DESC LIMIT 3600")
	o3 = c.fetchall()
	o3 = round(float(o3[0][0]),3)
	o3 = aqi.o3(o3)
	o3c = aqi_dict[o3[0]]

	c.execute("SELECT avg(CO) FROM productTable ORDER BY time DESC LIMIT 3600")
	co = c.fetchall()
	co = round(float(co[0][0]),1)
	co = aqi.co(co)
	coc = aqi_dict[co[0]]

	c.execute("SELECT avg(SO2) FROM productTable ORDER BY time DESC LIMIT 3600")
	so2 = c.fetchall()
	so2 = int(so2[0][0])
	so2 = aqi.so2(so2)
	so2c = aqi_dict[so2[0]]

	c.execute("SELECT avg(PM25) FROM productTable ORDER BY time DESC LIMIT 3600")
	pm25 = c.fetchall()
	pm25 = round(float(pm25[0][0]),1)
	pm25 = aqi.pm25(pm25)
	pm25c = aqi_dict[pm25[0]]

	try:
		a.execute("INSERT INTO aqiTable VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (timestamp, no2c, no2[1], o3c, o3[1], coc, co[1], so2c, so2[1], pm25c, pm25[1]))
	except:
		print("AQI Data insert error")
		exit()

	aon.commit()
	aon.close()
	con.close()