示例#1
0
def setColor(polygonID, color):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.VAR_COLOR, polygonID,
                        1 + 1 + 1 + 1 + 1)
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR,
                                         int(color[0]), int(color[1]),
                                         int(color[2]), int(color[3]))
    trace._sendExact()
def setColor(typeID, color):
    trace._beginMessage(tc.CMD_SET_VEHICLETYPE_VARIABLE, tc.VAR_COLOR, typeID,
                        1 + 1 + 1 + 1 + 1)
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR,
                                         int(color[0]), int(color[1]),
                                         int(color[2]), int(color[3]))
    trace._sendExact()
示例#3
0
def setShape(polygonID, shape):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.VAR_SHAPE, polygonID,
                        1 + 1 + len(shape) * (8 + 8))
    trace._message.string += struct.pack("!BB", tc.TYPE_POLYGON, len(shape))
    for p in shape:
        trace._message.string += struct.pack("!dd", p)
    trace._sendExact()
示例#4
0
def slowDown(vehID, speed, duration):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_SLOWDOWN, vehID,
                        1 + 4 + 1 + 8 + 1 + 4)
    trace._message.string += struct.pack("!BiBdBi", tc.TYPE_COMPOUND, 2,
                                         tc.TYPE_DOUBLE, speed,
                                         tc.TYPE_INTEGER, duration)
    trace._sendExact()
示例#5
0
def add(routeID, edges):
    trace._beginMessage(tc.CMD_SET_ROUTE_VARIABLE, tc.ADD, routeID,
                        1+4+sum(map(len, edges))+4*len(edges))
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRINGLIST, len(edges))
    for e in edges:
        trace._message.string += struct.pack("!i", len(e)) + e
    trace._sendExact()
示例#6
0
def changeLane(vehID, laneIndex, duration):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_CHANGELANE, vehID,
                        1 + 4 + 1 + 1 + 1 + 4)
    trace._message.string += struct.pack("!BiBBBi", tc.TYPE_COMPOUND, 2,
                                         tc.TYPE_BYTE, laneIndex,
                                         tc.TYPE_INTEGER, duration)
    trace._sendExact()
示例#7
0
def setCompleteRedYellowGreenDefinition(tlsID, tls):
    length = 1 + 4 + 1 + 4 + len(
        tls._subID) + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 4  # tls parameter
    itemNo = 1 + 1 + 1 + 1 + 1
    for p in tls._phases:
        length += 1 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + len(p._phaseDef)
        itemNo += 4
    trace._beginMessage(tc.CMD_SET_TL_VARIABLE, tc.TL_COMPLETE_PROGRAM_RYG,
                        tlsID, length)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, itemNo)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(
        tls._subID)) + tls._subID  # programID
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, 0)  # type
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND,
                                         0)  # subitems
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER,
                                         tls._currentPhaseIndex)  # index
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER,
                                         len(tls._phases))  # phaseNo
    for p in tls._phases:
        trace._message.string += struct.pack("!BiBiBi", tc.TYPE_INTEGER,
                                             p._duration, tc.TYPE_INTEGER,
                                             p._duration1, tc.TYPE_INTEGER,
                                             p._duration2)
        trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                             len(p._phaseDef)) + p._phaseDef
    trace._sendExact()
示例#8
0
def setEffort(vehID, begTime, endTime, edgeID, effort):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_EDGE_EFFORT, vehID,
                        1 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + len(edgeID) + 1 + 4)
    trace._message.string += struct.pack(
        "!BiBiBiBi", tc.TYPE_COMPOUND, 4, tc.TYPE_INTEGER, begTime,
        tc.TYPE_INTEGER, endTime, tc.TYPE_STRING, len(edgeID)) + edgeID
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, effort)
    trace._sendExact()
