コード例 #1
0
	def doNextStepInFlowChart(self):
		
		if self.waitingForHandshake == False:
			self.flowConditionOutcome =  self.determineFlowConditionTypeAndOutcome()
		
		print "self.flowConditionOutcome: " + str(self.flowConditionOutcome)
				
		self.flowOperationOutcome = self.performFlowOperation(self.flowConditionOutcome)
	
		print "self.flowOperationOutcome: " + str(self.flowOperationOutcome)
			
		if self.flowOperationOutcome == "Complete":
			
			if self.flowConditionOutcome == "Yes":			
				self.nextStepInThisFlowChart = self.flowDictionary[self.flowChartStep]["YesNextStepInThisFlowChart"]
				
				if self.nextStepInThisFlowChart != "Finished":
					self.flowChartStep = self.nextStepInThisFlowChart
					
					try:
						print "EskySincePreviousYes before reset: " + str(globalvars.timers["EskySincePreviousYes"])
					
					except:
						a = 1
					
					globalvars.timers["EskySincePreviousYes"] = globalfxns.millis()
					
					print "EskySincePreviousYes after reset: " + str(globalvars.timers["EskySincePreviousYes"])
					return "Not finished"
				
				else:
					self.flowChartStep = "1"
					return "Finished"

			if self.flowConditionOutcome == "No":
				self.nextStepInThisFlowChart = self.flowDictionary[self.flowChartStep]["NoNextStepInThisFlowChart"]

				if self.nextStepInThisFlowChart != "Finished":
					self.flowChartStep = self.nextStepInThisFlowChart
					
					try:
						print "EskySincePreviousNo before reset: " + str(globalvars.timers["EskySincePreviousNo"])
					
					except:
						a = 1
					
					globalvars.timers["EskySincePreviousNo"] = globalfxns.millis()
					
					print "EskySincePreviousNo after reset: " + str(globalvars.timers["EskySincePreviousNo"])
					return "Not finished"
				
				else:
					self.flowChartStep = "1"
					return "Finished"
					
		else:
			return "Repeating"
コード例 #2
0
	def doNextStepInFlowChart(self):
		
		if self.turnUpdateHandshakesFromComsFlagOn == True:
			globalvars.updateHandshakesFromComs = True
			self.turnUpdateHandshakesFromComsFlagOn = False
		
		if self.justStarted == True:
			globalvars.timers["EskyLastStartup"] = globalfxns.millis()			
			self.justStarted = False
		
		if self.waitingForHandshake == False:
			self.flowConditionOutcome =  self.determineFlowConditionTypeAndOutcome()
		
		print "self.flowConditionOutcome: " + str(self.flowConditionOutcome)
				
		self.flowOperationOutcome = self.performFlowOperation(self.flowConditionOutcome)
	
		print "self.flowOperationOutcome: " + str(self.flowOperationOutcome)
			
		if self.flowOperationOutcome == "Complete":	
			
			self.turnUpdateHandshakesFromComsFlagOn = True
			
			if self.flowConditionOutcome == "Yes":			
				self.nextStepInThisFlowChart = self.flowDictionary[self.flowChartStep]["YesNextStepInThisFlowChart"]
				
				if self.nextStepInThisFlowChart != "Finished":
					self.flowChartStep = self.nextStepInThisFlowChart
					globalvars.timers["EskySincePreviousYes"] = globalfxns.millis()
					return "Not finished"
				
				else:
					self.flowChartStep = "1"
					globalvars.timers["EskyLastFinish"] = globalfxns.millis()
					self.justStarted = True
					return "Finished"

			if self.flowConditionOutcome == "No":
				self.nextStepInThisFlowChart = self.flowDictionary[self.flowChartStep]["NoNextStepInThisFlowChart"]

				if self.nextStepInThisFlowChart != "Finished":
					self.flowChartStep = self.nextStepInThisFlowChart
					globalvars.timers["EskySincePreviousNo"] = globalfxns.millis()
					return "Not finished"
				
				else:
					self.flowChartStep = "1"
					globalvars.timers["EskyLastFinish"] = globalfxns.millis()
					self.justStarted = True
					return "Finished"
					
		else:
			return "Repeating"
コード例 #3
0
ファイル: AIModule.py プロジェクト: AnthonyWalton1/ARBI
	def __init__(self):
		
		# Create GUI object and assign to its own thread
		self.GUI = GUIModule.GUIClass("ARBI GUI")
		self.GUIThread = threading.Thread(target = self.GUI.createGUI)
		self.GUIThread.start()

		# Create data logger object and clear previous file
		self.DataLogger = DataLoggerModule.DataLoggerClass("textfile.txt")
		self.DataLogger.clearFile()

		# Create Coms object
		self.Coms = ComsModule.ComsClass()
		
		# Create CSV Reader objects for as many csv files as there is to read
		self.StepReader = CsvReaderModule.CsvReaderClass("tasksEsky.csv", "Step")
		globalvars.taskDictionary = self.StepReader.csvReturnDict()

		self.EskyReader = CsvReaderModule.CsvReaderClass("flowEsky.csv", "Flow")
		self.eskyDictionary = self.EskyReader.csvReturnDict()

		# Create Task Controller objects for as many flow chart dictionaries as there is to implement
		self.EskyController = ProcessControllerModule.ProcessControllerClass(self.eskyDictionary)	
				
		# Intialise starting time references in milliseconds
		globalvars.timers["EskyLastStartup"] = globalfxns.millis()
