Ejemplo n.º 1
0
    def get_lrdata_xlist_t(self, sdata):
        sdef = sdf.StringDef(self.stype)
        xlist = []

        # F0
        xlist.append(float(sdata.get_f0()))

        # Main String
        msg = float(sdef.get_gauge(sdata.get_main_string()))
        msd = float(sdef.get_density(sdata.get_main_string()))
        # Cross String
        if sdata.get_cross_string() == '':
            csg = float(sdef.get_gauge(sdata.get_main_string()))
            csd = float(sdef.get_density(sdata.get_main_string()))
        else:
            csg = float(sdef.get_gauge(sdata.get_cross_string()))
            csd = float(sdef.get_density(sdata.get_cross_string()))

        # Main Gaug
        xlist.append(msg)
        # Main Density
        xlist.append(msd)
        # Cross Gauge
        xlist.append(csg)
        # Cross Density
        xlist.append(csd)
        # Face Size
        xlist.append(float(sdata.get_size()))
        # Main Pattern Number
        xlist.append(sdata.get_main_pat_n())
        # Cross Pattern Number
        xlist.append(sdata.get_cross_pat_n())
        return xlist
Ejemplo n.º 2
0
    def get_lrdata_xlist_b(self, sdata):
        sdef = sdf.StringDef(self.stype)
        xlist = []

        # F0
        xlist.append(float(sdata.get_f0()))

        # Main String
        msg = float(sdef.get_gauge(sdata.get_main_string()))
        # Cross String
        if sdata.get_cross_string() == '':
            csg = float(sdef.get_gauge(sdata.get_main_string()))
        else:
            csg = float(sdef.get_gauge(sdata.get_cross_string()))

        # Gauge AVG
        xlist.append((msg + csg) / 2.0)

        return xlist
Ejemplo n.º 3
0
    def get_lrdata_xlist_b(self, sdata):
        sdef = sdf.StringDef(self.stype)
        xlist = []

        # F0
        xlist.append(float(sdata.get_f0()))

        # Main String
        msg = float(sdef.get_gauge(sdata.get_main_string()))
        # Cross String
        if sdata.get_cross_string() == '':
            csg = float(sdef.get_gauge(sdata.get_main_string()))
        else:
            csg = float(sdef.get_gauge(sdata.get_cross_string()))

        # Main Gauge
        xlist.append(msg)
        # Cross Gauge
        xlist.append(csg)

        # Face Size
        xlist.append(float(sdata.get_size()))
        return xlist
Ejemplo n.º 4
0
    sdata = sda.StringData()
    sdata.make_data(wavfile)
    stype = sdata.get_stype()
    stglr = slr.StringLr01(stype)
    xlist = stglr.get_lrdata_xlist(sdata)
    if cnt == 0:
        dt0 = sdata.get_datetime()
    td = sdata.get_datetime() - dt0
    hours = td.total_seconds() / 3600.0
    x.append(hours)
    y.append(stglr.get_lrcal_tension(xlist))
    yy.append(sdata.get_tension())
    cnt += 1
    x_max = td.seconds

# Show graph
sdef = sde.StringDef(stype)
if sdata.get_cross_string() == "":
    plt_title = sdef.get_name(sdata.get_main_string())
else:
    plt_title = sdef.get_name(sdata.get_main_string()) + " / " + sdef.get_name(
        sdata.get_cross_string())

plt.title(plt_title)
plt.xlabel("Time (Hours)")
plt.ylabel("Tension (lbs)")
plt.plot(x, y, label="predicted Tension")
plt.plot(x, yy, label="Machine Tension")
plt.legend()
plt.show()
Ejemplo n.º 5
0
def run_click():
    # run_btn.grid_forget()
    # data_exp_label_text.set("Recording...")
    messagebox.showinfo(
        "Rcording",
        "After ckicking [OK] button,\nplease hit your racket face near PC.")

    sdef = sde.StringDef(stype)
    main_s = ""
    cross_s = ""
    if main_s_comb.get() != "":
        main_s = sdef.get_key_from_name(main_s_comb.get())
    if cross_s_comb.get() != "":
        cross_s = sdef.get_key_from_name(cross_s_comb.get())

    args = ""
    if stype == "B":
        args = sda.get_argstr(stype, main_t_comb.get(), cross_t_comb.get(),
                              main_s, cross_s, size_comb.get(), "", "")
    if stype == "T":
        args = sda.get_argstr(stype, main_t_comb.get(), cross_t_comb.get(),
                              main_s, cross_s, size_comb.get(),
                              main_n_comb.get(), cross_n_comb.get())

    csv_append = 0
    if data_comb.get() == "Yes":
        csv_append = 1

    if csv_append == 0:
        srec = sre.StringRec(args, "tmp/")
    if csv_append == 1:
        srec = sre.StringRec(args)

    # data_exp_label_text.set("Calculating...")

    tension = []
    for filename in srec.get_file_list():
        sdata = sda.StringData()
        sdata.make_data(filename)
        stglr = slr.StringLr01(stype)
        xlist = stglr.get_lrdata_xlist(sdata)
        tension.append(stglr.get_lrcal_tension(xlist))

    tension_error = 0.0
    for i, val in enumerate(tension):
        tension_error += abs(tension[0] - val)
    tension_error = tension_error / (len(tension) - 1)
    print("MAError = " + str(tension_error))

    rstr = ""
    if tension_error > sda.tension_error_val[stype]:
        for filename in srec.get_file_list():
            os.remove(filename)
            print("Removed: " + filename)
        rstr = "Measurement error.\nPlease try again."
    else:
        if csv_append == 1:
            for filename in srec.get_file_list():
                sdata = sda.StringData()
                sdata.make_data(filename, csv_append)
        total = 0.0
        avg = 0.0
        for i, val in enumerate(tension):
            rstr += str(i + 1) + ": " + str(round(val, 2)) + " lbs\n"
            total += float(val)
        avg = total / len(tension)
        rstr += "Average: " + str(round(avg, 2)) + " lbs"

    srec.init_file_list()

    messagebox.showinfo("Results", rstr)
    print(rstr)

    main_win.focus_force()