示例#9
0
def setOffset(viewID, x, y):
    """setOffset(string, double, double) -> None
    
    Set the current offset for the given view.
    """
    trace._beginMessage(tc.CMD_SET_GUI_VARIABLE, tc.VAR_VIEW_OFFSET, viewID, 1+8+8)
    trace._message.string += struct.pack("!Bdd", tc.POSITION_2D, x, y)
    trace._sendExact()
示例#10
0
def setEffort(edgeID, effort):
    """setEffort(string, double) -> None
    
    Adapt the effort value used for (re-)routing for the given edge.
    """
    trace._beginMessage(tc.CMD_SET_EDGE_VARIABLE, tc.VAR_EDGE_EFFORT, edgeID, 1+4+1+8)
    trace._message.string += struct.pack("!BiBd", tc.TYPE_COMPOUND, 1, tc.TYPE_DOUBLE, effort)
    trace._sendExact()
示例#11
0
def moveTo(vehID, laneID, pos):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_MOVE_TO, vehID,
                        1 + 4 + 1 + 4 + len(laneID) + 1 + 8)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 2)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(laneID)) + laneID
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, pos)
    trace._sendExact()
示例#12
0
def adaptTraveltime(edgeID, time):
    """adaptTraveltime(string, double) -> None
    
    Adapt the travel time value (in s) used for (re-)routing for the given edge.
    """
    trace._beginMessage(tc.CMD_SET_EDGE_VARIABLE, tc.VAR_EDGE_TRAVELTIME, edgeID, 1+4+1+8)
    trace._message.string += struct.pack("!BiBd", tc.TYPE_COMPOUND, 1, tc.TYPE_DOUBLE, time)
    trace._sendExact()
示例#13
0
def setBoundary(viewID, xmin, ymin, xmax, ymax):
    """setBoundary(string, double, double, double, double) -> None
    
    Set the current boundary for the given view (see getBoundary()).
    """
    trace._beginMessage(tc.CMD_SET_GUI_VARIABLE, tc.VAR_VIEW_BOUNDARY, viewID, 1+8+8+8+8)
    trace._message.string += struct.pack("!Bdddd", tc.TYPE_BOUNDINGBOX, xmin, ymin, xmax, ymax)
    trace._sendExact()
示例#14
0
def add(poiID, x, y, color, poiType="", layer=0):
    trace._beginMessage(tc.CMD_SET_POI_VARIABLE, tc.ADD, poiID, 1+4 + 1+4+len(poiType) + 1+1+1+1+1 + 1+4 + 1+8+8)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(poiType)) + poiType
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR, int(color[0]), int(color[1]), int(color[2]), int(color[3]))
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, layer)
    trace._message.string += struct.pack("!Bdd", tc.POSITION_2D, x, y)
    trace._sendExact()
示例#15
0
def setDisallowed(laneID, disallowedClasses):
    trace._beginMessage(
        tc.CMD_SET_LANE_VARIABLE, tc.LANE_DISALLOWED, laneID,
        1 + 4 + sum(map(len, disallowedClasses)) + 4 * len(disallowedClasses))
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRINGLIST,
                                         len(disallowedClasses))
    for c in disallowedClasses:
        trace._message.string += struct.pack("!i", len(c)) + c
    trace._sendExact()
示例#16
0
def setAdaptedTraveltime(vehID, begTime, endTime, edgeID, time):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_EDGE_TRAVELTIME,
                        vehID,
                        1 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + len(edgeID) + 1 + 8)
    trace._message.string += struct.pack(
        "!BiBiBiBi", tc.TYPE_COMPOUND, 4, tc.TYPE_INTEGER, begTime,
        tc.TYPE_INTEGER, endTime, tc.TYPE_STRING, len(edgeID)) + edgeID
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, time)
    trace._sendExact()
示例#17
0
def setStop(vehID, edgeID, pos=1.0, laneIndex=0, duration=2 ** 31 - 1):
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_STOP, vehID, 1 + 4 + 1 + 4 + len(edgeID) + 1 + 8 + 1 + 1 + 1 + 4
    )
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(edgeID)) + edgeID
    trace._message.string += struct.pack(
        "!BdBBBi", tc.TYPE_DOUBLE, pos, tc.TYPE_BYTE, laneIndex, tc.TYPE_INTEGER, duration
    )
    trace._sendExact()
