# server connection watchdog = ConnectionWatchdog(globalData.serverComm, globalData.pingInterval, globalData.smtpAlert) # set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # start data collector thread dataCollector = LightningmapDataCollector(globalData.sensors) # set thread to daemon # => threads terminates when main thread terminates dataCollector.daemon = True dataCollector.start() # only start update checker if it is activated if updateActivated is True: updateChecker = UpdateChecker(updateServer, updatePort, updateLocation, updateCaFile, updateInterval, updateEmailNotification, globalData) # set thread to daemon # => threads terminates when main thread terminates updateChecker.daemon = True updateChecker.start() # set up sensor executer and execute it # (note: we will not return from the executer unless the client # is terminated) sensorExecuter = SensorExecuter(globalData.serverComm, globalData) sensorExecuter.execute()
time.sleep(5) # when connected => generate watchdog object to monitor the # server connection logging.info("[%s] Starting watchdog thread." % fileName) watchdog = ConnectionWatchdog(globalData.serverComm, globalData.pingInterval, globalData.smtpAlert) # set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # Set up sensor executer and execute it. logging.info("[%s] Starting sensor thread." % fileName) sensorExecuter = SensorExecuter(globalData) sensorExecuter.daemon = True sensorExecuter.start() # Wait until thread is initialized. while not sensorExecuter.isInitialized(): time.sleep(0.1) logging.info("[%s] Client started." % fileName) # read keyboard input and toggle the sensors accordingly while True: print "--------" for sensor in globalData.sensors: dataString = ""
# when connected => generate watchdog object to monitor the # server connection watchdog = ConnectionWatchdog(globalData.serverComm, globalData.pingInterval, globalData.smtpAlert) # set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # start data collector thread dataCollector = LightningmapDataCollector(globalData.sensors) # set thread to daemon # => threads terminates when main thread terminates dataCollector.daemon = True dataCollector.start() # only start update checker if it is activated if updateActivated is True: updateChecker = UpdateChecker(updateServer, updatePort, updateLocation, updateCaFile, updateInterval, updateEmailNotification, globalData) # set thread to daemon # => threads terminates when main thread terminates updateChecker.daemon = True updateChecker.start() # set up sensor executer and execute it # (note: we will not return from the executer unless the client # is terminated) sensorExecuter = SensorExecuter(globalData.serverComm, globalData) sensorExecuter.execute()
# if smtp alert is activated # => send email that communication problems are solved if not globalData.smtpAlert is None: globalData.smtpAlert.sendCommunicationAlertClear() connectionRetries = 1 break connectionRetries += 1 logging.critical("[%s]: Connecting to server failed. " % fileName + "Try again in 5 seconds.") time.sleep(5) # when connected => generate watchdog object to monitor the # server connection logging.info("[%s] Starting watchdog thread." % fileName) watchdog = ConnectionWatchdog(globalData.serverComm, globalData.pingInterval, globalData.smtpAlert) # set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() logging.info("[%s] Client started." % fileName) # set up sensor executer and execute it # (note: we will not return from the executer unless the client # is terminated) sensorExecuter = SensorExecuter(globalData) sensorExecuter.execute()
logging.critical( "[%s]: Connecting to server failed. Try again in 5 seconds." % fileName) time.sleep(5) # when connected => generate watchdog object to monitor the # server connection logging.info("[%s]: Starting watchdog thread." % fileName) watchdog = ConnectionWatchdog(globalData.serverComm, globalData.pingInterval, globalData.smtpAlert) # set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # set up sensor executer and execute it executer = SensorExecuter(globalData) # set thread to daemon # => threads terminates when main thread terminates executer.daemon = True executer.start() logging.info("[%s]: Client started." % fileName) # generate receiver to handle incoming data (for example status updates) # (note: we will not return from the receiver unless the client is terminated) receiver = Receiver(globalData.serverComm) receiver.run()
# => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # only start update checker if it is activated if updateActivated is True: updateChecker = UpdateChecker(updateServer, updatePort, updateLocation, updateCaFile, updateInterval, updateEmailNotification, globalData) # set thread to daemon # => threads terminates when main thread terminates updateChecker.daemon = True updateChecker.start() # set up sensor executer and execute it sensorExecuter = SensorExecuter(globalData.serverComm, globalData) sensorExecuter.daemon = True sensorExecuter.start() # read keyboard input and toggle the sensors accordingly while True: print "--------" for sensor in globalData.sensors: if sensor.consoleInputState == sensor.triggerState: print("Sensor Id: %d - Triggered" % sensor.id) else: print("Sensor Id: %d - Not Triggered" % sensor.id) try: localSensorId = int(
+ "Try again in 5 seconds.") time.sleep(5) # when connected => generate watchdog object to monitor the # server connection logging.info("[%s] Starting watchdog thread." % fileName) watchdog = ConnectionWatchdog(globalData.serverComm, globalData.pingInterval, globalData.smtpAlert) # set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # Set up sensor executer and execute it. logging.info("[%s] Starting sensor thread." % fileName) sensorExecuter = SensorExecuter(globalData) sensorExecuter.daemon = True sensorExecuter.start() # Wait until thread is initialized. while not sensorExecuter.isInitialized(): time.sleep(0.1) logging.info("[%s] Client started." % fileName) # read keyboard input and toggle the sensors accordingly while True: print("--------") for sensor in globalData.sensors: dataString = ""
# set thread to daemon # => threads terminates when main thread terminates watchdog.daemon = True watchdog.start() # only start update checker if it is activated if updateActivated is True: updateChecker = UpdateChecker(updateServer, updatePort, updateLocation, updateCaFile, updateInterval, updateEmailNotification, globalData) # set thread to daemon # => threads terminates when main thread terminates updateChecker.daemon = True updateChecker.start() # set up sensor executer and execute it sensorExecuter = SensorExecuter(globalData.serverComm, globalData) sensorExecuter.daemon = True sensorExecuter.start() # read keyboard input and toggle the sensors accordingly while True: print "--------" for sensor in globalData.sensors: if sensor.consoleInputState == sensor.triggerState: print ("Sensor Id: %d - Triggered" % sensor.id) else: print ("Sensor Id: %d - Not Triggered" % sensor.id) try: localSensorId = int(