コード例 #1
0
                            (tt - lastMsg) > 200)):
            lastMsg = tt
            lastData = copy.copy(data)
            try:
                #U.toLog(2, u"sending url: "+unicode(data))
                U.sendURL({"sensors": data})
            except Exception, e:
                U.toLog(-1,
                        u"in Line '%s' has error='%s'" %
                        (sys.exc_traceback.tb_lineno, e),
                        permanentLog=True)
            time.sleep(0.05)

        quick = U.checkNowFile(G.program)

        U.makeDATfile(G.program, data)
        U.echoLastAlive(G.program)

        tt = time.time()
        NSleep = int(sensorRefreshSecs) * 2
        if tt - lastregularCycle > sensorRefreshSecs:
            regularCycle = True
            lastregularCycle = tt

        for n in range(NSleep):
            if quick: break

            readParams()
            time.sleep(0.5)
            quick = U.checkNowFile(G.program)
            if tt - lastRead > 5:
コード例 #2
0
ファイル: as726x.py プロジェクト: kw123/piBeacon
				if ( ( deltaN > deltaX[devId]							) or 
					 (	tt - G.lastAliveSend  > abs(G.sendToIndigoSecs) ) or  
					 ( quick											)	
					)  and	(		   \
					 ( doAverage == 0  and	 tt - minSendDelta	> G.lastAliveSend  )  or avsend		)	: 
						sendURLnow = True
						lastValue[devId]  = values
						#print " sending",avsend, deltaN ,deltaX[devId],  tt - G.lastAliveSend ,tt - minSendDelta  , G.sendToIndigoSecs
			if sendURLnow:
					##print data
					U.sendURL(data)

		loopCount +=1

		U.makeDATfile(G.program, data)
		quick = U.checkNowFile(G.program)				 
		U.echoLastAlive(G.program)

		if loopCount %40 ==0 and not quick:
			tt= time.time()
			if tt - lastRead > 5.:	
				readParams()
				lastRead = tt
		if not quick:
			time.sleep(loopSleep)
		if rebootCount >20:
			U.restartMyself(reason="badsensor")
		
	except	Exception, e:
		U.toLog(-1, u"in Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))