示例#18
0
def setStop(vehID, edgeID, pos=1., laneIndex=0, duration=2**31 - 1):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_STOP, vehID,
                        1 + 4 + 1 + 4 + len(edgeID) + 1 + 8 + 1 + 1 + 1 + 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(edgeID)) + edgeID
    trace._message.string += struct.pack("!BdBBBi", tc.TYPE_DOUBLE, pos,
                                         tc.TYPE_BYTE, laneIndex,
                                         tc.TYPE_INTEGER, duration)
    trace._sendExact()
示例#19
0
def adaptTraveltime(edgeID, time):
    """adaptTraveltime(string, double) -> None
    
    Adapt the travel time value (in s) used for (re-)routing for the given edge.
    """
    trace._beginMessage(tc.CMD_SET_EDGE_VARIABLE, tc.VAR_EDGE_TRAVELTIME,
                        edgeID, 1 + 4 + 1 + 8)
    trace._message.string += struct.pack("!BiBd", tc.TYPE_COMPOUND, 1,
                                         tc.TYPE_DOUBLE, time)
    trace._sendExact()
示例#20
0
def moveToVTD(vehID, edgeID, lane, x, y):
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_MOVE_TO_VTD, vehID, 1 + 4 + 1 + 4 + len(edgeID) + 1 + 4 + 1 + 8 + 1 + 8
    )
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(edgeID)) + edgeID
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, lane)
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, x)
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, y)
    trace._sendExact()
示例#21
0
def moveToVTD(vehID, edgeID, lane, x, y):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_MOVE_TO_VTD, vehID,
                        1 + 4 + 1 + 4 + len(edgeID) + 1 + 4 + 1 + 8 + 1 + 8)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(edgeID)) + edgeID
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, lane)
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, x)
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, y)
    trace._sendExact()
示例#22
0
def setEffort(edgeID, effort):
    """setEffort(string, double) -> None
    
    Adapt the effort value used for (re-)routing for the given edge.
    """
    trace._beginMessage(tc.CMD_SET_EDGE_VARIABLE, tc.VAR_EDGE_EFFORT, edgeID,
                        1 + 4 + 1 + 8)
    trace._message.string += struct.pack("!BiBd", tc.TYPE_COMPOUND, 1,
                                         tc.TYPE_DOUBLE, effort)
    trace._sendExact()
示例#23
0
def add(polygonID, shape, color, fill=False, polygonType="", layer=0):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.ADD, polygonID, 1+4 + 1+4+len(polygonType) + 1+1+1+1+1 + 1+1 + 1+4 + 1+1+len(shape)*(8+8))
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 5)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(polygonType)) + polygonType
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR, int(color[0]), int(color[1]), int(color[2]), int(color[3]))
    trace._message.string += struct.pack("!BB", tc.TYPE_UBYTE, int(fill))
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, layer)
    trace._message.string += struct.pack("!BB", tc.TYPE_POLYGON, len(shape))
    for p in shape:
        trace._message.string += struct.pack("!dd", *p)
    trace._sendExact()
示例#24
0
def setColor(vehID, color):
    """setColor(string, (integer, integer, integer, integer))
    sets color for vehicle with the given ID.
    i.e. (255,0,0,0) for the color red. 
    The fourth integer (alpha) is currently ignored
    """
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_COLOR, vehID, 1 + 1 + 1 + 1 + 1)
    trace._message.string += struct.pack(
        "!BBBBB", tc.TYPE_COLOR, int(color[0]), int(color[1]), int(color[2]), int(color[3])
    )
    trace._sendExact()
