Commit 3ab29ca0 authored by LorenzoMonti's avatar LorenzoMonti
Browse files

Add User Interface and config files

Added a User Interface in order to support the users. Moreover, configuration file has been created
parent 2e84a94d
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
{
    "start_freq": 1000000000,
    "stop_freq": 4000000000,
    "center_freq": 2000000000,
    "sweep_trace_points": 5001,
    "resolution_bandwith": 1000000,
    "visual_bandwith": 100,
    "amplitude_log_scale": 1,
    "reference_level": -62,
    "zoom_spot_marker": [
        "1",
        "SPOT"
    ]
}
 No newline at end of file
+11 −0
Original line number Diff line number Diff line
{
    "start_freq": 1000000000,
    "stop_freq": 4000000000,
    "center_freq": 2000000000,
    "sweep_trace_points": 5001,
    "resolution_bandwith": 1000000,
    "visual_bandwith": 100,
    "amplitude_log_scale": 1,
    "reference_level": -62,
    "zoom_spot_marker": [1, "SPOT"]
}
+6 −0
Original line number Diff line number Diff line
{
    "gpib": "GPIB::18::INSTR",
    "remote_eth": "TCPIP0::localhost::49153::SOCKET",
    "local_eth": ""
}
+5002 −0

File added.

Preview size limit exceeded, changes collapsed.

+20 −10
Original line number Diff line number Diff line
@@ -3,9 +3,9 @@ import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import datetime
import json
  
  
def set_SPA_for_measure(ms2830a):
def set_SPA_for_measure(ms2830a, config_file):
        """
        This method allows to set the Anritsu MS2830A for the measurements
        """    
@@ -14,31 +14,31 @@ def set_SPA_for_measure(ms2830a):
        ms2830a.set_SPA()
        
        # Frequency
        ms2830a.do_set_startfreq(1000000000) # 1Ghz
        ms2830a.do_set_stopfreq(4000000000)
        ms2830a.do_set_centerfreq(2000000000)
        ms2830a.do_set_startfreq(config_file["start_freq"]) # 1Ghz
        ms2830a.do_set_stopfreq(config_file["stop_freq"])
        ms2830a.do_set_centerfreq(config_file["center_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()))
        
        # Time sweep
        ms2830a.set_trace_points_sweeptime(5001)
        ms2830a.set_trace_points_sweeptime(config_file["sweep_trace_points"])
        print("Sweep Trace points: " + str(ms2830a.get_trace_points_sweeptime()))

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

        # MARKER
        ms2830a.set_zoom_spot_marker(1, "SPOT")
        ms2830a.set_zoom_spot_marker(config_file["zoom_spot_marker"][0], config_file["zoom_spot_marker"][1])


def plot_lineplot(trace):
@@ -55,3 +55,13 @@ def save_data_as_csv(trace):
        dataset = pd.DataFrame(trace)
        dataset.to_csv("../data/measure-" + str(datetime.datetime.now()) + ".csv")

def read_config_file(filename):
        data = []
        with open(filename, 'r') as file:
                data = file.read()
        return json.loads(data)

def write_config_file(filename, confDict):
        json_obj = json.dumps(confDict, indent=4)
        with open(filename, 'w') as file:
                file.write(json_obj)
Loading