예제 #1
0
import zmq
import Locker
import constraints as c
import cPickle
import commands

# The port to which this server will listen
PORT = '5060'
# Setting up 0mq to work as socket server
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://0.0.0.0:%s" % PORT)


lock = Locker.Lock(300)
# In testing mode no drive commands are executed
TESTING_MODE = True
#import Controller
#from Manual_Drive import *
# create controller entity
#controller = Controller.Controller()

#manualDrive = ManualDrive(controller.start_command,controller.forward,controller.backward,controller.left,controller.right,controller.stop)



# A dictionnary containing the possible commands (keys)
# Correct formated command : {'command':'NameCommand',ID:{}}
commands = {
'LOCK':{'nb_of_arguments':0,'function':func_lock},
'UNLOCK':{'nb_of_arguments':0,'function':func_unlock},
예제 #2
0
import Locker
import constraints as c
import cPickle
from commands import *
DEBUG = True
scriptPath = os.path.realpath(os.path.dirname(sys.argv[0]))
os.chdir(scriptPath)
#append the relative location you want to import from
sys.path.append("../Socket")
import sockets_server

# Setting up a new a new socket server
socket = sockets_server.SocketServer(6001)
socket.start()
# Create a lock entity with a lock time of 20 minutes
lock = Locker.Lock(1200)
if not DEBUG:
    # Import controller, entity responsible for starting and stopping controller commands
    import Controller
    # Import commands that the controller can start
    import ControllerCommands
    # Import manual drive is entity to select the right controller command given the chosen keys
    from ManualDrive import *
    # create controller entity
    print 'Start controller'
    controller = Controller.Controller()
    manualDrive = ManualDrive(
        controller.start_command, ControllerCommands.forward,
        ControllerCommands.backward, ControllerCommands.left,
        ControllerCommands.right, ControllerCommands.forward_left,
        ControllerCommands.forward_right, ControllerCommands.backward_left,