示例#25
0
def setColor(vehID, color):
    """setColor(string, (integer, integer, integer, integer))
    sets color for vehicle with the given ID.
    i.e. (255,0,0,0) for the color red. 
    The fourth integer (alpha) is currently ignored
    """
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_COLOR, vehID,
                        1 + 1 + 1 + 1 + 1)
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR,
                                         int(color[0]), int(color[1]),
                                         int(color[2]), int(color[3]))
    trace._sendExact()
示例#26
0
def add(poiID, x, y, color, poiType="", layer=0):
    trace._beginMessage(
        tc.CMD_SET_POI_VARIABLE, tc.ADD, poiID,
        1 + 4 + 1 + 4 + len(poiType) + 1 + 1 + 1 + 1 + 1 + 1 + 4 + 1 + 8 + 8)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(poiType)) + poiType
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR,
                                         int(color[0]), int(color[1]),
                                         int(color[2]), int(color[3]))
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, layer)
    trace._message.string += struct.pack("!Bdd", tc.POSITION_2D, x, y)
    trace._sendExact()
示例#27
0
def add(vehID, routeID, depart=DEPART_NOW, pos=0, speed=0, lane=0, typeID="DEFAULT_VEHTYPE"):
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE,
        tc.ADD,
        vehID,
        1 + 4 + 1 + 4 + len(typeID) + 1 + 4 + len(routeID) + 1 + 4 + 1 + 8 + 1 + 8 + 1 + 1,
    )
    if depart > 0:
        depart *= 1000
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 6)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(typeID)) + typeID
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(routeID)) + routeID
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, depart)
    trace._message.string += struct.pack("!BdBd", tc.TYPE_DOUBLE, pos, tc.TYPE_DOUBLE, speed)
    trace._message.string += struct.pack("!BB", tc.TYPE_BYTE, lane)
    trace._sendExact()
示例#28
0
def setRoute(vehID, edgeList):
    """
    changes the vehicle route to given edges list.
    The first edge in the list has to be the one that the vehicle is at at the moment.
    
    example usage:
    setRoute('1', ['1', '2', '4', '6', '7'])
    
    this changes route for vehicle id 1 to edges 1-2-4-6-7
    """
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_ROUTE, vehID,
                        1 + 4 + sum(map(len, edgeList)) + 4 * len(edgeList))
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRINGLIST,
                                         len(edgeList))
    for edge in edgeList:
        trace._message.string += struct.pack("!i", len(edge)) + edge
    trace._sendExact()
示例#29
0
def setRoute(vehID, edgeList):
    """
    changes the vehicle route to given edges list.
    The first edge in the list has to be the one that the vehicle is at at the moment.
    
    example usage:
    setRoute('1', ['1', '2', '4', '6', '7'])
    
    this changes route for vehicle id 1 to edges 1-2-4-6-7
    """
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_ROUTE, vehID, 1 + 4 + sum(map(len, edgeList)) + 4 * len(edgeList)
    )
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRINGLIST, len(edgeList))
    for edge in edgeList:
        trace._message.string += struct.pack("!i", len(edge)) + edge
    trace._sendExact()
def setCompleteRedYellowGreenDefinition(tlsID, tls):
    length = 1+4 + 1+4+len(tls._subID) + 1+4 + 1+4 + 1+4 + 1+4 # tls parameter
    itemNo = 1+1+1+1+1
    for p in tls._phases:
        length += 1+4 + 1+4 + 1+4 + 1+4+len(p._phaseDef)
        itemNo += 4
    trace._beginMessage(tc.CMD_SET_TL_VARIABLE, tc.TL_COMPLETE_PROGRAM_RYG, tlsID, length)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, itemNo)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(tls._subID)) + tls._subID # programID
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, 0) # type
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 0) # subitems
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, tls._currentPhaseIndex) # index
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, len(tls._phases)) # phaseNo
    for p in tls._phases:
        trace._message.string += struct.pack("!BiBiBi", tc.TYPE_INTEGER, p._duration, tc.TYPE_INTEGER, p._duration1, tc.TYPE_INTEGER, p._duration2)
        trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(p._phaseDef)) + p._phaseDef
    trace._sendExact()
