Skip to content

Commit

Permalink
angle guiye forward backward üzerine interrupt eklendi
Browse files Browse the repository at this point in the history
  • Loading branch information
alithethird committed Mar 19, 2021
1 parent 332dce9 commit 3c0d054
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 5 deletions.
95 changes: 95 additions & 0 deletions fpdf_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,44 @@ def create_pdf(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1
except:
pass
"""

def create_pdf_angle(self, max_static, mean_static, max_dynamic, mean_dynamic, sample1, sample2, test_mode, forces):

self.set_time()
self.add_page()
self.set_font('Times', '', 12)
if sample2.name == "":
self.single_table_angle(sample1, max_static, mean_static, max_dynamic, mean_dynamic, test_mode)
self.graph_to_pdf(1)
else:
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/"
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"
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))
except:
print(" ")


def single_table(self, sample, max_static, mean_static, max_dynamic, mean_dynamic, test_mode):
if test_mode == 1:
test_mode = "Angle Test"
Expand Down Expand Up @@ -187,3 +225,60 @@ def diff_table(self, sample1, sample2, max_static, mean_static, max_dynamic, mea
self.cell(col_width, row_height * spacing,
txt=item, border=0)
self.ln(row_height * spacing)


def single_table_angle(self, sample, max_static, mean_static, max_dynamic, mean_dynamic, test_mode):
if test_mode == 1:
test_mode = "Angle Test"
elif test_mode == 0:
test_mode = "Motorized Test"
data = [['Standard: ', "ISO 8295"],
['Company Name: ', str(sample.company_name)],
['Operator Name: ', str(sample.operator_name)],
['Testing Weight(gr): ', str(sample.testing_weight)],
['Test Mode: ', str(test_mode)],
['Sample Name: ', str(sample.name)],
['Sample Width(mm): ', str(sample.width)],
['Sample Height(mm): ', str(sample.height)],
['Sample Age(months): ', str(sample.age)],
['Testing Against: ', 'The same sample'],
['Static Coefficient of Friction: ', str(max_static)]
]
spacing = 2
self.set_font("Arial", size=12)
col_width = self.w / 2.2
row_height = self.font_size
for row in data:
for item in row:
self.cell(col_width, row_height * spacing,
txt=item, border=0)
self.ln(row_height * spacing)

def diff_table_angle(self, sample1, sample2, max_static, mean_static, max_dynamic, mean_dynamic, test_mode):

test_mode = "Angle Test"
data = [['Standard: ', "ISO 8295"],
['Company Name: ', str(sample1.company_name)],
['Operator Name: ', str(sample1.operator_name)],
['Testing Weight(gr): ', str(sample1.testing_weight)],
['Test Mode: ', str(test_mode)],
['Sample Name: ', str(sample1.name)],
['Sample Width(mm): ', str(sample1.width)],
['Sample Height(mm): ', str(sample1.height)],
['Sample Age: ', str(sample1.age)],
['Testing Against: ', 'Different Sample'],
['Second Sample Name: ', str(sample2.name)],
['Second Sample Width(mm): ', str(sample2.width)],
['Second Sample Height(mm): ', str(sample2.height)],
['Second Sample Age(months): ', str(sample2.age)],
['Static Coefficient of Friction: ', str(max_static)]
]
spacing = 2
self.set_font("Arial", size=12)
col_width = self.w / 2.2
row_height = self.font_size
for row in data:
for item in row:
self.cell(col_width, row_height * spacing,
txt=item, border=0)
self.ln(row_height * spacing)
24 changes: 19 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,13 +736,28 @@ def min_angle_event(self):
def motor_forward(self):
gpio.setup(stop_switch, gpio.IN, pull_up_down=gpio.PUD_UP)
if gpio.input(stop_switch):
self.max_distance_event()
md.motor_start(8000, 0)

def motor_backward(self):
gpio.setup(start_switch, gpio.IN, pull_up_down=gpio.PUD_UP)
if gpio.input(start_switch):
self.min_distance_event()
md.motor_start(8000, 1)

def max_distance_event(self):
try:
gpio.setup(stop_switch, gpio.IN, pull_up_down=gpio.PUD_UP)
gpio.add_event_detect(stop_switch, gpio.FALLING, callback=self.stop_event, bouncetime=200)
except:
pass

def min_distance_event(self):
try:
gpio.setup(start_switch, gpio.IN, pull_up_down=gpio.PUD_UP)
gpio.add_event_detect(start_switch, gpio.FALLING, callback=self.stop_event, bouncetime=200)
except:
pass

class ScreenFive(Screen):
# distance#, speed#, sample time, normal force
Expand Down Expand Up @@ -848,6 +863,7 @@ def find_static_cof(self):
def update_results(self):
try:
print(cof_angle_xyz)
self.static_cof = self.create_results()
self.ids.l_static.text = self.create_results()
# pdfe de ekle, json düzenle
self.max_static, self.mean_static, self.max_dynamic, self.mean_dynamic = self.static_cof, self.static_cof, self.static_cof, self.static_cof
Expand All @@ -856,16 +872,14 @@ def update_results(self):
sample2, test_mode, ScreenFour.plot.points)
except:
pass

def createPDF(self):
self.pdf = fpdf_handler()

self.update_results()

if test_mode == 0:
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,

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()
Expand Down

0 comments on commit 3c0d054

Please sign in to comment.