Esempio n. 1
0
    def __init__(self, master, userdata):
        self.master = master
        self.testcase_master = Toplevel(master)
        self.testcase_master.protocol("WM_DELETE_WINDOW", self.mainwin)
        self.userdata = userdata

        self.db = MindClockDb(self.testcase_master)

        self.messages = McError()

        self.keypress = False

        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Reproduction", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        self.canvas1 = Canvas(self.testcase_master, width=350, height=300)
        self.canvas1.pack()
        self.canvas1.create_oval(200, 200, 70, 70, fill='#6666ff')
        self.canvas1.create_text(134,
                                 134,
                                 text="R",
                                 fill="white",
                                 font=("tahoma", 30))
        self.canvas1.after(3000, self.clear)

        self.canvas = Canvas(self.testcase_master, width=350, height=300)
        self.canvas.pack()
        self.testcase_master.bind("<space>", self.show_ball)
        self.testcase_master.geometry('500x400')
Esempio n. 2
0
	def save(self):
		db = MindClockDb(self.dashboard_master)
		
		type = self.type.get()
		Replication=self.entry_Replication.get()
		Interval=self.entry_Intervals.get()

		sql = "INSERT INTO test_types(replicate, intervals, type) VALUES('{}','{}','{}')".format(Replication, Interval, type)
		sql1 = "DELETE FROM test_types WHERE type=('{}')".format(type)

		if(db.delete(sql1)):
			if(db.insert(sql)):
				self.messages.success("Success", "Saved Successfully!")
		else:
			dashboard_master.withdraw()
			self.messages.error("Error", "Something went wrong!")
			dashboard_master.deiconify()
Esempio n. 3
0
    def __init__(self, master, userdata):

        # logged in userdata
        self.userdata = userdata
        self.productioncounter = 0
        self.replicationcounter = 1

        self.production_master = Toplevel(master)
        self.production_master.protocol("WM_DELETE_WINDOW", sys.exit)
        self.production_master.title("Production")
        self.production_master.focus_set()

        self.messages = McError()

        self.db = MindClockDb(self.production_master)
        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Production", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        # self.production_master.attributes('-fullscreen', True)
        self.init_production()
Esempio n. 4
0
    def insert(self, type, interval_no, interval_time, interval_master):

        db = MindClockDb(self.master)

        if (type == "Production"):
            #sql="DELETE FROM production_interval"
            sql1 = "INSERT INTO production_interval(interval_no, interval) VALUES('{}','{}')".format(
                interval_no, interval_time)
        if (type == "Reproduction"):
            #sql="DELETE FROM reproduction_interval"
            sql1 = "INSERT INTO reproduction_interval(interval_no, interval) VALUES('{}','{}')".format(
                interval_no, interval_time)

        if (db.insert(sql1)):
            self.messages.success("Success", "Saved Successfully!")
        else:
            interval_master.withdraw()
            self.messages.error("Error", "Something went wrong!")
            interval_master.deiconify()
        self.interval_no = self.interval_no - 1
        self.interval_master.destroy()
        self.__init__(self.master, self.interval_no, self.type)
Esempio n. 5
0
    def _signup_btn_clicked(self):
        db = MindClockDb(self.signup_master)

        username = self.entry_Username.get()
        firstname = self.entry_Firstname.get()
        lastname = self.entry_Lastname.get()
        age = self.entry_Age.get()
        gender = self.gender.get()
        height = self.entry_Height.get()
        weight = self.entry_Weight.get()

        bmi = self.BMI(weight, height)

        sql = "INSERT INTO users(userid,firstname,lastname, age, weight, height, gender, bmi) VALUES('{}','{}','{}',{},'{}','{}','{}','{}')".format(
            username, firstname, lastname, age, weight, height, gender, bmi)

        if (db.insert(sql)):
            self.messages.success("Success", "Registered Successfully!")
            self.signup_master.destroy()
            self.master.deiconify()
        else:
            self.signup_master.withdraw()
            self.messages.error("Error", "Something went wrong!")
            self.signup_master.deiconify()
