Example #1
0
	def transition_Root_running(self, event) :
		catched = False
		enableds = []
		if event.name == "mouse_click" and event.getPort() == "ui" :
			parameters = event.getParameters()
			x = parameters[0]
			y = parameters[1]
			button = parameters[2]
			if button == ui.MOUSE_BUTTONS.LEFT :
				enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_running. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				x = parameters[0]
				y = parameters[1]
				button = parameters[2]
				self.exit_Root_running()
				send_event = Event("button_pressed", parameters = [self.event_name])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, 'parent' , send_event]))
				self.enter_Root_running()
			catched = True

		return catched
Example #2
0
	def transition_Root_running_root_cd_behaviour_waiting(self, event) :
		catched = False
		enableds = []
		if event.name == "create_field" and event.getPort() == "" :
			enableds.append(1)

		if event.name == "delete_field" and event.getPort() == "" :
			enableds.append(2)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_running_root_cd_behaviour_waiting. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				self.exit_Root_running_root_cd_behaviour_waiting()
				self.object_manager.addEvent(Event("create_instance", parameters = [self, 'fields']))
				self.enter_Root_running_root_cd_behaviour_creating()
			elif enabled == 2 :
				parameters = event.getParameters()
				association_name = parameters[0]
				self.exit_Root_running_root_cd_behaviour_waiting()
				self.object_manager.addEvent(Event("delete_instance", parameters = [self, association_name]))
				self.nr_of_fields -= 1
				self.enter_Root_running_root_cd_behaviour_check_nr_of_fields()
			catched = True

		return catched
Example #3
0
	def transition_Root_root_running(self, event) :
		catched = False
		enableds = []
		if event.name == "window_close" and event.getPort() == "ui" :
			parameters = event.getParameters()
			window = parameters[0]
			if window == self.field_window or window == ui.window :
				enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_root_running. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				window = parameters[0]
				self.exit_Root_root_running()
				self.object_manager.addEvent(Event("delete_instance", parameters = [self, 'buttons']))
				send_event = Event("delete_self", parameters = [])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, 'balls' , send_event]))
				self.enter_Root_root_deleting()
			catched = True

		if not catched :
			catched = self.transition_Root_root_running_main_behaviour(event) or catched
			catched = self.transition_Root_root_running_deleting_behaviour(event) or catched
			catched = self.transition_Root_root_running_child_behaviour(event) or catched
		return catched
Example #4
0
 def throwEvents(self):
     # Check if we passed anything
     if hasattr(self, "controller"):
         for item in self.items:
             coords = self.canvas.coords(item)
             if coords[0] < 30 and item not in marked:
                 # Passed light or entered station
                 t = kind_of_object[item]
                 if t == "STATION":
                     marked[item] = False
                     self.controller.addInput(
                         Event("enter", "tkinter_input", []))
                 elif t == "RED":
                     marked[item] = True
                     self.controller.addInput(
                         Event("red_light", "tkinter_input", []))
                 elif t == "YELLOW":
                     marked[item] = True
                     self.controller.addInput(
                         Event("yellow_light", "tkinter_input", []))
                 elif t == "GREEN":
                     marked[item] = True
                     self.controller.addInput(
                         Event("green_light", "tkinter_input", []))
             elif coords[0] < -170 and not marked[item]:
                 self.controller.addInput(
                     Event("leave", "tkinter_input", []))
                 marked[item] = True
     self.after(20, self.throwEvents)
Example #5
0
	def transition_Root_main_behaviour(self, event) :
		catched = False
		enableds = []
		if event.name == "delete_self" and event.getPort() == "" :
			enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_main_behaviour. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				self.exit_Root_main_behaviour()
				send_event = Event("delete_ball", parameters = [self.association_name])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, 'parent' , send_event]))
				self.enter_Root_deleted()
			catched = True

		if not catched :
			if self.current_state[self.Root_main_behaviour][0] == self.Root_main_behaviour_dragging:
				catched = self.transition_Root_main_behaviour_dragging(event)
			elif self.current_state[self.Root_main_behaviour][0] == self.Root_main_behaviour_selected:
				catched = self.transition_Root_main_behaviour_selected(event)
			elif self.current_state[self.Root_main_behaviour][0] == self.Root_main_behaviour_initializing:
				catched = self.transition_Root_main_behaviour_initializing(event)
			elif self.current_state[self.Root_main_behaviour][0] == self.Root_main_behaviour_bouncing:
				catched = self.transition_Root_main_behaviour_bouncing(event)
		return catched
Example #6
0
	def transition_Root_initializing(self, event) :
		catched = False
		enableds = []
		enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_initializing. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				self.exit_Root_initializing()
				send_event = Event("button_created", parameters = [])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, 'parent' , send_event]))
				self.enter_Root_running()
			catched = True

		return catched
Example #7
0
	def transition_Root_root_deleting(self, event) :
		catched = False
		enableds = []
		if event.name == "_0after" and event.getPort() == "" :
			enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_root_deleting. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				self.exit_Root_root_deleting()
				send_event = Event("delete_field", parameters = [self.association_name])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, 'parent' , send_event]))
				self.enter_Root_root_deleted()
			catched = True

		return catched
