Ejemplo n.º 1
0
def outgauge_init():
    global insim
    while (running):
        insim = pyinsim.insim('192.168.1.10', 29999, Admin='')
        insim.bind(pyinsim.EVT_ALL, all)
        outsim = pyinsim.outsim('0.0.0.0', 10000, outsim_packet, 2.0)
        outgauge = pyinsim.outgauge('0.0.0.0', 10001, outgauge_packet, 2.0)

        pyinsim.run()
        print "Connection Closed, Retrying"
Ejemplo n.º 2
0
def doVJoyThink():
    global theta
    theta += 0.05
    events = []
    x = int(math.cos(theta) * 32500)
    y = int(math.sin(theta) * 32500)
    insim.send(pyinsim.ISP_MST, Msg='tore')
    events.append([vjoy.EV_ABS, vjoy.ABS_X, x])
    events.append([vjoy.EV_ABS, vjoy.ABS_Y, y])
    print theta
    insim.send(pyinsim.ISP_MST, Msg='Hello, InSim!')
    pyinsim.run()
    print "2"
    return events
Ejemplo n.º 3
0
 def __init__(self, count):       
     # Create 'count' number relay hosts.
     for i in xrange(count):
         relay = pyinsim.relay(name='Relay %d' % (i + 1))
         relay.hosts = [] # Give each relay its own host list.
         
         # Bind events.
         relay.bind(pyinsim.IRP_HOS, self.host_list)
         relay.bind(pyinsim.IRP_ERR, self.relay_error)
         relay.bind(pyinsim.ISP_NCN, self.new_connection)
         
         # Request host list.
         relay.send(pyinsim.IRP_HLR)
         
     # Start pyinsim.
     pyinsim.run()
Ejemplo n.º 4
0
 def run(self, b):
     pyinsim.run(b)
Ejemplo n.º 5
0
 def run(self,b):
     pyinsim.run(b)    
Ejemplo n.º 6
0
    
def new_player(insim, npl):
    # Add the new player to the players dict.
    players[npl.PLID] = npl
    print 'New player: %s' % pyinsim.stripcols(npl.PName)
    
    
def player_left(insim, pll):
    # Get player from the players dict.
    npl = players[pll.PLID]
    # Delete them from the dict.
    del players[pll.PLID]
    print 'Player left: %s' % pyinsim.stripcols(npl.PName)
    

# Init new InSim object.
insim = pyinsim.insim('127.0.0.1', 29999, Admin='')

# Bind events for the connection and player packets.
insim.bind(pyinsim.ISP_NCN, new_connection)
insim.bind(pyinsim.ISP_CNL, connection_left)
insim.bind(pyinsim.ISP_NPL, new_player)
insim.bind(pyinsim.ISP_PLL, player_left)

# Request for LFS to send all connections and players.
insim.send(pyinsim.ISP_TINY, ReqI=255, SubT=pyinsim.TINY_NCN)
insim.send(pyinsim.ISP_TINY, ReqI=255, SubT=pyinsim.TINY_NPL)

# Start pyinsim.
pyinsim.run()
Ejemplo n.º 7
0
                         packet.Vel[0], packet.Vel[1], packet.Vel[2],
                         packet.Pos[0], packet.Pos[1], packet.Pos[2])


def outsim_handler(outsim, packet):
    if(outSocket != None):
        for a in addrs:
            outSocket.sendto(pack_outsimpacket(packet), (a[0], a[1]));



if __name__ == '__main__':
    parser = OptionParser();
    parser.add_option("--outsim-port", action="store", type="int", dest="outsimPort", default=13338);
    parser.add_option("--remote-host", action="store", type="str", dest="remote_host", default="127.0.0.1");
    parser.add_option("--remote-port", action="store", type="int", dest="remote_port", default=13336);

    (options, args) = parser.parse_args();

    # Lägg till remote host
    addrs.append((options.remote_host, options.remote_port));
    
    outsimPort = options.outsimPort;
    outSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);
    pyinsim.outsim('127.0.0.1', outsimPort, outsim_handler, 30.0);
    while(True):
        pyinsim.run(False);
        # Insim fick timeout, vi försöker igen
        print "Insim timeout, retrying...";
    
Ejemplo n.º 8
0
        npl = players.get(info.PLID)
        if npl:
            # Print the player's name.
            #            print npl.PName
            if npl.PName == "Kaarel":
                print info.X, info.Y, info.Speed / 100, info.Heading / 180, info.PLID, npl.PName


#                savetxt("xy.dat", info.X, info.Y, info.Speed/100, info.Heading/180, info.PLID, npl.PName)
#                savetxt('myfile.txt', info.X, info.Y, info.Speed/100, info.Heading/180, info.PLID, npl.PName, fmt="%12.6G")
# Initialize InSim.
insim = pyinsim.insim('127.0.0.1',
                      29999,
                      Flags=pyinsim.ISF_MCI,
                      Interval=600,
                      Admin='')

# Bind packet events.
insim.bind(pyinsim.ISP_ISM, insim_multi)
insim.bind(pyinsim.ISP_NCN, new_connection)
insim.bind(pyinsim.ISP_CNL, connection_leave)
insim.bind(pyinsim.ISP_NPL, new_player)
insim.bind(pyinsim.ISP_PLL, player_leave)
insim.bind(pyinsim.ISP_MCI, multi_car_info)

# When first connected request current host info.
insim.send(pyinsim.ISP_TINY, ReqI=1, SubT=pyinsim.TINY_ISM)

# Run packet receive loop.
pyinsim.run()