Ejemplo n.º 1
0
 def sendCpdlcMsg(self, callsign, msg):
     link = env.cpdlc.currentDataLink(callsign)
     if link == None:
         return
     if msg.type() == CpdlcMessage.ACK and link.msgCount() > 0:
         last_msg = link.lastMsg()
         if not last_msg.isFromMe() and last_msg.type() == CpdlcMessage.INSTR \
           and yesNo_question(self.gui, 'ACK after received INSTR', last_msg.contents(), 'Execute instruction?'):
             try:
                 instr = Instruction.fromEncodedStr(last_msg.contents())
                 self.instructAircraftByCallsign(callsign, instr)
             except ValueError:  # raised by Instruction.fromEncodedStr
                 if not yesNo_question(self.gui, 'CPDLC comm error', \
                   'Unable to decode instruction.', 'Send ACK and perform manually?'):
                     return  # cancel sending any message
             except Instruction.Error as err:  # raised by TeacherSessionManager.instructAircraftByCallsign
                 if not yesNo_question(self.gui, 'CPDLC instruction error', \
                   'Unable to perform instruction: %s' % err, 'Send ACK anyway?'):
                     return  # cancel sending any message
             else:  # no problem executing instruction
                 selection.writeStripAssignment(instr)
     if self.studentConnected() and link != None:
         link.appendMessage(msg)
         self.student.sendMessage(
             TeachingMsg(
                 TeachingMsg.CPDLC,
                 data=('%s\n%s%s' %
                       (callsign, CPDLC_message_cmd_prefix, msg.text()))))
Ejemplo n.º 2
0
 def sendCpdlcMsg(self, callsign, msg):
     link = env.cpdlc.currentDataLink(callsign)
     if link != None:
         link.appendMessage(msg)
         if msg.type(
         ) == CpdlcMessage.INSTR:  # other message types ignored (unimplemented in solo)
             try:
                 acft = next(
                     a for a in self.controlled_traffic if a.identifier ==
                     callsign)  # uncontrolled traffic is not in contact
                 acft.instruct([Instruction.fromEncodedStr(msg.contents())])
                 # FUTURE ingest before instruct to allow exception raised or (delayed?) WILCO msg before actually executing
             except StopIteration:  # ACFT not found or not connected
                 print('WARNING: Aircraft %s not found.' % callsign)
             except Instruction.Error as err:  # raised by ControlledAircraft.instruct
                 link.appendMessage(
                     CpdlcMessage(False,
                                  CpdlcMessage.REJECT,
                                  contents=str(err)))
             else:  # instruction sent and already accepted
                 link.appendMessage(CpdlcMessage(False, CpdlcMessage.ACK))
Ejemplo n.º 3
0
 def ackButtonClicked(self):
     if self.data_link_model.msgCount() > 0:
         last_msg = self.data_link_model.lastMsg()
         if not last_msg.isFromMe() and last_msg.type(
         ) == CpdlcMessage.REQUEST:
             try:
                 instr = Instruction.fromEncodedStr(last_msg.contents())
             except ValueError:
                 QMessageBox.critical(
                     self, 'CPDLC comm error',
                     'Unable to decode request. Mismatching program versions?'
                 )
             else:
                 selection.writeStripAssignment(instr)
                 msg = CpdlcMessage(True,
                                    CpdlcMessage.INSTR,
                                    contents=instr.encodeToStr())
                 settings.session_manager.sendCpdlcMsg(
                     self.data_link_model.acftCallsign(), msg)
             return
     msg = CpdlcMessage(True, CpdlcMessage.ACK)
     settings.session_manager.sendCpdlcMsg(
         self.data_link_model.acftCallsign(), msg)