def get_current_fuel(self): # Read data. results = pyuipc.read(self.pyuipc_offsets) # Write on Ground flag. self.onGround = results[0] # Get fuel density. self.fuel_pound_gallon = results[1] / 256 self.fuel_kg_gallon = self.fuel_pound_gallon / 2.20462 # Initialise fuel properties. fuel_levels = [0.0] * self.N_TANKS fuel_capacity_gal = [0.0] * self.N_TANKS self.fuel_levels_kg = [0.0] * self.N_TANKS self.fuel_capacity_kg = [0.0] * self.N_TANKS # Get fuel for each tank. for lvl in range(self.N_TANKS): fuel_levels[lvl] = results[2 + lvl * 2] / 8388608 fuel_capacity_gal[lvl] = results[3 + lvl * 2] self.fuel_capacity_kg[ lvl] = fuel_capacity_gal[lvl] * self.fuel_kg_gallon self.fuel_levels_kg[lvl] = round(fuel_levels[lvl] * self.fuel_capacity_kg[lvl]) # print('Tank {}: {}'.format(lvl, self.fuel_levels_kg[lvl])) # Get total fuel in kg. self.fuel_capacity_total = sum(self.fuel_capacity_kg) self.fuel_level_total = sum(self.fuel_levels_kg) pass
def read(self): try: data = pyuipc.read(self.pdata) except pyuipc.FSUIPCException: self.connected = False return wind_heading = int(round(data[5])) wind_speed = int(round(data[6])) update = { "pos": (round(data[0], 8), round(data[1], 8)), "alt": int(round(data[2]*3.28)), # m to ft "speed": int(round(data[3]*1.944)), # m/s to kt "hdg": int(round(data[4]*57.296))%360, # rad to deg "wind": "%i/%i" % (wind_heading, wind_speed), "temp": data[7]/256, "brk": data[8] == 32767, "gear": data[9] == 16383, "eng": (round(data[10]/163.84, 1), round(data[11]/163.84, 1), round(data[12]/163.84, 1), round(data[13]/163.84, 1)), } print(update) self.avionics.update(update)
def dec_fs_com1(): lgt = 2 dat = pyuipc.prepare_data([(0x311A, lgt)]) val = pyuipc.read(dat) freq = decode_freq(decode_bcd(val[0])) new = encode_bcd(encode_freq(dec_com(freq))) pyuipc.write(dat, [new])
def run(self, event): pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS) results = pyuipc.read(pyuipcOffsets) weight=results[0]*32 # in lbs OAT=results[1]/256 # in degC CG=results[2] #in percents # WEIGHT at LSK3 if weight!=self.__oldWeight: self.mqttpublish(Config.topic_display, "T,03,99,0,2,"+str(round(weight))) self.__oldWeight=weight # OAT at RSK3 if OAT!=self.__oldOAT: self.mqttpublish(Config.topic_display, "T,33,99,0,2,"+str(round(OAT))) self.__oldOAT=OAT # CG at LSK6 if CG!=self.__oldCG: self.mqttpublish(Config.topic_display, "T,05,99,0,2,"+str('{0:.2f}'.format(CG))) self.__oldCG=CG if (not(event.isEmpty())): if (event.getTopic()=="j/npanel/e/s" and event.getPayload()=="1"): self.draw(); logging.debug("Redraw")
def update_knob(board): ul = [] fn = [] rng = [] ks = [] fmts = {4:'i', 8:'d'} for key in led_rings_to_update.keys(): ul.append(led_rings_to_update[key][0]) fn.append(led_rings_to_update[key][1]) rng.append(led_rings_to_update[key][2]) ks.append(key) pyuipc.prepare_data(ul, True) res = pyuipc.read(ul) # for i,r in enumerate(res): # print "(%d):%s => %d"%(i, # ks[i], # fn[i]( (struct.unpack(fmts[ul[i][1]], res[i])[0])) ) for i,r in enumerate(res): light_ring(board, rng[i], fn[i]( (struct.unpack(fmts[ul[i][1]], res[i])[0])) )
def read(self): try: data = pyuipc.read(self.pdata) except pyuipc.FSUIPCException: self.connected = False return wind_heading = int(round(data[5])) wind_speed = int(round(data[6])) update = { "pos": (round(data[0], 8), round(data[1], 8)), "alt": int(round(data[2] * 3.28)), # m to ft "speed": int(round(data[3] * 1.944)), # m/s to kt "hdg": int(round(data[4] * 57.296)) % 360, # rad to deg "wind": "%i/%i" % (wind_heading, wind_speed), "temp": data[7] / 256, "brk": data[8] == 32767, "gear": data[9] == 16383, "eng": (round(data[10] / 163.84, 1), round(data[11] / 163.84, 1), round(data[12] / 163.84, 1), round(data[13] / 163.84, 1)), } print(update) self.avionics.update(update)
def read_offsets(offsets_to_read): offset_results = {} offset_values = pyuipc.read(offsets_to_read) for (key, offset), value in zip(offsets.items(), offset_values): offset_results[key] = value return offset_results
def read(self): offset_results = {} offset_values = pyuipc.read(self.prepared_data) for (key, offset), value in zip(self.offsets.items(), offset_values): offset_results[key] = value self.latest_read = offset_results return offset_results
def getPyuipcData(self): if pyuipcImported: results = pyuipc.read(self.pyuipcOffsets) # frequency hexCode = hex(results[0])[2:] self.com1frequency = float('1{}.{}'.format(hexCode[0:2], hexCode[2:])) hexCode = hex(results[1])[2:] self.com2frequency = float('1{}.{}'.format(hexCode[0:2], hexCode[2:])) # radio active #TODO: Test accuracy of this data (with various planes and sims) radioActiveBits = list(map(int, '{0:08b}'.format(results[2]))) if radioActiveBits[2]: self.com1active = True self.com2active = True elif radioActiveBits[0]: self.com1active = True self.com2active = False elif radioActiveBits[1]: self.com1active = False self.com2active = True else: self.com1active = False self.com2active = False # lat lon self.lat = results[3] * (90.0 / (10001750.0 * 65536.0 * 65536.0)) self.lon = results[4] * (360.0 / (65536.0 * 65536.0 * 65536.0 * 65536.0)) else: self.com1frequency = self.COM1_FREQUENCY_DEBUG self.com2frequency = self.COM2_FREQUENCY_DEBUG self.com1active = True self.com2active = True self.lat = self.LAT_DEBUG self.lon = self.LON_DEBUG # Logging. if self.com1active: com1activeStr = 'active' else: com1activeStr = 'inactive' if self.com2active: com2activeStr = 'active' else: com2activeStr = 'inactive' self.logger.debug('COM 1: {} ({}), COM 2: {} ({})'.format( self.com1frequency, com1activeStr, self.com2frequency, com2activeStr))
def loop(): global pyuipcOffsets, oldActMode, actMode, client, alivetime, hasAP, oldAPStatus, panel, APStatus results = pyuipc.read(pyuipcOffsets) APStatus = results[0] hasAP = results[1] if (oldActMode != actMode): # Instanciate panel class child, specific to each panel logging.info("Changing mode to " + actMode) if actMode == "Home": panel = Home(client) if actMode == "RtuCom": panel = RtuCom(client) if actMode == "RtuNav": panel = RtuNav(client) if actMode == "Audio": panel = Audio(client) if actMode == "AP": panel = AP(client) if actMode == "Perfs": panel = Perfs(client) if actMode == "Trim": panel = Trim(client) oldActMode = actMode # loop that updates panel panel.run(event) if event.getPayload() == str(Const.BTMAIN): #return to home actMode = "Home" event.clear() if event.getPayload() == str(Const.BTAP): # AP APStatus = APStatus ^ 1 event.clear() # de/activate autopilot if (APStatus != oldAPStatus): if (APStatus == 0): client.publish(Config.topic_display, "X") client.publish(Config.topic_display, "L,0") # Beep when AP is disabled client.publish(Config.topic_display, "X") else: client.publish(Config.topic_display, "L,1") pyuipc.write([(OFFSETS[0][0], OFFSETS[0][1], APStatus)]) oldAPStatus = APStatus # keepalive to esp32 module every 2 seconds, just say "i'm here" if ((time.time() - alivetime) > 2): logging.debug("Send keep alive to esp32 module") client.publish(Config.topic_prefix + "/c/reqstatus", "1") alivetime = time.time()
def requestAicraftData(): """ Returns a tuple with aircraft latitude, longitude, FL, Altitude AMSL, true heading and mag dev at aircraft position """ data = [ (ACFT_LAT,byte[ACFT_LAT]),\ (ACFT_LONG,byte[ACFT_LONG]), (ACFT_ALT,byte[ACFT_ALT]), (ACFT_HDG_T,byte[ACFT_HDG_T]), (ACFT_MAG_VAR,byte[ACFT_MAG_VAR]), (ACFT_FL,byte[ACFT_FL]) ] pdata = fsuipc.prepare_data(data) acft_data = fsuipc.read(pdata) return [struct.unpack('d',acft_data[i])[0] for i in range(len(acft_data)) ]
def requestAicraftData(): """ Returns a tuple with aircraft latitude, longitude, FL, Altitude AMSL, true heading and mag dev at aircraft position """ data = [ (ACFT_LAT,byte[ACFT_LAT]),\ (ACFT_LONG,byte[ACFT_LONG]), (ACFT_ALT,byte[ACFT_ALT]), (ACFT_HDG_T,byte[ACFT_HDG_T]), (ACFT_MAG_VAR,byte[ACFT_MAG_VAR]), (ACFT_FL,byte[ACFT_FL]) ] pdata = fsuipc.prepare_data(data) acft_data = fsuipc.read(pdata) return [struct.unpack('d', acft_data[i])[0] for i in range(len(acft_data))]
def requestMETAR(ICAOid): """ Returns a METAR string given the 4 code ICAO. The METAR is in FSX enanched format. """ # Writing both signature ('05FC'+ICAO) as 8 byte. Signature is the # required trigger. data = [(WRITE_ICAO_FOR_METAR, byte[WRITE_ICAO_FOR_METAR])] signature = '05FC' pdata = fsuipc.prepare_data(data) fsuipc.write(pdata, [signature + ICAOid]) time_delay = 250e-3 # ms. Required for FSX reading. time.sleep(time_delay) data = [(METAR, byte[METAR])] pdata = fsuipc.prepare_data(data) metar = fsuipc.read(pdata) return metar[0].rstrip('\x00')
def requestMETAR(ICAOid): """ Returns a METAR string given the 4 code ICAO. The METAR is in FSX enanched format. """ # Writing both signature ('05FC'+ICAO) as 8 byte. Signature is the # required trigger. data = [ (WRITE_ICAO_FOR_METAR, byte[WRITE_ICAO_FOR_METAR]) ] signature = '05FC' pdata = fsuipc.prepare_data(data) fsuipc.write(pdata, [signature+ICAOid]) time_delay = 250e-3 # ms. Required for FSX reading. time.sleep(time_delay) data = [ (METAR, byte[METAR]) ] pdata = fsuipc.prepare_data(data) metar = fsuipc.read(pdata) return metar[0].rstrip('\x00')
def update_knob(board): ul = [] fn = [] rng = [] ks = [] fmts = {4: 'i', 8: 'd'} for key in led_rings_to_update.keys(): ul.append(led_rings_to_update[key][0]) fn.append(led_rings_to_update[key][1]) rng.append(led_rings_to_update[key][2]) ks.append(key) pyuipc.prepare_data(ul, True) res = pyuipc.read(ul) # for i,r in enumerate(res): # print "(%d):%s => %d"%(i, # ks[i], # fn[i]( (struct.unpack(fmts[ul[i][1]], res[i])[0])) ) for i, r in enumerate(res): light_ring(board, rng[i], fn[i]((struct.unpack(fmts[ul[i][1]], res[i])[0])))
def posUpdate(): # Update input folder with latest data from FSUIPC/XPUIPC. lat = pyuipc.read([(0x6010, "f")]) lat = float(lat[0]) long = pyuipc.read([(0x6018, "f")]) long = float(long[0]) hdg = pyuipc.read([(0x6040, "f")]) hdg = float(hdg[0]) hdg = hdg * 180 / math.pi vs = pyuipc.read([(0x0842, "h")]) vs = float(vs[0]) vs = vs * -3.28084 alt = pyuipc.read([(0x6020, "f")]) alt = float(alt[0]) alt = alt * 3.28084 gs = pyuipc.read([(0x6030, "f")]) gs = float(gs[0]) gs = gs * 3600 / 1852 return lat, long, hdg, vs, alt, gs
def posUpdate(): # Update input folder with latest data from FSUIPC/XPUIPC. lat = pyuipc.read([(0x6010, "f")]) lat = float(lat[0]) writeData('lat', lat) long = pyuipc.read([(0x6018, "f")]) long = float(long[0]) writeData('lon', long) # hdg = pyuipc.read([(0x6038, "f")]) True Heading hdg = pyuipc.read([(0x6040, "f")]) # Magnetic Heading hdg = float(hdg[0]) hdg = hdg*180/math.pi writeData('heading', hdg) vs = pyuipc.read([(0x0842, "h")]) vs = float(vs[0]) vs = vs * -3.28084 writeData('vs', vs) alt = pyuipc.read([(0x6020, "f")]) alt = float(alt[0]) alt = alt*3.28084 writeData('altitude', alt) gs = pyuipc.read([(0x6030, "f")]) gs = float(gs[0]) gs = gs*3600/1852 writeData('gs', gs)
def read_value(offset, lgt): dat = pyuipc.prepare_data([(offset, lgt)], True) return (pyuipc.read(dat)[0])
def switch_one_of_many_bit(offset, bitNr): lgt = 1 dat = pyuipc.prepare_data([(offset, 1)]) val_ist = pyuipc.read(dat) val_sol = chr(toggleBit(ord(val_ist[0]), bitNr)) pyuipc.write(dat, [val_sol])
def run(self, event): global actMode, APStatus pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS) results = pyuipc.read(pyuipcOffsets) com1=results[0]&128 com2=results[0]&64 both=results[0]&32 nav1=results[0]&16 nav2=results[0]&8 marker=results[0]&4 dme=results[0]&2 adf1=results[0]&1 # com1 select if com1!=self.__oldCom1: if (com1==0): self.mqttpublish(Config.topic_display, "T,02,97,1,4,CM1") else: self.mqttpublish(Config.topic_display, "T,02,97,1,5,CM1") self.__oldCom1=com1 # com2 select if com2!=self.__oldCom2: if (com2==0): self.mqttpublish(Config.topic_display, "T,12,97,1,4,CM2") else: self.mqttpublish(Config.topic_display, "T,12,97,1,5,CM2") self.__oldCom2=com2 # receive both com1 and com1 if both!=self.__oldBoth: if (both==0): self.mqttpublish(Config.topic_display, "T,22,97,1,4,BTH") else: self.mqttpublish(Config.topic_display, "T,22,97,1,5,BTH") self.__oldBoth=both # nav1 if nav1!=self.__oldNav1: if (nav1==0): self.mqttpublish(Config.topic_display, "T,04,97,1,4,NV1") else: self.mqttpublish(Config.topic_display, "T,04,97,1,5,NV1") self.__oldNav1=nav1 # nav1 if nav2!=self.__oldNav2: if (nav2==0): self.mqttpublish(Config.topic_display, "T,14,97,1,4,NV2") else: self.mqttpublish(Config.topic_display, "T,14,97,1,5,NV2") self.__oldNav2=nav2 # marker if marker!=self.__oldMarker: if (marker==0): self.mqttpublish(Config.topic_display, "T,24,97,1,4,MKR") else: self.mqttpublish(Config.topic_display, "T,24,97,1,5,MKR") self.__oldMarker=marker # dme if dme!=self.__oldDme: if (dme==0): self.mqttpublish(Config.topic_display, "T,34,97,1,4,DME") else: self.mqttpublish(Config.topic_display, "T,34,97,1,5,DME") self.__oldDme=dme # adf1 if adf1!=self.__oldAdf1: if (adf1==0): self.mqttpublish(Config.topic_display, "T,06,97,1,4,ADF") else: self.mqttpublish(Config.topic_display, "T,06,97,1,5,ADF") self.__oldAdf1=adf1 if (not(event.isEmpty())): if (event.getTopic()=="j/npanel/e/s" and event.getPayload()=="1"): self.draw(); logging.debug("Redraw") if event.getTopic()==Config.topic_keys: if event.getPayload()==str(Const.LSK2): # com1 pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^192)]) event.clear() if event.getPayload()==str(Const.LCK2): # com2 pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^192)]) event.clear() if event.getPayload()==str(Const.RCK2): # both pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^32)]) event.clear() if event.getPayload()==str(Const.LSK4): # nav1 pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^16)]) event.clear() if event.getPayload()==str(Const.LCK4): # nav2 pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^8)]) event.clear() if event.getPayload()==str(Const.RCK4): # marker pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^4)]) event.clear() if event.getPayload()==str(Const.RSK4): # dme pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^2)]) event.clear() if event.getPayload()==str(Const.LSK6): # adf pyuipc.write([(self.__OFFSETS[0][0],self.__OFFSETS[0][1],results[0]^1)]) event.clear()
def switch_one_bit(offset): lgt = 1 dat = pyuipc.prepare_data([(offset, lgt)]) val_ist = pyuipc.read(dat) val_sol = chr(not (ord(val_ist[0]))) pyuipc.write(dat, [val_sol])
def status_one_of_many_bit(offset, bitNr): lgt = 1 dat = pyuipc.prepare_data([(offset, lgt)], True) val_all = pyuipc.read(dat) val_bit = (ord(val_all[0]) & (1 << bitNr)) return bool(val_bit)
def status_one_bit(offset): lgt = 1 dat = pyuipc.prepare_data([(offset, lgt)], True) val = pyuipc.read(dat) return (True if ord(val[0]) > 0 else False)
def mainFunction(ui, Form): if not isConnectedToSim: confirm = QMessageBox() showDia = confirm.question( None, "", "Are you sure you want to proceed without connecting to the simulator?", confirm.Yes | confirm.No) if showDia == confirm.No: return simulator = clientIds[ui.simCombo.currentText().lower()] departure = ui.depLine.text() destination = ui.arrLine.text() airframe = ui.airframeLine.text() altitude = ui.cruiseLine.text() network = ui.networkCombo.currentText() callsign = ui.callLine.text() if departure == "" or destination == "" or airframe == "" or callsign == "" or altitude == "": msg = QMessageBox() msg.setText("Please enter a value in all fields") msg.exec() return Form.close() standardItems = {"large_image": "planeiconlarge", "large_text": "FSX"} rotatingItems = [{ "state": f"Airframe: {airframe}" }, { "state": f"Cruise: {altitude}ft" }, { "state": f"Callsign: {callsign}" }] if not network.lower() == "offline": rotatingItems.append({"state": f"Connected to: {network}"}) else: rotatingItems.append({"state": f"Cruise: {altitude}ft"}) rotatingStats = [{ "text": "Ground speed: {}kts", "action": lambda: str( round((fs.read(fs.prepare_data([(0x02B4, "d")]))[0] / 65536) * 1.94384)) }, { "text": "Altitude: {}ft", "action": lambda: str( round(fs.read(fs.prepare_data([(0x6020, "f")]))[0] * 3.28084)) }, { "text": "Status: {}", "action": lambda: "On ground" if fs.read(fs.prepare_data([(0x0366, "b")]))[0] == 1 else "Climb" if round( fs.read(fs.prepare_data([(0x02C8, "d")]))[0] * 60 * 3.28084 / 256) > 20 else "Descent" if round( fs.read(fs.prepare_data([(0x02C8, "d")]))[0] * 60 * 3.28084 / 256 ) < -20 else "Levelled off" }, { "text": "Flying {}", "action": lambda: f"{departure} to {destination}" if True else "no" }] rp = Presence(simulator) rp.connect() print("Running") while True: for i in range(4): print(f"Item {i}") for index, item in enumerate(rotatingItems): print(f" Sub-item {index}") for ii in range(5): print(f" Sub-sub-item {ii}") if isConnectedToSim: disp = { "details": rotatingStats[index]["text"].format( rotatingStats[index]["action"]()) } else: disp = { "details": rotatingStats[-1]["text"].format( rotatingStats[-1]["action"]()) } rp.update(**item, **standardItems, **disp) sleep(1)
def run(self, event): global actMode, APStatus if (self.__editCur != self.__oldEditCur): self.draw() self.__oldEditCur = self.__editCur pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS) results = pyuipc.read(pyuipcOffsets) actFreq1 = vhf_bcd2float(results[0]) stbFreq1 = vhf_bcd2float(results[1]) actFreq2 = vhf_bcd2float(results[2]) stbFreq2 = vhf_bcd2float(results[3]) HdgNav1 = results[4] HdgNav2 = results[5] # NAV1 Active at LSK3 if actFreq1 != self.__oldActFreq1: self.mqttpublish(Config.topic_display, "T,03,99,0,3," + str('{0:.3f}'.format(actFreq1))) self.__oldActFreq1 = actFreq1 # NAV1 Stand by at LSK4 if stbFreq1 != self.__oldStbFreq1: if (self.__editCur == "NAV1"): self.mqttpublish( Config.topic_display, "T,04,98,0,3," + str('{0:.3f}'.format(stbFreq1))) self.mqttpublish(Config.topic_display, "T,38,94,0,1,Nav1StbFq/Psh SW>") else: self.mqttpublish( Config.topic_display, "T,04,99,1,3," + str('{0:.3f}'.format(stbFreq1))) self.__oldStbFreq1 = stbFreq1 # NAV2 Active at RSK3 if actFreq2 != self.__oldActFreq2: self.mqttpublish(Config.topic_display, "T,33,99,0,3," + str('{0:.3f}'.format(actFreq2))) self.__oldActFreq2 = actFreq2 # NAV2 Stand by at RSK4 if stbFreq2 != self.__oldStbFreq2: if (self.__editCur == "NAV2"): self.mqttpublish( Config.topic_display, "T,34,98,0,3," + str('{0:.3f}'.format(stbFreq2))) self.mqttpublish(Config.topic_display, "T,38,94,0,1,Nav2StbFq/Psh SW>") else: self.mqttpublish( Config.topic_display, "T,34,99,1,3," + str('{0:.3f}'.format(stbFreq2))) self.__oldStbFreq2 = stbFreq2 # NAV1 HDG at LSK7 if HdgNav1 != self.__oldHdgNav1: if (self.__editCur == "HDG1"): self.mqttpublish( Config.topic_display, "T,07,98,0,3," + str('{0:0>3.0f}'.format(HdgNav1))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, OBS1Hdg>") else: self.mqttpublish( Config.topic_display, "T,07,99,1,3," + str('{0:0>3.0f}'.format(HdgNav1))) self.__oldHdgNav1 = HdgNav1 # NAV2 HDG at RSK17 if HdgNav2 != self.__oldHdgNav2: if (self.__editCur == "HDG2"): self.mqttpublish( Config.topic_display, "T,37,98,0,3," + str('{0:0>3.0f}'.format(HdgNav2))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, OBS2Hdb>") else: self.mqttpublish( Config.topic_display, "T,37,99,1,3," + str('{0:0>3.0f}'.format(HdgNav2))) self.__oldHdgNav2 = HdgNav2 if (not (event.isEmpty())): if (event.getTopic() == "j/npanel/e/s" and event.getPayload() == "1"): self.draw() logger.debug("Redraw") if event.getTopic() == Config.topic_keys: if event.getPayload() == str(Const.ENC1DN): # INC1 DN if (self.__editCur == "NAV1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 - 0.025))]) if (self.__editCur == "NAV2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 - 0.025))]) if (self.__editCur == "HDG1"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], bearing(HdgNav1 - 1))]) if (self.__editCur == "HDG2"): pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[4][1], bearing(HdgNav1 - 1))]) event.clear() if event.getPayload() == str(Const.ENC1UP): # INC1 UP if (self.__editCur == "NAV1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 + 0.025))]) if (self.__editCur == "NAV2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 + 0.025))]) if (self.__editCur == "HDG1"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], bearing(HdgNav1 + 1))]) if (self.__editCur == "HDG2"): pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[4][1], bearing(HdgNav1 + 1))]) event.clear() if event.getPayload() == str(Const.BTENC): # SW if (self.__editCur == "NAV1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(actFreq1))]) pyuipc.write([(self.__OFFSETS[0][0], self.__OFFSETS[0][1], vhf_float2bcd(stbFreq1))]) if (self.__editCur == "NAV2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(actFreq2))]) pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], vhf_float2bcd(stbFreq2))]) event.clear() if event.getPayload() == str(Const.ENC2DN): # INC2 DN if (self.__editCur == "NAV1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 - 1))]) if (self.__editCur == "NAV2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 - 1))]) if (self.__editCur == "HDG1"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], bearing(HdgNav1 - 10))]) if (self.__editCur == "HDG2"): pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[4][1], bearing(HdgNav1 - 10))]) event.clear() if event.getPayload() == str(Const.ENC2UP): # INC2 UP if (self.__editCur == "NAV1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 + 1))]) if (self.__editCur == "NAV2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 + 1))]) if (self.__editCur == "HDG1"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], bearing(HdgNav1 + 10))]) if (self.__editCur == "HDG2"): pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[4][1], bearing(HdgNav1 + 10))]) event.clear() if event.getPayload() == str(Const.RSK4): #NAV2 self.__editCur = "NAV2" self.draw() event.clear() if event.getPayload() == str(Const.LSK1): #NAV1 self.__editCur = "NAV1" self.draw() event.clear() if event.getPayload() == str(Const.LSK7): #HDG1 self.__editCur = "HDG1" self.draw() event.clear() if event.getPayload() == str(Const.RSK7): #HDG2 self.__editCur = "HDG2" self.draw() event.clear()
import pyuipc pyuipc.open(7) #fs2004 def convertBCD(data, length): """BCD to string""" bcd = "" for i in range (0, length): digit = chr(ord('0') + (data&0x0f)) data >>= 4 bcd = digit + bcd return bcd nav1 = pyuipc.read([(0x0350, "H"),]) #Nav1 print nav1 print convertBCD(nav1, 4)
#Open Fs2004 pyuipc.open(7) def convertBCD(data, length): """BCD to string""" bcd = "" for i in range(0, length): digit = chr(ord('0') + (data&0x0f)) data >>= 4 bcd = digit + bcd return bcd batteryToRead = pyuipc.prepare_data([(0x028c, "d")]) batteryState = pyuipc.read(batteryToRead) #batteryStateConverted = convertBCD(batteryState[0], len(batteryState)) #print batteryStateConverted print batteryState[0] print chr(batteryState[0]+48) print str(chr(batteryState[0]+48)) #arduinoSerial.write(str(0)) arduinoSerial.write(str(batteryState[0])) #arduinoSerial.write(str(chr(batteryState[0]+48))) print arduinoSerial.readline() #batteryToSet = pyuipc.prepare_data([(0x281C, "d", 1),], False) #batteryToSet = pyuipc.prepare_data([(0x281c, "d")], False) #pyuipc.write(batteryToSet, [1]) if batteryState[0] == 1:
def switch_one_bit(offset): lgt = 1 dat = pyuipc.prepare_data([(offset, lgt)]) val_ist = pyuipc.read(dat) val_sol = chr(not(ord(val_ist[0]))) pyuipc.write(dat, [val_sol])
def run(self, event): if (self.__editCur != self.__oldEditCur): self.draw() self.__oldEditCur = self.__editCur pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS) results = pyuipc.read(pyuipcOffsets) actFreq1 = vhf_bcd2float(results[0]) stbFreq1 = vhf_bcd2float(results[1]) actFreq2 = vhf_bcd2float(results[2]) stbFreq2 = vhf_bcd2float(results[3]) adfFreq = adf_bcd2float(results[4], results[5]) xpdrCode = int(str(xpdr_bcd2int(results[6])), 8) # COM1 Active at LSK3 if actFreq1 != self.__oldActFreq1: self.mqttpublish(Config.topic_display, "T,03,99,0,3," + str('{0:.3f}'.format(actFreq1))) self.__oldActFreq1 = actFreq1 # COM1 Stand by at LSK4 if stbFreq1 != self.__oldStbFreq1: if (self.__editCur == "COM1"): self.mqttpublish( Config.topic_display, "T,04,98,0,3," + str('{0:.3f}'.format(stbFreq1))) self.mqttpublish(Config.topic_display, "T,38,94,0,1,Com1StbFq/Psh SW>") else: self.mqttpublish( Config.topic_display, "T,04,99,1,3," + str('{0:.3f}'.format(stbFreq1))) self.__oldStbFreq1 = stbFreq1 # COM2 Active at RSK3 if actFreq2 != self.__oldActFreq2: self.mqttpublish(Config.topic_display, "T,33,99,0,3," + str('{0:.3f}'.format(actFreq2))) self.__oldActFreq2 = actFreq2 # COM2 Stand by at RSK4 if stbFreq2 != self.__oldStbFreq2: if (self.__editCur == "COM2"): self.mqttpublish( Config.topic_display, "T,34,98,0,3," + str('{0:.3f}'.format(stbFreq2))) self.mqttpublish(Config.topic_display, "T,38,94,0,1,Com2StbFq/Psh SW>") else: self.mqttpublish( Config.topic_display, "T,34,99,1,3," + str('{0:.3f}'.format(stbFreq2))) self.__oldStbFreq2 = stbFreq2 # ADF at LSK7 if adfFreq != self.__oldAdfFreq: if (self.__editCur == "ADF"): self.mqttpublish( Config.topic_display, "T,07,98,0,3," + str('{0:0>6.1f}'.format(adfFreq))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, ADFFq>") else: self.mqttpublish( Config.topic_display, "T,07,99,1,3," + str('{0:0>6.1f}'.format(adfFreq))) self.__oldAdfFreq = adfFreq # XPDR at RSK7 if xpdrCode != self.__oldXpdrCode: if (self.__editCur == "XPDR"): self.mqttpublish( Config.topic_display, "T,37,98,0,3," + str('{0:0>4.0f}'.format(int(oct(xpdrCode))))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, XPDR code>") else: self.mqttpublish( Config.topic_display, "T,37,99,1,3," + str('{0:0>4.0f}'.format(int(oct(xpdrCode))))) self.__oldXpdrCode = xpdrCode if (not (event.isEmpty())): if (event.getTopic() == "j/npanel/e/s" and event.getPayload() == "1"): self.draw() logger.debug("Redraw") if event.getTopic() == Config.topic_keys: if event.getPayload() == str(Const.ENC1DN): # INC1 DN if (self.__editCur == "COM1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 - 0.025))]) if (self.__editCur == "COM2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 - 0.025))]) if (self.__editCur == "ADF"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], adf_float2bcd(adfFreq - 0.5)[0])]) pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[5][1], adf_float2bcd(adfFreq - 0.5)[1])]) if (self.__editCur == "XPDR"): pyuipc.write([(self.__OFFSETS[6][0], self.__OFFSETS[6][1], xpdr_int2bcd(int(oct(xpdrCode - 1))))]) if event.getPayload() == str(Const.ENC1UP): # INC1 UP if (self.__editCur == "COM1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 + 0.025))]) if (self.__editCur == "COM2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 + 0.025))]) if (self.__editCur == "ADF"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], adf_float2bcd(adfFreq + 0.5)[0])]) pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[5][1], adf_float2bcd(adfFreq + 0.5)[1])]) if (self.__editCur == "XPDR"): pyuipc.write([(self.__OFFSETS[6][0], self.__OFFSETS[6][1], xpdr_int2bcd(int(oct(xpdrCode + 1))))]) event.clear() if event.getPayload() == str(Const.BTENC): # SW if (self.__editCur == "COM1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(actFreq1))]) pyuipc.write([(self.__OFFSETS[0][0], self.__OFFSETS[0][1], vhf_float2bcd(stbFreq1))]) if (self.__editCur == "COM2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(actFreq2))]) pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], vhf_float2bcd(stbFreq2))]) event.clear() if event.getPayload() == str(Const.ENC2DN): # INC2 DN if (self.__editCur == "COM1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 - 1))]) if (self.__editCur == "COM2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 - 1))]) if (self.__editCur == "ADF"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], adf_float2bcd(adfFreq - 10)[0])]) pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[5][1], adf_float2bcd(adfFreq - 10)[1])]) if (self.__editCur == "XPDR"): pyuipc.write([(self.__OFFSETS[6][0], self.__OFFSETS[6][1], xpdr_int2bcd(int(oct(xpdrCode - 64))))]) event.clear() if event.getPayload() == str(Const.ENC2UP): # INC2 UP if (self.__editCur == "COM1"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], vhf_float2bcd(stbFreq1 + 1))]) if (self.__editCur == "COM2"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], vhf_float2bcd(stbFreq2 + 1))]) if (self.__editCur == "ADF"): pyuipc.write([(self.__OFFSETS[4][0], self.__OFFSETS[4][1], adf_float2bcd(adfFreq + 10)[0])]) pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[5][1], adf_float2bcd(adfFreq + 10)[1])]) if (self.__editCur == "XPDR"): pyuipc.write([(self.__OFFSETS[6][0], self.__OFFSETS[6][1], xpdr_int2bcd(int(oct(xpdrCode + 64))))]) event.clear() if event.getPayload() == str(Const.RSK4): #COM2 self.__editCur = "COM2" self.draw() event.clear() if event.getPayload() == str(Const.LSK4): #COM1 self.__editCur = "COM1" self.draw() event.clear() if event.getPayload() == str(Const.LSK7): #ADF self.__editCur = "ADF" self.draw() event.clear() if event.getPayload() == str(Const.RSK7): #XPDR self.__editCur = "XPDR" self.draw() event.clear()
def run(self, event): if (self.__editCur != self.__oldEditCur): self.draw() self.__oldEditCur = self.__editCur pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS) results = pyuipc.read(pyuipcOffsets) eTrim = results[0] aTrim = results[1] rTrim = results[2] # ELEVATOR at RSK3 if eTrim != self.__oldETrim: if (self.__editCur == "ELEV"): self.mqttpublish(Config.topic_display, "S,33,98,0," + str(round(eTrim / 280))) else: self.mqttpublish(Config.topic_display, "S,33,99,1," + str(round(eTrim / 280))) self.__oldETrim = eTrim # AILERON at RSK5 if aTrim != self.__oldATrim: if (self.__editCur == "AIL"): self.mqttpublish(Config.topic_display, "S,35,98,0," + str(round(aTrim / 280))) else: self.mqttpublish(Config.topic_display, "S,35,99,1," + str(round(aTrim / 280))) self.__oldATrim = aTrim # RUDDER at RSK7 if rTrim != self.__oldRTrim: if (self.__editCur == "RUD"): self.mqttpublish(Config.topic_display, "S,37,98,0," + str(round(rTrim / 280))) else: self.mqttpublish(Config.topic_display, "S,37,99,1," + str(round(rTrim / 280))) self.__oldRTrim = rTrim if (not (event.isEmpty())): if (event.getTopic() == "j/npanel/e/s" and event.getPayload() == "1"): self.draw() logging.debug("Redraw") if event.getTopic() == Config.topic_keys: if event.getPayload() == str(Const.ENC1DN): # INC1 DN if (self.__editCur == "ELEV"): pyuipc.write([(self.__OFFSETS[0][0], self.__OFFSETS[0][1], eTrim - 100)]) if (self.__editCur == "AIL"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], aTrim - 100)]) if (self.__editCur == "RUD"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], rTrim - 100)]) event.clear() if event.getPayload() == str(Const.ENC1UP): # INC1 UP if (self.__editCur == "ELEV"): pyuipc.write([(self.__OFFSETS[0][0], self.__OFFSETS[0][1], eTrim + 100)]) if (self.__editCur == "AIL"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], aTrim + 100)]) if (self.__editCur == "RUD"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], rTrim + 100)]) event.clear() if event.getPayload() == str(Const.ENC2DN): # INC2 DN if (self.__editCur == "ELEV"): pyuipc.write([(self.__OFFSETS[0][0], self.__OFFSETS[0][1], eTrim - 1000)]) if (self.__editCur == "AIL"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], aTrim - 1000)]) if (self.__editCur == "RUD"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], rTrim - 1000)]) event.clear() if event.getPayload() == str(Const.ENC2UP): # INC2 UP if (self.__editCur == "ELEV"): pyuipc.write([(self.__OFFSETS[0][0], self.__OFFSETS[0][1], eTrim + 1000)]) if (self.__editCur == "AIL"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], aTrim + 1000)]) if (self.__editCur == "RUD"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], rTrim + 1000)]) event.clear() if event.getPayload() == str(Const.RSK3): #ELEV self.__editCur = "ELEV" self.draw() event.clear() if event.getPayload() == str(Const.RSK5): #AIL self.__editCur = "AIL" self.draw() event.clear() if event.getPayload() == str(Const.RSK7): #RUDDER self.__editCur = "RUD" self.draw() event.clear()
def run(self, event): if (self.__editCur != self.__oldEditCur): self.draw() self.__oldEditCur = self.__editCur pyuipcOffsets = pyuipc.prepare_data(self.__OFFSETS) results = pyuipc.read(pyuipcOffsets) altitude = results[0] / 19975 # in feet heading = results[1] / 182 # in deg vertSpeed = results[2] # in feet/min Course = results[3] # in deg IAS = results[4] # in kts lockALT = results[5] lockIAS = results[6] lockHDG = results[7] lockAT = results[8] lockNAV = results[9] lockBC = results[10] lockAPP = results[11] lockATT = results[12] lockYD = results[13] # ALT at LSK3 if altitude != self.__oldAltitude: if (self.__editCur == "ALT"): self.mqttpublish( Config.topic_display, "T,03,98,0,2," + str('{0:0>5.0f}'.format(altitude // 100 * 100))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, Set ALT (x1000 ox100>") else: self.mqttpublish( Config.topic_display, "T,03,99,1,2," + str('{0:0>5.0f}'.format(altitude // 100 * 100))) self.__oldAltitude = altitude # IAS at LCK3 if IAS != self.__oldIAS: if (self.__editCur == "IAS"): self.mqttpublish( Config.topic_display, "T,13,98,0,3," + str('{0:0>3.0f}'.format(IAS))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, Set IAS (x10 ox1>") else: self.mqttpublish( Config.topic_display, "T,13,99,1,3," + str('{0:0>3.0f}'.format(IAS))) self.__oldIAS = IAS # HDG at RSK3 if heading != self.__oldHeading: if (self.__editCur == "HDG"): self.mqttpublish( Config.topic_display, "T,23,98,0,3," + str('{0:0>3.0f}'.format(heading))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, Set HDG (x10 ox1>") else: self.mqttpublish( Config.topic_display, "T,23,99,1,3," + str('{0:0>3.0f}'.format(heading))) self.__oldHeading = heading # VERTICAL SPEED at LSK6 if vertSpeed != self.__oldVertSpeed: if (self.__editCur == "VERTSPEED"): self.mqttpublish( Config.topic_display, "T,06,98,0,2," + str('{0:05.0f}'.format(vertSpeed))) self.mqttpublish(Config.topic_display, "T,38,94,0,1,Set Vspd (x1000 ox100>") else: self.mqttpublish( Config.topic_display, "T,06,99,1,2," + str('{0:05.0f}'.format(vertSpeed))) self.__oldVertSpeed = vertSpeed # Course at RSK6 if Course != self.__oldCourse: if (self.__editCur == "COURSE"): self.mqttpublish( Config.topic_display, "T,33,98,0,3," + str('{0:0>3.0f}'.format(Course))) self.mqttpublish(Config.topic_display, "T,38,94,0,1, Set CRS (x10 ox1>") else: self.mqttpublish( Config.topic_display, "T,33,99,1,3," + str('{0:0>3.0f}'.format(Course))) self.__oldCourse = Course # LockALT if lockALT != self.__oldLockALT: if (lockALT == 0): self.mqttpublish(Config.topic_display, "T,04,97,1,4,ALT") else: self.mqttpublish(Config.topic_display, "T,04,97,1,5,ALT") self.__oldLockALT = lockALT # LockIAS if lockIAS != self.__oldLockIAS: if (lockIAS == 0): self.mqttpublish(Config.topic_display, "T,14,97,1,4,IAS") else: self.mqttpublish(Config.topic_display, "T,14,97,1,5,IAS") self.__oldLockIAS = lockIAS # LockAT if lockAT != self.__oldLockAT: if (lockAT == 0): self.mqttpublish(Config.topic_display, "T,15,97,1,4,A/T") else: self.mqttpublish(Config.topic_display, "T,15,97,1,5,A/T") self.__oldLockAT = lockAT # LockHDG if lockHDG != self.__oldLockHDG: if (lockHDG == 0): self.mqttpublish(Config.topic_display, "T,24,97,1,4,HDG") else: self.mqttpublish(Config.topic_display, "T,24,97,1,5,HDG") self.__oldLockHDG = lockHDG # LockNAV if lockNAV != self.__oldLockNAV: if (lockNAV == 0): self.mqttpublish(Config.topic_display, "T,34,97,1,4,NAV") else: self.mqttpublish(Config.topic_display, "T,34,97,1,5,NAV") self.__oldLockNAV = lockNAV # LockBC if lockBC != self.__oldLockBC: if (lockBC == 0): self.mqttpublish(Config.topic_display, "T,35,97,1,4,BC") else: self.mqttpublish(Config.topic_display, "T,35,97,1,5,BC") self.__oldLockBC = lockBC # LockAPP if lockAPP != self.__oldLockAPP: if (lockAPP == 0): self.mqttpublish(Config.topic_display, "T,36,97,1,4,APP") else: self.mqttpublish(Config.topic_display, "T,36,97,1,5,APP") self.__oldLockAPP = lockAPP # LockATT if lockATT != self.__oldLockATT: if (lockATT == 0): self.mqttpublish(Config.topic_display, "T,17,97,1,4,ATT") else: self.mqttpublish(Config.topic_display, "T,17,97,1,5,ATT") self.__oldLockATT = lockATT # LockYD if lockYD != self.__oldLockYD: if (lockYD == 0): self.mqttpublish(Config.topic_display, "T,27,97,1,4,Y/D") else: self.mqttpublish(Config.topic_display, "T,27,97,1,5,Y/D") self.__oldLockYD = lockYD if (not (event.isEmpty())): if (event.getTopic() == "j/npanel/e/s" and event.getPayload() == "1"): self.draw() logging.debug("Redraw") if event.getTopic() == Config.topic_keys: if event.getPayload() == str(Const.ENC1DN): # INC1 DN if (self.__editCur == "ALT"): pyuipc.write([ (self.__OFFSETS[0][0], self.__OFFSETS[0][1], (altitude - 99) * 19975) ]) if (self.__editCur == "HDG"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], bearing(heading - 1) * 182)]) if (self.__editCur == "VERTSPEED"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], vertSpeed - 100)]) if (self.__editCur == "COURSE"): pyuipc.write([ (self.__OFFSETS[3][0], self.__OFFSETS[3][1], bearing(Course - 1)) ]) event.clear() if event.getPayload() == str(Const.ENC1UP): # INC1 UP if (self.__editCur == "ALT"): pyuipc.write([ (self.__OFFSETS[0][0], self.__OFFSETS[0][1], (altitude + 101) * 19975) ]) if (self.__editCur == "HDG"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], bearing(heading + 1) * 182)]) if (self.__editCur == "VERTSPEED"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], vertSpeed + 100)]) if (self.__editCur == "COURSE"): pyuipc.write([ (self.__OFFSETS[3][0], self.__OFFSETS[3][1], bearing(Course + 1)) ]) event.clear() if event.getPayload() == str(Const.ENC2DN): # INC2 DN if (self.__editCur == "ALT"): pyuipc.write([ (self.__OFFSETS[0][0], self.__OFFSETS[0][1], (altitude - 999) * 19975) ]) if (self.__editCur == "HDG"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], bearing(heading - 10) * 182)]) if (self.__editCur == "VERTSPEED"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], vertSpeed - 100)]) if (self.__editCur == "COURSE"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], bearing(Course - 10))]) event.clear() if event.getPayload() == str(Const.ENC2UP): # INC2 UP if (self.__editCur == "ALT"): pyuipc.write([ (self.__OFFSETS[0][0], self.__OFFSETS[0][1], (altitude + 1001) * 19975) ]) if (self.__editCur == "HDG"): pyuipc.write([(self.__OFFSETS[1][0], self.__OFFSETS[1][1], bearing(heading + 10) * 182)]) if (self.__editCur == "VERTSPEED"): pyuipc.write([(self.__OFFSETS[2][0], self.__OFFSETS[2][1], vertSpeed + 100)]) if (self.__editCur == "COURSE"): pyuipc.write([(self.__OFFSETS[3][0], self.__OFFSETS[3][1], bearing(Course + 10))]) event.clear() if event.getPayload() == str(Const.LSK3): #ALT self.__editCur = "ALT" self.draw() event.clear() if event.getPayload() == str(Const.LSK4): # LockAlt lockALT = lockALT ^ 1 pyuipc.write([(self.__OFFSETS[5][0], self.__OFFSETS[5][1], lockALT)]) event.clear() if event.getPayload() == str(Const.LCK3): #IAS self.__editCur = "IAS" self.draw() event.clear() if event.getPayload() == str(Const.LCK4): # LockIAS lockIAS = lockIAS ^ 1 pyuipc.write([(self.__OFFSETS[6][0], self.__OFFSETS[6][1], lockIAS)]) event.clear() if event.getPayload() == str(Const.LCK5): # LockAT lockAT = lockAT ^ 1 pyuipc.write([(self.__OFFSETS[8][0], self.__OFFSETS[8][1], lockAT)]) event.clear() if event.getPayload() == str(Const.RCK3): #HDG self.__editCur = "HDG" self.draw() event.clear() if event.getPayload() == str(Const.RCK4): # LockHDG lockHDG = lockHDG ^ 1 pyuipc.write([(self.__OFFSETS[7][0], self.__OFFSETS[7][1], lockHDG)]) event.clear() if event.getPayload() == str(Const.LSK6): #VERTSPEED self.__editCur = "VERTSPEED" self.draw() event.clear() if event.getPayload() == str(Const.RSK3): #COURSE self.__editCur = "COURSE" self.draw() event.clear() if event.getPayload() == str(Const.RSK4): # LockNAV lockNAV = lockNAV ^ 1 pyuipc.write([(self.__OFFSETS[9][0], self.__OFFSETS[9][1], lockNAV)]) event.clear() if event.getPayload() == str(Const.RSK5): # LockBC lockBC = lockBC ^ 1 pyuipc.write([(self.__OFFSETS[10][0], self.__OFFSETS[10][1], lockBC)]) event.clear() if event.getPayload() == str(Const.RSK6): # LockAPP lockAPP = lockAPP ^ 1 pyuipc.write([(self.__OFFSETS[11][0], self.__OFFSETS[11][1], lockAPP)]) #pyuipc.write([(0x800,'u',lockAPP)]) #Specific to APP offset, must write at two offsets event.clear() if event.getPayload() == str(Const.LCK7): # LockATT lockATT = lockATT ^ 1 pyuipc.write([(self.__OFFSETS[12][0], self.__OFFSETS[12][1], lockATT)]) event.clear() if event.getPayload() == str(Const.RCK7): # LockYD lockYD = lockYD ^ 1 pyuipc.write([(self.__OFFSETS[13][0], self.__OFFSETS[13][1], lockYD)]) event.clear()
toread = pyuipc.prepare_data([(0x034E, "integer"),], True) TypeError: list element 0: type string be of length 1 >>> toread = pyuipc.prepare_data([(0x034E, "i"),], True) Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> toread = pyuipc.prepare_data([(0x034E, "i"),], True) TypeError: list element 0: invalid type letter: i >>> toread = pyuipc.prepare_data([(0x034E, "h"),], True) >>> read(toread) Traceback (most recent call last): File "<pyshell#9>", line 1, in <module> read(toread) NameError: name 'read' is not defined >>> pyuipc.read(toread) [8853] >>> toread = pyuipc.prepare_data([(0x034E, "H"),], True) >>> pyuipc.read(toread) [8853] >>> nav1 = pyuipc.prepare_data([(0x0350, "H"),], True) >>> pyuipc.read(nav1) [4144] >>> pyuipc.read([(0x0350, "H"),], True) Traceback (most recent call last): File "<pyshell#15>", line 1, in <module> pyuipc.read([(0x0350, "H"),], True) ValueError: exactly one argument is expected >>> pyuipc.read([(0x0350, "H"),]) [4144]