Skip to content

Commit

Permalink
Merge branch 'devel' of github.com:filipsPL/autowx2
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsPL committed Nov 25, 2018
2 parents 9754a0e + 53b0250 commit 614bfd5
Show file tree
Hide file tree
Showing 11 changed files with 287 additions and 13 deletions.
14 changes: 3 additions & 11 deletions autowx2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,18 @@
# https://github.com/filipsPL/autowx2/
#


from autowx2_conf import * # configuration
from autowx2_functions import *


me = singleton.SingleInstance()
# will sys.exit(-1) if other instance is running


satellites = list(satellitesData)
qth = (stationLat, stationLon, stationAlt)
from autowx2_functions import * # all functions and magic hidden here

from autowx2_webserver import *
from threading import Thread


# ------------------------------------------------------------------------------------------------------ #

if __name__ == "__main__":
log("⚡ Program start")
dongleShift = getDefaultDongleShift()

while True:

# recalculate table of next passes
Expand Down
97 changes: 95 additions & 2 deletions autowx2_functions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

#
# autowx2 - genpastable.py
# generates the pass table and recording plan for tne next few days and the appropriate plot
# autowx2 - function and classes used by autowx2 and auxiliary programs
#
# GANTT Chart with Matplotlib
# Sukhbinder
Expand Down Expand Up @@ -36,6 +35,9 @@
# configuration
from autowx2_conf import *

satellites = list(satellitesData)
qth = (stationLat, stationLon, stationAlt)


def mkdir_p(outdir):
''' bash "mkdir -p" analog'''
Expand Down Expand Up @@ -543,3 +545,94 @@ def generatePassTableAndSaveFiles(satellites, qth, verbose=True):

if verbose:
print listNextPasesTxt(passTable, 100)



# --------------------------------------------------------------------------- #
# --------- THE MAIN LOOP --------------------------------------------------- #
# --------------------------------------------------------------------------- #

def mainLoop():
while True:
# recalculate table of next passes
passTable = genPassTable(satellites, qth)

# save table to disk
generatePassTableAndSaveFiles(satellites, qth, verbose=False)

# show next five passes
log("Next five passes:")
listNextPases(passTable, 5)

# get the very next pass
satelitePass = passTable[0]

satellite, start, duration, peak, azimuth = satelitePass

satelliteNoSpaces = satellite.replace(" ", "-") #remove spaces from the satellite name

freq = satellitesData[satellite]['freq']
processWith = satellitesData[satellite]['processWith']

fileNameCore = datetime.fromtimestamp(
start).strftime(
'%Y%m%d-%H%M') + "_" + satelliteNoSpaces

log("Next pass:")
log(printPass(satellite, start, duration,
peak, azimuth, freq, processWith))

towait = int(start - time.time())

# test if SDR dongle is available
if towait > 15: # if we have time to perform the test?
while not runTest():
log("Waiting for the SDR dongle...")
time.sleep(10)

# It's a high time to record!
if towait <= 1 and duration > 0:
# here the recording happens
log("!! Recording " + printPass(satellite, start, duration,
peak, azimuth, freq, processWith), style=bc.WARNING)

processCmdline = [
processWith,
fileNameCore,
satellite,
start,
duration + towait,
peak,
azimuth,
freq]
justRun(processCmdline, loggingDir)
time.sleep(10.0)

# still some time before recording
else:
# recalculating waiting time
if towait > 300:
log("Recalibrating the dongle...")
dongleShift = calibrate(dongleShift) # replace the global value

towait = int(start - time.time())
if scriptToRunInFreeTime:
if towait >= 120: # if we have more than [some] minutes spare time, let's do something useful
log("We have still %ss free time to the next pass. Let's do something useful!" %
(t2humanMS(towait - 1)))
log("Running: %s for %ss" %
(scriptToRunInFreeTime, t2humanMS(towait - 1)))
runForDuration(
[scriptToRunInFreeTime,
towait - 1,
dongleShift],
towait - 1, loggingDir)
# scrript with run time and dongle shift as
# arguments
else:
log("Sleeping for: " + t2humanMS(towait - 1) + "s")
time.sleep(towait - 1)
else:
towait = int(start - time.time())
log("Sleeping for: " + t2humanMS(towait - 1) + "s")
time.sleep(towait - 1)
56 changes: 56 additions & 0 deletions autowx2_webserver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*-

#
# autowx2 - webserver definitions


# configuration
from autowx2_conf import *
from autowx2_functions import * # all functions and magic hidden here
from flask import Flask, render_template
import codecs

# satellites = list(satellitesData)
# qth = (stationLat, stationLon, stationAlt)

def file_read(filename):
with codecs.open(filename, 'r', encoding='utf-8') as f:
lines = f.read()
return lines


# -------------------------------------------------------------------------- #


app = Flask(__name__, template_folder="var/flask/templates/", static_folder='var/flask/static')

body="body"

#
# homepage
#

@app.route('/')
def homepage():
return render_template('index.html', title="Home page", body=body)


#
# display last log
#

@app.route('/lastlog')
def lastlog():
logfile = logFile(loggingDir)
logs = file_read(logfile)
body = "<p><strong>File</strong>: %s</p><pre class='small'>%s</pre>" % (logfile, logs)
return render_template('index.html', title="Recent logs", body=body)

#
# show pass table
#

@app.route('/table')
def passTable():
body=file_read(htmlNextPassList)
return render_template('index.html', title="Pass table", body=body)
7 changes: 7 additions & 0 deletions var/flask/static/bootstrap.bundle.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions var/flask/static/bootstrap.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions var/flask/static/fancybox/jquery.fancybox.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions var/flask/static/fancybox/jquery.fancybox.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions var/flask/static/fancybox/source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/fancyapps/fancyBox
2 changes: 2 additions & 0 deletions var/flask/static/jquery.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 614bfd5

Please sign in to comment.