示例#1
0
 def __init__(self, argv):
     logging.basicConfig(filename=CB_LOGFILE,level=CB_LOGGING_LEVEL,format='%(asctime)s %(message)s')
     self.state = "idle"
     self.previousState = "off"
     self.apps = []
     #CbAdaprot.__init__ MUST be called
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     logging.basicConfig(filename=CB_LOGFILE,level=CB_LOGGING_LEVEL,format='%(asctime)s %(message)s')
     self.status = "ok"
     self.state = "stopped"
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status =           "ok"
     self.state =            "stopped"
     self.apps =             {"binary_sensor": [],
                              "battery": [],
                              "connected": [],
                              "temperature": [],
                              "humidity": [],
                              "ultraviolet": [],
                              "luminance": []}
     self.intervals = {
         "binary_sensor": MAX_INTERVAL,
         "battery": BATTERY_CHECK_INTERVAL,
         "temperature": MAX_INTERVAL,
         "humidity": MAX_INTERVAL,
         "ultraviolet": MAX_INTERVAL,
         "luminance": MAX_INTERVAL
     }
     self.intervalChanged = False
     self.pollInterval = MIN_INTERVAL - 1 # Start with a short poll interval when no apps have requested
     self.lastTemperatureTime =   0
     self.lastHumidityTime =      0
     self.lastLuminanceTime =     0
     self.lastBinaryTime =        0
     self.lastBatteryTime =       0
     self.lastUltravioletTime =   0
     self.updateTime =            0
     self.lastUpdateTime =        0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.apps = {
         "binary_sensor": [],
         "battery": [],
         "connected": [],
         "temperature": [],
         "humidity": [],
         "ultraviolet": [],
         "luminance": []
     }
     self.intervals = {
         "binary_sensor": MAX_INTERVAL,
         "battery": BATTERY_CHECK_INTERVAL,
         "temperature": MAX_INTERVAL,
         "humidity": MAX_INTERVAL,
         "ultraviolet": MAX_INTERVAL,
         "luminance": MAX_INTERVAL
     }
     self.intervalChanged = False
     self.pollInterval = MIN_INTERVAL - 1  # Start with a short poll interval when no apps have requested
     self.lastTemperatureTime = 0
     self.lastHumidityTime = 0
     self.lastLuminanceTime = 0
     self.lastBinaryTime = 0
     self.lastBatteryTime = 0
     self.lastUltravioletTime = 0
     self.updateTime = 0
     self.lastUpdateTime = 0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
示例#5
0
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.inputs = KitchenMinderInputs()
     self.inputs.setupSwitch(self.switchPressed)
     self.inputs.setupPIR(self.movementDetected)
     self.apps = {"binary_sensor": [], "gpio": []}
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.uuids = {}
     self.scanLength = 3
     self.lastScanTime = 0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.inputs = KitchenMinderInputs()
     self.inputs.setupSwitch(self.switchPressed)
     self.inputs.setupPIR(self.movementDetected)
     self.apps =             {"binary_sensor": [],
                              "gpio": []}
     CbAdaptor.__init__(self, argv)
示例#8
0
 def __init__(self, argv):
     logging.basicConfig(filename=CB_LOGFILE,level=CB_LOGGING_LEVEL,format='%(asctime)s %(message)s')
     self.status =           "ok"
     self.state =            "stopped"
     self.apps =             {"temperature": [],
                              "connected": []}
     reactor.callLater(SENSOR_POLL_INTERVAL, self.pollSensor)
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status =           "ok"
     self.state =            "stopped"
     self.apps =             {"binary_sensor": [],
                              "battery": []}
     self.lastBinaryTime =   0
     self.lastBatteryTime =  0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
