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: if self.verbose: self.info("position service not available") return nemid = self.getnemid(netif) ifname = netif.localname if nemid is None: self.info("nemid for %s is unknown" % ifname) return (lat, long, alt) = self.session.location.getgeo(x, y, z) if self.verbose: self.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)" "(%.6f,%.6f,%.6f)" % \ (ifname, nemid, x, y, z, lat, long, alt)) if self.session.emane.version >= self.session.emane.EMANE091: event = LocationEvent() else: event = emaneeventlocation.EventLocation(1) # altitude must be an integer or warning is printed # unused: yaw, pitch, roll, azimuth, elevation, velocity alt = int(round(alt)) if self.session.emane.version >= self.session.emane.EMANE091: event.append(nemid, latitude=lat, longitude=long, altitude=alt) self.session.emane.service.publish(0, event) else: event.set(0, nemid, lat, long, alt) self.session.emane.service.publish(emaneeventlocation.EVENT_ID, emaneeventservice.PLATFORMID_ANY, emaneeventservice.NEMID_ANY, emaneeventservice.COMPONENTID_ANY, event.export())
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: if self.verbose: self.info("position service not available") return nemid = self.getnemid(netif) ifname = netif.localname if nemid is None: self.info("nemid for %s is unknown" % ifname) return (lat, long, alt) = self.session.location.getgeo(x, y, z) if self.verbose: self.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)" "(%.6f,%.6f,%.6f)" % \ (ifname, nemid, x, y, z, lat, long, alt)) if self.session.emane.version >= self.session.emane.EMANE091: event = LocationEvent() else: event = emaneeventlocation.EventLocation(1) # altitude must be an integer or warning is printed # unused: yaw, pitch, roll, azimuth, elevation, velocity alt = int(round(alt)) if self.session.emane.version >= self.session.emane.EMANE091: event.append(nemid, latitude=lat, longitude=long, altitude=alt) self.session.emane.service.publish(0, event) else: event.set(0, nemid, lat, long, alt) self.session.emane.service.publish( emaneeventlocation.EVENT_ID, emaneeventservice.PLATFORMID_ANY, emaneeventservice.NEMID_ANY, emaneeventservice.COMPONENTID_ANY, event.export())
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: if self.verbose: self.info("position service not available") return if self.session.emane.version >= self.session.emane.EMANE091: event = LocationEvent() else: event = emaneeventlocation.EventLocation(len(moved_netifs)) i = 0 for netif in moved_netifs: nemid = self.getnemid(netif) ifname = netif.localname if nemid is None: self.info("nemid for %s is unknown" % ifname) continue (x, y, z) = netif.node.getposition() (lat, long, alt) = self.session.location.getgeo(x, y, z) if self.verbose: self.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)) if self.session.emane.version >= self.session.emane.EMANE091: event.append(nemid, latitude=lat, longitude=long, altitude=alt) else: event.set(i, nemid, lat, long, alt) i += 1 if self.session.emane.version >= self.session.emane.EMANE091: self.session.emane.service.publish(0, event) else: self.session.emane.service.publish( emaneeventlocation.EVENT_ID, emaneeventservice.PLATFORMID_ANY, emaneeventservice.NEMID_ANY, emaneeventservice.COMPONENTID_ANY, event.export(), )
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: if self.verbose: self.info("position service not available") return if self.session.emane.version >= self.session.emane.EMANE091: event = LocationEvent() else: event = emaneeventlocation.EventLocation(len(moved_netifs)) i = 0 for netif in moved_netifs: nemid = self.getnemid(netif) ifname = netif.localname if nemid is None: self.info("nemid for %s is unknown" % ifname) continue (x, y, z) = netif.node.getposition() (lat, long, alt) = self.session.location.getgeo(x, y, z) if self.verbose: self.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)) if self.session.emane.version >= self.session.emane.EMANE091: event.append(nemid, latitude=lat, longitude=long, altitude=alt) else: event.set(i, nemid, lat, long, alt) i += 1 if self.session.emane.version >= self.session.emane.EMANE091: self.session.emane.service.publish(0, event) else: self.session.emane.service.publish( emaneeventlocation.EVENT_ID, emaneeventservice.PLATFORMID_ANY, emaneeventservice.NEMID_ANY, emaneeventservice.COMPONENTID_ANY, event.export())