Added more flaps logic and some gear logic
Signed-off-by: merspieler <merspieler@users.noreply.github.com>
This commit is contained in:
parent
7665a37bdf
commit
4d51c29fe0
1 changed files with 76 additions and 19 deletions
97
__init__.py
97
__init__.py
|
@ -13,35 +13,40 @@ class FlightGearCopilotSkill(MycroftSkill):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FlightGearCopilotSkill, self).__init__()
|
super(FlightGearCopilotSkill, self).__init__()
|
||||||
|
|
||||||
# setting defaults, if not set
|
|
||||||
self.settings['profiles'] = ({"name": "IDG Airbus", "acid": ("a320-200-cfm", "a320-200-iae"), "flaps": ({"id": "up", "min-spd": 210, "max-spd": 350}, {"id": 1, "min-spd": 190, "max-spd": 230}), "gear-retractable": "true"},{})
|
|
||||||
|
|
||||||
# DEFINITION of the settings['profiles'] structure
|
# DEFINITION of the settings['profiles'] structure
|
||||||
# (
|
# [
|
||||||
# {
|
# {
|
||||||
# "name": "<profile-name>",
|
# "name": "<profile-name>",
|
||||||
# "acid":
|
# "acid":
|
||||||
# (
|
# [
|
||||||
# "<Aircraft-id> can be found in /???",
|
# "<Aircraft-id> can be found in /???",
|
||||||
# ...
|
# ...
|
||||||
# ),
|
# ],
|
||||||
# flaps:
|
# flaps:
|
||||||
# (
|
# [
|
||||||
# {
|
# {
|
||||||
# "id": "<flaps-name> can be up|down|full|number",
|
# "id": "<flaps-name> can be up|down|full|number",
|
||||||
# "min-spd": "<minimum speed for save retraction>",
|
# "min-spd": "<minimum speed for save retraction>",
|
||||||
# "max-spd": "<maximum speed for save extention>"
|
# "max-spd": "<maximum speed for save extention>",
|
||||||
|
# "value": "<value in the prop tree>"
|
||||||
# },
|
# },
|
||||||
# ...
|
# ...
|
||||||
# )
|
# ]
|
||||||
# "flaps-path": "<path to current flaps-position>"
|
# "flaps-path": "<path to current flaps-position>"
|
||||||
# "gear-retractable": "<true|false>"
|
# "gear-retractable": "<true|false>"
|
||||||
# }
|
# },
|
||||||
# )
|
# ...
|
||||||
|
# ]
|
||||||
|
|
||||||
# might be useful
|
# might be useful
|
||||||
# make_active()
|
# make_active()
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# #
|
||||||
|
# Flaps #
|
||||||
|
# #
|
||||||
|
#########################
|
||||||
|
|
||||||
@intent_handler(IntentBuilder('FlapsIntent').require('flaps'))
|
@intent_handler(IntentBuilder('FlapsIntent').require('flaps'))
|
||||||
def handle_flaps_intent(self, message):
|
def handle_flaps_intent(self, message):
|
||||||
flaps_request = message.data['utterance']
|
flaps_request = message.data['utterance']
|
||||||
|
@ -51,6 +56,10 @@ class FlightGearCopilotSkill(MycroftSkill):
|
||||||
|
|
||||||
# extracting the flaps setting from the utterance
|
# extracting the flaps setting from the utterance
|
||||||
match = re.match(r'.*flaps.* (up|full|down|\d{1,2}).*', flaps_request, re.I)
|
match = re.match(r'.*flaps.* (up|full|down|\d{1,2}).*', flaps_request, re.I)
|
||||||
|
if match == None:
|
||||||
|
self.speak_dialog("no.valid.flaps")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
flaps_request = match.group(1)
|
flaps_request = match.group(1)
|
||||||
|
|
||||||
# TODO add connection to fg
|
# TODO add connection to fg
|
||||||
|
@ -61,36 +70,84 @@ class FlightGearCopilotSkill(MycroftSkill):
|
||||||
acid = "a320-200-cfm"
|
acid = "a320-200-cfm"
|
||||||
# END DEMO DATA
|
# END DEMO DATA
|
||||||
|
|
||||||
profile = ''
|
profile = None
|
||||||
|
|
||||||
# TODO read acid to know which profile to use
|
# TODO read acid to know which profile to use
|
||||||
|
|
||||||
for i_profiles in self.settings['profiles']:
|
for i_profiles in self.settings['profiles']:
|
||||||
for i_acid in i_profiles:
|
for i_acid in i_profiles['acid']:
|
||||||
if i_acid == acid:
|
if i_acid == acid:
|
||||||
|
profile = i_profiles
|
||||||
break
|
break
|
||||||
if profile != '':
|
if profile != None:
|
||||||
break
|
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)
|
||||||
|
|
||||||
# TODO read flaps and kias
|
# TODO read flaps and kias
|
||||||
|
|
||||||
|
o_flaps = None
|
||||||
|
|
||||||
|
# find the flaps value for the flaps id
|
||||||
|
for i_flaps in profile['flaps']:
|
||||||
|
if str(i_flaps['id']) == str(flaps_request):
|
||||||
|
o_flaps = i_flaps
|
||||||
|
break
|
||||||
|
|
||||||
|
if o_flaps == None:
|
||||||
|
self.speak_dialog("flaps.setting.unknown")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# check if extend or retract flaps
|
# check if extend or retract flaps
|
||||||
# TODO add seperate handling of the up|down|full value
|
# TODO add handling up|down|full is already set
|
||||||
if str(flaps_request) == "up" or str(flaps_request) == "down" or str(flaps_request) == "full":
|
if str(flaps_request) == "down" or str(flaps_request) == "full":
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if int(flaps_request) > flaps:
|
|
||||||
flaps_mov = "extend"
|
flaps_mov = "extend"
|
||||||
elif int(flaps_request) < flaps:
|
elif str(flaps_request) == "up":
|
||||||
|
flaps_mov = "retract"
|
||||||
|
else:
|
||||||
|
if int(flaps_request) > o_flaps:
|
||||||
|
flaps_mov = "extend"
|
||||||
|
elif int(flaps_request) < o_flaps:
|
||||||
flaps_mov = "retract"
|
flaps_mov = "retract"
|
||||||
else:
|
else:
|
||||||
self.speak_dialog("keep.flaps")
|
self.speak_dialog("keep.flaps")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
# check if speed is high/low enough for retraction/extention
|
||||||
|
if flaps_mov == "extend":
|
||||||
|
if o_flaps['max-spd'] < kias:
|
||||||
|
self.speak_dialog("spd.high")
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
if o_flaps['min-spd'] > kias:
|
||||||
|
self.speak_dialog("spd.low")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
# TODO set flaps in fg
|
# TODO set flaps in fg
|
||||||
|
|
||||||
self.speak("Speed checked. Flaps " + str(flaps_request))
|
self.speak("Speed checked. Flaps " + str(flaps_request))
|
||||||
|
|
||||||
|
|
||||||
|
#########################
|
||||||
|
# #
|
||||||
|
# Gear #
|
||||||
|
# #
|
||||||
|
#########################
|
||||||
|
|
||||||
|
@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")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
match = re.match(r'.*gear.* (up|down|) +.*|.*(retract|extend) .*gear.*', gear_request, re.i)
|
||||||
|
|
||||||
|
self.speak("Gear " + str(gear_request))
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue