예제 #1
0
파일: mag3110.py 프로젝트: kw123/piBeacon
def readParams():
	global sensors, sensor
	global rawOld
	global theSENSORdict
	global oldRaw, lastRead
	try:

		inp,inpRaw,lastRead2 = U.doRead(lastTimeStamp=lastRead)
		if inp == "": return
		if lastRead2 == lastRead: return
		lastRead   = lastRead2
		if inpRaw == oldRaw: return
		oldRaw	   = inpRaw

		U.getGlobalParams(inp)
		if "sensors"			in inp:	 sensors =				 (inp["sensors"])
		if "debugRPI"			in inp:	 G.debug=			  int(inp["debugRPI"]["debugRPISENSOR"])
 
		if sensor not in sensors:
			U.toLog(-1, G.program+" is not in parameters = not enabled, stopping "+G.program+".py" )
			exit()
				
		for devId in sensors[sensor]:
			U.getMAGReadParameters(sensors[sensor][devId],devId)
			if devId not in theSENSORdict:
				startTheSensor(devId, G.i2cAddress, G.offsetTemp[devId], G.magOffset[devId], G.magDivider[devId], G.declination[devId], G.magResolution[devId],G.enableCalibration[devId])
			U.setMAGParams(theSENSORdict[devId],magOffset=G.magOffset[devId], magDivider=G.magDivider[devId],enableCalibration=G.enableCalibration[devId], declination=G.declination[devId], offsetTemp=G.offsetTemp[devId])
			 
		theSENSORdict = U.cleanUpSensorlist( sensors[sensor], theSENSORdict)	   

	except	Exception, e:
		U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
예제 #2
0
def readParams():
	global sensors, sensor 
	global theSENSORdict 
	global oldRaw, lastRead
	try:

		inp,inpRaw,lastRead2 = U.doRead(lastTimeStamp=lastRead)
		if inp == "": return
		if lastRead2 == lastRead: return
		lastRead   = lastRead2
		if inpRaw == oldRaw: return
		oldRaw	   = inpRaw

		U.getGlobalParams(inp)
		if "sensors"			in inp:	 sensors =				 (inp["sensors"])
		if "debugRPI"			in inp:	 G.debug=			  int(inp["debugRPI"]["debugRPISENSOR"])
 
		if sensor not in sensors:
			U.toLog(-1, G.program+" is not in parameters = not enabled, stopping "+G.program+".py" )
			exit()
				
		for devId in sensors[sensor]:
			U.getMAGReadParameters(sensors[sensor][devId],devId)
			if devId not in theSENSORdict:
				startTheSensor(devId, G.i2cAddress,	 G.magResolution[devId],  G.declination[devId],	 G.magOffset[devId],  G.magDivider[devId],	G.enableCalibration[devId])
			U.setMAGParams(theSENSORdict[devId],magOffset= G.magOffset[devId], magDivider= G.magDivider[devId], declination= G.declination[devId])
		 
		theSENSORdict = U.cleanUpSensorlist( sensors[sensor], theSENSORdict)	   

	except	Exception, e:
		U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
예제 #3
0
def readParams():
	global sensors, sensor
	global BNO055sensor, resetPin
	global oldRaw, lastRead

	try:

		inp,inpRaw,lastRead2 = U.doRead(lastTimeStamp=lastRead)
		if inp == "": return
		if lastRead2 == lastRead: return
		lastRead   = lastRead2
		if inpRaw == oldRaw: return
		oldRaw	   = inpRaw



		externalSensor=False
		sensorsOld= copy.copy(sensors)

 
		
		U.getGlobalParams(inp)
		if "sensors"			in inp:	 sensors =				 (inp["sensors"])
		if "debugRPI"			in inp:	 G.debug=			  int(inp["debugRPI"]["debugRPISENSOR"])
		
 
		if sensor not in sensors:
			U.toLog(-1, "BNO055 is not in parameters = not enabled, stopping ina219.py" )
			exit()
			
				
		for devId in sensors[sensor]:
			U.getMAGReadParameters(sensors[sensor][devId],devId)


			try:
				if "resetPin" in sensors[sensor][devId]: 
					resetPin= int(sensors[sensor][devId]["resetPin"])
			except:
				resetPin = -1
				
			if devId not in BNO055sensor:
				startBNO(devId, G.i2cAddress)
				
		deldevID={}		   
		for devId in BNO055sensor:
			if devId not in sensors[sensor]:
				deldevID[devId]=1
		for dd in  deldevID:
			del BNO055sensor[dd]
		if len(BNO055sensor) ==0: 
			####exit()
			pass

	except	Exception, e:
		U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
