Exemple #1
0
        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()
    # 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 = ""
            if sensor.sensorDataType == SensorDataType.NONE:
                dataString = "Current Data: NONE"
Exemple #3
0
    # 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 = ""
            if sensor.sensorDataType == SensorDataType.NONE:
                dataString = "Current Data: NONE"