print "FAIL" print "-------------------------------------------------------" value=DataReadWrite.isBalanceDoorOpen() print "isBalanceDoorOpen() result ->",value test += 1 if (value=="OPEN" or value=="CLOSED"): print "PASS" passed += 1 else: print "FAIL" runID=1 position=1 print "-------------------------------------------------------" value=DataReadWrite.getMaxPreFireCount(runID,position) print "getMaxPreFireCount(",runID,",",position,") result ->",value test += 1 if value==True: print "PASS" passed += 1 else: print "FAIL" print "-------------------------------------------------------" value=DataReadWrite.getMaxPostFireCount(runID,position) print "getMaxPostFireCount(",runID,",",position,") result ->",value test += 1 if value==True: print "PASS" passed += 1
def weighAllSamplesPreFire(runID,duration,loggingInterval, numberOfSamples,startPosition, tempCorrection,rhCorrection,repetition, robotStatus,POSITION,MCOUNT,CURRENTSTEP, STATUS,DURATION,LOGGERINTERVAL,RUNID, NUMBEROFSAMPLES,TIMEREMAINING,CYCLE,MEAN,STDEV,VARIANCE): # Find elapsed time #first put robot back to zero position=int(startPosition) if position=="": position=1 logger.debug("weighAllSamplesPreFire( %d,%d,%d,%d,%d )" % (runID,duration,loggingInterval,numberOfSamples,startPosition)) status="prefire" preOrPost=1 #HomePosition() listOfValues=() RUNID.set(runID) NUMBEROFSAMPLES.set(numberOfSamples) DURATION.set(duration) POSITION.set(position) CYCLE.set(repetition) MCOUNT.set(0) STATUS.set("Initializing") LOGGERINTERVAL.set(loggingInterval) crucibleWeight=0.0 startTime=datetime.today() endPoint=timedelta(minutes=duration) endTime=startTime+endPoint robotStatus.deiconify() Label(robotStatus,text="Run ID:").grid(row=0,column=0,sticky=W) Label(robotStatus,textvariable=RUNID).grid(row=0,column=1, sticky=W) Label(robotStatus,text="Current sample number:").grid(row=1,column=0,sticky=W) Label(robotStatus,textvariable=POSITION).grid(row=1,column=1, sticky=W) Label(robotStatus,text="Total Number of Samples:").grid(row=2,column=0,sticky=W) Label(robotStatus,textvariable=NUMBEROFSAMPLES).grid(row=2,column=1,sticky=W) Label(robotStatus,text="Cycle Number:").grid(row=3,column=0,sticky=W) Label(robotStatus,textvariable=CYCLE).grid(row=3,column=1,sticky=W) Label(robotStatus,textvariable=MCOUNT).grid(row=4,column=1,sticky=W) Label(robotStatus,text="Current measurement count:").grid(row=4,column=0,sticky=W) Label(robotStatus,text="Logging interval:").grid(row=5,column=0, sticky=W) Label(robotStatus,textvariable=LOGGERINTERVAL).grid(row=5,column=1,sticky=W) Label(robotStatus,text="Duration of Measurements:").grid(row=6,column=0, sticky=W) Label(robotStatus,textvariable=DURATION).grid(row=6,column=1,sticky=W) Label(robotStatus,text="Number of Samples:").grid(row=7,column=0,sticky=W) Label(robotStatus,textvariable=NUMBEROFSAMPLES).grid(row=7,column=1,sticky=W) Label(robotStatus,text="Time remaining for this sample:").grid(row=8,column=0,sticky=W) Label(robotStatus,textvariable=TIMEREMAINING).grid(row=8,column=1,sticky=W) Label(robotStatus,text="Status").grid(row=9,column=0, sticky=W) Label(robotStatus,textvariable=STATUS).grid(row=9,column=1,sticky=W) sleep(5) while position < numberOfSamples+1: statustext="Now on sample %d",int(position) STATUS.set(statustext) logger.debug("Now on position: %d ", int(position)) statustext="Go to position %d",int(position) STATUS.set(statustext) #goToSamplePosition(position) #val = samplePickUp() #if val == False: # return False ## zero the balance for each sample logger.debug("Zero balance") #DataReadWrite.zeroBalance() logger.debug("Open balance door") #DataReadWrite.openBalanceDoor() statustext="Going to outside of balance" STATUS.set(statustext) #logger.debug("Go to outside balance.") #goToOutsideBalanceFromOutside() statustext="Going into the balance." STATUS.set(statustext) logger.debug("go to inside balance.") #goToInsideBalanceFromOutside() logger.debug("put sample on balance.") statustext="Putting sample on balance." STATUS.set(statustext) #val = putSampleOnBalance() #if val == False: # return False ## may need to check to see if arm is clear of door. logger.debug("go to outsisde balance from the inside.") statustext="Going to outside of balance" STATUS.set(statustext) #goToOutsideBalanceFromInside() logger.debug("close balance door") #DataReadWrite.closeBalanceDoor() crucibleWeight=double(DataReadWrite.getCrucibleWeight(runID,position)) if crucibleWeight==False: alertWindow("get Crucible Weight returned an error") sampleID=DataReadWrite.getSampleID(runID,position) startTime=datetime.today() durationOfLogging=int(duration) endPoint=timedelta(minutes=durationOfLogging) endTime=startTime+endPoint repetition_count=0 kcount=0 standard_weight=float(0.0) count=0 #get the latest count for this sample total_count = int(DataReadWrite.getMaxPreFireCount(runID,position)) if (total_count == 0 or total_count == ""): total_count=0 listOfValues=[] a = array([]) weight=double(0.0) statustext="Weighing sample # %d"% position STATUS.set(statustext) while datetime.today() < endTime: timeLeft=endTime-datetime.today() TIMEREMAINING.set(int(timeLeft.seconds/60)) result=[] (measurement,status)=DataReadWrite.readWeightFromBalance() weight=double(crucibleWeight)-double(measurement) if weight>0.0: a=append(a,double(weight)) averageWeight=a.mean() stdevWeight=a.std() logger.debug( "Count: %d the average weight of sample # %d is %f with stdev of %f" % (count,position,float(averageWeight),float(stdevWeight))) ## now update crucible position record now = datetime.today() today = now.strftime("%m-%d-%y %H:%M:%S") repetition_count += 1 total_count += 1 MCOUNT.set(count) temperature=xyzRobot.getTemperature() humidity=xyzRobot.getHumidity() logger.debug( "TMP: temp: %s, humidity: %s" % (temperature,humidity)) standard_weight=0.0 if (temperature==""): temperature=0.0 if (humidity==""): humidity=0.0 value=DataReadWrite.insertPreFireMeasurement(runID,sampleID,position,weight,status, temperature,humidity,crucibleWeight, standard_weight,today,total_count,repetition,repetition_count,count) if value==False: alertWindow("insertPreFireMeasurement has returned an error") count += 1 ### check to see if enough measurements have been made. First at least 100 must have been done if (count > COUNTS_FOR_STATS): (mean,stdev,variance,tempMean,tempStdev,humidityMean,humidityStdev)=DataReadWrite.getStatsForPrefireWeightOfSample(runID,sampleID,count) MEAN.set(mean) STDEV.set(stdev) VARIANCE.set(variance) logger.debug("Mean: %d Stdev: %d Variance: %d TempMean: %d TempStDev: %d HumidityMean: %d HumidityStdDev: %d" % (mean,stdev,variance,tempMean,tempStdev,humidityMean,humidityStdev)) value=DataReadWrite.updateSamplePreFire(runID,sampleID,position,mean,stdev,tempMean,tempStdev,humidityMean,humidityStdev) sleep(loggingInterval) if count==0: ## check to see if balance is giving anything (value,status)=DataReadWrite.readInstantWeightFromBalance() logger.debug( "Instant value from balance (unstable): %f ",float(value)) if (value>0): logger.debug( "Since this is >0 the balance is reading but not stable") logger.debug( "resetting clock. Waiting for a valid entry before storing data...") startTime=datetime.today() endPoint=timedelta(minutes=durationOfLogging) endTime=startTime+endPoint else: logger.error( "There is a problem: no output from balance at all: Count: %d ",int(kcount)) kcount += 1 if kcount==500: logger.error( "There is a problem: no output for 500 counts -- quitting ") KillMotors() exit(1) #DataReadWrite.openBalanceDoor() statustext="Going into balance." STATUS.set(statustext) #goToInsideBalanceFromOutside() statustext="Picking up sample." STATUS.set(statustext) #val=pickUpSampleFromBalance() #if val == False: # return False statustext="Going to outside of balance." STATUS.set(statustext) #goToOutsideBalanceFromInside() statustext="Going to position %d." % position STATUS.set(statustext) #goToSamplePosition(position) statustext="Putting sample down." #val=samplePutDown() #if val == False: # return False statustext="Going to home position." #response=goHome() #if response==False: # logger.error( "Home point not reached. Stopping.") # STATUS.set("Error: home point not reached.") # return False #DataReadWrite.closeBalanceDoor() position += 1 POSITION.set(int(position)) statustext= "Now moving to the next sample %d." % position STATUS.set(statustext) STATUS.set("Done!") robotStatus.withdraw() return runID;