Guest User

Untitled

a guest
Jun 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. # Inital Setups
  2. global forklift_count
  3. global person_count
  4. global barrier_remote_pressed_a
  5. global barrier_remote_pressed_b
  6. global tsA_signal
  7. global tsB_signal
  8. forklift_count = 0
  9. person_count = 0
  10. barrier_remote_pressed_a = False
  11. barrier_remote_pressed_b = False
  12.  
  13. GPIO.output(8, 1)
  14. GPIO.output(10, 1)
  15. GPIO.output(12, 1)
  16. GPIO.output(16, 1)
  17. GPIO.output(18, 1)
  18. GPIO.output(22, 1)
  19.  
  20. while True:
  21.  
  22. # Input buttons and sensors
  23. # omitted unnecessary inputs from Stackoverflow example
  24. tsB_signal = GPIO.input(37)
  25. tsA_signal = GPIO.input(38)
  26.  
  27. # Turnstile B Entry Pressed
  28. if tsB_entry_button == False:
  29. triggered = False
  30. if check_forklift_count() == 0:
  31. timeout1 = time.time() + 20
  32. while True:
  33. if time.time() > timeout1:
  34. print("turnstile not activated in time")
  35. break
  36. if triggered == False:
  37. GPIO.output(18, 0)
  38. time.sleep(2)
  39. GPIO.output(18, 1)
  40. print("Turnstile B - Triggered Enter Warehouse")
  41. triggered = True
  42. if tsB_signal == False: # Never executes even when signal sent
  43. print("Signal received")
  44. person_count += 1
  45. print("Person Count = %s" % check_person_count())
  46. break
  47. else:
  48. print("Turnstile B - There are forklifts %s in the warehouse or there are forklifts entering the warehouse" % check_forklift_count())
  49. break
  50.  
  51. # Never goes false so never runs
  52. if tsB_signal == False: # Never executes even when signal sent
  53. print("Signal received")
  54. person_count += 1
  55. print("Person Count = %s" % check_person_count())
  56. break
  57.  
  58. # Goes false without issue when signal sent prints that it has been received
  59. if tsB_signal == False:
  60. print("Signal Received")
  61. sleep(0.2)
Add Comment
Please, Sign In to add comment