diff --git a/cof.kv b/cof.kv index cb2b452..2002f6c 100644 --- a/cof.kv +++ b/cof.kv @@ -448,7 +448,7 @@ write_tab: False multiline: False id: normal_force_text - hint_text: 'Normal Force(N)' + hint_text: 'Normal Mass(gr)' pos_hint: {'center_x': 0.2, "center_y": 0.84} font_size: 12 size_hint: 1/7, 0.06 @@ -465,7 +465,7 @@ Label: id: normal_force_label - text: "Normal Force:" + text: "Normal Mass:" color: (0,0,0,1) pos_hint: {"center_x": 0.5, "center_y": 0.84} halign: "left" diff --git a/fpdf_handler.py b/fpdf_handler.py index 56c7d82..7f5f1b0 100644 --- a/fpdf_handler.py +++ b/fpdf_handler.py @@ -29,7 +29,7 @@ def set_time(self): def header(self): # Set up a logo - self.image('mini_logo.png', 10, 8, 33) + self.image('/home/pi/Cof-Tabs/mini_logo.png', 10, 8, 33) self.set_font('Arial', 'I', 15) @@ -50,18 +50,17 @@ def footer(self): self.set_y(-10) self.set_font('Arial', 'I', 12) - self.set_line_width(1) self.line(x1=10, y1=285, x2=200, y2=285) self.cell(0, 10, - "Alarge Laboratory Test Teknology - https://www.alarge.com.tr/en/ - info@alarge.com.tr") + "Alarge Laboratory Test Technology - https://www.alarge.com.tr/en/ - info@alarge.com.tr") def graph_to_pdf(self, choise): if choise == 1: - self.image('graph.png', x=30, y=160, w=150) + self.image('/home/pi/Cof-Tabs/graph.png', x=30, y=160, w=150) else: - self.image('graph.png', x=30, y=190, w=150) + self.image('/home/pi/Cof-Tabs/graph.png', x=30, y=190, w=150) def print_obj(self, obj): print(obj.name) @@ -78,52 +77,20 @@ def create_pdf(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1 self.diff_table(sample1, sample2, max_static, mean_static, max_dynamic, mean_dynamic, test_mode) self.graph_to_pdf(2) - filename = "COF_Test_" + self.date_and_time + ".pdf" - mount_dir = "/media/pi/" + filename = "/home/pi/Cof-Tabs/COF_Test_" + self.date_and_time + ".pdf" + mount_dir = "/media/usb0" self.output(filename) self.close() print("pdf created") json_out.dump_time(max_static, mean_static, max_dynamic, mean_dynamic, sample1, sample2, test_mode, forces, self.date_and_time) - filename_json = "COF_Test_" + self.date_and_time + ".json" + filename_json = "/home/pi/Cof-Tabs/COF_Test_" + self.date_and_time + ".json" print("1") - usb_dir = popen("ls " + mount_dir).read() - usb_dir = usb_dir.split() - print(usb_dir) - if usb_dir.count("ALI") > 0: - usb_dir = usb_dir.remove("ALI") - print("ALI'yi buldum ve silmeye calistim") try: - if len(usb_dir) > 0: - usb_dir = usb_dir[-1] - shutil.copy(filename, mount_dir + str(usb_dir)) - shutil.copy(filename_json, mount_dir + str(usb_dir)) + shutil.copy(filename, mount_dir) + shutil.copy(filename_json, mount_dir) except: print(" ") - """ - if usb_dir.count("media/pi/ALI") > 0: - usb_dir = usb_dir.remove("/media/pi/ALI") - print("ALI'yi buldum ve silmeye calistim") - try: - print("3") - print(usb_dir) - usb_dir = usb_dir[0] - print(usb_dir) - destination = usb_dir + filename - - popen("cp " + source + " " + str(destination) +"/") - print("4") - try: - print(source) - shutil.copy(source, str(destination)) - print("5") - except shutil.Error as e: - print("Error: %s" % e) - except IOError as e: - print("Error: %s" % e.strerror) - except: - pass - """ def create_pdf_angle(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1, sample2, test_mode, forces): @@ -137,27 +104,21 @@ def create_pdf_angle(self, max_static, mean_static, max_dynamic, mean_dynamic, s self.diff_table_angle(sample1, sample2, max_static, mean_static, max_dynamic, mean_dynamic, test_mode) self.graph_to_pdf(2) - filename = "COF_Test_" + self.date_and_time + ".pdf" - mount_dir = "/media/pi/" + filename = "/home/pi/Cof-Tabs/COF_Test_" + self.date_and_time + ".pdf" + mount_dir = "/media/usb0/" + self.output(filename) self.close() print("pdf created") json_out.dump_time(max_static, mean_static, max_dynamic, mean_dynamic, sample1, sample2, test_mode, forces, self.date_and_time) - filename_json = "COF_Test_" + self.date_and_time + ".json" + filename_json = "/home/pi/Cof-Tabs/COF_Test_" + self.date_and_time + ".json" print("1") - usb_dir = popen("ls " + mount_dir).read() - usb_dir = usb_dir.split() - print(usb_dir) - if usb_dir.count("ALI") > 0: - usb_dir = usb_dir.remove("ALI") - print("ALI'yi buldum ve silmeye calistim") + try: - if len(usb_dir) > 0: - usb_dir = usb_dir[-1] - shutil.copy(filename, mount_dir + str(usb_dir)) - shutil.copy(filename_json, mount_dir + str(usb_dir)) + shutil.copy(filename, mount_dir) + shutil.copy(filename_json, mount_dir) except: print(" ") diff --git a/json_dumper.py b/json_dumper.py index 81a4273..0e5ca81 100644 --- a/json_dumper.py +++ b/json_dumper.py @@ -38,7 +38,7 @@ def dump_all(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1, "Mean Dynamic Coefficient of Friction:": mean_dynamic, "Forces:": forces } - with open('data.json', 'w', encoding='utf-8') as f: + with open('/home/pi/Cof-Tabs/data.json', 'w', encoding='utf-8') as f: json.dump(dic, f, ensure_ascii=False, indent=2) def dump_time(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1, sample2, test_mode, forces, @@ -80,7 +80,7 @@ def dump_time(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1, "Forces:": forces } - file_name = "COF_Test_" + date_and_time + ".json" + file_name = "/home/pi/Cof-Tabs/COF_Test_" + date_and_time + ".json" with open(file_name, 'w', encoding='utf-8') as f: json.dump(dic, f, ensure_ascii=False, indent=2) @@ -136,12 +136,12 @@ def dump_calib_save(self, distance, speed, normal_force, sample_time, calib, ang "Angular Speed:": angular_speed } - file_name = "calibration_save.json" + file_name = "/home/pi/Cof-Tabs/calibration_save.json" with open(file_name, 'w', encoding='utf-8') as f: json.dump(dic, f, ensure_ascii=False, indent=2) def import_save(self): - file_name = "calibration_save.json" + file_name = "/home/pi/Cof-Tabs/calibration_save.json" with open(file_name) as json_file: data = json.load(json_file) return data["Distance:"], data["Speed:"], data["Normal_Force:"], data["Sample_Time:"], data[ diff --git a/main.py b/main.py index 56f749d..a996549 100644 --- a/main.py +++ b/main.py @@ -548,14 +548,12 @@ def createPDF(self): self.update_results() - if test_mode == 0: + try: self.pdf.create_pdf(self.max_static, self.mean_static, self.max_dynamic, self.mean_dynamic, sample1, sample2, test_mode, ScreenTwo.plot.points) - else: - self.pdf.create_pdf(self.max_static, self.mean_static, self.max_dynamic, self.mean_dynamic, sample1, - sample2, test_mode, ScreenFour.plot.points) - - self.show_popup() + self.show_popup() + except: + pass def show_popup(self): show = P() @@ -878,11 +876,13 @@ def createPDF(self): self.update_results() - + self.pdf.create_pdf_angle(self.max_static, self.mean_static, self.max_dynamic, self.mean_dynamic, sample1, sample2, test_mode, ScreenFour.plot.points) - self.show_popup() + + + def show_popup(self): show = P()