2016-07-19 14 views
0

Ich versuche, einen Agenten zu entwickeln, der platform.historian abfragt, aber diese Fehlermeldung bei Verwendung der RPC-Abfrage-Methode: AttributeError: 'NoneType' Objekt hat kein AttributRPC stürzt mit AttributeError ab: 'NoneType' -Objekt hat kein Attribut 'call'

class TCMAgent(Agent): 
    def __init__(self, config_path, **kwargs): 
     super(TCMAgent, self).__init__(**kwargs) 
     self.config = utils.load_config(config_path) 
     self.site = self.config.get('campus') 
     self.building = self.config.get('building') 
     self.unit = self.config.get('unit') 
     self.subdevices = self.config.get('subdevices') 
     self.subdevice = self.subdevices[0] 
    ... 
    ... 


def test_api(): 
    '''To test Volttron APIs''' 
    import os 

    topic_tmpl = "{campus}/{building}/{unit}/{subdevice}/{point}" 
    tcm = TCMAgent(os.environ.get('AGENT_CONFIG')) 

    topic1 = topic_tmpl.format(campus='PNNL', 
           building='SEB', 
           unit='AHU1', 
           subdevice='VAV123A', 
           point='MaximumZoneAirFlow') 
    result = tcm.vip.rpc.call('platform.historian', 
           'query', 
           topic=topic1, 
           count=20, 
           order="LAST_TO_FIRST").get(timeout=100) 
    assert result is not None 

if __name__ == '__main__': 
    # Entry point for script 
    #sys.exit(main()) 
    test_api() 

Update-Fehler Trace unter 'Anruf':

2016-07-19 14:58:31,362 volttron.platform.vip.agent.core DEBUG: publickey is None 
2016-07-19 14:58:31,362 volttron.platform.vip.agent.core DEBUG: secretkey is None 
Traceback (most recent call last): 
    File "/home/hngo/volttron/examples/TCMAgent/tcm/agent.py", line 236, in <module> 
    test_api() 
    File "/home/hngo/volttron/examples/TCMAgent/tcm/agent.py", line 230, in test_api 
    order="LAST_TO_FIRST").get(timeout=100) 
    File "/home/hngo/volttron/volttron/platform/vip/agent/subsystems/rpc.py", line 303, in call 
    request, result = self._dispatcher.call(method, args, kwargs) 
AttributeError: 'NoneType' object has no attribute 'call' 
+0

Können Sie die vollständige Rückverfolgung des Fehlers buchen? – Kwarrtz

Antwort

1

Ihr Agent keine Verbindung mit der Plattform auch nicht auf "Start". Das ist das Problem, mit dem Sie es hier zu tun haben. Ich sehe nicht, wie Sie Ihre VIP-Adresse angeben, um sich entweder mit der laufenden Plattform zu verbinden.

Sie müssen Ihren Agenten ausführen, bevor Sie RPC-Anrufe zulassen können. Etwas wie das Folgende, modifiziert von https://github.com/VOLTTRON/volttron/blob/develop/examples/SimpleForwarder/simpleforwarder/simpleforwarder.py#L118 als ein Beispiel.

destination_vip="tcp://127.0.0.1:22916?serverkey=blah&publickey=wah&privatekey=nah 

agent = TMCAgent(config_path=cfg_path, identity=tester, address=destination_vip) 

event = gevent.event.Event() 

# agent.core.run set the event flag to true when agent is running 
gevent.spawn(agent.core.run, event) 

# Wait until the agent is fully initialized and ready to 
# send and receive messages. 
event.wait(timeout=3) 
+0

Großartig! Wenn Sie das gleiche Problem haben, sehen Sie sich [volttron] /platform/vip/agent/example.py an. Es sollte alles abdecken. – HNGO