Пример #1
0
			sensor.alertDelay = int(item.find("general").attrib["alertDelay"])
			sensor.triggerAlert = (str(item.find("general").attrib[
				"triggerAlert"]).upper() == "TRUE")
			sensor.triggerAlertNormal = (str(item.find("general").attrib[
				"triggerAlertNormal"]).upper() == "TRUE")
			sensor.triggerState = int(item.find("general").attrib[
				"triggerState"])

			sensor.alertLevels = list()
			for alertLevelXml in item.iterfind("alertLevel"):
				sensor.alertLevels.append(int(alertLevelXml.text))

			# fifo specific options
			sensor.umask = int(item.find("fifo").attrib[
				"umask"], 8)
			sensor.fifoFile = str(item.find("fifo").attrib[
				"fifoFile"])

			# check if description is empty
			if len(sensor.description) == 0:
				raise ValueError("Description of sensor %d is empty."
					% sensor.id)

			# check if the id of the sensor is unique
			for registeredSensor in globalData.sensors:
				if registeredSensor.id == sensor.id:
					raise ValueError("Id of sensor %d"
						% sensor.id + "is already taken.")

			if (not sensor.triggerAlert
				and sensor.triggerAlertNormal):
					raise ValueError("'triggerAlert' for sensor %d "
Пример #2
0
            # these options are needed by the server to
            # differentiate between the registered sensors
            sensor.id = int(item.find("general").attrib["id"])
            sensor.description = str(item.find("general").attrib["description"])
            sensor.alertDelay = int(item.find("general").attrib["alertDelay"])
            sensor.triggerAlert = (str(item.find("general").attrib["triggerAlert"]).upper() == "TRUE")
            sensor.triggerAlertNormal = (str(item.find("general").attrib["triggerAlertNormal"]).upper() == "TRUE")
            sensor.triggerState = 1

            sensor.alertLevels = list()
            for alertLevelXml in item.iterfind("alertLevel"):
                sensor.alertLevels.append(int(alertLevelXml.text))

            # fifo specific options
            sensor.umask = int(item.find("fifo").attrib["umask"], 8)
            sensor.fifoFile = makePath(str(item.find("fifo").attrib["fifoFile"]))
            sensor.sensorDataType = int(item.find("fifo").attrib["dataType"])

            # Check sanity of sensor data type.
            if (sensor.sensorDataType != SensorDataType.NONE
                and sensor.sensorDataType != SensorDataType.INT
                and sensor.sensorDataType != SensorDataType.FLOAT):
                raise ValueError("Illegal data type for sensor %d." % sensor.id)

            # check if description is empty
            if len(sensor.description) == 0:
                raise ValueError("Description of sensor %d is empty." % sensor.id)

            # check if the id of the sensor is unique
            for registeredSensor in globalData.sensors:
                if registeredSensor.id == sensor.id:
Пример #3
0
            sensor.alertDelay = int(item.find("general").attrib["alertDelay"])
            sensor.triggerAlert = (str(
                item.find("general").attrib["triggerAlert"]).upper() == "TRUE")
            sensor.triggerAlertNormal = (str(
                item.find("general").attrib["triggerAlertNormal"]).upper() ==
                                         "TRUE")
            sensor.triggerState = int(
                item.find("general").attrib["triggerState"])

            sensor.alertLevels = list()
            for alertLevelXml in item.iterfind("alertLevel"):
                sensor.alertLevels.append(int(alertLevelXml.text))

            # fifo specific options
            sensor.umask = int(item.find("fifo").attrib["umask"], 8)
            sensor.fifoFile = str(item.find("fifo").attrib["fifoFile"])

            # check if description is empty
            if len(sensor.description) == 0:
                raise ValueError("Description of sensor %d is empty." %
                                 sensor.id)

            # check if the id of the sensor is unique
            for registeredSensor in globalData.sensors:
                if registeredSensor.id == sensor.id:
                    raise ValueError("Id of sensor %d" % sensor.id +
                                     "is already taken.")

            if (not sensor.triggerAlert and sensor.triggerAlertNormal):
                raise ValueError("'triggerAlert' for sensor %d " % sensor.id +
                                 "has to be activated when " +
Пример #4
0
			sensor.alertDelay = int(item.find("general").attrib["alertDelay"])
			sensor.triggerAlert = (str(item.find("general").attrib[
				"triggerAlert"]).upper() == "TRUE")
			sensor.triggerAlertNormal = (str(item.find("general").attrib[
				"triggerAlertNormal"]).upper() == "TRUE")
			sensor.triggerState = int(item.find("general").attrib[
				"triggerState"])

			sensor.alertLevels = list()
			for alertLevelXml in item.iterfind("alertLevel"):
				sensor.alertLevels.append(int(alertLevelXml.text))

			# fifo specific options
			sensor.umask = int(item.find("fifo").attrib[
				"umask"], 8)
			sensor.fifoFile = makePath(str(item.find("fifo").attrib[
				"fifoFile"]))
			sensor.sensorDataType = int(item.find("fifo").attrib[
				"dataType"])

			# Check sanity of sensor data type.
			if (sensor.sensorDataType != SensorDataType.NONE
				and sensor.sensorDataType != SensorDataType.INT
				and sensor.sensorDataType != SensorDataType.FLOAT):
				raise ValueError("Illegal data type for sensor %d."
					% sensor.id)

			# check if description is empty
			if len(sensor.description) == 0:
				raise ValueError("Description of sensor %d is empty."
					% sensor.id)