# -*- coding: utf-8 -*- """ GUEZ NASAT Simulator Via this script it is possible to communicate with the GUEZ NASAT Proxy Server to send individual messages or make an aircraft fly in a circle. @author: Filip Biedziak """ import sys import argparse from nasat_socket import NasatSocket from signal_handler import SignalHandler if __name__ == "__main__": parser = argparse.ArgumentParser( description="GUEZ NASAT Simulator - This script can be used to send messages to the GUEZ NASAT Proxy over a " + "WebSocket. Using this method simulates the real life workflow with a real aircraft or by use of the " + "simulator. The following telegram types a currently supported: NasatPosition and NasatNineLiner. If you " + "want a new telegram type to be added to this script, feel free to contact Filip Biedziak " + "(SLTE, filip.biedziak@rheinmetall.com)." ) parser.add_argument( "-a", "--aircraft", action="store", dest="aircraft", type=int, help="Aircraft ID (required for telegram type NasatPosition)" ) parser.add_argument( "-f", "--fname", action="store", dest="fname", type=str, help="JSON file with data for NasatNineLiner/WeaponRelease telegram" ) parser.add_argument( "-n", "--lon", action="store", dest="lon", type=float, help="replaces lon value in WeaponRelease Telegream" ) parser.add_argument( "-g", "--lat", action="store", dest="lat", type=float, help="replaces lat value in WeaponRelease Telegream" ) parser.add_argument( "-l", "--location", action="store", dest="location", default="Bremen", type=str, help="Location used to send NasatPosition telegrams (either Bremen or Letzlingen, default=Bremen)" ) parser.add_argument( "-u", "--fusetype", action="store", dest="fusetype", type=int, help="replaces fusetype value in WeaponRelease Telegream 0=Unkwon, 1=Instand, 2=Delay, 3=Burst" ) parser.add_argument( "-i", "--flighttime", action="store", dest="flightTime", type=float, help="replaces flightTime value in WeaponRelease Telegream" ) parser.add_argument( "-m", "--munition", action="store", dest="mun", type=int, help="replaces munnition Code value in WeaponRelease Telegream ( 1-41)" ) parser.add_argument( "-t", "--type", action="store", dest="type", default="NasatWeaponRelease", type=str, help="NASAT telegram type (default=NasatWeaponRelease). NasatPosition will send the given aircraft on an elliptical path " + "around the training area. Requires options -a and -l to be specified."+ "NasatNineLiner sends the specified JSON file as NineLiner Telegram " + "NasatWeaponRelease if -f specified it sends the given JSON file otherwise it used the default file and replaces gived attibutes (-m -i -u -g -n)"+ "Default = NasatWeaponRelease" ) parser.add_argument( "-v", "--verbose", action="store", dest="verbose", default=1, type=int, help="Increase output verbosity (default=1)" ) args = parser.parse_args(sys.argv[1:]) aircraft = args.aircraft location = args.location telegramType = args.type verbose = args.verbose lon = args.lon lat = args.lat fuseType = args.fusetype muncode = args.mun flightTime = args.flightTime kwargs = {} kwargs["fname"] = "nasat_weapon_release_template.json" if args.fname is not None: kwargs["fname"] = args.fname print("================================ GUEZ NASAT Simulator ================================") if telegramType != "NasatPosition": if location is not None and verbose > 0: print("Ignoring option -l/--location with value: ", location) #aircraft = 0 else: stop = False if aircraft is None: print("Please specify an aircraft ID.") stop = True if location is None: print("Please specify a location (Bremen or Letzlingen).") stop = True elif location not in ("Bremen", "Letzlingen"): print("Unknown location: %s" % location) stop = True if stop: sys.exit(0) socket = NasatSocket(telegramType, verbose) if (lon is not None and lat is not None): socket.setPosition(lon, lat) print("SET LON " , lon) print("SET LAT " , lat) else: print("NO LON LAT") if (muncode is not None): socket.setMunition(muncode) print("our fusetype", fuseType) if (fuseType is not None): socket.setFuseType(fuseType) if (flightTime is not None): socket.setFlightTime(flightTime) signalHandler = SignalHandler(socket) if socket.telegramType() == "NasatPosition": socket.setAircraftId(aircraft) socket.setLocation(location) elif aircraft is not None: socket.setAircraftId(aircraft) socket.connect() socket.start(**kwargs)