示例#10
0
 def __init__(self, argv):
     logging.basicConfig(filename=CB_LOGFILE,level=CB_LOGGING_LEVEL,format='%(asctime)s %(message)s')
     self.status = "ok"
     self.state = "stopped"
     self.apps =         {"temperature": []}
     self.pollInterval = {"temperature": 1000}
     self.pollTime =     {"temperature": 0}
     self.activePolls = []
     self.processedApps = []
     #CbAdaprot.__init__ MUST be called
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.apps = {"number_buttons": [], "battery": [], "connected": []}
     self.currentValue = "0"
     self.lastButtonTime = 0
     self.lastBatteryTime = 0
     self.lastWakeupTime = time.time()
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     logging.basicConfig(filename=CB_LOGFILE,level=CB_LOGGING_LEVEL,format='%(asctime)s %(message)s')
     self.status =             "ok"
     self.state =              "stopped"
     self.previousAlarmState = 0
     self.prevInvalidateTime = time.time()
     self.apps =               {"binary_sensor": [],
                                "battery": [],
                                "connected": []}
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status =           "ok"
     self.state =            "stopped"
     self.apps =             {"number_buttons": [],
                              "battery": [],
                              "connected": []}
     self.currentValue =     "0"
     self.lastUpdateTime = 0
     self.lastIdTime = 0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
示例#14
0
 def __init__(self, argv):
     self.status =           "ok"
     self.state =            "stopped"
     self.apps =             {
         "binary_sensor": [],
         "connected": []
     }
     self.minInterval =      1000
     self.connected = False
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status =           "ok"
     self.state =            "stopped"
     self.connected =        False
     self.lastValueTime =    0
     self.lastUpdateTime =   0
     self.isFailed =         False
     self.switchState =      "unknown"
     self.apps =             {"binary_sensor": [],
                              "switch": [],
                              "connected": []}
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
示例#16
0
文件: adaptor_a.py 项目: lool/sspur
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.stop = False
     self.apps = {"spur": []}
     self.toSend = 0
     self.tracking = {}
     self.count = 0
     self.channel = 0
     self.bandwidth = 0
     self.listening = False
     reactor.callLater(0.5, self.initRadio)
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status =                "ok"
     self.state =                 "stopped"
     self.apps =                  {"binary_sensor": [],
                                   "temperature": [],
                                   "luminance": [],
                                   "battery": [],
                                   "connected": []}
     self.lastTemperatureTime =   0
     self.lastHumidityTime =      0
     self.lastLuminanceTime =     0
     self.lastBinaryTime =        0
     self.lastBatteryTime =       0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