示例#31
0
def add(polygonID, shape, color, fill=False, polygonType="", layer=0):
    trace._beginMessage(
        tc.CMD_SET_POLYGON_VARIABLE, tc.ADD, polygonID,
        1 + 4 + 1 + 4 + len(polygonType) + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 4 +
        1 + 1 + len(shape) * (8 + 8))
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 5)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(polygonType)) + polygonType
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR,
                                         int(color[0]), int(color[1]),
                                         int(color[2]), int(color[3]))
    trace._message.string += struct.pack("!BB", tc.TYPE_UBYTE, int(fill))
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, layer)
    trace._message.string += struct.pack("!BB", tc.TYPE_POLYGON, len(shape))
    for p in shape:
        trace._message.string += struct.pack("!dd", *p)
    trace._sendExact()
示例#32
0
def setAdaptedTraveltime(vehID, begTime, endTime, edgeID, time):
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_EDGE_TRAVELTIME, vehID, 1 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + len(edgeID) + 1 + 8
    )
    trace._message.string += (
        struct.pack(
            "!BiBiBiBi",
            tc.TYPE_COMPOUND,
            4,
            tc.TYPE_INTEGER,
            begTime,
            tc.TYPE_INTEGER,
            endTime,
            tc.TYPE_STRING,
            len(edgeID),
        )
        + edgeID
    )
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, time)
    trace._sendExact()
示例#33
0
def setEffort(vehID, begTime, endTime, edgeID, effort):
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_EDGE_EFFORT, vehID, 1 + 4 + 1 + 4 + 1 + 4 + 1 + 4 + len(edgeID) + 1 + 4
    )
    trace._message.string += (
        struct.pack(
            "!BiBiBiBi",
            tc.TYPE_COMPOUND,
            4,
            tc.TYPE_INTEGER,
            begTime,
            tc.TYPE_INTEGER,
            endTime,
            tc.TYPE_STRING,
            len(edgeID),
        )
        + edgeID
    )
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, effort)
    trace._sendExact()
示例#34
0
def add(vehID,
        routeID,
        depart=DEPART_NOW,
        pos=0,
        speed=0,
        lane=0,
        typeID="DEFAULT_VEHTYPE"):
    trace._beginMessage(
        tc.CMD_SET_VEHICLE_VARIABLE, tc.ADD, vehID, 1 + 4 + 1 + 4 +
        len(typeID) + 1 + 4 + len(routeID) + 1 + 4 + 1 + 8 + 1 + 8 + 1 + 1)
    if depart > 0:
        depart *= 1000
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 6)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(typeID)) + typeID
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(routeID)) + routeID
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, depart)
    trace._message.string += struct.pack("!BdBd", tc.TYPE_DOUBLE, pos,
                                         tc.TYPE_DOUBLE, speed)
    trace._message.string += struct.pack("!BB", tc.TYPE_BYTE, lane)
    trace._sendExact()
示例#35
0
def remove(poiID, layer=0):
    trace._beginMessage(tc.CMD_SET_POI_VARIABLE, tc.REMOVE, poiID, 1+4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, layer)
    trace._sendExact()
示例#36
0
def setType(poiID, poiType):
    trace._beginMessage(tc.CMD_SET_POI_VARIABLE, tc.VAR_TYPE, poiID, 1+4+len(poiType))
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(poiType)) + poiType
    trace._sendExact()
示例#37
0
def setPosition(poiID, x, y):
    trace._beginMessage(tc.CMD_SET_POI_VARIABLE, tc.VAR_POSITION, poiID, 1+8+8)
    trace._message.string += struct.pack("!Bdd", tc.POSITION_2D, x, y)
    trace._sendExact()
示例#38
0
def moveTo(vehID, laneID, pos):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.VAR_MOVE_TO, vehID, 1 + 4 + 1 + 4 + len(laneID) + 1 + 8)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 2)
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING, len(laneID)) + laneID
    trace._message.string += struct.pack("!Bd", tc.TYPE_DOUBLE, pos)
    trace._sendExact()
