Commit 52585f49 authored by LorenzoMonti's avatar LorenzoMonti
Browse files

add log in configuration tab

parent 9ea57de6
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ def set_SPA_for_measure(ms2830a, config_file, manual_command):
        """
        This method allows to set the Anritsu MS2830A for the measurements
        """
        log_list = []    
        ms2830a.set_reset()
        ms2830a.self_test()
        ms2830a.set_SPA()
@@ -16,25 +17,26 @@ def set_SPA_for_measure(ms2830a, config_file, manual_command):
        # Frequency
        ms2830a.do_set_startfreq(config_file["start_freq"]) # 1Ghz
        ms2830a.do_set_stopfreq(config_file["stop_freq"])
        print("Start Frequency: " + str(ms2830a.do_get_startfreq()))
        print("Stop Frequency: " + str(ms2830a.do_get_stopfreq()))
        print("Center Frequency: " + str(ms2830a.do_get_centerfreq()))

        log_list.append("Start Frequency: " + str(ms2830a.do_get_startfreq()))
        log_list.append("Stop Frequency: " + str(ms2830a.do_get_stopfreq()))
        log_list.append("Center Frequency: " + str(ms2830a.do_get_centerfreq()))
        
        # Time sweep
        ms2830a.set_trace_points_sweeptime(config_file["sweep_trace_points"])
        print("Sweep Trace points: " + str(ms2830a.get_trace_points_sweeptime()))
        log_list.append("Sweep Trace points: " + str(ms2830a.get_trace_points_sweeptime()))

        # BW
        ms2830a.do_set_resolutionBW(config_file["resolution_bandwith"]) # 1Mhz
        print("Resolution Bandwith: " + str(ms2830a.do_get_resolutionBW()))
        log_list.append("Resolution Bandwith: " + str(ms2830a.do_get_resolutionBW()))
        ms2830a.do_set_videoBW(100)
        print("Video bandwith:" + str(ms2830a.do_get_videoBW))
        log_list.append("Video bandwith:" + str(ms2830a.do_get_videoBW()))
        
        # AMPLITUDE
        ms2830a.set_amplitude_scale(config_file["amplitude_log_scale"])
        print("Amplitude log scale: " + str(ms2830a.get_amplitude_scale()))
        log_list.append("Amplitude log scale: " + str(ms2830a.get_amplitude_scale()))
        ms2830a.set_reference_level(config_file["reference_level"])
        print("Reference level: " + str(ms2830a.get_reference_level()))
        log_list.append("Reference level: " + str(ms2830a.get_reference_level()))

        # MARKER
        ms2830a.set_zoom_spot_marker(config_file["zoom_spot_marker"][0], config_file["zoom_spot_marker"][1])
@@ -43,6 +45,8 @@ def set_SPA_for_measure(ms2830a, config_file, manual_command):
        if(len(manual_command) != 0):
                ms2830a.write(manual_command)
        
        return log_list

def plot_lineplot(trace):
        
        x = np.arange(len(trace)) # x axis
+17 −12
Original line number Diff line number Diff line
from logging import disable
from tkinter import Tk
import Anritsu_MS2830A as SPA
import Utils

@@ -155,16 +157,14 @@ def configuration(self, TNotebook1, config_interface, config_file):
    self.Entry10.configure(font="TkTextFont")
    self.Entry10.configure(selectbackground="blue")
    self.Entry10.configure(selectforeground="white")
    self.Entry10.insert(0, "")

    # text for log output
    self.Entry11 = tk.Entry(self.TNotebook1_t2)
    self.Entry11.place(relx=0.035, rely=0.818, relheight=0.154, relwidth=0.94)
    self.Entry11.configure(background="white")
    self.Entry11.configure(font="TkTextFont")
    self.Entry11.configure(selectbackground="blue")
    self.Entry11.configure(selectforeground="grey")
    self.Entry11.configure(state="disabled")
    self.Text1 = tk.Text(self.TNotebook1_t2)
    self.scroll = tk.Scrollbar(self.TNotebook1_t2)
    self.Text1.configure(yscrollcommand=self.scroll.set)
    self.Text1.place(relx=0.035, rely=0.818, relheight=0.154, relwidth=0.94)
    self.Text1.configure(background='#d9d9d9')
    self.Text1.configure(font="TkTextFont")

    # function for button "Write configuration"
    def write_conf():
@@ -180,10 +180,9 @@ def configuration(self, TNotebook1, config_interface, config_file):
        }
        try:
            Utils.write_config_file("../config/config_MS2830A.json", config_file)
            print("Scrittura del file di configurazione eseguita con successo")
            self.Text1.insert(tk.END, "Configuration file written successfully \n")
        except:
            print("La scrittura su file non è andata a buon fine")
        
            self.Text1.insert(tk.END, "Error writing configuration file \n")
        
    self.Button1 = tk.Button(self.TNotebook1_t2)
    self.Button1.place(relx=0.035, rely=y_button, height=h_button, width=w_button)
@@ -194,7 +193,11 @@ def configuration(self, TNotebook1, config_interface, config_file):
    def set_conf():
        global instr
        instr = SPA.Anritsu_MS2830A("Anritsu_MS2830A",config_interface[self.selected_interface.get()])
        Utils.set_SPA_for_measure(instr, config_file, self.Entry10.get())
        log_list = Utils.set_SPA_for_measure(instr, config_file, self.Entry10.get())
        self.Text1.insert(tk.END, "Configuration\n")
        for l in log_list:
            self.Text1.insert(tk.END, l + "\n")


    self.Button2 = tk.Button(self.TNotebook1_t2)
    self.Button2.place(relx=0.350, rely=y_button, height=h_button, width=w_button)
@@ -205,6 +208,8 @@ def configuration(self, TNotebook1, config_interface, config_file):
    def plot_data():
        trace = instr.get_trace(1) # Get trace
        Utils.plot_lineplot(trace)
        self.Text1.insert(tk.END, "Data plotted\n")


    self.Button3 = tk.Button(self.TNotebook1_t2)
    self.Button3.place(relx=0.665, rely=y_button, height=h_button, width=w_button)
+2 −3
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ def connect(self, TNotebook1, config_interface, config_file):
    
    self.TNotebook1.add(self.TNotebook1_t1, padding=3)
    self.TNotebook1.tab(0, text="Connection",compound="left",underline="-1",)
    self.TNotebook1_t1.configure(cursor="arrow")

    # label
    self.Label0 = tk.Label(self.TNotebook1_t1)
@@ -41,7 +40,7 @@ def connect(self, TNotebook1, config_interface, config_file):

    options = [interface_key for interface_key, interface_value in config_interface.items()]
    self.selected_interface = tk.StringVar() # Dropmenu variable (store option choice)
    self.selected_interface.set(options[0]) # first element is selected as default
    self.selected_interface.set(options[0]) # first element (GPIB) is selected as default

    # text for log output    
    self.EntryMenu = tk.Entry(self.TNotebook1_t1, textvariable= self.selected_interface)