Beispiel #1
0
 def starting(self, sender, **kwargs):
     env = os.environ.copy()
     env.pop('AGENT_UUID', None)
     for config_name in driver_config_list:
         _log.debug("Launching driver for config "+config_name)
         driver = DriverAgent(self, config_name)
         gevent.spawn(driver.core.run)   
Beispiel #2
0
 def starting(self, sender, **kwargs):
     start_delay = None
     if self.staggered_start is not None:
         start_delay = self.staggered_start / float(
             len(self.driver_config_list))
     for config_name in self.driver_config_list:
         _log.debug("Launching driver for config " + config_name)
         driver = DriverAgent(self, config_name)
         gevent.spawn(driver.core.run)
         if start_delay is not None:
             gevent.sleep(start_delay)
Beispiel #3
0
 def update_driver(self, config_name, action, contents):
     topic = self.derive_device_topic(config_name)
     self.stop_driver(topic)
     slot = self.freed_time_slots.pop(0) if self.freed_time_slots else len(
         self.instances)
     _log.info("Starting driver: {}".format(topic))
     driver = DriverAgent(self, contents, slot, self.driver_scrape_interval,
                          topic)
     gevent.spawn(driver.core.run)
     self.instances[topic] = driver
     self._name_map[topic.lower()] = topic
     self._update_override_state(topic, 'add')
Beispiel #4
0
    def _setup(self):
        from main import SERVER_NAME, routes
        self.drivers = []
        self.pedestrians = []
        for route in routes:
            if len(route) == 1:
                self.pedestrians.append(PedestrianAgent(address=route[0].lower(),
                                                        agentjid='pedestrian-%s@%s' % (str(uuid4())[:4], SERVER_NAME),
                                                        password='******'))
            else:
                self.drivers.append(DriverAgent(routes=route,
                                                agentjid='driver-%s@%s' % (str(uuid4())[:4], SERVER_NAME),
                                                password='******'))

        for driver in self.drivers:
            driver.start()

        for pedestrian in self.pedestrians:
            pedestrian.start()
Beispiel #5
0
    def update_driver(self, config_name, action, contents):
        topic = self.derive_device_topic(config_name)
        self.stop_driver(topic)

        group = int(contents.get("group", 0))

        slot = self.group_counts[group]

        if self.freed_time_slots[group]:
            slot = self.freed_time_slots[group].pop(0)

        _log.info("Starting driver: {}".format(topic))
        driver = DriverAgent(self, contents, slot, self.driver_scrape_interval,
                             topic, group, self.group_offset_interval,
                             self.publish_depth_first_all,
                             self.publish_breadth_first_all,
                             self.publish_depth_first,
                             self.publish_breadth_first)
        gevent.spawn(driver.core.run)
        self.instances[topic] = driver
        self.group_counts[group] += 1
        self._name_map[topic.lower()] = topic
        self._update_override_state(topic, 'add')