# save file name
         outfile_name = open('current_file.txt', 'w+')
         print(file_name_can, file=outfile_name)
         outfile_name.close()
         # write to a new file
         outfile_can = open(file_name_can, 'w+')
         print('Logging to file')
         # set flags
         file_open = True
         NEW_DATA_START_LOC = True
         FIRST_TIME_START = False
         #file_count += 1
 else:
     NEW_DATA_START_LOC = False
 if not CIRCULATOR:
     if hf.geo_fence_stop(float(curr_lat), float(curr_lon),
                          distance):
         if not NEW_DATA_STOP_LOC and vspeed2 == 0:
             if file_open:
                 outfile_can.close()
                 print('Closed previous file')
             # recaliberate count n distance
             count = 0
             distance = 0
             total_time = 0
             time1_accn = 0
             time2_accn = 0
             distance_half_sec = 0
             prev_dist = 0
             curr_dist = 0
             acceleration = 0
             prev_acceleration = 0
Пример #2
0
         to_be_removed = "rm -f " + filename.rstrip()
         os.system(to_be_removed)
         # open previously logged file and start appending to it (there will be time stamp delay of 5 seconds but vehicle didn't move during then)
         # this means we need current file and previous file, prev file will be tracked only when we come to first bus stop, not at depot
         outfile_name = open('previous_file.txt', 'r')
         filename = outfile_name.readline()
         outfile_name.close()
         outfile_can = open(filename.rstrip(), 'a')
         file_open = True
     time_curr_at_stop = time.time()
     time_spent_at_stop = time_curr_at_stop - time_start_at_stop
 else:
     NEW_DATA_START_LOC = False
     FIRST_TIME_CAPTURE = True
 if not CIRCULATOR:
     if hf.geo_fence_stop(float(curr_lat), float(curr_lon),
                          distance, vspeed2):
         if FIRST_TIME_CAPTURE:
             #capture start time
             time_start_at_stop = time.time()
             time_curr_at_stop = time_start_at_stop
             time_spent_at_stop = 0.0
             FIRST_TIME_CAPTURE = False
         if time_spent_at_stop > 15.0 and time_spent_at_stop < 20.0:
             if not NEW_DATA_STOP_LOC:
                 if file_open:
                     outfile_can.close()
                     print('Closed previous file')
                 # recaliberate count n distance
                 count = 0
                 distance = 0
                 # save previous file