コード例 #4
0
ファイル: Main.py プロジェクト: AnthonyWalton1/ARBI
def main():	
	time.sleep(2)

	HATstarttime = globalfxns.millis()

	globalvars.timers = {"HAT" : HATstarttime}
	globalvars.machineState = {"FCV301" : "0", "V201a" : "0", "V201b" :"0", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : 30}
	globalvars.handshakes = {"FCV301" : "", "V201a" : "", "V201b" :"", "V301" : "", "V302" : "", "heya" : ""}
	print globalvars.timers
	print globalvars.machineState
	print globalvars.handshakes

	ArbiAI = AI.AIclass()

	times = 0

	while True:
		time.sleep(1)
			
		times = times + 1
		if times == 2:
			globalvars.machineState = {"FCV301" : "0", "V201a" : "0", "V201b" :"0", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : "30"}
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "1", "V302" : "1", "heya" : "0"}
		if times == 6:
			globalvars.machineState = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "1", "V302" : "1", "heya" : "1", "FL301" : "30"}
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "1", "V302" : "1", "heya" : "1"}
		if times == 9:
			globalvars.machineState = {"FCV301" : "1", "V201a" : "0", "V201b" :"1", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : "200"}
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "0", "V201b" :"1", "V301" : "1", "V302" : "0", "heya" : "1"} #make handshake wrong
		if times == 10:
			globalvars.machineState = {"FCV301" : "1", "V201a" : "0", "V201b" :"0", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : "200"}
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "1", "V302" : "1", "heya" : "1"}
		if times == 12:
			globalvars.machineState = {"FCV301" : "1", "V201a" : "1", "V201b" :"0", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : "30"}
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "1", "V302" : "1", "heya" : "1"}
		if times == 15:
			globalvars.machineState = {"FCV301" : "1", "V201a" : "1", "V201b" :"0", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : "10000"}
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "0", "V302" : "1", "heya" : ""} # make handshake wrong
		if times == 17:
			globalvars.machineState = {"FCV301" : "1", "V201a" : "0", "V201b" :"0", "V301" : "0", "V302" : "0", "heya" : "1", "FL301" : "10000"}		
			globalvars.handshakes = {"FCV301" : "1", "V201a" : "1", "V201b" :"1", "V301" : "1", "V302" : "1", "heya" : "1"}

		
		outcome = ArbiAI.ArbiFeedAlgaeInterpreter.doNextStepInFlowChart()
		print outcome + str(times)
		
		ArbiAI.status()
		ArbiAI.decide()
		
		ArbiAI.ArbiDataLogger.logData(str(globalvars.machineState))
		
		ArbiAI.ArbiUART.serialWrite("1_hi0_ACM0\r\n")
		ArbiAI.ArbiUART.serialWrite("1_hi1_ACM1\r\n")
		ArbiAI.ArbiUART.serialReceive()

		print globalvars.UARTvar
		
		time.sleep(4)
コード例 #5
0
	def hasTimePassed(self):
		
		self.timerID = self.flowDictionary[self.flowChartStep]["ConditionDescription"] 
		self.timeToWaitSinceReferenceTime = self.flowDictionary[self.flowChartStep]["ConditionValue"]

		self.referenceTime = globalvars.timers[self.timerID]
		
		self.timeElapsedSinceReferenceTime = (globalfxns.millis() - self.referenceTime)/1000
		
		print "ConditionType: hasTimePassed"
		print "referenceTime: " + str(globalvars.timers[self.timerID])
		print "timeElapsedSinceReferenceTime: " + str(self.timeElapsedSinceReferenceTime)
		
		if int(self.timeElapsedSinceReferenceTime) > int(self.timeToWaitSinceReferenceTime):
			return "Yes"
		else:
			return "No"
コード例 #6
0
ファイル: AI.py プロジェクト: AnthonyWalton1/ARBI
	def __init__(self):
		
		self.ArbiGUI = GUI.GUIclass("ARBI GUI")
		self.guiThread = threading.Thread(target = self.ArbiGUI.createGUI)
		self.guiThread.start()

		self.ArbiDataLogger = DataLogger.DataLoggerclass("textfile.txt")
		self.ArbiDataLogger.clearFile()

		self.ArbiUART = UART.UARTclass()
		
		self.ArbiTaskReader = csvReader.csvReaderclass("CSVTask.csv", "Step")
		globalvars.taskDictionary = self.ArbiTaskReader.csvReturnDict()

		self.ArbiFeedAlgaeReader = csvReader.csvReaderclass("CSVFlow.csv", "Flow")
		self.feedAlgaeDictionary = self.ArbiFeedAlgaeReader.csvReturnDict()

		self.ArbiFeedAlgaeInterpreter = csvInterpreter.csvInterpreterclass(self.feedAlgaeDictionary)	
				
		# Intialise start-time reference in milliseconds
		globalvars.timers["startTime"] = globalfxns.millis()