示例#39
0
def setColor(typeID, color):
    trace._beginMessage(tc.CMD_SET_VEHICLETYPE_VARIABLE, tc.VAR_COLOR, typeID, 1+1+1+1+1)
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR, int(color[0]), int(color[1]), int(color[2]), int(color[3]))
    trace._sendExact()
示例#40
0
def setColor(polygonID, color):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.VAR_COLOR, polygonID, 1+1+1+1+1)
    trace._message.string += struct.pack("!BBBBB", tc.TYPE_COLOR, int(color[0]), int(color[1]), int(color[2]), int(color[3]))
    trace._sendExact()
示例#41
0
def changeLane(vehID, laneIndex, duration):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_CHANGELANE, vehID, 1 + 4 + 1 + 1 + 1 + 4)
    trace._message.string += struct.pack(
        "!BiBBBi", tc.TYPE_COMPOUND, 2, tc.TYPE_BYTE, laneIndex, tc.TYPE_INTEGER, duration
    )
    trace._sendExact()
示例#42
0
def slowDown(vehID, speed, duration):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_SLOWDOWN, vehID, 1 + 4 + 1 + 8 + 1 + 4)
    trace._message.string += struct.pack(
        "!BiBdBi", tc.TYPE_COMPOUND, 2, tc.TYPE_DOUBLE, speed, tc.TYPE_INTEGER, duration
    )
    trace._sendExact()
示例#43
0
def setType(polygonID, polygonType):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.VAR_TYPE, polygonID,
                        1 + 4 + len(polygonType))
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRING,
                                         len(polygonType)) + polygonType
    trace._sendExact()
示例#44
0
def rerouteTraveltime(vehID):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_REROUTE_TRAVELTIME, vehID, 1 + 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 0)
    trace._sendExact()
示例#45
0
def rerouteEffort(vehID):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_REROUTE_EFFORT,
                        vehID, 1 + 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 0)
    trace._sendExact()
示例#46
0
def rerouteTraveltime(vehID):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_REROUTE_TRAVELTIME,
                        vehID, 1 + 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 0)
    trace._sendExact()
示例#47
0
def remove(polygonID, layer=0):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.REMOVE, polygonID,
                        1 + 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_INTEGER, layer)
    trace._sendExact()
示例#48
0
def setShape(polygonID, shape):
    trace._beginMessage(tc.CMD_SET_POLYGON_VARIABLE, tc.VAR_SHAPE, polygonID, 1+1+len(shape)*(8+8))
    trace._message.string += struct.pack("!BB", tc.TYPE_POLYGON, len(shape))
    for p in shape:
        trace._message.string += struct.pack("!dd", p)
    trace._sendExact()
示例#49
0
def setDisallowed(laneID, disallowedClasses):
    trace._beginMessage(tc.CMD_SET_LANE_VARIABLE, tc.LANE_DISALLOWED, laneID, 1+4+sum(map(len, disallowedClasses))+4*len(disallowedClasses))
    trace._message.string += struct.pack("!Bi", tc.TYPE_STRINGLIST, len(disallowedClasses))
    for c in disallowedClasses:
        trace._message.string += struct.pack("!i", len(c)) + c
    trace._sendExact()
示例#50
0
def setPosition(poiID, x, y):
    trace._beginMessage(tc.CMD_SET_POI_VARIABLE, tc.VAR_POSITION, poiID,
                        1 + 8 + 8)
    trace._message.string += struct.pack("!Bdd", tc.POSITION_2D, x, y)
    trace._sendExact()
示例#51
0
def rerouteEffort(vehID):
    trace._beginMessage(tc.CMD_SET_VEHICLE_VARIABLE, tc.CMD_REROUTE_EFFORT, vehID, 1 + 4)
    trace._message.string += struct.pack("!Bi", tc.TYPE_COMPOUND, 0)
    trace._sendExact()