Example #1
0
def switchByArg(arr):
    arg=arr[0]
    b_data=b''
    if arg==USE_DATA:
        print(USE_DATA)
        b_data=busDataClient.constructData(arr[1], arr[2], arr[3], arr[4], arr[5])
        busDataClient.sendDataTCP(b_data)
    elif arg== NO_HEAD:
        print(NO_HEAD)
        b_data=busDataClient.constructData(arr[1], arr[2], arr[3], arr[4], arr[5])
        b_data[0]=0
        busDataClient.sendDataTCP(b_data)
    elif arg==NO_END:
        print(NO_END)
        b_data=busDataClient.constructData(arr[1], arr[2], arr[3], arr[4], arr[5])
        b_data[-1]=0
        busDataClient.sendDataTCP(b_data)
    elif arg==LEN_ERR:
        print(LEN_ERR)
        b_data=busDataClient.constructData(arr[1], arr[2], arr[3], arr[4], arr[5])
        b_data+=b'x'
        busDataClient.sendDataTCP(b_data)
    elif arg==CHK_ERR:
        print(CHK_ERR)
        b_data=busDataClient.constructData(arr[1], arr[2], arr[3], arr[4], arr[5])
        b_data[-2]^=1
        busDataClient.sendDataTCP(b_data)
    return
Example #2
0
def simu_busDataClient():
    bus_id = str(7023)
    line = "303"
    stream = "иопп"
    lng = str(70922263)
    lat = str(20374106)

    data = busDataClient.constructData(bus_id, line, stream, lng, lat)

    busDataClient.sendDataTCP(data)
    print("exit")
    return
Example #3
0
def simu_busDataClient():
    bus_id=str(7023)
    line='303'
    stream='иопп'
    lng=str(70922263)
    lat=str(20374106)
    
    data=busDataClient.constructData(bus_id, line, stream, lng, lat)
    
    busDataClient.sendDataTCP(data)
    print('exit')
    return
Example #4
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 #5
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