diff --git a/__init__.py b/__init__.py index cc7e535..8eebb89 100644 --- a/__init__.py +++ b/__init__.py @@ -13,6 +13,9 @@ LOGGER = getLogger(__name__) class FlightGearCopilotSkill(MycroftSkill): def __init__(self): super(FlightGearCopilotSkill, self).__init__() + self.settings['host'] = "localhost" + self.settings['port'] = 8081 + # TODO add self.settings['profiles'] with default profiles (A32X and c172p) # DEFINITION of the settings['profiles'] structure # [ @@ -76,10 +79,12 @@ class FlightGearCopilotSkill(MycroftSkill): # END DEMO DATA # get acid - tn.write("get /sim/aircraft") + tn.write("get /sim/aircraft\r\n") acid = tn.read_until("\n") profile = None + + # read acid to know which profile to use for i_profiles in self.settings['profiles']: for i_acid in i_profiles['acid']: if i_acid == acid: @@ -146,16 +151,78 @@ class FlightGearCopilotSkill(MycroftSkill): # # ######################### - @intent_handler(IntentBuilder('GearIntent').require('gear')) - def handle_gear_intent(self, message): - gear_request = message.data['utterance'] - if gear_request == "gear": - self.speak_dialog("no.gear.action") + @intent_handler(IntentBuilder('GearUpIntent').require('gearup')) + def handle_gear_up_intent(self, message): + + # TODO add connection to fg + # TODO read acid from fg + + # read acid to know which profile to use + for i_profiles in self.settings['profiles']: + for i_acid in i_profiles['acid']: + if i_acid == acid: + profile = i_profiles + break + if profile != None: + break + + if profile == None: + # TODO when creation of profiles via voice is possible, add dialog how to + self.speak("Profile not found") sys.exit(0) - match = re.match(r'.*gear.* (up|down|) +.*|.*(retract|extend) .*gear.*', gear_request, re.i) + if profile['gear-retractable'] == true: + # TODO set gear up in fg + self.speak("Gear up") + else: + self.speak_dialog("gear.not.retractable") - self.speak("Gear " + str(gear_request)) + @intent_handler(IntentBuilder('GearDownIntent').require('geardown')) + def handle_gear_down_intent(self, message): + + # TODO add connection to fg + # TODO read acid from fg + + # read acid to know which profile to use + for i_profiles in self.settings['profiles']: + for i_acid in i_profiles['acid']: + if i_acid == acid: + profile = i_profiles + break + if profile != None: + break + + if profile == None: + # TODO when creation of profiles via voice is possible, add dialog how to + self.speak("Profile not found") + sys.exit(0) + + if profile['gear-retractable'] == true: + # TODO set gear down in fg + self.speak("Gear down") + else: + self.speak_dialog("gear.not.retractable") + + +################################################################# +# # +# Checklists # +# # +################################################################# + +# TODO add all possible checklist +# TODO make it possible, to play a .mp3 file instead of tts + +######################### +# # +# LDG Check # +# # +######################### + + @intent_handler(IntentBuilder('LDGCheckIntent').require('ldgcheck')) + def handle_ldg_check_intent(self, message): + # TODO make checklist plane specific + self.speak("Landing no blue. . . Landing checklist completed") def stop(self): pass diff --git a/vocab/en-us/gear.voc b/vocab/en-us/gear.voc deleted file mode 100644 index 3f47798..0000000 --- a/vocab/en-us/gear.voc +++ /dev/null @@ -1 +0,0 @@ -gear diff --git a/vocab/en-us/geardown.voc b/vocab/en-us/geardown.voc new file mode 100644 index 0000000..f754bb6 --- /dev/null +++ b/vocab/en-us/geardown.voc @@ -0,0 +1,3 @@ +gear down +extend gear +extend the gear diff --git a/vocab/en-us/gearup.voc b/vocab/en-us/gearup.voc new file mode 100644 index 0000000..d83dfbc --- /dev/null +++ b/vocab/en-us/gearup.voc @@ -0,0 +1,3 @@ +gear up +retract gear +retract the gear diff --git a/vocab/en-us/ldgcheck.voc b/vocab/en-us/ldgcheck.voc new file mode 100644 index 0000000..e9b29c5 --- /dev/null +++ b/vocab/en-us/ldgcheck.voc @@ -0,0 +1,2 @@ +landing check list +landing checklist