Example #1
0
    def changePara():
        write = ['N/A'] * 4
        d = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            aoo_aa_p = AA_roll.get()
            if aoo_aa_p == 'OFF':
                aoo_aa_p = 0
            else:
                aoo_aa_p = int(100 * float(aoo_aa_p))
            write[3] = APW_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_AOO,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_AOO,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode=1,
                          Lower_Rate=int(LRL_roll.get()),
                          ATR_Amplitude=int(aoo_aa_p),
                          ATR_Width=int(APW_roll.get()))

                with open("parameterAOO.txt", "w") as parameterFile:
                    while (d < 4):
                        parameterFile.write(
                            write[d] +
                            "\n")  #Write every index of list write[] into file
                        d += 1
                    d = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                apwLabel.set(write[3])
                paraWindow.destroy()
Example #2
0
def AAIR_window(upper_tk=None):

    global root_AAIR
    global lrlLabel
    global urlLabel
    global aaLabel
    global apwLabel
    global msrLabel
    global atLabel
    global reacLabel
    global rfLabel
    global recoLabel
    global asLabel
    global arpLabel
    global pvarpLabel
    global rsLabel

    global connectLable

    index = 0

    try:
        with open("parameterAAIR.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    except FileNotFoundError:
        with open("parameterAAIR.txt", "w") as parameterFile:
            while (index < 13):
                parameterFile.write("N/A\n")
                index += 1
            index = 0
        with open("parameterAAIR.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    root_AAIR = tk.Toplevel()
    root_AAIR.title('AAIR')
    root_AAIR.geometry('500x650')

    label = tk.Label(root_AAIR,
                     text="Current Mode:   AAIR",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(root_AAIR,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    label = tk.Label(root_AAIR,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    label = tk.Label(root_AAIR,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    label = tk.Label(root_AAIR,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=200)
    label = tk.Label(root_AAIR,
                     text="Maximum Sensor Rate (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=240)
    label = tk.Label(root_AAIR,
                     text="Activity Threshold:",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    label = tk.Label(root_AAIR,
                     text="Reaction Time (sec):",
                     font=("Times New Roman", 14)).place(x=10, y=320)
    label = tk.Label(root_AAIR,
                     text="Response Factor:",
                     font=("Times New Roman", 14)).place(x=10, y=360)
    label = tk.Label(root_AAIR,
                     text="Recovery Time (min):",
                     font=("Times New Roman", 14)).place(x=10, y=400)
    label = tk.Label(root_AAIR,
                     text="Atrial Sensitivity (V):",
                     font=("Times New Roman", 14)).place(x=10, y=440)
    label = tk.Label(root_AAIR,
                     text="Atrial Refractory Period (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=480)
    label = tk.Label(root_AAIR,
                     text="PVARP (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=520)
    label = tk.Label(root_AAIR,
                     text="Rate Smoothing (%):",
                     font=("Times New Roman", 14)).place(x=10, y=560)

    connectLable = tk.StringVar()
    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(root_AAIR,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(root_AAIR,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    lrlLabel = tk.StringVar()
    lrlLabel.set(read[0].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=lrlLabel,
                     font=("Times New Roman", 14)).place(x=320, y=80)

    urlLabel = tk.StringVar()
    urlLabel.set(read[1].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=urlLabel,
                     font=("Times New Roman", 14)).place(x=320, y=120)

    aaLabel = tk.StringVar()
    aaLabel.set(read[2].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=aaLabel,
                     font=("Times New Roman", 14)).place(x=320, y=160)

    apwLabel = tk.StringVar()
    apwLabel.set(read[3].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=apwLabel,
                     font=("Times New Roman", 14)).place(x=320, y=200)

    msrLabel = tk.StringVar()
    msrLabel.set(read[4].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=msrLabel,
                     font=("Times New Roman", 14)).place(x=320, y=240)

    atLabel = tk.StringVar()
    atLabel.set(read[5].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=atLabel,
                     font=("Times New Roman", 14)).place(x=320, y=280)

    reacLabel = tk.StringVar()
    reacLabel.set(read[6].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=reacLabel,
                     font=("Times New Roman", 14)).place(x=320, y=320)

    rfLabel = tk.StringVar()
    rfLabel.set(read[7].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=rfLabel,
                     font=("Times New Roman", 14)).place(x=320, y=360)

    recoLabel = tk.StringVar()
    recoLabel.set(read[8].strip("\n"))
    label = tk.Label(root_AAIR,
                     textvariable=recoLabel,
                     font=("Times New Roman", 14)).place(x=320, y=400)

    asLabel = tk.StringVar()
    asLabel.set(read[9].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_AAIR,
                     textvariable=asLabel,
                     font=("Times New Roman", 14)).place(x=320, y=440)

    arpLabel = tk.StringVar()
    arpLabel.set(read[10].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_AAIR,
                     textvariable=arpLabel,
                     font=("Times New Roman", 14)).place(x=320, y=480)

    pvarpLabel = tk.StringVar()
    pvarpLabel.set(read[6].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_AAIR,
                     textvariable=pvarpLabel,
                     font=("Times New Roman", 14)).place(x=320, y=520)

    rsLabel = tk.StringVar()
    rsLabel.set(read[11].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_AAIR,
                     textvariable=rsLabel,
                     font=("Times New Roman", 14)).place(x=320, y=560)

    #modeWindowButton = tk.Button(root_AAIR, text = "Change Mode", command = lambda:[root_AAIR.destroy()], width = 13).place(x = 300, y = 10)
    paraWindowButton = tk.Button(root_AAIR,
                                 text="Change Parameter",
                                 command=AAIR_ParameterWindow,
                                 width=20,
                                 height=1).place(x=200, y=600)
Example #3
0
    def changePara():
        write = ['N/A'] * 13
        p = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            aair_aa_p = AA_roll.get()
            if aair_aa_p == 'OFF':
                aair_aa_p = 0
            else:
                aair_aa_p = int(100 * float(aair_aa_p))
            write[3] = APW_roll.get()
            write[4] = MSR_roll.get()
            write[5] = AT_roll.get()
            aair_at_p = AT_roll.get()
            if aair_at_p == 'V-Low':
                aair_at_p = 0.5
            elif aair_at_p == 'Low':
                aair_at_p = 1.0
            elif aair_at_p == 'Med-Low':
                aair_at_p = 1.5
            elif aair_at_p == 'Med':
                aair_at_p = 1.75
            elif aair_at_p == 'Med-High':
                aair_at_p = 2.0
            elif aair_at_p == 'High':
                aair_at_p = 2.5
            elif aair_at_p == 'V_High':
                aair_at_p = 3.0
            write[6] = REAC_roll.get()
            aair_reac_p = REAC_roll.get()
            if aair_reac_p == '5(Test)':
                aair_reac_p = 5
            write[7] = RF_roll.get()
            write[8] = RECO_roll.get()
            aair_reco_p = RECO_roll.get()
            if aair_reco_p == '0.1(Test)':
                aair_reco_p = 6
            else:
                aair_reco_p = 60 * int(aair_reco_p)
            write[9] = AS_roll.get()
            write[10] = ARP_roll.get()
            write[11] = PVARP_roll.get()
            write[12] = RS_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_AAIR,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_AAIR,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode = 9, Lower_Rate = int(LRL_roll.get()), MSR = int(MSR_roll.get()), ATR_Amplitude = int(aair_aa_p), ATR_Width = int(APW_roll.get()), \
                    ATR_Refractory = int(ARP_roll.get()), Activity_Threshold = aair_at_p, Reaction_Time = int(aair_reac_p), Response_Factor = int(RF_roll.get()), \
                    Recovery_Time = int(aair_reco_p))

                with open("parameterAAIR.txt", "w") as parameterFile:
                    while (p < 13):
                        parameterFile.write(
                            write[p] +
                            "\n")  #Write every index of list write[] into file
                        p += 1
                    p = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                apwLabel.set(write[3])
                msrLabel.set(write[4])
                atLabel.set(write[5])
                reacLabel.set(write[6])
                rfLabel.set(write[7])
                recoLabel.set(write[8])
                asLabel.set(write[9])
                arpLabel.set(write[10])
                pvarpLabel.set(write[11])
                rsLabel.set(write[12])
                paraWindow.destroy()
Example #4
0
def AAIR_ParameterWindow():

    with open("parameterAAIR.txt", "r") as parameterFile:
        readpara = parameterFile.readlines()

    global paraWindow

    paraWindow = tk.Toplevel()
    paraWindow.title('AAIR Parameter Setting')
    paraWindow.geometry('500x650')
    label = tk.Label(paraWindow,
                     text="Current Mode   AAIR",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(paraWindow,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    LRL_data = ['30', '35', '40', '45']
    for i in range(50, 90):
        LRL_data.append(i)
    for j in range(90, 180):
        if j % 5 == 0:
            LRL_data.append(j)
    LRL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    LRL_roll['values'] = LRL_data
    LRL_roll.place(x=320, y=80)
    if readpara[0] != 'N/A\n':  #Secret
        LRL_roll.set(readpara[0].strip("\n"))
    else:
        LRL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    URL_data = []
    for k in range(50, 180):
        if k % 5 == 0:
            URL_data.append(k)

    URL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    URL_roll['values'] = URL_data
    URL_roll.place(x=320, y=120)
    if readpara[1] != 'N/A\n':
        URL_roll.set(readpara[1].strip("\n"))
    else:
        URL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    AA_data = ['OFF']
    for a in range(1, 51):
        AA_data.append(float(a / 10))

    AA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AA_roll['values'] = AA_data
    AA_roll.place(x=320, y=160)
    if readpara[2] != 'N/A\n':
        AA_roll.set(readpara[2].strip("\n"))
    else:
        AA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=200)
    APW_data = []
    for c in range(1, 31):
        APW_data.append(c)

    APW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    APW_roll['values'] = APW_data
    APW_roll.place(x=320, y=200)
    if readpara[3] != 'N/A\n':
        APW_roll.set(readpara[3].strip("\n"))
    else:
        APW_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Maximum Sensor Rate (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=240)

    MSR_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    MSR_roll['values'] = URL_data
    MSR_roll.place(x=320, y=240)
    if readpara[4] != 'N/A\n':
        MSR_roll.set(readpara[4].strip("\n"))
    else:
        MSR_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Activity Threshold:",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    AT_data = ['V-Low', 'Low', 'Med-Low', 'Med', 'Med-High', 'High', 'V-High']

    AT_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AT_roll['values'] = AT_data
    AT_roll.place(x=320, y=280)
    if readpara[5] != 'N/A\n':
        AT_roll.set(readpara[5].strip("\n"))
    else:
        AT_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Reaction Time (sec)",
                     font=("Times New Roman", 14)).place(x=10, y=320)
    REAC_data = ['5(Test)', '10', '20', '30', '40', '50']

    REAC_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    REAC_roll['values'] = REAC_data
    REAC_roll.place(x=320, y=320)
    if readpara[6] != 'N/A\n':
        REAC_roll.set(readpara[6].strip("\n"))
    else:
        REAC_roll.current(1)

    label = tk.Label(paraWindow,
                     text="Response Factor:",
                     font=("Times New Roman", 14)).place(x=10, y=360)
    RF_data = []
    for a in range(1, 17):
        RF_data.append(a)
    RF_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    RF_roll['values'] = RF_data
    RF_roll.place(x=320, y=360)
    if readpara[7] != 'N/A\n':
        RF_roll.set(readpara[7].strip("\n"))
    else:
        RF_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Recovery Time (min):",
                     font=("Times New Roman", 14)).place(x=10, y=400)
    RECO_data = ['0.1(Test)']
    for a in range(2, 17):
        RECO_data.append(a)
    RECO_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    RECO_roll['values'] = RECO_data
    RECO_roll.place(x=320, y=400)
    if readpara[8] != 'N/A\n':
        RECO_roll.set(readpara[8].strip("\n"))
    else:
        RECO_roll.current(1)

    label = tk.Label(paraWindow,
                     text="Atrial Sensitivity (V):",
                     font=("Times New Roman", 14)).place(x=10, y=440)
    AS_data = ['0']
    for c in range(1, 51):
        AS_data.append(float(c / 10))

    AS_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AS_roll['values'] = AS_data
    AS_roll.place(x=320, y=440)
    if readpara[9] != 'N/A\n':
        AS_roll.set(readpara[9].strip("\n"))
    else:
        AS_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Refractory Period (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=480)
    ARP_data = []
    for p in range(15, 51):
        ARP_data.append(p)

    ARP_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    ARP_roll['values'] = ARP_data
    ARP_roll.place(x=320, y=480)
    if readpara[10] != 'N/A\n':
        ARP_roll.set(readpara[10].strip("\n"))
    else:
        ARP_roll.current(0)

    label = tk.Label(paraWindow,
                     text="PVARP (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=520)
    PVARP_roll = ttk.Combobox(paraWindow,
                              width=15,
                              height=10,
                              state='readonly')
    PVARP_roll['values'] = ARP_data
    PVARP_roll.place(x=320, y=520)
    if readpara[11] != 'N/A\n':
        PVARP_roll.set(readpara[11].strip("\n"))
    else:
        PVARP_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Rate Smoothing (%):",
                     font=("Times New Roman", 14)).place(x=10, y=560)
    RS_data = ['OFF', '3', '6', '9', '12', '15', '18', '21', '25']

    RS_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    RS_roll['values'] = RS_data
    RS_roll.place(x=320, y=560)
    if readpara[12] != 'N/A\n':
        RS_roll.set(readpara[12].strip("\n"))
    else:
        RS_roll.current(0)

    connectLable = tk.StringVar()
    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    def changePara():
        write = ['N/A'] * 13
        p = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            aair_aa_p = AA_roll.get()
            if aair_aa_p == 'OFF':
                aair_aa_p = 0
            else:
                aair_aa_p = int(100 * float(aair_aa_p))
            write[3] = APW_roll.get()
            write[4] = MSR_roll.get()
            write[5] = AT_roll.get()
            aair_at_p = AT_roll.get()
            if aair_at_p == 'V-Low':
                aair_at_p = 0.5
            elif aair_at_p == 'Low':
                aair_at_p = 1.0
            elif aair_at_p == 'Med-Low':
                aair_at_p = 1.5
            elif aair_at_p == 'Med':
                aair_at_p = 1.75
            elif aair_at_p == 'Med-High':
                aair_at_p = 2.0
            elif aair_at_p == 'High':
                aair_at_p = 2.5
            elif aair_at_p == 'V_High':
                aair_at_p = 3.0
            write[6] = REAC_roll.get()
            aair_reac_p = REAC_roll.get()
            if aair_reac_p == '5(Test)':
                aair_reac_p = 5
            write[7] = RF_roll.get()
            write[8] = RECO_roll.get()
            aair_reco_p = RECO_roll.get()
            if aair_reco_p == '0.1(Test)':
                aair_reco_p = 6
            else:
                aair_reco_p = 60 * int(aair_reco_p)
            write[9] = AS_roll.get()
            write[10] = ARP_roll.get()
            write[11] = PVARP_roll.get()
            write[12] = RS_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_AAIR,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_AAIR,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode = 9, Lower_Rate = int(LRL_roll.get()), MSR = int(MSR_roll.get()), ATR_Amplitude = int(aair_aa_p), ATR_Width = int(APW_roll.get()), \
                    ATR_Refractory = int(ARP_roll.get()), Activity_Threshold = aair_at_p, Reaction_Time = int(aair_reac_p), Response_Factor = int(RF_roll.get()), \
                    Recovery_Time = int(aair_reco_p))

                with open("parameterAAIR.txt", "w") as parameterFile:
                    while (p < 13):
                        parameterFile.write(
                            write[p] +
                            "\n")  #Write every index of list write[] into file
                        p += 1
                    p = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                apwLabel.set(write[3])
                msrLabel.set(write[4])
                atLabel.set(write[5])
                reacLabel.set(write[6])
                rfLabel.set(write[7])
                recoLabel.set(write[8])
                asLabel.set(write[9])
                arpLabel.set(write[10])
                pvarpLabel.set(write[11])
                rsLabel.set(write[12])
                paraWindow.destroy()

    saveButton = tk.Button(paraWindow,
                           text="Save",
                           command=changePara,
                           width=13).place(x=50, y=600)
    cancelButton = tk.Button(paraWindow,
                             text="Cancel",
                             command=lambda: [paraWindow.destroy()],
                             width=13).place(x=220, y=600)
Example #5
0
def DOOR_ParameterWindow():

    with open("parameterDOOR.txt", "r") as parameterFile:
        readpara = parameterFile.readlines()

    global paraWindow

    paraWindow = tk.Toplevel()
    paraWindow.title('DOOR Parameter Setting')
    paraWindow.geometry('500x650')
    label = tk.Label(paraWindow,
                     text="Current Mode   DOOR",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(paraWindow,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    LRL_data = ['30', '35', '40', '45']
    for i in range(50, 90):
        LRL_data.append(i)
    for j in range(90, 180):
        if j % 5 == 0:
            LRL_data.append(j)
    LRL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    LRL_roll['values'] = LRL_data
    LRL_roll.place(x=320, y=80)
    if readpara[0] != 'N/A\n':  #Secret
        LRL_roll.set(readpara[0].strip("\n"))
    else:
        LRL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    URL_data = []
    for k in range(50, 180):
        if k % 5 == 0:
            URL_data.append(k)

    URL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    URL_roll['values'] = URL_data
    URL_roll.place(x=320, y=120)
    if readpara[1] != 'N/A\n':
        URL_roll.set(readpara[1].strip("\n"))
    else:
        URL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    AA_data = ['OFF']
    for a in range(1, 51):
        AA_data.append(float(a / 10))

    AA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AA_roll['values'] = AA_data
    AA_roll.place(x=320, y=160)
    if readpara[2] != 'N/A\n':
        AA_roll.set(readpara[2].strip("\n"))
    else:
        AA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Ventricular Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=200)

    VA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    VA_roll['values'] = AA_data
    VA_roll.place(x=320, y=200)
    if readpara[3] != 'N/A\n':
        VA_roll.set(readpara[3].strip("\n"))
    else:
        VA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=240)
    APW_data = []
    for c in range(1, 31):
        APW_data.append(c)

    APW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    APW_roll['values'] = APW_data
    APW_roll.place(x=320, y=240)
    if readpara[4] != 'N/A\n':
        APW_roll.set(readpara[4].strip("\n"))
    else:
        APW_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Ventricular Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    VPW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    VPW_roll['values'] = APW_data
    VPW_roll.place(x=320, y=280)
    if readpara[5] != 'N/A\n':
        VPW_roll.set(readpara[5].strip("\n"))
    else:
        VPW_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Fixed AV Delay (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=320)
    DELAY_data = []
    for b in range(7, 31):
        DELAY_data.append(b * 10)
    DELAY_roll = ttk.Combobox(paraWindow,
                              width=15,
                              height=10,
                              state='readonly')
    DELAY_roll['values'] = DELAY_data
    DELAY_roll.place(x=320, y=320)
    if readpara[6] != 'N/A\n':
        DELAY_roll.set(readpara[6].strip("\n"))
    else:
        DELAY_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Maximum Sensor Rate (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=360)

    MSR_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    MSR_roll['values'] = URL_data
    MSR_roll.place(x=320, y=360)
    if readpara[7] != 'N/A\n':
        MSR_roll.set(readpara[7].strip("\n"))
    else:
        MSR_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Activity Threshold:",
                     font=("Times New Roman", 14)).place(x=10, y=400)
    AT_data = ['V-Low', 'Low', 'Med-Low', 'Med', 'Med-High', 'High', 'V-High']
    AT_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AT_roll['values'] = AT_data
    AT_roll.place(x=320, y=400)
    if readpara[8] != 'N/A\n':
        AT_roll.set(readpara[8].strip("\n"))
    else:
        AT_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Reaction Time (sec)",
                     font=("Times New Roman", 14)).place(x=10, y=440)
    REAC_data = ['5(Test)', '10', '20', '30', '40', '50']

    REAC_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    REAC_roll['values'] = REAC_data
    REAC_roll.place(x=320, y=440)
    if readpara[9] != 'N/A\n':
        REAC_roll.set(readpara[9].strip("\n"))
    else:
        REAC_roll.current(1)

    label = tk.Label(paraWindow,
                     text="Response Factor:",
                     font=("Times New Roman", 14)).place(x=10, y=480)
    RF_data = []
    for p in range(1, 17):
        RF_data.append(p)
    RF_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    RF_roll['values'] = RF_data
    RF_roll.place(x=320, y=480)
    if readpara[10] != 'N/A\n':
        RF_roll.set(readpara[10].strip("\n"))
    else:
        RF_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Recovery Time (min):",
                     font=("Times New Roman", 14)).place(x=10, y=520)
    RECO_data = ['0.1(Test)']
    for q in range(2, 17):
        RECO_data.append(q)
    RECO_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    RECO_roll['values'] = RECO_data
    RECO_roll.place(x=320, y=520)
    if readpara[11] != 'N/A\n':
        RECO_roll.set(readpara[11].strip("\n"))
    else:
        RECO_roll.current(1)

    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    def changePara():
        write = ['N/A'] * 12
        d = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            door_aa_p = AA_roll.get()
            if door_aa_p == 'OFF':
                door_aa_p = 0
            else:
                door_aa_p = int(100 * float(door_aa_p))
            write[3] = VA_roll.get()
            door_va_p = VA_roll.get()
            if door_va_p == 'OFF':
                door_va_p = 0
            else:
                door_va_p = int(100 * float(door_va_p))
            write[4] = APW_roll.get()
            write[5] = VPW_roll.get()
            write[6] = DELAY_roll.get()
            write[7] = MSR_roll.get()
            write[8] = AT_roll.get()
            door_at_p = AT_roll.get()
            if door_at_p == 'V-Low':
                door_at_p = 0.5
            elif door_at_p == 'Low':
                door_at_p = 1.0
            elif door_at_p == 'Med-Low':
                door_at_p = 1.5
            elif door_at_p == 'Med':
                door_at_p = 1.75
            elif door_at_p == 'Med-High':
                door_at_p = 2.0
            elif door_at_p == 'High':
                door_at_p = 2.5
            elif door_at_p == 'V_High':
                door_at_p = 3.0
            write[9] = REAC_roll.get()
            door_reac_p = REAC_roll.get()
            if door_reac_p == '5(Test)':
                door_reac_p = 5
            write[10] = RF_roll.get()
            write[11] = RECO_roll.get()
            door_reco_p = RECO_roll.get()
            if door_reco_p == '0.1(Test)':
                door_reco_p = 6
            else:
                door_reco_p = 60 * int(door_reco_p)

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_DOOR,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_DOOR,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode = 10, Lower_Rate = int(LRL_roll.get()), MSR = int(MSR_roll.get()), AV_Delay = int(DELAY_roll.get()), ATR_Amplitude = int(door_aa_p), \
                    VENT_Amplitude = int(door_va_p),  ATR_Width = int(APW_roll.get()), VENT_Width = int(VPW_roll.get()), Activity_Threshold = door_at_p, \
                    Reaction_Time = int(door_reac_p), Response_Factor = int(RF_roll.get()), Recovery_Time = int(door_reco_p))

                with open("parameterDOOR.txt", "w") as parameterFile:
                    while (d < 12):
                        parameterFile.write(
                            write[d] +
                            "\n")  #Write every index of list write[] into file
                        d += 1
                    d = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                vaLabel.set(write[3])
                apwLabel.set(write[4])
                vpwLabel.set(write[5])
                delayLabel.set(write[6])
                msrLabel.set(write[7])
                atLabel.set(write[8])
                reacLabel.set(write[9])
                rfLabel.set(write[10])
                recoLabel.set(write[11])
                paraWindow.destroy()

    saveButton = tk.Button(paraWindow,
                           text="Save",
                           command=changePara,
                           width=13).place(x=50, y=570)
    cancelButton = tk.Button(paraWindow,
                             text="Cancel",
                             command=lambda: [paraWindow.destroy()],
                             width=13).place(x=220, y=570)
Example #6
0
def egramCheck():
        if checkConnect() == 6:
                        tkinter.messagebox.showerror("Error","Failed to connect to Pacemaker")
        else:
                egram()
Example #7
0
def writePara(mode=6,
              Lower_Rate=60,
              MSR=120,
              AV_Delay=100,
              ATR_Amplitude=70,
              VENT_Amplitude=75,
              ATR_Width=1,
              VENT_Width=2,
              VENT_Refractory=350,
              ATR_Refractory=250,
              Activity_Threshold=1.7,
              Reaction_Time=5,
              Response_Factor=1000,
              Recovery_Time=5):
    if checkConnect() == 3:
        ser = serial.Serial(port="COM3", baudrate=115200)
    elif checkConnect() == 4:
        ser = serial.Serial(port="COM4", baudrate=115200)
    elif checkConnect() == 5:
        ser = serial.Serial(port="COM5", baudrate=115200)
    Header = '<3B10H1d2H'
    Buffer1 = 40
    spk = struct.pack(Header, 0x16, 0x55, mode, Lower_Rate, ATR_Amplitude,
                      VENT_Amplitude, ATR_Width, VENT_Width, ATR_Refractory,
                      VENT_Refractory, MSR, Reaction_Time, Recovery_Time,
                      Activity_Threshold, AV_Delay, Response_Factor)
    ser.write(spk)
    serialdata = ser.read(49)
    modeV = serialdata[0]
    LRLV = struct.unpack('H', serialdata[1:3])
    ATR_AMPV = struct.unpack('H', serialdata[3:5])
    VENT_AMPV = struct.unpack('H', serialdata[5:7])
    A_WidthV = struct.unpack('H', serialdata[7:9])
    V_WidthV = struct.unpack('H', serialdata[9:11])
    VRPV = struct.unpack('H', serialdata[11:13])
    ARPV = struct.unpack('H', serialdata[13:15])
    MSRV = struct.unpack('H', serialdata[15:17])
    ReactionTV = struct.unpack('H', serialdata[17:19])
    RecoveryTV = struct.unpack('H', serialdata[19:21])
    ThresholdV = struct.unpack('d', serialdata[21:29])
    AVdV = struct.unpack('H', serialdata[29:31])
    RCV = struct.unpack('H', serialdata[31:33])
    print(LRLV[0])
    if ((modeV == mode) & (LRLV[0] == Lower_Rate) &
        (ATR_AMPV[0] == ATR_Amplitude) & (VENT_AMPV[0] == VENT_Amplitude)
            & (A_WidthV[0] == ATR_Width) & (V_WidthV[0] == VENT_Width) &
        (VRPV[0] == VENT_Refractory) & (ARPV[0] == ATR_Refractory)
            & (MSRV[0] == MSR) & (ReactionTV[0] == Reaction_Time) &
        (RecoveryTV[0] == Recovery_Time) &
        (ThresholdV[0] == Activity_Threshold)
            & (AVdV[0] == AV_Delay) & (RCV[0] == Response_Factor)):

        ve = 1
        tkinter.messagebox.showinfo('Great', 'Parameters all set')
    else:

        ve = 2
        tkinter.messagebox.showwarning(
            'Pleas Note',
            'Parameters have been sent, however some/all parameters in Pacemaker do not match with DCM'
        )

    VSIGN = struct.unpack('d', serialdata[33:41])
    ASIGN = struct.unpack('d', serialdata[41:49])
    print(VSIGN[0])
    print(ASIGN[0])
    ser.close()
Example #8
0
def VOOR_window(upper_tk=None):

    global root_VOOR
    global lrlLabel
    global urlLabel
    global vaLabel
    global vpwLabel
    global msrLabel
    global atLabel
    global reacLabel
    global rfLabel
    global recoLabel

    global connectLable

    index = 0

    try:
        with open("parameterVOOR.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    except FileNotFoundError:
        with open("parameterVOOR.txt", "w") as parameterFile:
            while (index < 9):
                parameterFile.write("N/A\n")
                index += 1
            index = 0
        with open("parameterVOOR.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    root_VOOR = tk.Toplevel()
    root_VOOR.title('VOOR')
    root_VOOR.geometry('500x550')

    label = tk.Label(root_VOOR,
                     text="Current Mode:   VOOR",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(root_VOOR,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    label = tk.Label(root_VOOR,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    label = tk.Label(root_VOOR,
                     text="Ventricular Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    label = tk.Label(root_VOOR,
                     text="Ventricular Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=200)
    label = tk.Label(root_VOOR,
                     text="Maximum Sensor Rate (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=240)
    label = tk.Label(root_VOOR,
                     text="Activity Threshold:",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    label = tk.Label(root_VOOR,
                     text="Reaction Time (sec):",
                     font=("Times New Roman", 14)).place(x=10, y=320)
    label = tk.Label(root_VOOR,
                     text="Response Factor:",
                     font=("Times New Roman", 14)).place(x=10, y=360)
    label = tk.Label(root_VOOR,
                     text="Recovery Time (min):",
                     font=("Times New Roman", 14)).place(x=10, y=400)

    connectLable = tk.StringVar()
    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(root_VOOR,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(root_VOOR,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    lrlLabel = tk.StringVar()
    lrlLabel.set(read[0].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=lrlLabel,
                     font=("Times New Roman", 14)).place(x=250, y=80)

    urlLabel = tk.StringVar()
    urlLabel.set(read[1].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=urlLabel,
                     font=("Times New Roman", 14)).place(x=250, y=120)

    vaLabel = tk.StringVar()
    vaLabel.set(read[2].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=vaLabel,
                     font=("Times New Roman", 14)).place(x=250, y=160)

    vpwLabel = tk.StringVar()
    vpwLabel.set(read[3].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=vpwLabel,
                     font=("Times New Roman", 14)).place(x=250, y=200)

    msrLabel = tk.StringVar()
    msrLabel.set(read[4].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=msrLabel,
                     font=("Times New Roman", 14)).place(x=250, y=240)

    atLabel = tk.StringVar()
    atLabel.set(read[5].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=atLabel,
                     font=("Times New Roman", 14)).place(x=250, y=280)

    reacLabel = tk.StringVar()
    reacLabel.set(read[6].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=reacLabel,
                     font=("Times New Roman", 14)).place(x=250, y=320)

    rfLabel = tk.StringVar()
    rfLabel.set(read[7].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=rfLabel,
                     font=("Times New Roman", 14)).place(x=250, y=360)

    recoLabel = tk.StringVar()
    recoLabel.set(read[8].strip("\n"))
    label = tk.Label(root_VOOR,
                     textvariable=recoLabel,
                     font=("Times New Roman", 14)).place(x=250, y=400)

    #modeWindowButton = tk.Button(root_VOOR, text = "Change Mode", command = lambda:[root_VOOR.destroy()], width = 13).place(x = 300, y = 10)
    paraWindowButton = tk.Button(root_VOOR,
                                 text="Change Parameter",
                                 command=VOOR_ParameterWindow,
                                 width=20,
                                 height=2).place(x=200, y=450)
Example #9
0
def AOO_window(upper_tk=None):

    global root_AOO
    global lrlLabel
    global urlLabel
    global aaLabel
    global apwLabel

    global connectLable

    index = 0

    try:
        with open("parameterAOO.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    except FileNotFoundError:
        with open("parameterAOO.txt", "w") as parameterFile:
            while (index < 4):
                parameterFile.write("N/A\n")
                index += 1
            index = 0
        with open("parameterAOO.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    #if upper_tk == None:
    #   root_AOO = tk.Tk()
    #else:
    root_AOO = tk.Toplevel()
    root_AOO.title('AOO')
    root_AOO.geometry('500x400')

    label = tk.Label(root_AOO,
                     text="Current Mode:   AOO",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(root_AOO,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    label = tk.Label(root_AOO,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=130)
    label = tk.Label(root_AOO,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=180)
    label = tk.Label(root_AOO,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=230)

    connectLable = tk.StringVar()
    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(root_AOO,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(root_AOO,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    lrlLabel = tk.StringVar()
    lrlLabel.set(read[0].strip("\n"))  #lrlValue is input from user
    label = tk.Label(root_AOO,
                     textvariable=lrlLabel,
                     font=("Times New Roman", 14)).place(x=220, y=80)

    urlLabel = tk.StringVar()
    urlLabel.set(read[1].strip("\n"))  #urlValue is input from user
    label = tk.Label(root_AOO,
                     textvariable=urlLabel,
                     font=("Times New Roman", 14)).place(x=220, y=130)

    aaLabel = tk.StringVar()
    aaLabel.set(read[2].strip("\n"))  #aaValue is input from user
    label = tk.Label(root_AOO,
                     textvariable=aaLabel,
                     font=("Times New Roman", 14)).place(x=220, y=180)

    apwLabel = tk.StringVar()
    apwLabel.set(read[3].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_AOO,
                     textvariable=apwLabel,
                     font=("Times New Roman", 14)).place(x=220, y=230)

    #modeWindowButton = tk.Button(root_AOO, text = "Change Mode", command = lambda:[root_AOO.destroy()], width = 13).place(x = 300, y = 10)
    paraWindowButton = tk.Button(root_AOO,
                                 text="Change Parameter",
                                 command=AOO_ParameterWindow,
                                 width=20,
                                 height=2).place(x=200, y=300)
Example #10
0
def AOO_ParameterWindow():

    with open("parameterAOO.txt", "r") as parameterFile:
        aooRead = parameterFile.readlines()

    global paraWindow

    paraWindow = tk.Toplevel()
    paraWindow.title('AOO Parameter Setting')
    paraWindow.geometry('500x400')
    label = tk.Label(paraWindow,
                     text="Current Mode   AOO",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(paraWindow,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    LRL_data = ['30', '35', '40', '45']
    for i in range(50, 90):
        LRL_data.append(i)
    for j in range(90, 180):
        if j % 5 == 0:
            LRL_data.append(j)
    LRL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    LRL_roll['values'] = LRL_data
    LRL_roll.place(x=250, y=80)
    if aooRead[0] != 'N/A\n':  #Secret
        LRL_roll.set(aooRead[0].strip("\n"))
    else:
        LRL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=130)
    URL_data = []
    for k in range(50, 180):
        if k % 5 == 0:
            URL_data.append(k)

    URL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    URL_roll['values'] = URL_data
    URL_roll.place(x=250, y=130)
    if aooRead[1] != 'N/A\n':
        URL_roll.set(aooRead[1].strip("\n"))
    else:
        URL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=180)
    AA_data = ['OFF']
    for a in range(1, 51):
        AA_data.append(float(a / 10))

    AA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AA_roll['values'] = AA_data
    AA_roll.place(x=250, y=180)
    if aooRead[2] != 'N/A\n':
        AA_roll.set(aooRead[2].strip("\n"))
    else:
        AA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=230)
    APW_data = []
    for c in range(1, 31):
        APW_data.append(c)

    APW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    APW_roll['values'] = APW_data
    APW_roll.place(x=250, y=230)
    if aooRead[3] != 'N/A\n':
        APW_roll.set(aooRead[3].strip("\n"))
    else:
        APW_roll.current(0)

    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    def changePara():
        write = ['N/A'] * 4
        d = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            aoo_aa_p = AA_roll.get()
            if aoo_aa_p == 'OFF':
                aoo_aa_p = 0
            else:
                aoo_aa_p = int(100 * float(aoo_aa_p))
            write[3] = APW_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_AOO,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_AOO,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode=1,
                          Lower_Rate=int(LRL_roll.get()),
                          ATR_Amplitude=int(aoo_aa_p),
                          ATR_Width=int(APW_roll.get()))

                with open("parameterAOO.txt", "w") as parameterFile:
                    while (d < 4):
                        parameterFile.write(
                            write[d] +
                            "\n")  #Write every index of list write[] into file
                        d += 1
                    d = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                apwLabel.set(write[3])
                paraWindow.destroy()

    saveButton = tk.Button(paraWindow,
                           text="Save",
                           command=changePara,
                           width=13).place(x=50, y=300)
    cancelButton = tk.Button(paraWindow,
                             text="Cancel",
                             command=lambda: [paraWindow.destroy()],
                             width=13).place(x=220, y=300)
Example #11
0
def egram(mode=7,
          Lower_Rate=60,
          MSR=120,
          AV_Delay=100,
          ATR_Amplitude=75,
          VENT_Amplitude=75,
          ATR_Width=10,
          VENT_Width=10,
          VENT_Refractory=250,
          ATR_Refractory=250,
          Activity_Threshold=1.1,
          Reaction_Time=5,
          Response_Factor=100,
          Recovery_Time=5):
    global atr
    global vent
    global t
    global x
    global com
    com = checkConnect()
    error = 0

    font = {'size': 9}
    matplotlib.rc('font', **font)

    f0 = figure(num=0, figsize=(12, 8))
    f0.suptitle("Electrogram", fontsize=18)
    ax01 = subplot2grid((2, 2), (0, 0), rowspan=1, colspan=2)
    ax02 = subplot2grid((2, 2), (1, 0), rowspan=1, colspan=2)

    ax01.set_title('Atrium Signals', y=1.0, pad=-14, fontsize=14)
    ax02.set_title('Ventricle Signals', y=1.0, pad=-14, fontsize=14)

    ax01.set_ylim(0.30, 0.70)
    ax02.set_ylim(0.30, 0.70)

    ax01.set_xlim(0, 4000)
    ax02.set_xlim(0, 4000)

    ax01.set_xlabel("Time (ms)", fontsize=10)
    ax01.set_ylabel("Voltage (mV)", fontsize=10)
    ax02.set_xlabel("Time (ms)", fontsize=10)
    ax02.set_ylabel("Voltage (mV)", fontsize=10)

    atr = zeros(0)
    vent = zeros(0)
    t = zeros(0)

    p01, = ax01.plot(t, atr, 'b-', label="Atrium")
    p02, = ax02.plot(t, vent, 'b-', label="Ventricle")

    xmin = 0.0
    xmax = 4000
    x = 0.0

    #ser = serial.Serial(port="COM5", baudrate=115200)
    #spk = struct.pack('<3B10H1d2H',0x16,0x22,mode,Lower_Rate,ATR_Amplitude,VENT_Amplitude,ATR_Width,VENT_Width,
    #ATR_Refractory,VENT_Refractory,MSR,Reaction_Time,
    #Recovery_Time,Activity_Threshold,AV_Delay,Response_Factor)
    #ser.write(spk)
    #ser.close()

    def updateData(self):
        global atr
        global vent
        global t
        global x

        if com == 3:
            ser = serial.Serial(port="COM3", baudrate=115200)
        elif com == 4:
            ser = serial.Serial(port="COM4", baudrate=115200)
        elif com == 5:
            ser = serial.Serial(port="COM5", baudrate=115200)

        spk = struct.pack('<3B10H1d2H', 0x16, 0x22, mode, Lower_Rate,
                          ATR_Amplitude, VENT_Amplitude, ATR_Width, VENT_Width,
                          ATR_Refractory, VENT_Refractory, MSR, Reaction_Time,
                          Recovery_Time, Activity_Threshold, AV_Delay,
                          Response_Factor)
        ser.write(spk)
        ser.close()
        if com == 3:
            ser = serial.Serial(port="COM3", baudrate=115200)
        elif com == 4:
            ser = serial.Serial(port="COM4", baudrate=115200)
        elif com == 5:
            ser = serial.Serial(port="COM5", baudrate=115200)

        serialdata = ser.read(49)
        VSIGN = struct.unpack('d', serialdata[33:41])
        ASIGN = struct.unpack('d', serialdata[41:49])
        ser.close()

        atrLine = ASIGN[0]
        ventLine = VSIGN[0]
        print(3000 * (VSIGN[0] - 0.499))
        print(3000 * (ASIGN[0] - 0.499))

        atr = append(atr, atrLine)
        vent = append(vent, ventLine)
        t = append(t, x)

        x += 10

        p01.set_data(t, atr)
        p02.set_data(t, vent)

        if x >= xmax - 200:
            p01.axes.set_xlim(x - xmax + 200, x + 200)
            p02.axes.set_xlim(x - xmax + 200, x + 200)

        return p01, p02

    simulation = animation.FuncAnimation(f0,
                                         updateData,
                                         blit=False,
                                         frames=10000,
                                         interval=10,
                                         repeat=False)
    plt.show()
Example #12
0
def AAI_ParameterWindow():

    with open("parameterAAI.txt", "r") as parameterFile:
        readpara = parameterFile.readlines()

    global paraWindow

    paraWindow = tk.Toplevel()
    paraWindow.title('AAI Parameter Setting')
    paraWindow.geometry('500x500')
    label = tk.Label(paraWindow,
                     text="Current Mode   AAI",
                     font=("Times New Roman", 14)).place(x=10, y=10)
    label = tk.Label(paraWindow,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    LRL_data = ['30', '35', '40', '45']
    for i in range(50, 90):
        LRL_data.append(i)
    for j in range(90, 180):
        if j % 5 == 0:
            LRL_data.append(j)
    LRL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    LRL_roll['values'] = LRL_data
    LRL_roll.place(x=320, y=80)
    if readpara[0] != 'N/A\n':  #Secret
        LRL_roll.set(readpara[0].strip("\n"))
    else:
        LRL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    URL_data = []
    for k in range(50, 180):
        if k % 5 == 0:
            URL_data.append(k)

    URL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    URL_roll['values'] = URL_data
    URL_roll.place(x=320, y=120)
    if readpara[1] != 'N/A\n':
        URL_roll.set(readpara[1].strip("\n"))
    else:
        URL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    AA_data = ['OFF']
    for a in range(1, 51):
        AA_data.append(float(a / 10))

    AA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AA_roll['values'] = AA_data
    AA_roll.place(x=320, y=160)
    if readpara[2] != 'N/A\n':
        AA_roll.set(readpara[2].strip("\n"))
    else:
        AA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=200)
    APW_data = []
    for b in range(1, 31):
        APW_data.append(b)

    APW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    APW_roll['values'] = APW_data
    APW_roll.place(x=320, y=200)
    if readpara[3] != 'N/A\n':
        APW_roll.set(readpara[3].strip("\n"))
    else:
        APW_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Sensitivity (V):",
                     font=("Times New Roman", 14)).place(x=10, y=240)
    AS_data = ['0']
    for c in range(1, 51):
        AS_data.append(float(c / 10))

    AS_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AS_roll['values'] = AS_data
    AS_roll.place(x=320, y=240)
    if readpara[4] != 'N/A\n':
        AS_roll.set(readpara[4].strip("\n"))
    else:
        AS_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Refractory Period (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    ARP_data = []
    for p in range(15, 51):
        ARP_data.append(p)

    ARP_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    ARP_roll['values'] = ARP_data
    ARP_roll.place(x=320, y=280)
    if readpara[5] != 'N/A\n':
        ARP_roll.set(readpara[5].strip("\n"))
    else:
        ARP_roll.current(0)

    label = tk.Label(paraWindow,
                     text="PVARP (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=320)
    PVARP_roll = ttk.Combobox(paraWindow,
                              width=15,
                              height=10,
                              state='readonly')
    PVARP_roll['values'] = ARP_data
    PVARP_roll.place(x=320, y=320)
    if readpara[6] != 'N/A\n':
        PVARP_roll.set(readpara[6].strip("\n"))
    else:
        PVARP_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Rate Smoothing (%):",
                     font=("Times New Roman", 14)).place(x=10, y=360)
    RS_data = ['OFF', '3', '6', '9', '12', '15', '18', '21', '25']

    RS_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    RS_roll['values'] = RS_data
    RS_roll.place(x=320, y=360)
    if readpara[7] != 'N/A\n':
        RS_roll.set(readpara[7].strip("\n"))
    else:
        RS_roll.current(0)

    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    def changePara():
        write = ['N/A'] * 8
        d = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            aai_aa_p = AA_roll.get()
            if aai_aa_p == 'OFF':
                aai_aa_p = 0
            else:
                aai_aa_p = int(100 * float(aai_aa_p))
            write[3] = APW_roll.get()
            write[4] = AS_roll.get()
            write[5] = ARP_roll.get()
            write[6] = PVARP_roll.get()
            write[7] = RS_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_AAI,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_AAI,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                writePara(mode=3,
                          Lower_Rate=int(LRL_roll.get()),
                          ATR_Amplitude=int(aai_aa_p),
                          ATR_Width=int(APW_roll.get()),
                          ATR_Refractory=int(ARP_roll.get()))

                with open("parameterAAI.txt", "w") as parameterFile:
                    while (d < 8):
                        parameterFile.write(
                            write[d] +
                            "\n")  #Write every index of list write[] into file
                        d += 1
                    d = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                apwLabel.set(write[3])
                asLabel.set(write[4])
                arpLabel.set(write[5])
                pvarpLabel.set(write[6])
                rsLabel.set(write[7])
                paraWindow.destroy()

    saveButton = tk.Button(paraWindow,
                           text="Save",
                           command=changePara,
                           width=13).place(x=50, y=410)
    cancelButton = tk.Button(paraWindow,
                             text="Cancel",
                             command=lambda: [paraWindow.destroy()],
                             width=13).place(x=220, y=410)
Example #13
0
def DOO_ParameterWindow():

    with open("parameterDOO.txt", "r") as parameterFile:
        readpara = parameterFile.readlines()

    global paraWindow

    paraWindow = tk.Toplevel()
    paraWindow.title('DOO Parameter Setting')
    paraWindow.geometry('500x450')
    label = tk.Label(paraWindow,
                     text="Current Mode   DOO",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(paraWindow,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    LRL_data = ['30', '35', '40', '45']
    for i in range(50, 90):
        LRL_data.append(i)
    for j in range(90, 180):
        if j % 5 == 0:
            LRL_data.append(j)
    LRL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    LRL_roll['values'] = LRL_data
    LRL_roll.place(x=320, y=80)
    if readpara[0] != 'N/A\n':  #Secret
        LRL_roll.set(readpara[0].strip("\n"))
    else:
        LRL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    URL_data = []
    for k in range(50, 180):
        if k % 5 == 0:
            URL_data.append(k)

    URL_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    URL_roll['values'] = URL_data
    URL_roll.place(x=320, y=120)
    if readpara[1] != 'N/A\n':
        URL_roll.set(readpara[1].strip("\n"))
    else:
        URL_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    AA_data = ['OFF']
    for a in range(1, 51):
        AA_data.append(float(a / 10))

    AA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    AA_roll['values'] = AA_data
    AA_roll.place(x=320, y=160)
    if readpara[2] != 'N/A\n':
        AA_roll.set(readpara[2].strip("\n"))
    else:
        AA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Ventricular Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=200)

    VA_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    VA_roll['values'] = AA_data
    VA_roll.place(x=320, y=200)
    if readpara[3] != 'N/A\n':
        VA_roll.set(readpara[3].strip("\n"))
    else:
        VA_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Atrial Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=240)
    APW_data = []
    for c in range(1, 31):
        APW_data.append(c)

    APW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    APW_roll['values'] = APW_data
    APW_roll.place(x=320, y=240)
    if readpara[4] != 'N/A\n':
        APW_roll.set(readpara[4].strip("\n"))
    else:
        APW_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Ventricular Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    VPW_roll = ttk.Combobox(paraWindow, width=15, height=10, state='readonly')
    VPW_roll['values'] = APW_data
    VPW_roll.place(x=320, y=280)
    if readpara[5] != 'N/A\n':
        VPW_roll.set(readpara[5].strip("\n"))
    else:
        VPW_roll.current(0)

    label = tk.Label(paraWindow,
                     text="Fixed AV Delay (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=320)
    DELAY_data = []
    for b in range(7, 31):
        DELAY_data.append(b * 10)
    DELAY_roll = ttk.Combobox(paraWindow,
                              width=15,
                              height=10,
                              state='readonly')
    DELAY_roll['values'] = DELAY_data
    DELAY_roll.place(x=320, y=320)
    if readpara[6] != 'N/A\n':
        DELAY_roll.set(readpara[6].strip("\n"))
    else:
        DELAY_roll.current(0)

    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(paraWindow,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    def changePara():
        write = ['N/A'] * 7
        d = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = AA_roll.get()
            doo_aa_p = AA_roll.get()
            if doo_aa_p == 'OFF':
                doo_aa_p = 0
            else:
                doo_aa_p = int(100 * float(doo_aa_p))
            write[3] = VA_roll.get()
            doo_va_p = VA_roll.get()
            if doo_va_p == 'OFF':
                doo_va_p = 0
            else:
                doo_va_p = int(100 * float(doo_va_p))
            write[4] = APW_roll.get()
            write[5] = VPW_roll.get()
            write[6] = DELAY_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_DOO,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_DOO,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode = 5, Lower_Rate = int(LRL_roll.get()), AV_Delay = int(DELAY_roll.get()), ATR_Amplitude = int(doo_aa_p), VENT_Amplitude = int(doo_va_p), \
                    ATR_Width = int(APW_roll.get()), VENT_Width = int(VPW_roll.get()))

                with open("parameterDOO.txt", "w") as parameterFile:
                    while (d < 7):
                        parameterFile.write(
                            write[d] +
                            "\n")  #Write every index of list write[] into file
                        d += 1
                    d = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                aaLabel.set(write[2])
                vaLabel.set(write[3])
                apwLabel.set(write[4])
                vpwLabel.set(write[5])
                delayLabel.set(write[6])
                paraWindow.destroy()

    saveButton = tk.Button(paraWindow,
                           text="Save",
                           command=changePara,
                           width=13).place(x=50, y=380)
    cancelButton = tk.Button(paraWindow,
                             text="Cancel",
                             command=lambda: [paraWindow.destroy()],
                             width=13).place(x=220, y=380)
Example #14
0
def VVI_window(upper_tk=None):

    global root_VVI
    global lrlLabel
    global urlLabel
    global vaLabel
    global vpwLabel
    global vsLabel
    global vrpLabel
    global rsLabel

    global connectLable

    index = 0

    try:
        with open("parameterVVI.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    except FileNotFoundError:
        with open("parameterVVI.txt", "w") as parameterFile:
            while (index < 7):
                parameterFile.write("N/A\n")
                index += 1
            index = 0
        with open("parameterVVI.txt", "r") as parameterFile:
            read = parameterFile.readlines()

    #if upper_tk == None:
    #   root_AOO = tk.Tk()
    #else:
    root_VVI = tk.Toplevel()
    root_VVI.title('VVI')
    root_VVI.geometry('500x500')

    label = tk.Label(root_VVI,
                     text="Current Mode:   VVI",
                     font=("Times New Roman", 14)).place(x=10, y=10)

    label = tk.Label(root_VVI,
                     text="Lower Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=80)
    label = tk.Label(root_VVI,
                     text="Upper Rate Limit (ppm):",
                     font=("Times New Roman", 14)).place(x=10, y=120)
    label = tk.Label(root_VVI,
                     text="Ventricular Amplitude (V):",
                     font=("Times New Roman", 14)).place(x=10, y=160)
    label = tk.Label(root_VVI,
                     text="Ventricular Pulse Width (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=200)
    label = tk.Label(root_VVI,
                     text="Ventricular Sensitivity (V):",
                     font=("Times New Roman", 14)).place(x=10, y=240)
    label = tk.Label(root_VVI,
                     text="Ventricular Refractory Period (ms):",
                     font=("Times New Roman", 14)).place(x=10, y=280)
    label = tk.Label(root_VVI,
                     text="Rate Smoothing (%):",
                     font=("Times New Roman", 14)).place(x=10, y=320)

    connectLable = tk.StringVar()
    if checkConnect() == 6:
        connectLable.set("No Pacemaker Connected")
        label = tk.Label(root_VVI,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="red").place(x=10, y=40)
    else:
        connectLable.set("Pacemaker is Connected")
        label = tk.Label(root_VVI,
                         textvariable=connectLable,
                         font=("Times New Roman", 14),
                         fg="green").place(x=10, y=40)

    lrlLabel = tk.StringVar()
    lrlLabel.set(read[0].strip("\n"))  #lrlValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=lrlLabel,
                     font=("Times New Roman", 14)).place(x=320, y=80)

    urlLabel = tk.StringVar()
    urlLabel.set(read[1].strip("\n"))  #urlValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=urlLabel,
                     font=("Times New Roman", 14)).place(x=320, y=120)

    vaLabel = tk.StringVar()
    vaLabel.set(read[2].strip("\n"))  #aaValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=vaLabel,
                     font=("Times New Roman", 14)).place(x=320, y=160)

    vpwLabel = tk.StringVar()
    vpwLabel.set(read[3].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=vpwLabel,
                     font=("Times New Roman", 14)).place(x=320, y=200)

    vsLabel = tk.StringVar()
    vsLabel.set(read[4].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=vsLabel,
                     font=("Times New Roman", 14)).place(x=320, y=240)

    vrpLabel = tk.StringVar()
    vrpLabel.set(read[5].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=vrpLabel,
                     font=("Times New Roman", 14)).place(x=320, y=280)

    rsLabel = tk.StringVar()
    rsLabel.set(read[6].strip("\n"))  #apwValue is input from user
    label = tk.Label(root_VVI,
                     textvariable=rsLabel,
                     font=("Times New Roman", 14)).place(x=320, y=320)

    #modeWindowButton = tk.Button(root_VVI, text = "Change Mode", command = lambda:[root_VVI.destroy()], width = 13).place(x = 300, y = 10)
    paraWindowButton = tk.Button(root_VVI,
                                 text="Change Parameter",
                                 command=VVI_ParameterWindow,
                                 width=20,
                                 height=2).place(x=200, y=400)
Example #15
0
    def changePara():
        write = ['N/A'] * 7
        d = 0

        write[0] = LRL_roll.get()
        write[1] = URL_roll.get()
        if int(write[0]) > int(write[1]):
            tkinter.messagebox.showerror(
                'Error',
                'Lower Rate Limit cannot be bigger than Upper Rate Limit')
        else:
            write[2] = VA_roll.get()
            vvi_va_p = VA_roll.get()
            if vvi_va_p == 'OFF':
                vvi_va_p = 0
            else:
                vvi_va_p = int(100 * float(vvi_va_p))
            write[3] = VPW_roll.get()
            write[4] = VS_roll.get()
            write[5] = VRP_roll.get()
            write[6] = RS_roll.get()

            if checkConnect() == 6:
                connectLable.set("No Pacemaker Connected")
                label = tk.Label(root_VVI,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="red").place(x=10, y=40)
                tkinter.messagebox.showerror(
                    'Error', 'Failed to connect to the Pacemaker')
            else:
                connectLable.set("Pacemaker is Connected")
                label = tk.Label(root_VVI,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)
                label = tk.Label(paraWindow,
                                 textvariable=connectLable,
                                 font=("Times New Roman", 14),
                                 fg="green").place(x=10, y=40)

                writePara(mode=4,
                          Lower_Rate=int(LRL_roll.get()),
                          VENT_Amplitude=int(vvi_va_p),
                          VENT_Width=int(VPW_roll.get()),
                          VENT_Refractory=int(VRP_roll.get()))

                with open("parameterVVI.txt", "w") as parameterFile:
                    while (d < 7):
                        parameterFile.write(
                            write[d] +
                            "\n")  #Write every index of list write[] into file
                        d += 1
                    d = 0

                lrlLabel.set(write[0])
                urlLabel.set(write[1])
                vaLabel.set(write[2])
                vpwLabel.set(write[3])
                vsLabel.set(write[4])
                vrpLabel.set(write[5])
                rsLabel.set(write[6])
                paraWindow.destroy()