-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparams.py
More file actions
161 lines (143 loc) · 6.27 KB
/
params.py
File metadata and controls
161 lines (143 loc) · 6.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
################################################################################
#
# Params.py - Rev 1.0
# Copyright (C) 2021-6 by Joseph B. Attili, joe DOT aa2il AT gmail DOT com
#
# Command line param parser for satellite predictions.
#
################################################################################
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
################################################################################
import os,sys
from rig_io.ft_tables import SATELLITE_LIST,CONNECTIONS,SAT_RIGS
import argparse
from settings import read_settings
import datetime
import platform
################################################################################
# Structure to contain processing params
class PARAMS:
def __init__(self):
# Process command line args
arg_proc = argparse.ArgumentParser()
arg_proc.add_argument("-n", help="No. Days",type=int,default=10)
arg_proc.add_argument('-update', action='store_true',\
help='Update TLE Data from Internet')
arg_proc.add_argument('-skip_satnogs', action='store_true',\
help='Skip updationg satnogs data - useful if their website is sluggish')
arg_proc.add_argument("-grid", help="Grid Square",
type=str,default=None)
arg_proc.add_argument("-rig", help="Connection Type",
type=str,default=["NONE"],nargs='+',
choices=CONNECTIONS+['NONE']+SAT_RIGS)
arg_proc.add_argument("-port", help="Connection Port",
type=int,default=0)
arg_proc.add_argument("-rotor", help="Rotor connection Type",
type=str,default="NONE",
choices=['HAMLIB','DIRECT','NONE'])
arg_proc.add_argument("-port2", help="Rotor connection Port",
type=int,default=0)
arg_proc.add_argument("-sat", help="Sat to Track",
type=str,default=None)
arg_proc.add_argument("-grid2", help="Show passes covering another grid",
type=str,default=None)
arg_proc.add_argument('-sdr', action='store_true',
help='Command SDR also')
arg_proc.add_argument("-tstart", help="Start Time",
type=int,default=0)
arg_proc.add_argument("-tend", help="End Time",
type=int,default=24)
arg_proc.add_argument('-udp', action='store_true',
help='Start UDP client')
arg_proc.add_argument('-gps', action='store_true',
help='Read GPS info from .gpsrc file')
arg_proc.add_argument('-test', action='store_true',
help='Test Mode')
arg_proc.add_argument('-map', action='store_true',
help='Show track Map')
args = arg_proc.parse_args()
self.NDAYS2 = args.n
self.UPDATE_TLE = args.update
self.SKIP_SATNOGS = args.skip_satnogs
if args.sat:
self.sat_name = args.sat.upper()
else:
self.sat_name = None
self.connection = args.rig[0]
if len(args.rig)>=2:
self.rig = args.rig[1]
else:
self.rig = None
self.PORT = args.port
self.UDP_CLIENT = args.udp
self.GPS = args.gps
self.TEST_MODE = args.test
self.SHOW_MAP = args.map
self.SAT_MODE = False
self.GRID2 = args.grid2
self.ROTOR_CONNECTION = args.rotor
self.PORT2 = args.port2
if self.PORT2==0:
if self.ROTOR_CONNECTION=='HAMLIB':
self.PORT2==433
elif self.ROTOR_CONNECTION=='DIRECT':
self.PORT2==232
self.USE_SDR = args.sdr
self.SDR_CONNECTION = 'HAMLIB'
self.PORT3 = 4575 # Needs to be same port SDR is listening on
self.TSTART = args.tstart
if self.TSTART<0:
now = datetime.datetime.now()
self.TSTART = now.hour
self.TEND = args.tend
if self.TEND<0 or self.TEND>24:
self.TEND = 24
self.NO_FLIPPER = False
self.PLATFORM=platform.system()
# Read config file
ATTR=['Call','Grid','Alt_ft']
self.SETTINGS,self.RCFILE = read_settings('.satrc',attr=ATTR)
"""
self.RCFILE=os.path.expanduser("~/.satrc")
self.SETTINGS=None
try:
with open(self.RCFILE) as json_data_file:
self.SETTINGS = json.load(json_data_file)
except:
print(self.RCFILE,' not found!\n')
sys.exit(0)
"""
self.MY_GRID = args.grid
if self.MY_GRID==None:
try:
self.MY_GRID = self.SETTINGS['MY_GRID']
except:
self.MY_GRID = 'DM12'
try:
ACTIVE = self.SETTINGS['ACTIVE']
# There is a goofy legacy thing that I need to look into
# that requires the first "sat" in the list be 'None'
if 'None' not in ACTIVE:
ACTIVE = ['None'] + ACTIVE
self.SATELLITE_LIST = []
for sat in ACTIVE:
if sat in SATELLITE_LIST:
self.SATELLITE_LIST.append(sat)
else:
print(sat,'not in list of known satellites - ignored')
except:
self.SATELLITE_LIST = SATELLITE_LIST
if False:
print('PARAMS: SATELLITE LIST=',self.SATELLITE_LIST)
print('Known SATS:',SATELLITE_LIST)
sys.exit(0)