Package kenozooid :: Package cli :: Module plan

Source Code for Module kenozooid.cli.plan

 1  # 
 2  # Kenozooid - dive planning and analysis toolbox. 
 3  # 
 4  # Copyright (C) 2009-2019 by Artur Wroblewski <wrobell@riseup.net> 
 5  # 
 6  # This program is free software: you can redistribute it and/or modify 
 7  # it under the terms of the GNU General Public License as published by 
 8  # the Free Software Foundation, either version 3 of the License, or 
 9  # (at your option) any later version. 
10  # 
11  # This program is distributed in the hope that it will be useful, 
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  # GNU General Public License for more details. 
15  # 
16  # You should have received a copy of the GNU General Public License 
17  # along with this program.  If not, see <http://www.gnu.org/licenses/>. 
18  # 
19   
20  """ 
21  Kenozooid dive planning commands. 
22  """ 
23   
24  from kenozooid.cli import CLICommand, ArgumentError, add_master_command 
25  from kenozooid.component import inject 
26   
27  # for comand 'plan deco' 
28  add_master_command( 
29      'plan', 
30      'Kenozooid dive planning commands', 
31      'plan a dive' 
32  ) 
33 34 35 @inject(CLICommand, name='plan deco') 36 -class DecoPlan(object):
37 """ 38 Kenozooid decompression dive planning command. 39 """ 40 description = 'decompression dive planner' 41 42 @classmethod
43 - def add_arguments(cls, parser):
44 """ 45 Parse decompression dive planner command arguments. 46 """ 47 parser.add_argument( 48 'gas_list', 49 help='gas list, i.e. "air" or "air ean50@20 o2"' 50 ) 51 parser.add_argument('depth', type=int, help='dive depth') 52 parser.add_argument('time', type=int, help='dive bottom time') 53 parser.add_argument( 54 '--rmv', '-r', dest='rmv', default=20, type=int, 55 help='respiratory minute volume, i.e. 16 [l/min]' 56 ) 57 parser.add_argument( 58 '-6', dest='last_stop_6m', action='store_true', default=False, 59 help='last stop at 6m' 60 ) 61 parser.add_argument( 62 '--gf-low', '-gl', dest='gf_low', default=30, type=int, 63 help='GF Low, i.e. 30 [%%]' 64 ) 65 parser.add_argument( 66 '--gf-high', '-gh', dest='gf_high', default=85, type=int, 67 help='GF High, i.e. 85 [%%]' 68 )
69 70
71 - def __call__(self, args):
72 """ 73 Execute Kenozooid decompression dive planning command. 74 """ 75 import kenozooid.plan.deco as planner 76 plan = planner.DivePlan() 77 78 plan.rmv = args.rmv 79 plan.last_stop_6m = args.last_stop_6m 80 plan.gf_low = args.gf_low 81 plan.gf_high = args.gf_high 82 83 gas_list = planner.parse_gas_list(*args.gas_list.split()) 84 85 try: 86 planner.plan_deco_dive(plan, gas_list, args.depth, args.time) 87 except planner.DivePlanError as ex: 88 raise ArgumentError(ex) 89 90 print(planner.plan_to_text(plan))
91 92 93 # vim: sw=4:et:ai 94