Пример #1
0
	def __init__(self, N):
		Py_Module.__init__(self)
		self.name = "py_Modem"
		t_mod = self.create_task("modulate")
		sb = self.create_socket_in (t_mod, "b", N, np.int32  )
		sx = self.create_socket_out(t_mod, "x", N, np.float32)
		self.create_codelet(t_mod, lambda m,l,f: m.modulate(l[0], l[1]))
Пример #2
0
    def __init__(self, N):

        Py_Module.__init__(self)

        self.N = N
        #infos
        self.F_ID = 0  #16 bits, file id (65536 file)
        self.F_TYPE = 0  #1 bit , file type (0 .Ts file, 1 img any type
        self.PACKET_ID = 0  #16 bits, packet order received for a ts file used to reorder in another
        self.PACKET_TYPE = 0  #2 bits to encode 3 types of frames ;1 start// 0 mid// 2 end//
        #total 59 bits ########## [P_TYPE P_ID F_ID F_TYPE F_SIZE]
        self.INFO_SIZE = 60

        dt_dec = self.create_task("decapsulate")
        # preferably input window should be smaller thacn frame size bigger than data size
        b_in_dec = self.create_socket_in(dt_dec, "IN", self.N + self.INFO_SIZE,
                                         np.int32)
        b_out_dec = self.create_socket_out(dt_dec, "OUT", self.N,
                                           np.int32)  # return frame size
        b_p_type = self.create_socket_out(dt_dec, "p_type", 1, np.int32)
        out_p_id = self.create_socket_out(dt_dec, "Packet_ID", 1, np.int32)
        out_f_id = self.create_socket_out(dt_dec, "Frame_ID", 1, np.int32)
        out_f_type = self.create_socket_out(dt_dec, "out_f_type", 1, np.int32)
        out_f_size = self.create_socket_out(dt_dec, "out_f_size", 1, np.int32)
        b_ts = self.create_socket_out(dt_dec, "ts_type", 1, np.int32)
        b_jpeg = self.create_socket_out(dt_dec, "jpeg_type", 1, np.int32)

        self.create_codelet(
            dt_dec,
            lambda slf, lsk, fid: slf.decapsulate(lsk[b_in_dec], lsk[
                b_out_dec], lsk[b_p_type], lsk[out_p_id], lsk[out_f_type], lsk[
                    out_f_id], lsk[out_f_size], lsk[b_ts], lsk[b_jpeg]))