Esempio n. 6
0
class Reproduction():
    def __init__(self, master, userdata):
        self.master = master
        self.testcase_master = Toplevel(master)
        self.testcase_master.protocol("WM_DELETE_WINDOW", self.mainwin)
        self.userdata = userdata

        self.db = MindClockDb(self.testcase_master)

        self.messages = McError()

        self.keypress = False

        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Reproduction", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        self.canvas1 = Canvas(self.testcase_master, width=350, height=300)
        self.canvas1.pack()
        self.canvas1.create_oval(200, 200, 70, 70, fill='#6666ff')
        self.canvas1.create_text(134,
                                 134,
                                 text="R",
                                 fill="white",
                                 font=("tahoma", 30))
        self.canvas1.after(3000, self.clear)

        self.canvas = Canvas(self.testcase_master, width=350, height=300)
        self.canvas.pack()
        self.testcase_master.bind("<space>", self.show_ball)
        self.testcase_master.geometry('500x400')
        #self.now1 = datetime.datetime.now()

    def mainwin(self):
        self.master.deiconify()
        self.testcase_master.destroy()

    def show_ball(self, event=None):
        #self.start=float(self.now1.isoformat())
        if (self.keypress == False):
            self.start = time.time()
            self.keypress = True
        else:
            self.canvas.create_oval(200, 200, 70, 70, fill='#6666ff')
            self.canvas.create_text(134,
                                    134,
                                    text="R",
                                    fill="white",
                                    font=("tahoma", 30))
            self.canvas.pack()

        self.testcase_master.bind("<KeyRelease>", self.hide_ball)
        #self.now2 = datetime.datetime.now()

    def hide_ball(self, event=None):
        self.canvas.delete(ALL)
        #self.end=float(self.now2.isoformat())
        self.keypress = False
        self.end = time.time()
        print("start time", self.start)
        print("end time", self.end)
        self.getdiff = self.end - self.start
        print("Difference", self.getdiff)
        sql = "INSERT INTO operations(user_id, replicate, production_time, reproduction_time, result_time, type) VALUES('{}','{}','{}','{}','{}','{}')".format(
            self.userdata, 1, None, 3, self.getdiff, "Reproduction")

        if (self.db.insert(sql) == False):
            self.messages.error("Error", "Something went wrong!")

    def clear(self):
        self.canvas1.destroy()
Esempio n. 7
0
class Production:
    def __init__(self, master, userdata):

        # logged in userdata
        self.userdata = userdata
        self.productioncounter = 0
        self.replicationcounter = 1

        self.production_master = Toplevel(master)
        self.production_master.protocol("WM_DELETE_WINDOW", sys.exit)
        self.production_master.title("Production")
        self.production_master.focus_set()

        self.messages = McError()

        self.db = MindClockDb(self.production_master)
        sql1 = "DELETE FROM operations WHERE type=('{}') AND user_id=('{}')".format(
            "Production", self.userdata)
        if (self.db.delete(sql1) == False):
            self.messages.error("Error", "Something went wrong!")

        # self.production_master.attributes('-fullscreen', True)
        self.init_production()

    def init_production(self):
        set = {'font': 'Times 70 bold'}
        self.get_production_intervals()

        self.production_timer = Label(self.production_master,
                                      text=self.time[self.productioncounter],
                                      **set)
        self.production_timer.pack(padx=200, pady=320)
        self.time1 = time.time()
        self.production_master.bind('<space>', self.get_production_event)

    def get_production_intervals(self):
        # self.time = []
        # self.event = []
        # self.data = self.db.select("SELECT ")
        data = self.db.select(
            "SELECT id, intervals, replicate, type FROM test_types WHERE type='Production'"
        )
        data = data.fetchone()
        intervals = dict(data)
        self.time = intervals['intervals'].split('-')
        self.replicate = intervals['replicate']

    def get_production_event(self, event):
        time.sleep(1)

        self.time1 = time.time() - self.time1
        print(self.time1)

        sql = "INSERT INTO operations(user_id, replicate, production_time, reproduction_time, result_time, type) VALUES('{}','{}','{}','{}','{}','{}')".format(
            self.userdata, self.replicationcounter,
            self.time[self.productioncounter], None, self.time1, "Production")

        if (self.db.insert(sql) == False):
            self.messages.error("Error", "Something went wrong!")

        self.time1 = time.time()

        self.productioncounter += 1
        print(self.replicationcounter)
        # check replication is
        if self.replicationcounter > self.replicate:
            sys.exit()

        # change text on key press
        try:
            self.production_timer.config(
                text=self.time[self.productioncounter])
        except IndexError as e:
            self.replicationcounter += 1
            self.productioncounter = 0