Ejemplo n.º 1
0
    def __init__(self,parent,**kwargs):
        # Init
        self.root = parent
        ttk.Frame.__init__(self,parent,**kwargs)

        # Init configuration
        ttk.Style().configure("BW.TLabel")
        ttk.Style().configure("BW.TButton")

        self.grid(row=0,column=0,sticky="WENS")

        # DistantIO api
        self.model = distantio.DistantIO()
        # Serial port will be our IO in this application
        self.serial = distantio.SerialPort(self.model.decode_rx_data)

        # Init COM port frame
        self.com_ports = COM_Frame(self,self.model,relief=Tk.GROOVE)
        self.com_ports.grid(column=0,row=0,sticky='NSEW',pady=2,padx=5)

        # Init table frame
        self.var_table = VariableTable_Frame(self,self.model,relief=Tk.GROOVE)
        self.var_table.grid(column=0,row=1,sticky='NSEW',pady=2,padx=5)

        # Init serial health Frame
        self.health_frame = SerialHealth_Frame(self,self.model,self.root,relief=Tk.GROOVE)
        self.health_frame.grid(column=0,row=2,sticky='NSEW',pady=2,padx=5)

        self.com_ports.refresh_COM_ports()
        self.update()
        self.refresh_ports()
Ejemplo n.º 2
0
    def __init__(self, parent, **kwargs):
        # Init
        self.root = parent
        ttk.Frame.__init__(self, parent, **kwargs)

        # Init configuration
        ttk.Style().configure("BW.TLabel")
        ttk.Style().configure("BW.TButton")

        self.grid(row=0, column=0, sticky="WENS")

        # DistantIO api
        self.model = distantio.DistantIO()
        # Serial port will be our IO in this application
        self.serial = distantio.SerialPort(self.model.decode_rx_data)

        # Init COM port frame
        self.com_ports = COM_Frame(self, self.model, relief=Tk.GROOVE)
        self.com_ports.grid(column=0, row=0, sticky='NSEW', pady=2, padx=5)

        # Init table frame
        self.var_table = VariableTable_Frame(self,
                                             self.model,
                                             relief=Tk.GROOVE)
        self.var_table.grid(column=0, row=1, sticky='NSEW', pady=2, padx=5)

        # Init serial health Frame
        self.health_frame = SerialHealth_Frame(self,
                                               self.model,
                                               self.root,
                                               relief=Tk.GROOVE)
        self.health_frame.grid(column=0, row=2, sticky='NSEW', pady=2, padx=5)

        self.com_ports.refresh_COM_ports()
        self.update()
        self.refresh_ports()
Ejemplo n.º 3
0
class Application(ttk.Frame):
    def __init__(self, parent, **kwargs):
        # Init
        self.root = parent
        ttk.Frame.__init__(self, parent, **kwargs)

        # Init configuration
        ttk.Style().configure("BW.TLabel")
        ttk.Style().configure("BW.TButton")

        self.grid(row=0, column=0, sticky="WENS")

        # DistantIO api
        self.model = distantio.DistantIO()
        # Serial port will be our IO in this application
        self.serial = distantio.SerialPort(self.model.decode_rx_data)

        # Init COM port frame
        self.com_ports = COM_Frame(self, self.model, relief=Tk.GROOVE)
        self.com_ports.grid(column=0, row=0, sticky='NSEW', pady=2, padx=5)

        # Init table frame
        self.var_table = VariableTable_Frame(self,
                                             self.model,
                                             relief=Tk.GROOVE)
        self.var_table.grid(column=0, row=1, sticky='NSEW', pady=2, padx=5)

        # Init serial health Frame
        self.health_frame = SerialHealth_Frame(self,
                                               self.model,
                                               self.root,
                                               relief=Tk.GROOVE)
        self.health_frame.grid(column=0, row=2, sticky='NSEW', pady=2, padx=5)

        self.com_ports.refresh_COM_ports()
        self.update()
        self.refresh_ports()

    def disconnect(self):
        self.serial.close()
        self.model.export_data()

    def connect(self, port, baudrate):

        self.serial.connect(port, baudrate)

    def stop(self):
        self.serial.close()
        logging.info('SerialPort stopped.')
        self.model.terminate()
        logging.info('Model terminated.')

    def update(self):
        # Decode instructions
        for i in range(20):
            self.model.update()

        self.root.after(10, self.update)

    def refresh_ports(self):
        if self.serial.connected():
            self.com_ports.com_connected()
        else:
            self.com_ports.com_disconnected()
        self.root.after(500, self.refresh_ports)

    def available_ports(self):
        return self.serial.get_ports()

    def request_write(self, variable_id, data):
        frame = self.model.request_write(variable_id, data)
        self.serial.write(frame)

    def request_read_all(self):
        frame_generator = self.model.request_read_all()

        for frame in frame_generator:
            self.serial.write(frame)

    def request_descriptors(self):
        frame = self.model.request_descriptors()
        self.serial.write(frame)
Ejemplo n.º 4
0
class Application(ttk.Frame):
    def __init__(self,parent,**kwargs):
        # Init
        self.root = parent
        ttk.Frame.__init__(self,parent,**kwargs)

        # Init configuration
        ttk.Style().configure("BW.TLabel")
        ttk.Style().configure("BW.TButton")

        self.grid(row=0,column=0,sticky="WENS")

        # DistantIO api
        self.model = distantio.DistantIO()
        # Serial port will be our IO in this application
        self.serial = distantio.SerialPort(self.model.decode_rx_data)

        # Init COM port frame
        self.com_ports = COM_Frame(self,self.model,relief=Tk.GROOVE)
        self.com_ports.grid(column=0,row=0,sticky='NSEW',pady=2,padx=5)

        # Init table frame
        self.var_table = VariableTable_Frame(self,self.model,relief=Tk.GROOVE)
        self.var_table.grid(column=0,row=1,sticky='NSEW',pady=2,padx=5)

        # Init serial health Frame
        self.health_frame = SerialHealth_Frame(self,self.model,self.root,relief=Tk.GROOVE)
        self.health_frame.grid(column=0,row=2,sticky='NSEW',pady=2,padx=5)

        self.com_ports.refresh_COM_ports()
        self.update()
        self.refresh_ports()

    def disconnect(self):
        self.serial.close()
        self.model.export_data()

    def connect(self,port,baudrate):

        self.serial.connect(port,baudrate)

    def stop(self):
        self.serial.close()
        logging.info('SerialPort stopped.')
        self.model.terminate()
        logging.info('Model terminated.')

    def update(self):
        # Decode instructions
        for i in range(20):
            self.model.update()

        self.root.after(10,self.update)

    def refresh_ports(self):
        if self.serial.connected():
            self.com_ports.com_connected()
        else:
            self.com_ports.com_disconnected()
        self.root.after(500,self.refresh_ports)

    def available_ports(self):
        return self.serial.get_ports()

    def request_write(self,variable_id,data):
        frame = self.model.request_write(variable_id, data)
        self.serial.write(frame)

    def request_read_all(self):
        frame_generator = self.model.request_read_all()

        for frame in frame_generator:
            self.serial.write(frame)

    def request_descriptors(self):
        frame = self.model.request_descriptors()
        self.serial.write(frame)