示例#18
0
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.connected = False
     self.apps = {"rgbww": []}
     self.colourState = {
         "soft_white": "0",
         "cold_white": "0",
         "red": "0",
         "green": "0",
         "blue": "0"
     }
     self.switchState = "0"
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status = "ok"
     self.state = "stopped"
     self.connected = False
     self.switchState = "unknown"
     self.apps = {
         "energy": [],
         "power": [],
         "voltage": [],
         "current": [],
         "power_factor": [],
         "binary_sensor": [],
         "temperature": [],
         "switch": [],
         "connected": []
     }
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
 def __init__(self, argv):
     self.status =           "ok"
     self.state =            "stopped"
     self.connected =        False
     self.switchState =      "unknown"
     self.apps =             {"energy": [],
                              "power": [],
                              "voltage": [],
                              "current": [],
                              "power_factor": [],
                              "binary_sensor": [],
                              "switch": [],
                              "connected": []}
     self.lastEnergyTime =    0
     self.lastPowerTime =     0
     self.lastVoltageTime =   0
     self.lastCurrentTime =   0
     self.lastPowerFactorTime = 0
     self.lastBinaryTime =    0
     # super's __init__ must be called:
     #super(Adaptor, self).__init__(argv)
     CbAdaptor.__init__(self, argv)
    def __init__(self, argv):
        logging.basicConfig(filename=CB_LOGFILE,level=CB_LOGGING_LEVEL,format='%(asctime)s %(message)s')
        self.connected = False  # Indicates we are connected to SensorTag
        self.status = "ok"
        self.state = "stopped"
        self.gattTimeout = 60   # How long to wait if not heard from tag
        self.badCount = 0       # Used to count errors on the BLE interface
        self.notifyApps = {"temperature": [],
                           "ir_temperature": [],
                           "acceleration": [],
                           "gyro": [],
                           "magnetometer": [],
                           "humidity": [],
                           "connected": [],
                           "buttons": []}
        self.pollApps =   {"temperature": [],
                           "ir_temperature": [],
                           "acceleration": [],
                           "gyro": [],
                           "magnetometer": [],
                           "humidity": [],
                           "connected": [],
                           "buttons": []}
        self.pollInterval = {"temperature": 10000,
                             "ir_temperature": 10000,
                             "acceleration": 10000,
                             "gyro": 10000,
                             "magnetometer": 10000,
                             "humidity": 10000,
                             "connected": 10000,
                             "buttons": 10000}
        self.pollTime =     {"temperature": 0,
                             "ir_temperature": 0,
                             "acceleration": 0,
                             "gyro": 0,
                             "magnetometer": 0,
                             "humidity": 0,
                             "connected": 0,
                             "buttons": 0}
        self.activePolls = []
        self.lastEOFTime = time.time()
        self.processedApps = []
        
        # characteristics for communicating with the SensorTag
        # Write 0 to turn off gyroscope, 1 to enable X axis only, 2 to
        # enable Y axis only, 3 = X and Y, 4 = Z only, 5 = X and Z, 6 =
        # Y and Z, 7 = X, Y and Z
        self.cmd = {"on": " 01",
                    "off": " 00",
                    "notify": " 0100",
                    "stop_notify": " 0000",
                    "gyro_on": " 07"
                   }
        self.primary = {"temp": 0x23,
                        "accel": 0x2E,
                        "humid": 0x39,
                        "magnet": 0x44,
                        "gyro": 0x5E,
                        "buttons": 0x69
                       }
        self.handles = {}
        self.handles["temperature"] =  {"en": str(hex(self.primary["temp"] + 6)), 
                                        "notify": str(hex(self.primary["temp"] + 3)),
                                        "data": str(format(self.primary["temp"] + 2, "#06x"))
                                       }
        self.handles["acceleration"] = {"en": str(hex(self.primary["accel"] + 6)), 
                                       "notify": str(hex(self.primary["accel"] + 3)),
                                       "period": str(hex(self.primary["accel"] + 9)), 
                                       # Period = 0x34 value x 10 ms (thought to be 0x0a)
                                       # Was running with 0x0A = 100 ms, now 0x22 = 500 ms
                                       "period_value": " 22", 
                                       "data": str(format(self.primary["accel"] + 2, "#06x"))
                                       }
        self.handles["humidity"] = {"en": str(hex(self.primary["humid"] + 6)), 
                                       "notify": str(hex(self.primary["humid"] + 3)),
                                       "data": str(format(self.primary["humid"] + 2, "#06x"))
                                       }
        self.handles["magnetometer"] = {"en": str(hex(self.primary["magnet"] + 6)), 
                                        "notify": str(hex(self.primary["magnet"] + 3)),
                                        "period": str(hex(self.primary["magnet"] + 9)), 
                                        "period_value": " 66", 
                                        "data": str(format(self.primary["magnet"] + 2, "#06x"))
                                       }
        self.handles["gyro"] =  {"en": str(hex(self.primary["gyro"] + 6)), 
                                 "notify": str(hex(self.primary["gyro"] + 3)),
                                 "data": str(format(self.primary["gyro"] + 2, "#06x"))
                                }
        self.handles["buttons"] =  {"notify": str(hex(self.primary["buttons"] + 3)),
                                    "data": str(format(self.primary["buttons"] + 2, "#06x"))
                                   }

        #CbAdaprot.__init__ MUST be called
        CbAdaptor.__init__(self, argv)
