Skip to content

Commit

Permalink
final version
Browse files Browse the repository at this point in the history
  • Loading branch information
alithethird committed Mar 22, 2021
1 parent 3c0d054 commit 76bdb5c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 69 deletions.
4 changes: 2 additions & 2 deletions cof.kv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down
71 changes: 16 additions & 55 deletions fpdf_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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):

Expand All @@ -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(" ")

Expand Down
8 changes: 4 additions & 4 deletions json_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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[
Expand Down
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 76bdb5c

Please sign in to comment.