Changeset 634 in tmcsimulator for branches/LCSv2/controllers/default.py
- Timestamp:
- 02/25/2021 10:00:55 AM (5 years ago)
- File:
-
- 1 edited
-
branches/LCSv2/controllers/default.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/LCSv2/controllers/default.py
r626 r634 1 1 # added comments for testing 2 2 # Constants 3 kLogfile = "samplelogfile.txt" 4 kSimtimefile = "sim_elapsedtime.json" 3 5 hwys = ['','1','5', '22', '55', '57', '73', '74', '91', '133', '142', '241', '261', '405', '605'] 4 6 hwyDirections = ['','NB', 'SB', 'NB/SB','EB','WB','EB/WB'] 5 # Names to appea er in the username dropdown box7 # Names to appear in the username dropdown box 6 8 users = [] 7 9 # Show the login page … … 189 191 fieldname = "s"+session.statustype[0:4]+"time" 190 192 db(db.closures.closureid == session.statustype[4:]).update(**{fieldname:now.strftime("%H%M")}) 193 # Log the update to external file 194 logmessage = getSimTime() + " LCS status update: " + session.username + ", " + session.statustype[4:] + ", " + session.statustype[0:4] + ", " + session.statuser + " " + "\n" 195 text_file = open(kLogfile, "a") 196 text_file.write(logmessage) 197 text_file.close() 191 198 else: 192 199 msg = "error because only checking one box is allowed." … … 201 208 else: 202 209 return "" 210 211 # Fetch simulation time and format it into a timestamp 212 def getSimTime(): 213 import json,datetime 214 try: 215 jsontime = json.load(open(kSimtimefile,'r')) 216 currentSimTime = jsontime["elapsedtime"] 217 timestamp = str(datetime.timedelta(seconds = int(currentSimTime))) 218 return timestamp 219 except: 220 # Fallback if missing file, use current time 221 now = datetime.datetime.today() 222 return now.strftime("%H:%M:%S") 203 223 204 224 # Create a new record … … 296 316 newrec = db.closures.insert(closureid=newID, lognum=newLognum, route=form.vars.route, direction=form.vars.direction, facility=form.vars.facility, startcounty=form.vars.startcounty, endcounty=form.vars.endcounty, startlocation=form.vars.startlocation, endlocation=form.vars.endlocation, startdate=form.vars.startdate, enddate=form.vars.enddate, starttime=form.vars.starttime+form.vars.starttimemin, endtime=form.vars.endtime+form.vars.endtimemin, closuretype=form.vars.closuretype, closedlanes=selectedlanes, worktype=form.vars.worktype, estdelay=form.vars.estdelay, tmpcozeep=getCheckbox(form.vars.cozeep), tmpdetour=getCheckbox(form.vars.detour), supervisor=supervisor_name, fieldrep=fieldrep_name, s1097date='', s1098date='', s1022date='' ) 297 317 session.flash = 'New lane closure added: ' + newID + ' ' + newLognum + ': ' + selectedlanes 318 # Log the new closure to external file. Username, closureID, route, dir, type of closure, type of work 319 logmessage = getSimTime() + " LCS new closure: " + session.username + ", " + newID + '.' + newLognum + ', ' + form.vars.route + form.vars.direction + ', ' + form.vars.closuretype + ', ' + form.vars.worktype + "\n" 320 text_file = open(kLogfile, "a") 321 text_file.write(logmessage) 322 text_file.close() 298 323 redirect(URL('search.html')) 299 324 return dict(form=form)
Note: See TracChangeset
for help on using the changeset viewer.
