Example #1
0
def simu_busDataClientByFile(filename):
    bus_id = str(7023)
    line = "303"
    stream = "иопп"
    try:
        file = open(filename, "r")
        gps_datas = getFileData(file)
        file.close()

        # second send data

        for pos in gps_datas:
            lng = coor_2_gps.coordinate2GPS(pos[0])
            lat = coor_2_gps.coordinate2GPS(pos[1])
            data = busDataClient.constructData(bus_id, line, stream, lng, lat)
            busDataClient.sendDataTCP(data)
            time.sleep(1)
            """"""
    except Exception as e:
        print(e)
    return
Example #2
0
 def run(self):
     print(self.ident, self.getName())
     # first read bus gps data file(ro)
     try:
         file = open(BUS_GPS_FILE, 'r')
         gps_datas = getFileData(file)
         file.close()
     
         # second send data
     
         for pos in gps_datas:
             lng = coor_2_gps.coordinate2GPS(pos[0])
             lat = coor_2_gps.coordinate2GPS(pos[1])
             data = busDataClient.constructData(self.bus_id, self.line, self.stream, lng, lat)
             busDataClient.sendDataTCP(data)
             time.sleep(self.interval_time)
         ''''''
     except Exception as e:
         print(e)
         print(self.getName, 'exit!')
     return