Example #8
0
        def __handle_event(ev=None):
            if event == ui.EVENTS.KEY_PRESS:
                controller.addInput(
                    Event(raise_name, port, [ev.keycode, source]), time_offset)

            elif event == ui.EVENTS.MOUSE_CLICK or \
               event == ui.EVENTS.MOUSE_MOVE or \
               event == ui.EVENTS.MOUSE_PRESS or \
               event == ui.EVENTS.MOUSE_RELEASE or \
                 event == ui.EVENTS.MOUSE_RIGHT_CLICK :
                controller.addInput(
                    Event(raise_name, port, [ev.x, ev.y, ev.num]), time_offset)

            elif event == ui.EVENTS.WINDOW_CLOSE:
                controller.addInput(Event(raise_name, port, [source]),
                                    time_offset)

            else:
                raise Exception('Unsupported event')
Example #9
0
	def transition_Root_root_running_child_behaviour_listening(self, event) :
		catched = False
		enableds = []
		if event.name == "button_pressed" and event.getPort() == "" :
			enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_root_running_child_behaviour_listening. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				event_name = parameters[0]
				self.exit_Root_root_running_child_behaviour_listening()
				send_event = Event("button_pressed", parameters = [event_name])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, 'parent' , send_event]))
				self.enter_Root_root_running_child_behaviour_listening()
			catched = True

		return catched
Example #10
0
	def transition_Root_root_running_main_behaviour_creating(self, event) :
		catched = False
		enableds = []
		if event.name == "instance_created" and event.getPort() == "" :
			enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_root_running_main_behaviour_creating. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				association_name = parameters[0]
				self.exit_Root_root_running_main_behaviour_creating()
				send_event = Event("set_association_name", parameters = [association_name])
				self.object_manager.addEvent(Event("narrow_cast", parameters = [self, association_name , send_event]))
				self.object_manager.addEvent(Event("start_instance", parameters = [self, association_name]))
				self.enter_Root_root_running_main_behaviour_running()
			catched = True

		return catched
Example #11
0
	def transition_Root_root_initializing(self, event) :
		catched = False
		enableds = []
		enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_root_initializing. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				self.exit_Root_root_initializing()
				self.object_manager.addEvent(Event("create_instance", parameters = [self, 'buttons','Button',self,'create_new_field','Spawn New Window']))
				self.enter_Root_root_creating()
			catched = True

		return catched
Example #12
0
	def transition_Root_running_root_main_behaviour_initializing(self, event) :
		catched = False
		enableds = []
		enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_running_root_main_behaviour_initializing. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				self.exit_Root_running_root_main_behaviour_initializing()
				self.addEvent(Event("create_field", parameters = []))
				self.enter_Root_running_root_main_behaviour_running()
			catched = True

		return catched
Example #13
0
	def transition_Root_main_behaviour_selected(self, event) :
		catched = False
		enableds = []
		if event.name == "mouse_press" and event.getPort() == "ball_ui" :
			parameters = event.getParameters()
			x = parameters[0]
			y = parameters[1]
			button = parameters[2]
			if button == ui.MOUSE_BUTTONS.LEFT :
				enableds.append(1)

		if event.name == "key_press" and event.getPort() == "ui" :
			parameters = event.getParameters()
			key = parameters[0]
			active_window = parameters[1]
			if key == ui.KEYCODES.DELETE and active_window == self.field_window :
				enableds.append(2)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_main_behaviour_selected. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				x = parameters[0]
				y = parameters[1]
				button = parameters[2]
				self.exit_Root_main_behaviour_selected()
				self.mouse_pos = {'x':x, 'y':y}
				self.enter_Root_main_behaviour_dragging()
			elif enabled == 2 :
				parameters = event.getParameters()
				key = parameters[0]
				active_window = parameters[1]
				self.exit_Root_main_behaviour_selected()
				self.addEvent(Event("delete_self", parameters = []))
				self.enter_Root_main_behaviour_selected()
			catched = True

		return catched
Example #14
0
	def transition_Root_root_running_main_behaviour_running(self, event) :
		catched = False
		enableds = []
		if event.name == "right_click" and event.getPort() == "field_ui" :
			enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_root_running_main_behaviour_running. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				x = parameters[0]
				y = parameters[1]
				button = parameters[2]
				self.exit_Root_root_running_main_behaviour_running()
				self.object_manager.addEvent(Event("create_instance", parameters = [self, 'balls','Ball',self.canvas,x,y,self.field_window]))
				self.enter_Root_root_running_main_behaviour_creating()
			catched = True

		return catched
Example #15
0
	def transition_Root_running_root_main_behaviour_running(self, event) :
		catched = False
		enableds = []
		if event.name == "button_pressed" and event.getPort() == "" :
			parameters = event.getParameters()
			event_name = parameters[0]
			if event_name == 'create_new_field' :
				enableds.append(1)

		if len(enableds) > 1 :
			print "Runtime warning : indeterminism detected in a transition from node Root_running_root_main_behaviour_running. Only the first in document order enabled transition is executed."

		if len(enableds) > 0 :
			enabled = enableds[0]
			if enabled == 1 :
				parameters = event.getParameters()
				event_name = parameters[0]
				self.exit_Root_running_root_main_behaviour_running()
				self.addEvent(Event("create_field", parameters = []))
				self.enter_Root_running_root_main_behaviour_running()
			catched = True

		return catched
Example #16
0
 def press_awake():
     self.controller.addInput(Event("awake", "tkinter_input", []))
Example #17
0
 def press_close():
     self.controller.addInput(Event("close", "tkinter_input", []))
Example #18
0
 def press_open():
     self.controller.addInput(Event("open", "tkinter_input", []))
Example #19
0
 def update_scale(value):
     if hasattr(self, "controller"):
         self.controller.addInput(
             Event("accel", "tkinter_input", [float(value)]))
Example #20
0
	def transition(self, event = Event("")):
		self.state_changed = self.transition_Root(event)