示例#1
0
class Server(object):
    def __init__(self, slam, MAP_SIZE_PIXELS, vehicle):
        self.map_server = MapServer(slam, MAP_SIZE_PIXELS)
        self.control_server = ControlServer(vehicle)

    def start(self):
        """
        Start the server.
        """
        self.map_server.start()
        self.control_server.start()

    def close(self):
        """
        Close the server.
        """
        self.map_server.close()
        self.map_server.join()
        print "MapServer closed."

        self.control_server.close()
        self.control_server.join()
        print "ControlServer closed."
示例#2
0
文件: server.py 项目: Balhau/pyutils
import socket
import sys
import threading
import signal
import yaml
from mapserver import MapServer

NUM_SLOT_MAX = 1000
CONFIG_FILE = "config.yml"
properties = None

with open(CONFIG_FILE,'r') as f:
	properties = yaml.load(f)


map_server = MapServer(NUM_SLOT_MAX,properties)
map_server.register()

IP   = properties['server']['ip']
PORT = properties['server']['port']

class ClientThread(threading.Thread):

	def __init__(self,con,ip,port,map_server):
		print "Start constructor client thread"
		threading.Thread.__init__(self)
		self.con = con
		self.ip = ip
		self.port = port
		self.map_server=map_server
		print "End constructor client thread"
示例#3
0
 def __init__(self, slam, MAP_SIZE_PIXELS, vehicle):
     self.map_server = MapServer(slam, MAP_SIZE_PIXELS)
     self.control_server = ControlServer(vehicle)
示例#4
0
 def startServer(self):
     MapServer('0.0.0.0', 1234, self).start_server()
示例#5
0
import sys
import os
import random
import time
import datetime
import json
import copy

from mapserver import MapServer
from test_spec import TestSpec, testRanges, generate_list_of_perturbation_sequences

cp1_map_fp      = sys.argv[1]
test_spec_fold  = sys.argv[2]
map_server      = MapServer(cp1_map_fp)
waypoints       = list(map_server.get_waypoints()) # node-id of each waypoint
# exclude l11 and l12 from the list of waypoints 
for w in waypoints:
    if (w == "l11") or ( w == "l12"):
        waypoints.remove(w)

def create_test_spec(test_spec_fold, num_targets, power_model_ID, budget, levels, perturbations):
    global waypoints
    global map_server

    # Start location and target locations
    start_loc = random.choice(waypoints)
    # Waypoints could repeat in the list of targets
    # as long as they are not consective in the list.
    target_loc_list = []
    prev_loc = start_loc
    for _ in range(num_targets):