Exemplo n.º 1
0
def dudewheresmyairplane():
    #planes={}
    print("Sending request for aircraft list...")
    airplanes = request_throttle('aircraft', 'key', 'Aircraft', 1)
    for plane in airplanes:
        loc = fseutils.gebtn(plane, "Location")
        reg = fseutils.gebtn(plane, "Registration")
        eng = fseutils.gebtn(plane, "EngineTime")
        chk = fseutils.gebtn(plane, "TimeLast100hr")
        #planes[reg]=(loc,eng,chk)
        print(reg + " at " + loc + "  tot: " + eng + "  last: " + chk)
Exemplo n.º 2
0
def getcommo(ctype): # Adds up locations and quantities of stuff to send to the mapper
	if ctype=="fuel":
		t1="JetA Fuel"
		t2="100LL Fuel"
	elif ctype=="mtrl":
		t1="Supplies"
		t2="Building materials"
	else:
		print("Commodity type "+ctype+" not recognized!")
	if t1 is not None:
		print("Sending request for commodities...")
		commo = fseutils.fserequest_new('commodities','key','Commodity','xml',1,1)
		print("Sorting results...")
		stuff = []
		for item in commo: #Parse commodity info
			typ = fseutils.gebtn(item, "Type")
			if typ==t1 or typ==t2:
				loc = fseutils.gebtn(item, "Location")
				amt = fseutils.gebtn(item, "Amount")
				stuff.append((loc,typ,amt))
		if stuff!=[]: #Add up quantity per location
			qty=[] #List to hold quantities and types
			for item in stuff:
				match=-1
				i=-1
				for prev in qty:
					i+=1
					if item[0]==qty[0]: #Test if the location has already been added
						match=1
						break
				if match==-1: #If location not added, then add new location/quantity
					if item[1]==t1:
						idx=0
					else: #t2
						idx=1
					qty.append([item[0],int(item[2].split()[0]),idx])
				else: #If location already added, then sum with other quantity
					qty[i][1]+=item[2].split()
					qty[i][2]=2 #Indicates a mix of t1 and t2
			coords,cmin,cmax=fseutils.getcoords(i[0] for i in qty)
			if len(coords)==len(qty): #If not, there was some key error I guess
				locations=[]
				print("Working with "+str(len(coords))+" coords...")
				for i in range(len(coords)):
					print("Apending "+str(coords[i][0])+","+str(coords[i][1])+","+str(qty[i][1])+","+str(qty[i][2]))
					locations.append([coords[i][0],coords[i][1],qty[i][1],qty[i][2]])
				return locations,cmin,cmax
		else:
			print("No "+ctype+" found!")
Exemplo n.º 3
0
def jobsforairplanes(price):
    models = {}
    jobs = []
    print("Sending request for aircraft list...")
    airplanes = request_throttle('aircraft', 'key', 'Aircraft', 1)
    for plane in airplanes:
        loc = fseutils.gebtn(plane, "Location")
        mod = fseutils.gebtn(plane, "MakeModel")
        if loc != "In Flight":
            near = nearby(loc, 75)
            try:
                apts = models[mod]
                apts = apts + "-" + near
            except (KeyError, IndexError) as e:
                apts = near
            models[mod] = apts
    for model, apts in models.items():
        seats = getseats(model)
        jobs = jobsfrom(apts, price, seats)
        print(model + ": " + str(seats) + " seats")
        printjobs(jobs, 0)
Exemplo n.º 4
0
def paxtest(assignments, minpax, maxpax, tofrom):
    candidates = []
    apts = {}
    jobs = []
    for assignment in assignments:
        loc = fseutils.gebtn(assignment, "Location")
        arr = fseutils.gebtn(assignment, "ToIcao")
        amt = fseutils.gebtn(assignment, "Amount")
        typ = fseutils.gebtn(assignment, "UnitType")
        if tofrom == "to":
            global totalto
            totalto += 1
            key = loc
        else:
            global totalfrom
            totalfrom += 1
            key = arr
        if not (int(amt) > maxpax
                and typ == "passengers") and typ == "passengers":
            amt = int(amt)
            pay = float(fseutils.gebtn(assignment, "Pay"))
            #dep = fseutils.gebtn(assignment, "FromIcao")
            exp = fseutils.gebtn(assignment, "Expires")
            candidates.append((loc, arr, amt, typ, pay, exp))
            try:
                tot = apts[key]
                tot += amt
            except (KeyError, IndexError) as e:
                tot = amt
            apts[key] = tot
    for option in candidates:
        tot = apts[option[0]]
        if tot > minpax:
            jobs.append(option)
    return jobs
