예제 #1
0
파일: TestEmitter.py 프로젝트: RManuM/uRC
 def __init__(self, config=types.ComponentConfig(u"anonymous")):
     PARSER_FILE = "../config/definitions.xml"
     uRC_MODULE_NAME = "TestEmitter"
     Autobahn_Client.__init__(self, uRC_MODULE_NAME, PARSER_FILE, config=config)
     
     
     self.worker = None
예제 #2
0
파일: TestEmitter.py 프로젝트: RManuM/uRC
 def onDisconnect(self):
     self.worker.interrupt()
     Autobahn_Client.onDisconnect(self)
예제 #3
0
파일: TestEmitter.py 프로젝트: RManuM/uRC
 def _startupComponents(self):
     Autobahn_Client._startupComponents(self)
     self.worker = EmitterThread(self)
     self.worker.start()
예제 #4
0
파일: TestEmitter.py 프로젝트: RManuM/uRC
 def _initRpcs(self):
     Autobahn_Client._initRpcs(self)
예제 #5
0
파일: TestEmitter.py 프로젝트: RManuM/uRC
 def _initSubscriptions(self):
     Autobahn_Client._initSubscriptions(self)
예제 #6
0
파일: TestEmitter.py 프로젝트: RManuM/uRC
        
    def run(self):
        Thread.run(self)
        for i in range(10):
            if self.interrupted:
                break
            time.sleep(2)
            print "==run # " + str(i) + "=="
            
            print "publishing..."
            data = {"message":"This is " + self.emitter.uRC_MODULE_NAME + " testing subscription 'uRC.testing.receiver.data'", "index":i}
            self.emitter.publishTestData(data)
            print "done"
            time.sleep(2)
            
            print "calling rpc..."
            result = self.emitter.testPing(i)
            print "done, result:", result
        self.emitter.leave()
        
if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
#     Autobahn_Client.startup_client(TestEmitter)

    ########################################################################
    
    from autobahn.twisted.choosereactor import install_reactor
    reactor = install_reactor()
    Autobahn_Client.startup_client_2(TestEmitter)
#     Autobahn_Client.startup_client_2(TestEmitter_cp)
    reactor.run()
예제 #7
0
파일: TestReceiver.py 프로젝트: RManuM/uRC
 def _initRpcs(self):
     Autobahn_Client._initRpcs(self)
     self._rpcs["uRC.testing.receiver.rpc."+self.uRC_MODULE_NAME] = self.handleRPC
예제 #8
0
파일: TestReceiver.py 프로젝트: RManuM/uRC
 def _startupComponents(self):
     Autobahn_Client._startupComponents(self)
예제 #9
0
파일: TestReceiver.py 프로젝트: RManuM/uRC
 def _initSubscriptions(self):
     Autobahn_Client._initSubscriptions(self)
     self._subscriptions["uRC.testing.receiver.data"] = self.handleTopic
예제 #10
0
파일: TestReceiver.py 프로젝트: RManuM/uRC
    def handleTopic(self, data):
        if self._parser.parse("uRC.testing.receiver.data", data):
            print "received: ", data
        else:
            print "received message contains error", data

    def handleRPC(self, data):
        def function(data):
            result = ""
            if self._parser.parse("uRC.testing.receiver.rpc", data):
                print "RPC: Data:" + str(data)
                time.sleep(3)
                result = "pong:" + str(data["index"])
            else:
                print "RPC: Data contains error: " + str(data)
                result = "received rpc contains error"
            return {"ping":result}
        return self._handle_RPC(function, data)
    
        
if __name__ == "__main__":
    logging.basicConfig(level=logging.INFO)
#     Autobahn_Client.startup_client(TestReceiver)
    
    ########################################################################
     
    from autobahn.twisted.choosereactor import install_reactor
    reactor = install_reactor()
    Autobahn_Client.startup_client_2(TestReceiver)
#     Autobahn_Client.startup_client_2(TestReceiver_cp)
    reactor.run()
예제 #11
0
 def _initRpcs(self):
     Autobahn_Client._initRpcs(self)
     self.__initRPCs_sensor()
예제 #12
0
 def __init__(self, config=types.ComponentConfig(u"anonymous")):
     PARSER_FILE = "../config/definitions.xml"
     uRC_MODULE_NAME = "AscTec_Falcon"
     Autobahn_Client.__init__(self, uRC_MODULE_NAME, PARSER_FILE, config=config)
 
     self._serial = None
예제 #13
0
    def _initRpcs(self):
        Autobahn_Client._initRpcs(self)
        self.__initRPCs_sensor()
        
    def __initRPCs_sensor(self):
        self._rpcs["uRC.sensor.TRIGGER."+self.uRC_MODULE_NAME] = self.on_trigger
        self._rpcs["uRC.sensor.STATUS.GET."+self.uRC_MODULE_NAME] = self.on_status_get
        self._rpcs["uRC.sensor.PROPS.GET."+self.uRC_MODULE_NAME] = self.on_props_get
        self._rpcs["uRC.sensor.PROPS.SET."+self.uRC_MODULE_NAME] = self.on_props_set
   
    def _startupComponents(self):
        Autobahn_Client._startupComponents(self)
        
    def on_trigger(self, data):
        pass
    
    def on_status_get(self, data):
        pass
    
    def on_props_get(self, data):
        pass
    
    def on_props_set(self, data):
        pass
        
        
if __name__ == "__main__":
    reactor = install_reactor()
    logging.basicConfig(level=logging.INFO)
    Autobahn_Client.startup_client_2(Sensor_WebSocket)
    reactor.run()