Ejemplo n.º 6
0
def make_win():
    global main_win
    main_win = tk.Tk()
    win_w = main_win.winfo_screenwidth()
    win_h = main_win.winfo_screenheight()
    app_w = 530
    app_h = 285
    if stype == "B":
        app_h = 230
    main_win.geometry(get_center_geometry_str(win_w, win_h, app_w, app_h))
    main_win.title("Stringing DATA")

    main_frm = ttk.Frame(main_win)
    main_frm.grid(column=0, row=0, sticky=tk.NSEW, padx=5, pady=10)

    sdef = sde.StringDef(stype)
    if stype == "T":
        t_list = list(range(0, 81))
        t_current = 50
    if stype == "B":
        t_list = list(range(0, 41))
        t_current = 20

    main_t_label = ttk.Label(main_frm, text="Main Tension (lbs)")
    global main_t_comb
    main_t_comb = ttk.Combobox(main_frm,
                               values=t_list,
                               state="readonly",
                               width=5)
    main_t_comb.current(t_current)
    cross_t_label = ttk.Label(main_frm, text="Cross Tension (lbs)")
    global cross_t_comb
    cross_t_comb = ttk.Combobox(main_frm,
                                values=t_list,
                                state="readonly",
                                width=5)
    main_s_label = ttk.Label(main_frm, text="Main String")
    global main_s_comb
    main_s_comb = ttk.Combobox(main_frm,
                               values=sdef.get_name_list(),
                               state="readonly",
                               width=30)
    main_s_comb.current(0)
    cross_s_label = ttk.Label(main_frm, text="Cross String")
    global cross_s_comb
    cross_s_comb = ttk.Combobox(main_frm,
                                values=sdef.get_name_list(),
                                state="readonly",
                                width=30)

    if stype == "T":
        s_list = list(range(70, 141))
        s_current = 30
    if stype == "B":
        s_list = list(range(50, 61))
        s_current = 6

    size_label = ttk.Label(main_frm, text="Face Size (in2)")
    global size_comb
    size_comb = ttk.Combobox(main_frm,
                             values=s_list,
                             state="readonly",
                             width=5)
    size_comb.current(s_current)

    if stype == "T":
        pat_list = list(range(0, 31))
        main_n_label = ttk.Label(main_frm, text="Main Number")
        global main_n_comb
        main_n_comb = ttk.Combobox(main_frm,
                                   values=pat_list,
                                   state="readonly",
                                   width=5)
        main_n_comb.current(16)
        cross_n_label = ttk.Label(main_frm, text="Cross Number")
        global cross_n_comb
        cross_n_comb = ttk.Combobox(main_frm,
                                    values=pat_list,
                                    state="readonly",
                                    width=5)
        cross_n_comb.current(19)

    data_label = ttk.Label(main_frm, text="Append DATA")
    global data_exp_label
    global data_exp_label_text
    data_exp_label_text = tk.StringVar()
    data_exp_label_text.set(
        "If you have just finished stringing, select Append DATA = Yes.")
    data_exp_label = ttk.Label(main_frm, textvariable=data_exp_label_text)
    global data_comb
    data_comb = ttk.Combobox(main_frm,
                             values=["Yes", "No"],
                             state="readonly",
                             width=5)
    data_comb.current(1)
    global run_btn
    run_btn = ttk.Button(main_frm, text="RUN", command=run_click)
    global top_btn
    top_btn = ttk.Button(main_frm, text="Back to top", command=top_click)

    main_t_label.grid(column=0, row=0)
    main_t_comb.grid(column=1, row=0, sticky=tk.W, padx=5)
    cross_t_label.grid(column=0, row=1)
    cross_t_comb.grid(column=1, row=1, sticky=tk.W, padx=5)
    main_s_label.grid(column=0, row=2)
    main_s_comb.grid(column=1, row=2, sticky=tk.W, padx=5)
    cross_s_label.grid(column=0, row=3)
    cross_s_comb.grid(column=1, row=3, sticky=tk.W, padx=5)
    size_label.grid(column=0, row=4)
    size_comb.grid(column=1, row=4, sticky=tk.W, padx=5)
    if stype == "T":
        main_n_label.grid(column=0, row=5)
        main_n_comb.grid(column=1, row=5, sticky=tk.W, padx=5)
        cross_n_label.grid(column=0, row=6)
        cross_n_comb.grid(column=1, row=6, sticky=tk.W, padx=5)
        data_label.grid(column=0, row=7)
        data_comb.grid(column=1, row=7, sticky=tk.W, padx=5)
        data_exp_label.grid(column=1, row=8)
        top_btn.grid(column=0, row=9)
        run_btn.grid(column=1, row=9)
    else:
        data_label.grid(column=0, row=5)
        data_comb.grid(column=1, row=5, sticky=tk.W, padx=5)
        data_exp_label.grid(column=1, row=6)
        top_btn.grid(column=0, row=7)
        run_btn.grid(column=1, row=7)

    main_win.columnconfigure(0, weight=1)
    main_win.rowconfigure(0, weight=1)
    main_win.columnconfigure(0, weight=1)

    main_win.mainloop()