예제 #4
0
def readParams():
	global sensorList, sensors,	 sensor,  sensorRefreshSecs, displayEnable
	global output, sensorActive, timing
	global oldRaw, lastRead
	try:

		inp,inpRaw,lastRead2 = U.doRead(lastTimeStamp=lastRead)
		if inp == "": return
		if lastRead2 == lastRead: return
		lastRead   = lastRead2
		if inpRaw == oldRaw: return
		oldRaw	   = inpRaw

		externalSensor=False
		sensorList=[]
		sensorsOld= copy.copy(sensors)

		U.getGlobalParams(inp)
		  
		  
		if "sensors"			 in inp:  sensors =				  (inp["sensors"])
		if "debugRPI"			 in inp:  G.debug=			   int(inp["debugRPI"]["debugRPISENSOR"])
		if "output"				 in inp:  output=				  (inp["output"])
		if "tempUnits"			 in inp:  tempUnits=			  (inp["tempUnits"])

		if sensor not in sensors:
			U.toLog(-1, G.program+" is not in parameters = not enabled, stopping "+G.program )
			exit()
			
		sensorChanged = doWeNeedToStartSensor(sensors,sensorsOld,sensor)
			
		if sensorChanged == -1:
			U.toLog(-1, "==== stop	"+G.program+ " sensorChanged==-1 =====")
			exit()

		U.getGlobalParams(inp)



		for devId in sensors[sensor]:
			U.getMAGReadParameters(sensors[sensor][devId],devId)

		if sensorChanged != 0: # something has changed
			if os.path.isfile(G.homeDir+"temp/"+sensor+".dat"):
				os.remove(G.homeDir+"temp/"+sensor+".dat")
				
			

	except	Exception, e:
		U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
예제 #5
0
def readParams():
    global sensors, sensor
    global threshold, theSENSORdict
    global oldRaw, lastRead
    try:

        inp, inpRaw, lastRead2 = U.doRead(lastTimeStamp=lastRead)
        if inp == "": return
        if lastRead2 == lastRead: return
        lastRead = lastRead2
        if inpRaw == oldRaw: return
        oldRaw = inpRaw

        externalSensor = False
        sensorsOld = copy.copy(sensors)
        U.getGlobalParams(inp)

        if "sensors" in inp: sensors = (inp["sensors"])
        if "debugRPI" in inp: G.debug = int(inp["debugRPI"]["debugRPISENSOR"])

        if sensor not in sensors:
            U.toLog(
                -1, G.program +
                " is not in parameters = not enabled, stopping " + G.program)
            exit()

        for devId in sensors[sensor]:
            U.getMAGReadParameters(sensors[sensor][devId], devId)

            if devId not in theSENSORdict:
                U.toLog(
                    -1, "==== Start " + G.program + " ===== @ i2c= " +
                    unicode(G.i2cAddress))
                theSENSORdict[devId] = THESENSORCLASS(i2cAddress=G.i2cAddress)

        deldevID = {}
        for devId in theSENSORdict:
            if devId not in sensors[sensor]:
                deldevID[devId] = 1
        for dd in deldevID:
            del theSENSORdict[dd]
        if len(theSENSORdict) == 0:
            ####exit()
            pass

    except Exception, e:
        U.toLog(
            -1,
            u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
예제 #6
0
파일: mpu6050.py 프로젝트: kw123/piBeacon
def readParams():
	global sensors, sensor
	global rawOld
	global theSENSORdict
	global oldRaw, lastRead
	try:

		inp,inpRaw,lastRead2 = U.doRead(lastTimeStamp=lastRead)
		if inp == "": return
		if lastRead2 == lastRead: return
		lastRead   = lastRead2
		if inpRaw == oldRaw: return
		oldRaw	   = inpRaw


		externalSensor=False
		sensorsOld= copy.copy(sensors)

		U.getGlobalParams(inp)
		  
		if "sensors"			in inp:	 sensors =				 (inp["sensors"])
		if "debugRPI"			in inp:	 G.debug=			  int(inp["debugRPI"]["debugRPISENSOR"])
 
		if sensor not in sensors:
			U.toLog(-1, G.program+" is not in parameters = not enabled, stopping "+G.program )
			exit()
			
		for devId in sensors[sensor]:
			U.getMAGReadParameters(sensors[sensor][devId],devId)
				
			if devId not in theSENSORdict:
				startSENSOR(devId, G.i2cAddress)
				
		deldevID={}		   
		for devId in theSENSORdict:
			if devId not in sensors[sensor]:
				deldevID[devId]=1
		for dd in  deldevID:
			del theSENSORdict[dd]
		if len(theSENSORdict) ==0: 
			####exit()
			pass

	except	Exception, e:
		U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
예제 #7
0
def readParams():
    global sensors, sensor
    global rawOld
    global theSENSORdict, resetPin
    global oldRaw, lastRead
    try:

        inp, inpRaw, lastRead2 = U.doRead(lastTimeStamp=lastRead)
        if inp == "": return
        if lastRead2 == lastRead: return
        lastRead = lastRead2
        if inpRaw == oldRaw: return
        oldRaw = inpRaw
        externalSensor = False
        sensorsOld = copy.copy(sensors)

        if "sensors" in inp: sensors = (inp["sensors"])
        if "debugRPI" in inp: G.debug = int(inp["debugRPI"]["debugRPISENSOR"])

        U.getGlobalParams(inp)

        if sensor not in sensors:
            U.toLog(
                -1, G.program +
                "is not in parameters = not enabled, stopping " + G.program)
            exit()

        for devId in sensors[sensor]:
            changed = U.getMAGReadParameters(sensors[sensor][devId], devId)
            if changed.find("accelerationGain") > -1 or changed.find(
                    "magGain") > -1:
                U.restartMyself(reason="new gain seetungs require restart ",
                                doPrint=False)

            if devId not in theSENSORdict:
                startSENSOR(devId, G.i2cAddress)

        deldevID = {}
        for devId in theSENSORdict:
            if devId not in sensors[sensor]:
                deldevID[devId] = 1
        for dd in deldevID:
            del theSENSORdict[dd]
        if len(theSENSORdict) == 0:
            ####exit()
            pass

    except Exception, e:
        U.toLog(
            -1,
            u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))