示例#1
0
文件: nodes.py 项目: sorianoas/core
    def setnempositions(self, moved_netifs):
        """
        Several NEMs have moved, from e.g. a WaypointMobilityModel
        calculation. Generate an EMANE Location Event having several
        entries for each netif that has moved.
        """
        if len(moved_netifs) == 0:
            return

        if self.session.emane.service is None:
            logging.info("position service not available")
            return

        event = LocationEvent()
        i = 0
        for netif in moved_netifs:
            nemid = self.getnemid(netif)
            ifname = netif.localname
            if nemid is None:
                logging.info("nemid for %s is unknown" % ifname)
                continue
            x, y, z = netif.node.getposition()
            lat, lon, alt = self.session.location.getgeo(x, y, z)
            # altitude must be an integer or warning is printed
            alt = int(round(alt))
            event.append(nemid, latitude=lat, longitude=lon, altitude=alt)
            i += 1

        self.session.emane.service.publish(0, event)
示例#2
0
文件: nodes.py 项目: gsomlo/core
    def setnempositions(self, moved_netifs):
        """
        Several NEMs have moved, from e.g. a WaypointMobilityModel
        calculation. Generate an EMANE Location Event having several
        entries for each netif that has moved.
        """
        if len(moved_netifs) == 0:
            return

        if self.session.emane.service is None:
            logger.info("position service not available")
            return

        event = LocationEvent()
        i = 0
        for netif in moved_netifs:
            nemid = self.getnemid(netif)
            ifname = netif.localname
            if nemid is None:
                logger.info("nemid for %s is unknown" % ifname)
                continue
            x, y, z = netif.node.getposition()
            lat, long, alt = self.session.location.getgeo(x, y, z)
            logger.info("setnempositions %d %s (%s) x,y,z=(%d,%d,%s)(%.6f,%.6f,%.6f)",
                        i, ifname, nemid, x, y, z, lat, long, alt)
            # altitude must be an integer or warning is printed
            alt = int(round(alt))
            event.append(nemid, latitude=lat, longitude=long, altitude=alt)
            i += 1

        self.session.emane.service.publish(0, event)
示例#3
0
    def set_nem_position(self, iface: CoreInterface) -> None:
        """
        Publish a NEM location change event using the EMANE event service.

        :param iface: interface to set nem position for
        """
        position = self.get_nem_position(iface)
        if position:
            nemid, lon, lat, alt = position
            event = LocationEvent()
            event.append(nemid, latitude=lat, longitude=lon, altitude=alt)
            self.publish_event(nemid, event, send_all=True)
示例#4
0
文件: nodes.py 项目: umr-ds/core
    def setnemposition(self, iface: CoreInterface) -> None:
        """
        Publish a NEM location change event using the EMANE event service.

        :param iface: interface to set nem position for
        """
        if self.session.emane.service is None:
            logging.info("position service not available")
            return
        position = self._nem_position(iface)
        if position:
            nemid, lon, lat, alt = position
            event = LocationEvent()
            event.append(nemid, latitude=lat, longitude=lon, altitude=alt)
            self.session.emane.service.publish(0, event)
示例#5
0
文件: nodes.py 项目: sorianoas/core
    def setnemposition(self, netif, x, y, z):
        """
        Publish a NEM location change event using the EMANE event service.
        """
        if self.session.emane.service is None:
            logging.info("position service not available")
            return
        nemid = self.getnemid(netif)
        ifname = netif.localname
        if nemid is None:
            logging.info("nemid for %s is unknown", ifname)
            return
        lat, lon, alt = self.session.location.getgeo(x, y, z)
        event = LocationEvent()

        # altitude must be an integer or warning is printed
        # unused: yaw, pitch, roll, azimuth, elevation, velocity
        alt = int(round(alt))
        event.append(nemid, latitude=lat, longitude=lon, altitude=alt)
        self.session.emane.service.publish(0, event)
示例#6
0
文件: nodes.py 项目: lyma/core
    def setnempositions(self, moved_netifs: List[CoreInterface]) -> None:
        """
        Several NEMs have moved, from e.g. a WaypointMobilityModel
        calculation. Generate an EMANE Location Event having several
        entries for each netif that has moved.
        """
        if len(moved_netifs) == 0:
            return

        if self.session.emane.service is None:
            logging.info("position service not available")
            return

        event = LocationEvent()
        for netif in moved_netifs:
            position = self._nem_position(netif)
            if position:
                nemid, lon, lat, alt = position
                event.append(nemid, latitude=lat, longitude=lon, altitude=alt)
        self.session.emane.service.publish(0, event)
示例#7
0
文件: nodes.py 项目: gsomlo/core
    def setnemposition(self, netif, x, y, z):
        """
        Publish a NEM location change event using the EMANE event service.
        """
        if self.session.emane.service is None:
            logger.info("position service not available")
            return
        nemid = self.getnemid(netif)
        ifname = netif.localname
        if nemid is None:
            logger.info("nemid for %s is unknown" % ifname)
            return
        lat, long, alt = self.session.location.getgeo(x, y, z)
        logger.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)(%.6f,%.6f,%.6f)", ifname, nemid, x, y, z, lat, long, alt)
        event = LocationEvent()

        # altitude must be an integer or warning is printed
        # unused: yaw, pitch, roll, azimuth, elevation, velocity
        alt = int(round(alt))
        event.append(nemid, latitude=lat, longitude=long, altitude=alt)
        self.session.emane.service.publish(0, event)
示例#8
0
#!/usr/bin/env python
try:
    from emane.events import EventService
    from emane.events import LocationEvent
except:
    from emanesh.events import EventService
    from emanesh.events import LocationEvent

# create the event service
service = EventService(('224.1.2.8', 45703, 'emanenode0'))

# create an event setting 10's position
event = LocationEvent()
event.append(10, latitude=40.031290, longitude=-74.523095, altitude=3.000000)

# publish the event
service.publish(0, event)