"""
Generated by Statechart compiler by Glenn De Jonghe and Joeri Exelmans

Date:   Mon Dec 07 22:42:50 2015

Model author: Sadaf Mustafiz and Bruno Barroca and Claudio Gomes
Model name:   Weaved_FSA_FSA_Simulator_Manual
Model description:
Manually woven FSA and FSA simulators.
"""

from python_runtime.statecharts_core import *
from python_runtime.libs.ui import *
from python_runtime.libs.utils import *
from fsa_fsa_weaved_classes import FSAState
from weaved_fsa_fsa_lib import FSAFSALib

# package "Weaved_FSA_FSA_Simulator_Manual"

class Weaved_FSA_FSA_Simulator(RuntimeClassBase):
	def __init__(self, controller, amodel, events, delta):
		RuntimeClassBase.__init__(self, controller)
		
		self.semantics.big_step_maximality = StatechartSemantics.TakeMany
		self.semantics.internal_event_lifeline = StatechartSemantics.Queue
		self.semantics.input_event_lifeline = StatechartSemantics.FirstComboStep
		self.semantics.priority = StatechartSemantics.SourceParent
		self.semantics.concurrency = StatechartSemantics.Single
		
		# User defined attributes
		self.woven_child_initialized = None
		self.child_currentState = None
		self.parent_timestep = None
		self.parent_selectedTransition = None
		self.parent_elapsed = None
		self.child_currentEvent = None
		self.child_logicalTime = None
		self.parent_eventList = None
		self.child_elapsed = None
		self.woven_delta = None
		self.parent_currentState = None
		self.child_timestep = None
		self.parent_currentEvent = None
		self.woven_child_processed = None
		self.parent_logicalTime = None
		self.child_selectedTransition = None
		self.child_eventList = None
		
		# Call user defined constructor
		Weaved_FSA_FSA_Simulator.user_defined_constructor(self, amodel, events, delta)
	
	def user_defined_constructor(self, amodel, events, delta):
		self.parent_model = amodel
		self.parent_eventList = events
		self.woven_delta = delta
		self.woven_lib = FSAFSALib()
	
	def user_defined_destructor(self):
		pass
	
	
	# User defined method
	def parent_processEvent(self, event):
		if (event != None):
			self.parent_eventList.popEvent(event)
			event.processed = True
	
	
	# User defined method
	def child_getInputEventAt(self, time):
		return self.child_eventList.getInputAt(time)
	
	
	# User defined method
	def child_processEvent(self, event):
		if (event != None):
			self.child_eventList.popEvent(event)
			event.processed = True
	
	
	# User defined method
	def assertion(self, condition):
		self.woven_lib.assertion(condition)
	
	
	# User defined method
	def lessThan(self, a, b):
		return a < b and not self.woven_lib.equal(a, b)
	
	
	# User defined method
	def parent_getInputEventAt(self, time):
		return self.parent_eventList.getInputAt(time)
	
	def initializeStatechart(self):
		self.current_state[self.Root] = []
		self.current_state[self.Root_Child_FSA] = []
		self.current_state[self.Root_Parent_FSA] = []
		
		# Enter default state
		self.enter_Root_Start_Woven()
	
	# Unique IDs for all statechart nodes
	Root = 0
	Root_Child_FSA = 1
	Root_Parent_FSA = 2
	Root_ProcessChild = 3
	Root_Start_Woven = 4
	Root_Child_FSA_FSA_Start = 5
	Root_Child_FSA_FSA_Processing = 6
	Root_Child_FSA_FSA_Check = 7
	Root_Parent_FSA_FSA_Start = 8
	Root_Parent_FSA_FSA_End = 9
	Root_Parent_FSA_FSA_Check = 10
	Root_Parent_FSA_FSA_Processing = 11
	
	# Statechart enter/exit action method(s)
	
	def enter_Root_Child_FSA(self):
		self.current_state[self.Root].append(self.Root_Child_FSA)
	
	def exit_Root_Child_FSA(self):
		if self.Root_Child_FSA_FSA_Start in self.current_state[self.Root_Child_FSA]:
			self.exit_Root_Child_FSA_FSA_Start()
		if self.Root_Child_FSA_FSA_Processing in self.current_state[self.Root_Child_FSA]:
			self.exit_Root_Child_FSA_FSA_Processing()
		if self.Root_Child_FSA_FSA_Check in self.current_state[self.Root_Child_FSA]:
			self.exit_Root_Child_FSA_FSA_Check()
		self.current_state[self.Root] = []
	
	def enter_Root_Parent_FSA(self):
		self.current_state[self.Root].append(self.Root_Parent_FSA)
	
	def exit_Root_Parent_FSA(self):
		if self.Root_Parent_FSA_FSA_Start in self.current_state[self.Root_Parent_FSA]:
			self.exit_Root_Parent_FSA_FSA_Start()
		if self.Root_Parent_FSA_FSA_End in self.current_state[self.Root_Parent_FSA]:
			self.exit_Root_Parent_FSA_FSA_End()
		if self.Root_Parent_FSA_FSA_Check in self.current_state[self.Root_Parent_FSA]:
			self.exit_Root_Parent_FSA_FSA_Check()
		if self.Root_Parent_FSA_FSA_Processing in self.current_state[self.Root_Parent_FSA]:
			self.exit_Root_Parent_FSA_FSA_Processing()
		self.current_state[self.Root] = []
	
	def enter_Root_ProcessChild(self):
		self.current_state[self.Root].append(self.Root_ProcessChild)
	
	def exit_Root_ProcessChild(self):
		self.current_state[self.Root] = []
	
	def enter_Root_Start_Woven(self):
		self.current_state[self.Root].append(self.Root_Start_Woven)
	
	def exit_Root_Start_Woven(self):
		self.current_state[self.Root] = []
	
	def enter_Root_Child_FSA_FSA_Start(self):
		self.current_state[self.Root_Child_FSA].append(self.Root_Child_FSA_FSA_Start)
	
	def exit_Root_Child_FSA_FSA_Start(self):
		self.current_state[self.Root_Child_FSA] = []
	
	def enter_Root_Child_FSA_FSA_Processing(self):
		self.current_state[self.Root_Child_FSA].append(self.Root_Child_FSA_FSA_Processing)
	
	def exit_Root_Child_FSA_FSA_Processing(self):
		self.current_state[self.Root_Child_FSA] = []
	
	def enter_Root_Child_FSA_FSA_Check(self):
		print('Attempting to read event: ')
		self.child_currentEvent = self.child_getInputEventAt(self.child_logicalTime)
		self.child_selectedTransition = self.child_model.getTransitionFrom(self.child_currentState, self.child_currentEvent, self.child_elapsed)
		print('Read event: ' + str(self.child_currentEvent))
		print('Selected transition: ' + str(self.child_selectedTransition))
		self.current_state[self.Root_Child_FSA].append(self.Root_Child_FSA_FSA_Check)
	
	def exit_Root_Child_FSA_FSA_Check(self):
		self.current_state[self.Root_Child_FSA] = []
	
	def enter_Root_Parent_FSA_FSA_Start(self):
		self.current_state[self.Root_Parent_FSA].append(self.Root_Parent_FSA_FSA_Start)
	
	def exit_Root_Parent_FSA_FSA_Start(self):
		self.current_state[self.Root_Parent_FSA] = []
	
	def enter_Root_Parent_FSA_FSA_End(self):
		self.current_state[self.Root_Parent_FSA].append(self.Root_Parent_FSA_FSA_End)
	
	def exit_Root_Parent_FSA_FSA_End(self):
		self.current_state[self.Root_Parent_FSA] = []
	
	def enter_Root_Parent_FSA_FSA_Check(self):
		print('Attempting to read event: ')
		self.parent_currentEvent = self.parent_getInputEventAt(self.parent_logicalTime)
		self.parent_selectedTransition = self.parent_model.getTransitionFrom(self.parent_currentState, self.parent_currentEvent, self.parent_elapsed)
		print('Read event: ' + str(self.parent_currentEvent))
		print('Selected transition: ' + str(self.parent_selectedTransition))
		self.current_state[self.Root_Parent_FSA].append(self.Root_Parent_FSA_FSA_Check)
	
	def exit_Root_Parent_FSA_FSA_Check(self):
		self.current_state[self.Root_Parent_FSA] = []
	
	def enter_Root_Parent_FSA_FSA_Processing(self):
		self.current_state[self.Root_Parent_FSA].append(self.Root_Parent_FSA_FSA_Processing)
	
	def exit_Root_Parent_FSA_FSA_Processing(self):
		self.current_state[self.Root_Parent_FSA] = []
	
	# Statechart enter/exit default method(s)
	
	def enterDefault_Root_Child_FSA(self):
		self.enter_Root_Child_FSA()
		self.enter_Root_Child_FSA_FSA_Start()
	
	def enterDefault_Root_Parent_FSA(self):
		self.enter_Root_Parent_FSA()
		self.enter_Root_Parent_FSA_FSA_Start()
	
	# Statechart transitions
	
	def generateCandidatesChildren_Root(self):
		if self.current_state[self.Root][0] == self.Root_ProcessChild:
			return self.generateCandidates_Root_ProcessChild()
		elif self.current_state[self.Root][0] == self.Root_Start_Woven:
			return self.generateCandidates_Root_Start_Woven()
		elif self.current_state[self.Root][0] == self.Root_Child_FSA:
			return self.generateCandidates_Root_Child_FSA()
		elif self.current_state[self.Root][0] == self.Root_Parent_FSA:
			return self.generateCandidates_Root_Parent_FSA()
		return False
	
	def generateCandidates_Root(self):
		if not self.combo_step.isArenaChanged(self.Root):
			return self.generateCandidatesChildren_Root()
		else:
			return True
	
	def generateCandidatesCurrent_Root_ProcessChild(self):
		enabled_events = self.getEnabledEvents()
		if self.woven_child_processed[self.parent_currentState.name] and self.lessThan(self.child_logicalTime, self.parent_logicalTime) or (self.child_selectedTransition != None and self.parent_selectedTransition == None):
			self.small_step.addCandidate(self.transition_Root_ProcessChild_1, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.woven_child_processed[self.parent_currentState.name] and self.child_selectedTransition == None and self.parent_selectedTransition != None and self.parent_logicalTime == self.child_logicalTime:
			self.small_step.addCandidate(self.transition_Root_ProcessChild_2, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.woven_child_processed[self.parent_currentState.name] and self.child_selectedTransition == None and self.parent_selectedTransition == None and self.parent_logicalTime == self.child_logicalTime:
			self.small_step.addCandidate(self.transition_Root_ProcessChild_3, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.woven_child_initialized[self.parent_currentState.name] and not self.woven_child_processed[self.parent_currentState.name]:
			self.small_step.addCandidate(self.transition_Root_ProcessChild_4, [])
			return True
		enabled_events = self.getEnabledEvents()
		if not self.woven_child_initialized[self.parent_currentState.name] and not self.woven_child_processed[self.parent_currentState.name]:
			self.small_step.addCandidate(self.transition_Root_ProcessChild_5, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.woven_child_processed[self.parent_currentState.name] and self.child_selectedTransition != None and self.parent_selectedTransition != None:
			self.small_step.addCandidate(self.transition_Root_ProcessChild_6, [])
			return True
		return False
	
	def generateCandidates_Root_ProcessChild(self):
		if not self.combo_step.isArenaChanged(self.Root_ProcessChild):
			return self.generateCandidatesCurrent_Root_ProcessChild()
		else:
			return True
	
	def transition_Root_ProcessChild_1(self, parameters):
		self.exit_Root_ProcessChild()
		print('Going to Child_FSA/FSA_Check via already processed with unsynched time or child transition only.')
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_Child_FSA()
		self.enter_Root_Child_FSA_FSA_Processing()
	
	def transition_Root_ProcessChild_2(self, parameters):
		self.exit_Root_ProcessChild()
		print('Going to Parent_FSA/FSA_Processing via only parent selected transitions and time synchronized.')
		self.woven_child_initialized[self.parent_selectedTransition.target.name] = False
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_Parent_FSA()
		self.enter_Root_Parent_FSA_FSA_Processing()
	
	def transition_Root_ProcessChild_3(self, parameters):
		self.exit_Root_ProcessChild()
		print('Going to Parent_FSA/FSA_Processing via no selected transitions and time synchronized.')
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_Parent_FSA()
		self.enter_Root_Parent_FSA_FSA_Processing()
	
	def transition_Root_ProcessChild_4(self, parameters):
		self.exit_Root_ProcessChild()
		print('Going to Child_FSA/FSA_Check via already initialized.')
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_Child_FSA()
		self.enter_Root_Child_FSA_FSA_Check()
	
	def transition_Root_ProcessChild_5(self, parameters):
		self.exit_Root_ProcessChild()
		print('Going to Child_FSA/FSA_Check via not initialized.')
		self.woven_child_initialized[self.parent_currentState.name] = True
		self.child_model = self.parent_currentState.model
		self.child_eventList = self.parent_eventList
		self.child_logicalTime = self.parent_logicalTime
		self.child_elapsed = 0.0
		self.child_timestep = self.woven_delta
		self.child_currentState = self.child_model.initialState
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_Child_FSA()
		self.enter_Root_Child_FSA_FSA_Check()
	
	def transition_Root_ProcessChild_6(self, parameters):
		self.exit_Root_ProcessChild()
		print('Going to Parent_FSA/FSA_Processing via conflict resolution.')
		self.woven_child_initialized[self.parent_selectedTransition.target.name] = False
		self.child_selectedTransition = None
		self.assertion(self.woven_lib.equal(self.parent_logicalTime, self.child_logicalTime))
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_Parent_FSA()
		self.enter_Root_Parent_FSA_FSA_Processing()
	
	def generateCandidatesCurrent_Root_Start_Woven(self):
		enabled_events = self.getEnabledEvents()
		self.small_step.addCandidate(self.transition_Root_Start_Woven_1, [])
		return True
		return False
	
	def generateCandidates_Root_Start_Woven(self):
		if not self.combo_step.isArenaChanged(self.Root_Start_Woven):
			return self.generateCandidatesCurrent_Root_Start_Woven()
		else:
			return True
	
	def transition_Root_Start_Woven_1(self, parameters):
		self.exit_Root_Start_Woven()
		self.woven_child_processed = dict()
		self.woven_child_initialized = dict()
		self.combo_step.setArenaChanged(self.Root)
		self.enterDefault_Root_Parent_FSA()
	
	def generateCandidatesChildren_Root_Child_FSA(self):
		if self.current_state[self.Root_Child_FSA][0] == self.Root_Child_FSA_FSA_Start:
			return self.generateCandidates_Root_Child_FSA_FSA_Start()
		elif self.current_state[self.Root_Child_FSA][0] == self.Root_Child_FSA_FSA_Processing:
			return self.generateCandidates_Root_Child_FSA_FSA_Processing()
		elif self.current_state[self.Root_Child_FSA][0] == self.Root_Child_FSA_FSA_Check:
			return self.generateCandidates_Root_Child_FSA_FSA_Check()
		return False
	
	def generateCandidates_Root_Child_FSA(self):
		if not self.combo_step.isArenaChanged(self.Root_Child_FSA):
			return self.generateCandidatesChildren_Root_Child_FSA()
		else:
			return True
	
	def generateCandidatesCurrent_Root_Child_FSA_FSA_Start(self):
		enabled_events = self.getEnabledEvents()
		self.small_step.addCandidate(self.transition_Root_Child_FSA_FSA_Start_1, [])
		return True
		return False
	
	def generateCandidates_Root_Child_FSA_FSA_Start(self):
		if not self.combo_step.isArenaChanged(self.Root_Child_FSA_FSA_Start):
			return self.generateCandidatesCurrent_Root_Child_FSA_FSA_Start()
		else:
			return True
	
	def transition_Root_Child_FSA_FSA_Start_1(self, parameters):
		self.exit_Root_Child_FSA_FSA_Start()
		self.child_logicalTime = 0.0
		self.child_elapsed = 0
		self.child_timestep = self.woven_delta
		self.child_currentState = self.child_model.initialState
		self.combo_step.setArenaChanged(self.Root_Child_FSA)
		self.enter_Root_Child_FSA_FSA_Check()
	
	def generateCandidatesCurrent_Root_Child_FSA_FSA_Processing(self):
		enabled_events = self.getEnabledEvents()
		if self.child_selectedTransition == None:
			self.small_step.addCandidate(self.transition_Root_Child_FSA_FSA_Processing_1, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.child_selectedTransition != None and (self.child_currentEvent == None or self.child_currentEvent.processed):
			self.small_step.addCandidate(self.transition_Root_Child_FSA_FSA_Processing_2, [])
			return True
		return False
	
	def generateCandidates_Root_Child_FSA_FSA_Processing(self):
		if not self.combo_step.isArenaChanged(self.Root_Child_FSA_FSA_Processing):
			return self.generateCandidatesCurrent_Root_Child_FSA_FSA_Processing()
		else:
			return True
	
	def transition_Root_Child_FSA_FSA_Processing_1(self, parameters):
		self.exit_Root_Child_FSA_FSA_Processing()
		print('Going to FSA_Check with no transition to be done... ')
		self.child_logicalTime = self.child_logicalTime + self.child_timestep
		self.child_elapsed = self.child_elapsed + self.child_timestep
		print(self.child_logicalTime)
		print(self.child_elapsed)
		self.combo_step.setArenaChanged(self.Root_Child_FSA)
		self.enter_Root_Child_FSA_FSA_Check()
	
	def transition_Root_Child_FSA_FSA_Processing_2(self, parameters):
		self.exit_Root_Child_FSA_FSA_Processing()
		print('Going to FSA_Check with transition to be done... ')
		self.child_currentState = self.child_selectedTransition.target
		self.child_elapsed = 0
		self.child_processEvent(self.parent_currentEvent)
		print('changing to state: ')
		print(self.child_currentState.getName())
		print(self.child_logicalTime)
		print(self.child_elapsed)
		self.combo_step.setArenaChanged(self.Root_Child_FSA)
		self.enter_Root_Child_FSA_FSA_Check()
	
	def generateCandidatesCurrent_Root_Child_FSA_FSA_Check(self):
		enabled_events = self.getEnabledEvents()
		self.small_step.addCandidate(self.transition_Root_Child_FSA_FSA_Check_1, [])
		return True
		return False
	
	def generateCandidates_Root_Child_FSA_FSA_Check(self):
		if not self.combo_step.isArenaChanged(self.Root_Child_FSA_FSA_Check):
			return self.generateCandidatesCurrent_Root_Child_FSA_FSA_Check()
		else:
			return True
	
	def transition_Root_Child_FSA_FSA_Check_1(self, parameters):
		self.exit_Root_Child_FSA()
		print('going to ProcessChild... ')
		self.woven_child_processed[self.parent_currentState.name] = True
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_ProcessChild()
	
	def generateCandidatesChildren_Root_Parent_FSA(self):
		if self.current_state[self.Root_Parent_FSA][0] == self.Root_Parent_FSA_FSA_Start:
			return self.generateCandidates_Root_Parent_FSA_FSA_Start()
		elif self.current_state[self.Root_Parent_FSA][0] == self.Root_Parent_FSA_FSA_End:
			return self.generateCandidates_Root_Parent_FSA_FSA_End()
		elif self.current_state[self.Root_Parent_FSA][0] == self.Root_Parent_FSA_FSA_Check:
			return self.generateCandidates_Root_Parent_FSA_FSA_Check()
		elif self.current_state[self.Root_Parent_FSA][0] == self.Root_Parent_FSA_FSA_Processing:
			return self.generateCandidates_Root_Parent_FSA_FSA_Processing()
		return False
	
	def generateCandidates_Root_Parent_FSA(self):
		if not self.combo_step.isArenaChanged(self.Root_Parent_FSA):
			return self.generateCandidatesChildren_Root_Parent_FSA()
		else:
			return True
	
	def generateCandidatesCurrent_Root_Parent_FSA_FSA_Start(self):
		enabled_events = self.getEnabledEvents()
		self.small_step.addCandidate(self.transition_Root_Parent_FSA_FSA_Start_1, [])
		return True
		return False
	
	def generateCandidates_Root_Parent_FSA_FSA_Start(self):
		if not self.combo_step.isArenaChanged(self.Root_Parent_FSA_FSA_Start):
			return self.generateCandidatesCurrent_Root_Parent_FSA_FSA_Start()
		else:
			return True
	
	def transition_Root_Parent_FSA_FSA_Start_1(self, parameters):
		self.exit_Root_Parent_FSA_FSA_Start()
		self.parent_logicalTime = 0.0
		self.parent_elapsed = 0
		self.parent_currentState = self.parent_model.initialState
		self.parent_timestep = self.woven_delta
		self.woven_child_initialized[self.parent_currentState.name] = False
		self.combo_step.setArenaChanged(self.Root_Parent_FSA)
		self.enter_Root_Parent_FSA_FSA_Check()
	
	def generateCandidates_Root_Parent_FSA_FSA_End(self):
		return False
	
	def generateCandidatesCurrent_Root_Parent_FSA_FSA_Check(self):
		enabled_events = self.getEnabledEvents()
		if self.parent_currentState.final == False and not isinstance(self.parent_currentState, FSAState):
			self.small_step.addCandidate(self.transition_Root_Parent_FSA_FSA_Check_1, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.parent_currentState.final == False and isinstance(self.parent_currentState, FSAState):
			self.small_step.addCandidate(self.transition_Root_Parent_FSA_FSA_Check_2, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.parent_currentState.final == True:
			self.small_step.addCandidate(self.transition_Root_Parent_FSA_FSA_Check_3, [])
			return True
		return False
	
	def generateCandidates_Root_Parent_FSA_FSA_Check(self):
		if not self.combo_step.isArenaChanged(self.Root_Parent_FSA_FSA_Check):
			return self.generateCandidatesCurrent_Root_Parent_FSA_FSA_Check()
		else:
			return True
	
	def transition_Root_Parent_FSA_FSA_Check_1(self, parameters):
		self.exit_Root_Parent_FSA_FSA_Check()
		print('Going to fsa process... ')
		self.combo_step.setArenaChanged(self.Root_Parent_FSA)
		self.enter_Root_Parent_FSA_FSA_Processing()
	
	def transition_Root_Parent_FSA_FSA_Check_2(self, parameters):
		self.exit_Root_Parent_FSA()
		print('Going to ProcessChild... ')
		self.woven_child_processed[self.parent_currentState.name] = False
		self.combo_step.setArenaChanged(self.Root)
		self.enter_Root_ProcessChild()
	
	def transition_Root_Parent_FSA_FSA_Check_3(self, parameters):
		self.exit_Root_Parent_FSA_FSA_Check()
		print('going to end... ')
		self.combo_step.setArenaChanged(self.Root_Parent_FSA)
		self.enter_Root_Parent_FSA_FSA_End()
	
	def generateCandidatesCurrent_Root_Parent_FSA_FSA_Processing(self):
		enabled_events = self.getEnabledEvents()
		if self.parent_selectedTransition != None and (self.parent_currentEvent == None or self.parent_currentEvent.processed):
			self.small_step.addCandidate(self.transition_Root_Parent_FSA_FSA_Processing_1, [])
			return True
		enabled_events = self.getEnabledEvents()
		if self.parent_selectedTransition == None:
			self.small_step.addCandidate(self.transition_Root_Parent_FSA_FSA_Processing_2, [])
			return True
		return False
	
	def generateCandidates_Root_Parent_FSA_FSA_Processing(self):
		if not self.combo_step.isArenaChanged(self.Root_Parent_FSA_FSA_Processing):
			return self.generateCandidatesCurrent_Root_Parent_FSA_FSA_Processing()
		else:
			return True
	
	def transition_Root_Parent_FSA_FSA_Processing_1(self, parameters):
		self.exit_Root_Parent_FSA_FSA_Processing()
		print('Going to FSA_Check with transition to be done... ')
		self.parent_currentState = self.parent_selectedTransition.target
		self.parent_elapsed = 0
		self.parent_processEvent(self.parent_currentEvent)
		self.woven_child_initialized[self.parent_currentState.name] = False
		print('changing to state: ')
		print(self.parent_currentState.getName())
		print(self.parent_logicalTime)
		print(self.parent_elapsed)
		self.combo_step.setArenaChanged(self.Root_Parent_FSA)
		self.enter_Root_Parent_FSA_FSA_Check()
	
	def transition_Root_Parent_FSA_FSA_Processing_2(self, parameters):
		self.exit_Root_Parent_FSA_FSA_Processing()
		print('Going to FSA_Check with no transition to be done... ')
		self.parent_logicalTime = self.parent_logicalTime + self.parent_timestep
		self.parent_elapsed = self.parent_elapsed + self.parent_timestep
		print(self.parent_logicalTime)
		print(self.parent_elapsed)
		self.combo_step.setArenaChanged(self.Root_Parent_FSA)
		self.enter_Root_Parent_FSA_FSA_Check()
	
	# Generate transition candidates for current small step
	def generateCandidates(self):
		self.generateCandidates_Root()

class ObjectManager(ObjectManagerBase):
	def __init__(self, controller):
		ObjectManagerBase.__init__(self, controller)
	
	def instantiate(self, class_name, construct_params):
		if class_name == "Weaved_FSA_FSA_Simulator":
			instance = Weaved_FSA_FSA_Simulator(self.controller, construct_params[0], construct_params[1], construct_params[2])
			instance.associations = {}
		return instance

class Controller(ThreadsControllerBase):
	def __init__(self, amodel, events, delta, keep_running = None):
		if keep_running == None: keep_running = True
		ThreadsControllerBase.__init__(self, ObjectManager(self), keep_running)
		self.object_manager.createInstance("Weaved_FSA_FSA_Simulator", [amodel, events, delta])