Skip to content

Commit

Permalink
fixed threaded ntp check
Browse files Browse the repository at this point in the history
  • Loading branch information
saschaludwig committed Feb 8, 2019
1 parent c876a91 commit 026c22f
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions start.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ def __init__(self):
self.statusAIR4 = False
self.streamTimerMode = 0 # count up mode

# Setup NTP Check Tread
self.checkNTPOffset = checkNTPOffsetTread(self)
# Setup NTP Check Thread
self.checkNTPOffset = checkNTPOffsetThread(self)

# Setup check NTP Timer
self.ntpHadWarning = True
Expand Down Expand Up @@ -888,10 +888,12 @@ def triggerNTPcheck(self):
ntpcheck = settings.value('ntpcheck', True)
settings.endGroup()
if not ntpcheck:
self.timerNTP.stop()
return
self.timerNTP.stop()
self.checkNTPOffset.start()
self.timerNTP.start(60000)
else:
self.timerNTP.stop()
self.checkNTPOffset.start()
self.timerNTP.start(60000)


def setLED1(self, action):
Expand Down Expand Up @@ -1045,7 +1047,7 @@ def shutdown_host(self):
pass


class checkNTPOffsetTread(QThread):
class checkNTPOffsetThread(QThread):

def __init__(self, oas):
self.oas = oas
Expand All @@ -1055,10 +1057,7 @@ def __del__(self):
self.wait()

def run(self):
print("entered run, sleeping")
sleep(5)
print("sleep done")

print("entered checkNTPOffsetThread.run")
settings = QSettings(QSettings.UserScope, "astrastudio", "OnAirScreen")
settings.beginGroup("NTP")
ntpserver = str(settings.value('ntpcheckserver', 'pool.ntp.org'))
Expand All @@ -1074,7 +1073,6 @@ def run(self):
else:
if self.oas.ntpHadWarning:
self.oas.ntpHadWarning = False
#self.oas.hideWarning()
except socket.timeout:
print("NTP error: timeout while checking NTP %s" % ntpserver)
self.oas.ntpWarnMessage = "Clock not NTP synchronized"
Expand All @@ -1087,16 +1085,10 @@ def run(self):
print("NTP error:", e)
self.oas.ntpWarnMessage = str(e)
self.oas.ntpHadWarning = True
# except:
# print("unknown error checking NTP %s" % ntpserver)
# print("error:", e)
# self.showWarning("Clock not NTP synchronized")
# self.ntpHadWarning = True



###################################
## App SIGINT handler
# App SIGINT handler
###################################
def sigint_handler(*args):
# Handler for SIGINT signal
Expand All @@ -1105,7 +1097,7 @@ def sigint_handler(*args):


###################################
## App Init
# App Init
###################################
if __name__ == "__main__":
signal.signal(signal.SIGINT, sigint_handler)
Expand Down

0 comments on commit 026c22f

Please sign in to comment.