-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfinal.py
146 lines (129 loc) · 3.88 KB
/
final.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import os
import RPi.GPIO as GPIO
import time
import module
import datetime
import linecache
import qrcode
import generate
import cc
GPIO.setwarnings(False)
class vehicle:
def __init__(self,spot,type,time):
self.spot = spot
self.type = type
self.time = time
def status():
print(" Searching for Spots...")
print("\n")
for i in range(1,5):
x = module.distance(i)
if x >= 4:
print("Spot ",i,"is Empty")
else:
continue
def showstatus():
for i in range(1,5):
x = module.distance(i)
if x >= 5:
print("Spot ",i,"is Empty")
else:
continue
def mainmenu(count):
y = str(count)+".jpg"
spot = int(input("\nChoose Your Spot: "))
cc.reserve(spot)
type = input("Choose Your Vehicle Type Car/Bike: ")
e = datetime.datetime.now()
date = e.strftime("%d/%m/%Y")
tym = e.strftime("%I:%M:%S %p")
z = vehicle(spot,type,e)
x = "Ticket No: " + str(count) + "\nSpot No: " + str(z.spot) + "\nVehical Type: " + str(z.type) + "\nArrival Time: " + tym + "\nDate: " + date + "\n"
img = qrcode.make(x)
img.save(y)
fhand = open('data.txt','a')
fhand.write(x)
fhand.write("\n")
fhand.close()
print("\nPlease Wait! Your Ticket is being Generated!")
generate.make(type,spot,tym,date,count)
os.remove(y)
def arrival(count):
status()
mainmenu(count)
print("Ticket generated successfully!\n")
print("Opening Gate, Please Collect Your Ticket and Enter")
module.servo(0)
module.servo(90)
time.sleep(4)
print("Closing Gate")
module.servo(0)
def departure(tn):
file = open("data.txt")
for line in file:
line = line.rstrip()
if line.startswith('Arrival '):
fhand = open("a.txt",'a')
fhand.write(line)
fhand.write("\n")
fhand.close()
else:
continue
ml = linecache.getline('a.txt',tn)
file = open("a.txt","r+")
file.truncate(0)
file.close()
ahr = int(ml[14:16])
amin = int(ml[17:19])
asec = int(ml[20:22])
#print(ahr,amin,asec)
t = datetime.datetime.now()
dtym = t.strftime("%I:%M:%S %p")
dtym = "Departure Time: " + dtym
print(dtym)
dhr = int(dtym[16:18])
dmin = int(dtym[19:21])
dsec = int(dtym[22:24])
#print(dhr,dmin,dsec)
hr = dhr-ahr
if amin > dmin:
min = amin - dmin
totaltime = hr*60 - min
else:
min = dmin - amin
totaltime = hr*60 + min
fare = totaltime*0.2
print("Your Vehicle Was Parked for: ",totaltime," Minutes")
print("\nYour Bill amount is: ",round(fare,2), "Rs")
print("\n ===========>Thank You!<===========")
print("\n")
while(True):
print("1.Arrival\n2.Status Check\n3.Departure\n")
x = int(input("Choose Option: "))
print("\n")
if x == 1:
fhand = open("data.txt")
for line in fhand:
line = line.rstrip()
if line.startswith('Ticket '):
fhand1 = open("a.txt",'a')
fhand1.write(line)
fhand1.write("\n")
fhand1.close()
else:
continue
fhand2 = open("a.txt")
count = 0
for i in fhand2:
count = count + 1
arrival(count+1)
file = open("a.txt","r+")
file.truncate(0)
file.close()
if x == 2:
showstatus()
if x == 3:
tn = int(input("Enter Your Ticket Number: "))
sn = int(input("Enter Your Spot Number: "))
cc.empty(sn)
departure(tn)