Пример #3
0
    def __init__(self, K, path):
        self.end = 0
        self.start = 0
        Py_Module.__init__(self)
        self.name = "detect"
        self.K = K
        self.path_dir = path
        self.count = 0
        self.pream = np.zeros((1, K))
        self.pream[0, ::2] = np.ones((1, K // 2))
        self.last = np.ones((1, K))
        self.reception = 0
        self.nb_packet = -1

        self.file = None
        self.count_image = 0
        self.count_video = 0

        t_func = self.create_task('detect')
        sin = self.create_socket_in(t_func, "X_N", self.K, np.int32)
        sout = self.create_socket_out(t_func, "Y_N", self.K, np.int32)
        s_end_packet = self.create_socket_out(t_func, "end_packet", 1,
                                              np.int32)
        tram_type = self.create_socket_in(t_func, "T_Type", 1, np.int32)
        sout_itr = self.create_socket_out(t_func, "itr", 1, np.int32)

        self.create_codelet(
            t_func, lambda slf, lsk, fid: self.func(lsk[sin], lsk[sout], lsk[
                sout_itr], lsk[s_end_packet], lsk[tram_type]))
Пример #4
0
    def __init__(self, len_pream, len_frame):
        Py_Module.__init__(self)
        self.name = 'preamble'
        self.len_frame = len_frame
        self.len_pream = len_pream

        #self.header1=self.create_preamble() #creer
        self.header = np.array(self.get_header("header.txt")).reshape(
            1,
            2 * len_pream)  #utiliser le preambule dans le fishier header.txt

        t_ins_pream = self.create_task('insert_preamble')
        sin = self.create_socket_in(t_ins_pream, "s_in", len_frame, np.float32)
        sout = self.create_socket_out(t_ins_pream, "s_out",
                                      len_frame + 2 * len_pream, np.float32)
        self.create_codelet(
            t_ins_pream,
            lambda slf, lsk, fid: self.insert_preamble(lsk[sin], lsk[sout]))

        t_rem_pream = self.create_task('remove_preamble')
        s_in = self.create_socket_in(t_rem_pream, "s_in", self.len_frame,
                                     np.float32)
        s_out = self.create_socket_out(t_rem_pream, "s_out",
                                       len_frame - 2 * len_pream, np.float32)
        self.create_codelet(
            t_rem_pream,
            lambda slf, lsk, fid: self.remove_preamble(lsk[s_in], lsk[s_out]))
Пример #5
0
    def __init__(self, fse, N):
        Py_Module.__init__(self)
        self.name = "py_sync_freq_fine"
        self.N = N
        self.Bn = 0.01
        self.zeta = sqrt(2)/2
        self.Kp = 2
        self.SPS = fse
        self.teta = (self.Bn * self.SPS) / \
        ((self.zeta + 0.25/self.zeta)*self.SPS)
        self.d = 1+2*self.zeta*self.teta+self.teta**2
        self.gI = (4*(self.teta**2)/self.d)/(self.Kp*self.SPS)
        self.gP = (4*(self.teta*self.zeta)/self.d)/(self.Kp*self.SPS)
        self.previousSample = 1
        self.phase = 0
        self.loopFiltState = 0
        self.DDSPreviousInp = 0
        self.IntegFiltState = 0

        t_source = self.create_task('synchronize')
        s_in = self.create_socket_in(t_source, 'sync_in', N, np.float32)
        s_out = self.create_socket_out(t_source, 'sync_out', N, np.float32)

        self.create_codelet(t_source, lambda slf, lsk,
                            fid: slf.func(lsk[s_in], lsk[s_out]))
Пример #6
0
    def __init__(self, path, N, auto_reset=False):
        Py_Module.__init__(self)
        if path:
            self.src = py_aff3ct.module.source.Source_user_binary(
                N, path, auto_reset=False)
        self.path = path
        self.N = N
        self.frame_nb = 1
        self.name = "source_file"
        self.tmp = 0
        self.number_packet = self.compute_packet_number()
        #infos
        self.F_ID = 0  #16 bits, file id (65536 file)
        self.F_TYPE = 0  #1 bit , file type (0 .Ts file, 1 img any type
        self.F_SIZE = int(
            self.number_packet
        ) + 1  #24 bits to encode file size in bytes (< 16Mbytes)
        self.PACKET_ID = 0  #16 bits, packet order received for a ts file used to reorder in another
        self.PACKET_TYPE = 0  #2 bits to encode 3 types of frames ;1 start// 0 mid// 2 end//
        #total 59 bits ########## [P_TYPE P_ID F_ID F_TYPE F_SIZE]
        self.INFO_SIZE = 60
        self.build_info_header()

        t_generate = self.create_task('generate')
        _out = self.create_socket_out(t_generate, 'U_K', N + self.INFO_SIZE,
                                      np.int32)
        nb = self.create_socket_out(t_generate, 'NB', 1, np.int32)
        id = self.create_socket_out(t_generate, 'ID', 1, np.int32)
        type = self.create_socket_out(t_generate, "type", 1, np.int32)
        self.create_codelet(
            t_generate, lambda slf, lsk, fid: slf.generate(
                lsk[_out], lsk[nb], lsk[id], lsk[type]))
Пример #7
0
    def __init__(self, window, len, header, alpha=0.9):
        self.len = len
        # HEADER not yet Conjugated and "turned-around" version of the actual header ) to defined when framing
        self.HEADER = header[0]

        self.size_header = header.size // 2
        # keep incomplete corr
        self.buff = np.zeros(self.size_header - 1, dtype=complex)
        # buffer to temporarly store the frame
        self.frame = np.zeros(self.len // 2, dtype=complex)
        self.buff_empty = 1
        self.left = np.zeros(
            self.len // 2,
            dtype=complex)  # size left to complete current frame

        self.prev_delay = 0
        self.score = np.zeros(self.len // 2)
        self.alpha = alpha

        Py_Module.__init__(self)
        self.name = "Frame_sync"
        tr_synch = self.create_task("tr_synchronize")
        # preferably input window should be smaller thacn frame size bigger than data size
        s_in_sig = self.create_socket_in(tr_synch, "IN", window, np.float32)
        s_out_main = self.create_socket_out(tr_synch, "OUT", len,
                                            np.float32)  # return frame size
        s_out_delay = self.create_socket_out(tr_synch, "delay", 1,
                                             np.int32)  # delay
        s_out_bool = self.create_socket_out(
            tr_synch, "itr_tr", 1, np.int32)  # 0 if output1 contains data

        self.create_codelet(
            tr_synch,
            lambda slf, lsk, fid: slf.synchronize(lsk[s_in_sig], lsk[
                s_out_main], lsk[s_out_delay], lsk[s_out_bool]))
Пример #8
0
    def __init__(
        self,
        N,
    ):
        Py_Module.__init__(self)
        self.name = "Frequency_Synchronizer"
        t_synch = self.create_task("synchronize")
        s_in = self.create_socket_in(t_synch, "IN", N, np.float32)
        s_in_M = self.create_socket_in(t_synch, "IN_m", 1, np.int32)
        s_in_ts = self.create_socket_in(t_synch, "IN_ts", 1, np.float32)
        s_in_fft = self.create_socket_in(t_synch, "IN_fft", N // 2, np.float32)
        s_in_alpha = self.create_socket_in(t_synch, "IN_alpha", 1, np.float32)
        s_out_fft = self.create_socket_out(t_synch, "OUT_fft", N // 2,
                                           np.float32)
        s_out = self.create_socket_out(t_synch, "OUT", N, np.float32)

        self.create_codelet(
            t_synch, lambda slf, lsk, fid: slf.synchronize(
                lsk[s_in], lsk[s_in_M], lsk[s_in_ts], lsk[s_in_fft], lsk[
                    s_in_alpha], lsk[s_out], lsk[s_out_fft]))

        t_desynch = self.create_task("desynchronize")
        s_in1 = self.create_socket_in(t_desynch, "IN_1", N, np.float32)
        s_in_ts1 = self.create_socket_in(t_desynch, "IN_ts1", 1, np.float32)
        s_out1 = self.create_socket_out(t_desynch, "OUT_1", N, np.float32)

        self.create_codelet(
            t_desynch, lambda slf, lsk, fid: slf.desynchronize(
                lsk[s_in1], lsk[s_in_ts1], lsk[s_out1]))
Пример #9
0
    def __init__(self):
        Py_Module.__init__(self)  # Call the aff3ct Py_Module __init__

        self.name = "s_catcher"  # Set your module's name

        tsk = self.create_task("do_nothing")  # create a task for your module

        self.create_fake_codelet(tsk)  # create codelet

        signal.signal(signal.SIGINT, self.signal_handler)
Пример #10
0
 def __init__(self, dc=50):
     # init
     Py_Module.__init__(self)
     self.name = "display_info"
     self.dc = dc
     t_dis = self.create_task('display')
     self.frame = 0
     self.init = True
     self.socket_name = []
     self.sepa = "#" + 20 * "-" + "|"
Пример #11
0
    def __init__(self, alpha, K):
        Py_Module.__init__(self)
        self.name = 'py_ampli'
        self.alpha = alpha
        t_amp = self.create_task('amplify')
        sin = self.create_socket_in(t_amp, "amp_in", K, np.float32)
        sout = self.create_socket_out(t_amp, "amp_out", K, np.float32)

        self.create_codelet(
            t_amp, lambda slf, lsk, fid: self.ampli(lsk[sin], lsk[sout]))
Пример #12
0
    def __init__(self, size_pream, N):
        Py_Module.__init__(self)
        self.name = "py_sync_pream"
        self.N = N
        self.size_pream = size_pream
        self.pream = [cos(3*np.pi/4), sin(3*np.pi/4)]*(size_pream//2)
        t_source = self.create_task('sync_pream')
        s_in = self.create_socket_in(t_source, 'sync_in', N, np.float32)
        s_out = self.create_socket_out(t_source, 'sync_out', N, np.float32)

        self.create_codelet(t_source, lambda slf, lsk,
                            fid: slf.func(lsk[s_in], lsk[s_out]))
Пример #13
0
    def __init__(self, K, scramble):
        # init
        Py_Module.__init__(self)
        self.name = "scrambler"
        t_amp = self.create_task('scramble')
        self.scram = self.get_scram(scramble)

        sin = self.create_socket_in(t_amp, "X_N", K, np.int32)
        sout = self.create_socket_out(t_amp, "Y_N", K, np.int32)

        # properties
        self.create_codelet(
            t_amp, lambda slf, lsk, fid: self.scramble(lsk[sin], lsk[sout]))
Пример #14
0
    def __init__(self, fech, K):
        # init
        Py_Module.__init__(self)
        self.name = "frequency_sync"
        t_amp = self.create_task('sync')
        self.fech = fech

        sin = self.create_socket_in(t_amp, "sync_in", K, np.float32)
        sout = self.create_socket_out(t_amp, "sync_out", K, np.float32)

        # properties
        self.create_codelet(
            t_amp, lambda slf, lsk, fid: self.sync(lsk[sin], lsk[sout]))
Пример #15
0
    def __init__(self, loop_max):
        Py_Module.__init__(self)  # Call the aff3ct Py_Module __init__
        self.name = "loop_cnt"  # Set your module's name
        self.loop_max = loop_max
        self.cnt = 0
        tsk = self.create_task("increment")  # create a task for your module

        self.create_socket_out(
            tsk, "ctrl", 1,
            np.int8)  # create an input socket for the task t_mod

        self.create_codelet(
            tsk, lambda slf, lsk, fid: slf.count(lsk[0]))  # create codelet
Пример #16
0
    def __init__(self, path, N):
        Py_Module.__init__(self)
        self.name = "py_Source_image"
        self.path = path
        self.N = N
        self.K = N
        self.pream = True
        self.offset = 0
        self.tabpream = fairepream.fairepream(128)
        t_source = self.create_task('generate')
        s_out = self.create_socket_out(t_source, 'img', N, np.int32)

        self.create_codelet(t_source,
                            lambda slf, lsk, fid: slf.imgToBits(lsk[s_out]))
Пример #17
0
    def __init__(self, N):
        Py_Module.__init__(self)
        t_plot = self.create_task("plot")
        self.create_socket_in(t_plot, "x", N, np.float32)
        self.create_codelet(t_plot, lambda m, l, f: m.plot(l[0]))

        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(1, 1, 1)
        self.line, = self.ax.plot([], '.b')
        self.i_plt = 0
        plt.xlabel("Real part")
        plt.ylabel("Imaginary part")
        plt.ylim(-2, 2)
        plt.xlim(-2, 2)
Пример #18
0
    def __init__(self, K, header):
        # init
        Py_Module.__init__(self)
        self.name = "sync"
        self.header = header
        t_amp = self.create_task('sync')

        sin = self.create_socket_in(t_amp, "X_N", K, np.float32)
        sout = self.create_socket_out(t_amp, "Y_N", K, np.float32)
        sout_jump = self.create_socket_out(t_amp, "phase_jump", 1, np.float32)

        # properties
        self.create_codelet(
            t_amp, lambda slf, lsk, fid: self.sync(lsk[sin], lsk[sout], lsk[
                sout_jump]))
Пример #19
0
    def __init__(self, out_amp, varNoise, K):
        # init
        Py_Module.__init__(self)
        self.name = "agc"
        t_amp = self.create_task('amplify')

        self.out_amp = out_amp
        self.varNoise = varNoise

        sin = self.create_socket_in(t_amp, "amp_in", K, np.float32)
        sout = self.create_socket_out(t_amp, "amp_out", K, np.float32)

        # properties
        self.gain = 1
        self.create_codelet(
            t_amp, lambda slf, lsk, fid: self.ampli(lsk[sin], lsk[sout]))
Пример #20
0
    def __init__(self, ref, K):
        # init
        Py_Module.__init__(self)
        self.ref = ref
        self.name = "agc"
        t_amp = self.create_task('amplify')
        sin = self.create_socket_in(t_amp, "amp_in", K, np.float32)
        sout2 = self.create_socket_out(t_amp, "gain_out", 1, np.float32)
        itr = self.create_socket_out(t_amp, "itr", 1, np.int32)
        sout = self.create_socket_out(t_amp, "amp_out", K, np.float32)

        # properties
        self.gain = 1
        self.create_codelet(
            t_amp, lambda slf, lsk, fid: self.ampli(lsk[sin], lsk[sout], lsk[
                sout2], lsk[itr]))
Пример #21
0
    def __init__(self, K, alpha):
        # init
        Py_Module.__init__(self)
        self.name = "est_noise"
        self.alpha = alpha
        self.prev_snr = 0
        t_estimate = self.create_task('estimate')
        sin = self.create_socket_in(t_estimate, "y", K, np.float32)
        sout1 = self.create_socket_out(t_estimate, "cp", 1, np.float32)
        sout2 = self.create_socket_out(t_estimate, "snr", 1, np.float32)

        # properties
        self.gain = 1
        self.create_codelet(
            t_estimate, lambda slf, lsk, fid: self.estimate(
                lsk[sin], lsk[sout1], lsk[sout2]))
Пример #22
0
	def __init__(self, N,window):
		Py_Module.__init__(self) # Call the aff3ct Py_Module __init__
		self.name = "py_plot"   # Set your module's name

		t_plot = self.create_task("plot") # create a task for your module
		self.create_socket_in (t_plot, "x", N, np.float32)

		self.create_codelet(t_plot, lambda slf, lsk, fid: slf.plot(lsk[0])) # create codelet

		self.fig   = plt.figure()
		self.ax    = self.fig.add_subplot(1, 1, 1)
		self.line, = self.ax.plot([], '*b')
		self.i_plt = 0
		plt.xlabel("Real part")
		plt.ylabel("Imaginary part")
		plt.ylim(-window,window)
		plt.xlim(-window,window)
Пример #23
0
    def __init__(self, len):

        #infos
        self.F_ID = 0  #16 bits, file id (65536 file)
        self.F_TYPE = 0  #1 bit , file type (0 .Ts file, 1 img any type)
        self.F_SIZE = 0  #24 bits to encode file size in bytes (< 16Mbytes)
        self.PACKET_ID = 0  #16 bits, packet order received for a ts file used to reorder in another
        self.PACKET_TYPE = 0  #2 bits to encode 3 types of frames ;1 start// 0 mid// 2 end//
        #total 59 bits ########## [P_TYPE P_ID F_ID F_TYPE F_SIZE]

        #
        self.PACKET_SIZE = len  #packet size
        self.INFO_SIZE = 59
        self.F_PATH = './test_tmp/test.ts'

        #create/update info header
        self.build_info_header()  #

        print(self.INFO)

        Py_Module.__init__(self)
        self.name = "data_encapsulation"
        dt_enc = self.create_task("encapsulate")
        b_in_enc = self.create_socket_in(
            dt_enc, "IN", self.PACKET_SIZE, np.int32
        )  #preferably input window should be smaller thacn frame size bigger than data size
        b_out_enc = self.create_socket_out(dt_enc, "OUT",
                                           self.PACKET_SIZE + self.INFO_SIZE,
                                           np.int32)  #return frame size

        self.create_codelet(
            dt_enc, lambda slf, lsk, fid: slf.encapsulate(
                lsk[b_in_enc], lsk[b_out_enc]))

        dt_dec = self.create_task("decapsulate")
        b_in_dec = self.create_socket_in(
            dt_enc, "IN", self.PACKET_SIZE, np.int32
        )  #preferably input window should be smaller thacn frame size bigger than data size
        b_out_dec = self.create_socket_out(dt_enc, "OUT",
                                           self.PACKET_SIZE + self.INFO_SIZE,
                                           np.int32)  #return frame size

        self.create_codelet(
            dt_enc, lambda slf, lsk, fid: slf.decapsulate(
                lsk[b_in_dec], lsk[b_out_dec]))
Пример #24
0
    def __init__(self):
        # init
        Py_Module.__init__(self)
        self.name = "power_control"

        switch = 18  #physical pin num attached to the switch
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(switch, GPIO.OUT)
        self.state = 0

        swtch = self.create_task('change_state')
        sin_change_state = self.create_socket_in(
            swtch, "X_N", 1, np.int32)  # send 1 to change state
        sout_state = self.create_socket_out(swtch, "Y_N", 1,
                                            np.int32)  #current state of switch

        # properties
        self.create_codelet(
            swtch, lambda slf, lsk, fid: self.change_state(
                lsk[sin_change_state], lsk[sout_state]))