示例#22
0
    def __init__(self, argv):
        self.connected = False  # Indicates we are connected to SensorTag
        self.status = "ok"
        self.state = "stopped"
        self.gattTimeout = 60   # How long to wait if not heard from tag
        self.badCount = 0       # Used to count errors on the BLE interface
        self.notifyApps = {"temperature": [],
                           "ir_temperature": [],
                           "acceleration": [],
                           "gyro": [],
                           "magnetometer": [],
                           "humidity": [],
                           "luminance": [],
                           "connected": [],
                           "buttons": []}
        self.pollApps =   {"temperature": [],
                           "ir_temperature": [],
                           "acceleration": [],
                           "gyro": [],
                           "magnetometer": [],
                           "humidity": [],
                           "luminance": [],
                           "connected": [],
                           "buttons": []}
        self.pollInterval = {"temperature": 10000,
                             "ir_temperature": 10000,
                             "acceleration": 10000,
                             "gyro": 10000,
                             "magnetometer": 10000,
                             "humidity": 10000,
                             "luminance": 10000,
                             "connected": 10000,
                             "buttons": 10000}
        self.pollTime =     {"temperature": 0,
                             "ir_temperature": 0,
                             "acceleration": 0,
                             "gyro": 0,
                             "magnetometer": 0,
                             "humidity": 0,
                             "luminance": 0,
                             "connected": 0,
                             "buttons": 0}
        self.activePolls = []
        self.lastEOFTime = time.time()
        self.processedApps = []
        
        # characteristics for communicating with the SensorTag
        # Write 0 to turn off gyroscope, 1 to enable X axis only, 2 to
        # enable Y axis only, 3 = X and Y, 4 = Z only, 5 = X and Z, 6 =
        # Y and Z, 7 = X, Y and Z
        self.cmd = {"on": " 01",
                    "off": " 00",
                    "notify": " 0100",
                    "stop_notify": " 0000",
                    "gyro_on": " 07",
                    "accel_on": " 8300"
                   }
        self.primary = {"temp": 0x1F,
                        "humid": 0x27,
                        "accel": 0x37,
                        "magnet": 0x44,
                        "luminance": 0x3F,
                        "gyro": 0x5E,
                        "buttons": 0x47
                       }
        self.handles = {}
        self.handles["temperature"] =  {"en": str(hex(self.primary["temp"] + 5)), 
                                        "notify": str(hex(self.primary["temp"] + 3)),
                                        "period": str(hex(self.primary["temp"] + 7)),
                                        "period_value": " ff", 
                                        "min_period": 30,
                                        "data": str(format(self.primary["temp"] + 2, "#06x"))
                                       }
        self.handles["acceleration"] = {"en": str(hex(self.primary["accel"] + 5)), 
                                        "en_on": " 3800",
                                        "en_off": " 0000",
                                        "notify": str(hex(self.primary["accel"] + 3)),
                                        "period": str(hex(self.primary["accel"] + 7)), 
                                        # Period min is 10 ms. Set to max.
                                        "period_value": " ff", 
                                        "min_period": 10,
                                        "data": str(format(self.primary["accel"] + 2, "#06x"))
                                       }
        self.handles["humidity"] = {"en": str(hex(self.primary["humid"] + 5)), 
                                    "notify": str(hex(self.primary["humid"] + 3)),
                                    "period": str(hex(self.primary["humid"] + 7)), 
                                    "period_value": " ff", 
                                    "min_period": 10,
                                    "data": str(format(self.primary["humid"] + 2, "#06x"))
                                       }
        self.handles["magnetometer"] = {"en": str(hex(self.primary["magnet"] + 6)), 
                                        "notify": str(hex(self.primary["magnet"] + 3)),
                                        "period": str(hex(self.primary["magnet"] + 9)), 
                                        "period_value": " ff", 
                                        "min_period": 30,
                                        "data": str(format(self.primary["magnet"] + 2, "#06x"))
                                       }
        self.handles["gyro"] =  {"en": str(hex(self.primary["gyro"] + 6)), 
                                 "notify": str(hex(self.primary["gyro"] + 3)),
                                 "data": str(format(self.primary["gyro"] + 2, "#06x"))
                                }
        self.handles["luminance"] =  {"en": str(hex(self.primary["luminance"] + 5)), 
                                      "notify": str(hex(self.primary["luminance"] + 3)),
                                      "period": str(hex(self.primary["luminance"] + 7)), 
                                      "period_value": " ff", 
                                      "min_period": 30,
                                      "data": str(format(self.primary["luminance"] + 2, "#06x"))
                                }
        self.handles["buttons"] =  {"notify": str(hex(self.primary["buttons"] + 3)),
                                    "data": str(format(self.primary["buttons"] + 2, "#06x"))
                                   }

        #CbAdaprot.__init__ MUST be called
        CbAdaptor.__init__(self, argv)