A maior rede de estudos do Brasil

Grátis
LidarPythonCode

Pré-visualização | Página 5 de 7

'''
fltAspectIncrement = 5.554
fltScanAspectChange = 1395.00 #dont put a zero in here
bAspectIncrease 
fltAngleLow = 1395.00
fltAngleMid = 1450
fltAngleHigh = 1505
'''
def fChangeScanAspect():
 global fltScanAspectChange
 ## global bAspectChangeInProgress
 ## global bFirstAlert
 global bAspectIncrease
 ## global fltDistanceAngle
 #global fltAspectIncrement
 fltAngleLow = 1375.00
 fltAspectIncrement = 5.0
 fltAngleHigh = 1575.00
 
 while (not bIsGPIO_CleanUp):
 try:
 ## bAspectChangeInProgress= True
 ## print( "fChangeScanAspect" )
 sMessage = ""
 sMessage = sConstants[iThree] + str(round(fltScanAspectChange, iTwo) ) + "\n"
 ## print( "fChangeScanAspect " + sMessage )
 ## with oLockQput:
 q.put(sMessage)
 ## save aspect angle for alert value
 if ( int(fltScanAspectChange) not in oOD.oScans ):
 oOD.oScans[int(fltScanAspectChange)] = 0
 ## fltDistanceAngle = round(fltScanAspectChange, iTwo)
 oOD.DistanceAngle = int(fltScanAspectChange)
######
## #setup next aspect change
 if ( bAspectIncrease ):
 ## fltScanAspectChange = fltScanAspectChange + fltAspectIncrement
 fltScanAspectChange += fltAspectIncrement
 if ( fltScanAspectChange > fltAngleHigh ):
 fltScanAspectChange = fltAngleLow
 oTriggerOLED.set() ## trigger display
 ##fltScanAspectChange = fltAngleHigh
 ## bAspectIncrease = not bAspectIncrease 
# else:
# ## fltScanAspectChange = fltScanAspectChange - fltAspectIncrement
# fltScanAspectChange -= fltAspectIncrement
# if ( fltScanAspectChange < fltAngleLow ):
# ##fltScanAspectChange = fltAngleLow
# bAspectIncrease = not bAspectIncrease 
####
 except Exception as e:
 print("fChangeScanAspect() " + str(e))
 finally:
 ## oOD.iDistanceLength = iZero
 oAspectChange.clear()
 oAspectChange.wait()
 return;
##################################################################################
#
##################################################################################
#################################################################################
# fSendAlertEmail():
# triggered by fHandleOnePPS_Triggers(iChannel):
#################################################################################
def fSendAlertEmail():
 try:
 if (len(oOD.sMsg)):
 oT = threading.Thread(target = fSendMail, args = (oOD.sMsg,))
 oT.start()
 oOD.sMsg = ""
 except Exception as e:
 print("fSendAlertEmail " + str(e))
 return;
#################################################################################
#
###################################################################################
class cProcessSerial():
 def __init__(self):
 self.oTrigger = threading.Event()
 self.procSerial = threading.Thread(target = self.fProcessData )
 self.procSerial.start()
 ## self.oLockCM = threading.Lock()
 self.sTandH = ""
 def fProcSerial(self, sTandH ):
 ## print( "fProcessData " + sTandH)
 self.sTandH = sTandH
 ## print( "fProcessData " + self.sTandH)
 self.oTrigger.set()
 ####
 def fProcessData( self ):
 while (not bIsGPIO_CleanUp):
 self.oTrigger.wait()
 ## print( "fProcessData 1")
 sTemp = ""
 try:
 ## print( "fProcessData " + self.sTandH)
 sTemp = self.sTandH.strip() # for error massage
 if ( len(self.sTandH) <= iTwo ):
 return;
 ## print( "fProcessData " + sTandH)
 self.sTandH = self.sTandH.strip()
 self.sTandH = self.sTandH.split()
####
 if( self.sTandH[iZero] == sConstants[iOne] ):
 if( self.sTandH[iOne].isdigit() ):
 ## print( "fProcessData 1")
 oOD.fDoTheObjectDetectThing( self.sTandH[iOne], self.sTandH[iTwo], self.sTandH[iThree] )
####
 elif ( self.sTandH[iZero] == sConstants[iTwo] ) :
 ##print( sTandH[iZero] + " " + sTandH[iOne] )
 oVin.fDoTheVoltageThing( self.sTandH[iOne]) 
####
 elif (self. sTandH[iZero] == sConstants[9] ):
 oE.fStoreC_F_H( self.sTandH[iOne], self.sTandH[iOne])
####
 elif ( self.sTandH[iZero] == "Pa" ):
 ## print( "fProcessData Pa " + sTandH[iOne] )
 oE.fDoThePressureThing( self.sTandH[iOne] )
####
#
####
# elif ( sTandH[iZero] == sConstants[4] ):
 ## receipt of completion of aspect change, allow detecion to resume
# bAspectChangeInProgress = False
 ## print( "aspect complete fProcessData" )
####
 else:
 print("fProcessData(sTandH) else " + sTemp)
####
 except Exception as e:
 print( "fProcessData Exception with " + sTemp + " len=" + str(len(sTemp)) + " " + str(e) )
 finally:
 #enable uno to collect and send data
 self.sTandH = ""
 ## GPIO.output(iPiReady, GPIO.LOW)
 self.oTrigger.clear()
 return;
###################################################################################
#
###################################################################################
class cRuntime():
 def __init__(self):
 self.iStartTime = int( time.time() )
 self.iRunTimeDays = iZero
 self.iRunTimeHours = iZero
 self.iRunTimeMinutes = iZero
 self.iRunTimeSeconds = iZero
 def fDoRunTime( self ):
 self.iRunTimeDays = divmod( (int(time.time()) - self.iStartTime), 86400 )
 self.iRunTimeHours = divmod( self.iRunTimeDays[iOne], 3600 )
 self.iRunTimeMinutes = divmod( self.iRunTimeHours[iOne], 60 )
 self.iRunTimeSeconds = self.iRunTimeMinutes[iOne]
 
 return "%03d:%02d:%02d:%02d" %( self.iRunTimeDays[iZero], self.iRunTimeHours[iZero], self.iRunTimeMinutes[iZero], self.iRunTimeSeconds);
###################################################################################
#
###################################################################################
##################################################################################
#
###################################################################################
###################################################################################
#
###################################################################################
def fSetup():
 try:
 ## GPIO.cleanup()
 GPIO.setmode(GPIO.BCM)
 ##triggred by Arduino to indicate serial data has been sent
 GPIO.setup(iUnoDataReady, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
 #causes a signal to be sent-to the attached multiprocessing process to exit
 GPIO.setup(iHalt, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 GPIO.setup( iPinInt, GPIO.IN) #pulse per second from rtc
 ## GPIO.setup( iAlertEmailTimerTrigger, GPIO.IN, pull_up_down = GPIO.PUD_UP ) # alarm from rtc
 GPIO.setup(iLowInputVoltage, GPIO.OUT)
 GPIO.setup(iPiReady, GPIO.OUT)
 GPIO.setup(iPinBuzzer0, GPIO.OUT)
####
 GPIO.output(iLowInputVoltage, GPIO.LOW)
 GPIO.output(iPinBuzzer0, GPIO.LOW)
####
 # event to read serial port
 GPIO.add_event_detect(iUnoDataReady, GPIO.RISING, callback=fSerialCallBack)
####
 GPIO.add_event_detect(iHalt, GPIO.FALLING,

Crie agora seu perfil grátis para visualizar sem restrições.