Exemplo n.º 5
0
def jobstest(assignment, jobs, price, pax):
    pay = float(fseutils.gebtn(assignment, "Pay"))
    if pay > price:
        amt = fseutils.gebtn(assignment, "Amount")
        typ = fseutils.gebtn(assignment, "UnitType")
        if not (int(amt) > pax and typ == "passengers"):
            #dep = fseutils.gebtn(assignment, "FromIcao")[0].firstChild.nodeValue
            arr = fseutils.gebtn(assignment, "ToIcao")
            loc = fseutils.gebtn(assignment, "Location")
            exp = fseutils.gebtn(assignment, "Expires")
            jobs.append((loc, arr, amt, typ, pay, exp))
            #if dep==loc:
            #	print (amt+" "+typ+" "+dep+"-"+arr+" $"+str(int(pay))+" "+exp)
            #else:
            #	print (amt+" "+typ+" @"+loc+"-"+arr+" $"+str(int(pay))+" "+exp)
    return jobs
Exemplo n.º 6
0
caut100ll = 1000 #Gallons of 100LL to first send first notification
warndays = 0 #Second notifications
warnjeta = 0
warn100ll = 0
print("Sending request for FBO list...")
commo = fseutils.fserequest_new('fbos','key','FBO','xml',2,0)
#print(commo)
lowjeta = []
low100ll = []
lowsupp = []
nojeta = []
no100ll = []
nosupp = []
for fbo in commo: #Parse commodity info
	#print(fbo)
	icao = fseutils.gebtn(fbo,"Icao",0)
	#print("ICAO="+icao)
	f100 = int(fseutils.gebtn(fbo,"Fuel100LL",0))
	#print("f100="+str(f100))
	fja = int(fseutils.gebtn(fbo,"FuelJetA",0))
	#print("fja="+str(fja))
	days = int(fseutils.gebtn(fbo,"SuppliedDays",0))
	#print("days="+str(days))
	if fja<1:
		nojeta.append((icao,str(round(fja/2.65))))
	elif fja/2.65 <= cautjeta:
		lowjeta.append((icao,str(round(fja/2.65))))
		#print(lowjeta)
	if f100 < 1:
		no100ll.append((icao,str(round(f100/2.65))))
	elif f100/2.65 <= caut100ll:
Exemplo n.º 7
0
caut100ll = 1000  #Gallons of 100LL to first send first notification
warndays = 0  #Second notifications
warnjeta = 0
warn100ll = 0
print("Sending request for FBO list...")
commo = fseutils.fserequest_new('fbos', 'key', 'FBO', 'xml', 2, 0)
#print(commo)
lowjeta = []
low100ll = []
lowsupp = []
nojeta = []
no100ll = []
nosupp = []
for fbo in commo:  #Parse commodity info
    #print(fbo)
    icao = fseutils.gebtn(fbo, "Icao", 0)
    #print("ICAO="+icao)
    f100 = int(fseutils.gebtn(fbo, "Fuel100LL", 0))
    #print("f100="+str(f100))
    fja = int(fseutils.gebtn(fbo, "FuelJetA", 0))
    #print("fja="+str(fja))
    days = int(fseutils.gebtn(fbo, "SuppliedDays", 0))
    #print("days="+str(days))
    if fja < 1:
        nojeta.append((icao, str(round(fja / 2.65))))
    elif fja / 2.65 <= cautjeta:
        lowjeta.append((icao, str(round(fja / 2.65))))
        #print(lowjeta)
    if f100 < 1:
        no100ll.append((icao, str(round(f100 / 2.65))))
    elif f100 / 2.65 <= caut100ll: