Example #1
0
    def __init__(self):
        threading.Thread.__init__(self)
        self.tb = thirtybirds.Thirtybirds(settings, app_path,
                                          self.network_message_handler,
                                          self.network_status_change_handler,
                                          self.exception_handler)
        self.deadman = deadman.Deadman_Switch(self.tb)
        self.queue = queue.Queue()
        self.hostname = self.tb.get_hostname()

        self.tb.subscribe_to_topic("cmd_all_off")
        self.tb.subscribe_to_topic("cmd_play_score")
        self.tb.subscribe_to_topic("cmd_set_phrase")
        self.tb.subscribe_to_topic("cmd_set_number")
        self.tb.subscribe_to_topic("request_display_leds_present")
        self.tb.subscribe_to_topic("request_display_solenoids_present")
        self.tb.subscribe_to_topic("request_system_tests")
        self.tb.subscribe_to_topic("request_computer_details")
        self.tb.subscribe_to_topic("request_current_sensor_nominal")
        self.tb.subscribe_to_topic("request_current_sensor_present")
        self.tb.subscribe_to_topic("request_current_sensor_value")

        self.tb.publish("connected", True)
        self.chime_player = Chime_Player()
        self.acrylic_display = Acrylic_Display()
        if self.tb.get_hostname() == 'pinball1game':
            self.power_sensor = ina260.INA260()
            self.tb.subscribe_to_topic("get_current")
        self.start()
Example #2
0
    def __init__(self):
        threading.Thread.__init__(self)
        class States:
            WAITING_FOR_CONNECTIONS = "waiting_for_connections"
        self.states =States()
        self.state = self.states.WAITING_FOR_CONNECTIONS

        # SET UP TB
        self.queue = queue.Queue()
        self.tb = thirtybirds.Thirtybirds(
            settings, 
            app_path,
            self.network_message_handler,
            self.network_status_change_handler,
            self.exception_handler
        )
        self.deadman = deadman.Deadman_Switch(self.tb)
        self.solenoids = Solenoids()
        self.lighting = lighting.Lights()
        self.inductive_sensors = Inductive_Sensors(self.tb)
        self.tb.subscribe_to_topic("cmd_carousel_all_off")
        self.tb.subscribe_to_topic("cmd_carousel_eject_ball")
        self.tb.subscribe_to_topic("cmd_carousel_lights")
        self.tb.subscribe_to_topic("connected")
        self.tb.subscribe_to_topic("request_carousel_detect_ball")
        self.tb.subscribe_to_topic("request_computer_details")
        self.tb.subscribe_to_topic("request_solenoids_present")
        self.tb.subscribe_to_topic("request_system_tests")
        self.start()
Example #3
0
    def __init__(self):

        threading.Thread.__init__(self)

        class States:
            WAITING_FOR_CONNECTIONS = "waiting_for_connections"
            WAITING_FOR_HOMING = "waiting_for_homing"
            READY = "ready"

        self.states = States()
        self.tb = thirtybirds.Thirtybirds(settings, app_path,
                                          self.network_message_handler,
                                          self.network_status_change_handler,
                                          self.exception_handler)
        self.transport_connected = False
        self.horsewheel_connected = False

        self.pitch_slider_home = False
        self.horsewheel_slider_home = False
        self.horsewheel_lifter_home = False
        self.state = self.states.WAITING_FOR_CONNECTIONS

        self.queue = queue.Queue()
        self.tb.subscribe_to_topic("transport_connected")
        self.tb.subscribe_to_topic("horsewheel_connected")
        self.tb.subscribe_to_topic("pitch_slider_home")
        self.tb.subscribe_to_topic("horsewheel_slider_home")
        self.tb.subscribe_to_topic("horsewheel_lifter_home")

        self.start()
Example #4
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.tb = thirtybirds.Thirtybirds(
         settings, 
         app_path,
         self.network_message_handler,
         self.network_status_change_handler,
         self.exception_handler
     )
     self.game_modes = settings.Game_Modes()
     self.game_mode = self.game_modes.WAITING_FOR_CONNECTIONS
     self.deadman = deadman.Deadman_Switch(self.tb)
     self.gamestation_lights = lighting.Lights()
     self.button_lights = Button_Lights()
     self.multimorphic = multimorphic.Multimorphic(self.add_to_queue)
     self.playfiels_sensors = Playfield_Sensors(self.add_to_queue)
     self.queue = queue.Queue()
     self.tb.subscribe_to_topic("cmd_all_off") # to do: finish code
     self.tb.subscribe_to_topic("cmd_kicker_launch") # to do: finish code -  might not be used
     self.tb.subscribe_to_topic("cmd_lefttube_launch")# to do: finish code -  might not be used
     self.tb.subscribe_to_topic("cmd_playfield_lights")
     self.tb.subscribe_to_topic("cmd_set_mode")
     self.tb.subscribe_to_topic("cmd_rightttube_launch")# to do: finish code -  might not be used
     self.tb.subscribe_to_topic("connected")
     self.tb.subscribe_to_topic("disable_gameplay")
     self.tb.subscribe_to_topic("enable_gameplay")
     self.tb.subscribe_to_topic("event_button_comienza")
     self.tb.subscribe_to_topic("event_button_derecha")
     self.tb.subscribe_to_topic("event_button_dinero")
     self.tb.subscribe_to_topic("event_button_izquierda")
     self.tb.subscribe_to_topic("event_button_trueque")
     self.tb.subscribe_to_topic("event_pop_left")
     self.tb.subscribe_to_topic("event_pop_middle")
     self.tb.subscribe_to_topic("event_pop_right")
     self.tb.subscribe_to_topic("event_rollover_inner_left")
     self.tb.subscribe_to_topic("event_rollover_inner_right")
     self.tb.subscribe_to_topic("event_rollover_outer_left")
     self.tb.subscribe_to_topic("event_rollover_outer_right")
     self.tb.subscribe_to_topic("event_slingshot_left")
     self.tb.subscribe_to_topic("event_slingshot_right")
     self.tb.subscribe_to_topic("event_spinner")
     self.tb.subscribe_to_topic("event_trough_sensor")
     self.tb.subscribe_to_topic("event_tube_sensor_left")
     self.tb.subscribe_to_topic("event_tube_sensor_right")
     self.tb.subscribe_to_topic("request_button_light_active")
     self.tb.subscribe_to_topic("request_button_switch_active") # to do: finish code -  this de/activates reactions to buttons
     self.tb.subscribe_to_topic("request_computer_details")
     self.tb.subscribe_to_topic("request_current_sensor_nominal")
     self.tb.subscribe_to_topic("request_current_sensor_present")
     self.tb.subscribe_to_topic("request_current_sensor_value")
     self.tb.subscribe_to_topic("request_lefttube_present")
     self.tb.subscribe_to_topic("request_rightttube_present")
     self.tb.subscribe_to_topic("request_system_tests")
     self.tb.subscribe_to_topic("request_troughsensor_value")
     self.tb.subscribe_to_topic("request_visual_tests") # not implemented yet
     self.tb.subscribe_to_topic("request_playfield_states")
     self.tb.publish("connected", True)
     self.start()
Example #5
0
    def __init__(self):
        print(">>>>> Main __init__")
        threading.Thread.__init__(self)
        ###### NETWORK #####
        self.queue = queue.Queue()
        self.tb = thirtybirds.Thirtybirds(
            settings, 
            app_path,
            self.network_message_handler,
            self.network_status_change_handler,
            self.exception_handler
        )
        self.hostname = self.tb.get_hostname()
        self.deadman = deadman.Deadman_Switch(self.tb)

        self.chip_select_pins_for_abs_enc = [12,13,17,18,5,16]
        ##### SUBSCRIPTIONS #####
        self.tb.subscribe_to_topic("cmd_rotate_carousel_to_target")
        self.tb.subscribe_to_topic("connected")
        self.tb.subscribe_to_topic("request_amt203_absolute_position")
        self.tb.subscribe_to_topic("request_amt203_present")
        self.tb.subscribe_to_topic("request_amt203_zeroed")
        self.tb.subscribe_to_topic("request_computer_details")
        self.tb.subscribe_to_topic("request_current_sensor_nominal")
        self.tb.subscribe_to_topic("request_current_sensor_present")
        self.tb.subscribe_to_topic("request_current_sensor_value")
        self.tb.subscribe_to_topic("request_motor_details")
        self.tb.subscribe_to_topic("request_sdc2160_channel_faults")
        self.tb.subscribe_to_topic("request_sdc2160_closed_loop_error")
        self.tb.subscribe_to_topic("request_sdc2160_controller_faults")
        self.tb.subscribe_to_topic("request_sdc2160_faults")
        self.tb.subscribe_to_topic("request_sdc2160_present")
        self.tb.subscribe_to_topic("request_sdc2160_relative_position")
        self.tb.subscribe_to_topic("request_system_tests")
        self.tb.subscribe_to_topic("request_target_position_confirmed")
        self.tb.subscribe_to_topic("response_high_power_enabled")

        self.motor_names = ("carousel_1","carousel_2","carousel_3","carousel_4","carousel_5","carousel_center")
        ##### absolute encoder status #####
        self.position_calibration = position_calibration
        self.absolute_encoders_presences = [False,False,False,False,False,False]
        self.absolute_encoders_positions = [None,None,None,None,None,None]
        self.absolute_encoders_zeroed = [True,True,True,True,True,True]
        time.sleep(1) # just being superstitious
        self.start()
Example #6
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.tb = thirtybirds.Thirtybirds(settings, app_path,
                                       self.network_message_handler,
                                       self.network_status_change_handler,
                                       self.exception_handler)
     self.queue = queue.Queue()
     self.controllers = roboteq_command_wrapper.Controllers(
         roboteq_data_receiver.add_to_queue, self.status_receiver,
         self.network_status_change_handler,
         {"bow": settings.Roboteq.BOARDS["bow"]}, {
             "bow_height": settings.Roboteq.MOTORS["bow_height"],
             "bow_rotation": settings.Roboteq.MOTORS["bow_rotation"],
         })
     self.tb.subscribe_to_topic("horsewheel_lifter_home")
     self.tb.subscribe_to_topic("horsewheel_speed")
     self.tb.subscribe_to_topic("horsewheel_lifter_position")
     self.tb.publish("horsewheel_connected", True)
     self.start()
Example #7
0
    def __init__(self):
        threading.Thread.__init__(self)
        self.tb = thirtybirds.Thirtybirds(settings, app_path,
                                          self.network_message_handler,
                                          self.network_status_change_handler,
                                          self.exception_handler)
        self.queue = queue.Queue()
        self.safety_enable = Safety_Enable.Safety_Enable(
            self.safety_enable_handler)
        self.hosts = Hosts.Hosts(self.tb)

        ##### SUBSCRIPTIONS #####
        # CONNECTIVITY
        self.tb.subscribe_to_topic("connected")
        self.tb.subscribe_to_topic("deadman")
        #system tests
        self.tb.subscribe_to_topic("request_current_sensor_nominal")
        self.tb.subscribe_to_topic("response_computer_details")
        self.tb.subscribe_to_topic("response_current_sensor_nominal")
        self.tb.subscribe_to_topic("response_current_sensor_present")
        self.tb.subscribe_to_topic("response_current_sensor_value")
        self.tb.subscribe_to_topic("response_visual_tests")
        # pinball events
        self.tb.subscribe_to_topic("event_mpf")

        self.tb.subscribe_to_topic("event_button_comienza")
        self.tb.subscribe_to_topic("event_button_derecha")
        self.tb.subscribe_to_topic("event_button_dinero")
        self.tb.subscribe_to_topic("event_button_izquierda")
        self.tb.subscribe_to_topic("event_button_trueque")
        self.tb.subscribe_to_topic("event_pop_left")
        self.tb.subscribe_to_topic("event_pop_middle")
        self.tb.subscribe_to_topic("event_pop_right")
        self.tb.subscribe_to_topic("event_slingshot_left")
        self.tb.subscribe_to_topic("event_slingshot_right")

        self.tb.subscribe_to_topic("event_left_stack_ball_present")
        self.tb.subscribe_to_topic("event_gamestation_button")
        self.tb.subscribe_to_topic("event_left_stack_motion_detected")
        self.tb.subscribe_to_topic("event_right_stack_ball_present")
        self.tb.subscribe_to_topic("event_right_stack_motion_detected")
        self.tb.subscribe_to_topic("event_roll_inner_left")
        self.tb.subscribe_to_topic("event_roll_inner_right")
        self.tb.subscribe_to_topic("event_roll_outer_left")
        self.tb.subscribe_to_topic("event_roll_outer_right")
        self.tb.subscribe_to_topic("event_trough_sensor")
        self.tb.subscribe_to_topic("event_tube_sensor_left")
        self.tb.subscribe_to_topic("event_tube_sensor_right")
        self.tb.subscribe_to_topic("event_spinner")

        # ENCODERS & MOTORS
        self.tb.subscribe_to_topic("event_destination_timeout")
        self.tb.subscribe_to_topic("event_destination_stalled")
        self.tb.subscribe_to_topic("event_destination_reached")

        self.tb.subscribe_to_topic("event_carousel_error")
        self.tb.subscribe_to_topic("event_carousel_target_reached")
        self.tb.subscribe_to_topic("response_amt203_absolute_position")
        self.tb.subscribe_to_topic("response_amt203_present")
        self.tb.subscribe_to_topic("response_amt203_zeroed")
        self.tb.subscribe_to_topic("response_carousel_absolute")
        self.tb.subscribe_to_topic("response_carousel_relative")
        self.tb.subscribe_to_topic("response_sdc2160_channel_faults")
        self.tb.subscribe_to_topic("response_sdc2160_closed_loop_error")
        self.tb.subscribe_to_topic("response_sdc2160_controller_faults")
        self.tb.subscribe_to_topic("response_sdc2160_present")
        self.tb.subscribe_to_topic("response_sdc2160_relative_position")

        # INDUCTIVE SENSORS
        self.tb.subscribe_to_topic("event_carousel_ball_detected")
        self.tb.subscribe_to_topic("response_carousel_ball_detected")
        self.choreography = Choreography(self.tb, self.hosts)
        self.email_message_data = []
        self.modes = {
            "error":
            Mode_Error(self.tb, self.hosts, self.set_current_mode,
                       self.safety_enable.set_active),
            "waiting_for_connections":
            Mode_Waiting_For_Connections(self.tb, self.hosts,
                                         self.set_current_mode),
            "system_tests":
            Mode_System_Tests(self.tb, self.hosts, self.set_current_mode),
            "inventory":
            Mode_Inventory(self.tb, self.hosts, self.set_current_mode,
                           self.choreography),
            "attraction":
            Mode_Attraction(self.tb, self.hosts, self.set_current_mode,
                            self.choreography),
            "reset":
            Mode_Reset(self.tb, self.hosts, self.set_current_mode,
                       self.choreography),
            "countdown":
            Mode_Countdown(self.tb, self.hosts, self.set_current_mode,
                           self.choreography),
            "barter_intro":
            Mode_Barter_Intro(self.tb, self.hosts, self.set_current_mode,
                              self.choreography),
            "barter":
            Mode_Barter(self.tb, self.hosts, self.set_current_mode),
            "money_intro":
            Mode_Money_Intro(self.tb, self.hosts, self.set_current_mode,
                             self.choreography),
            "money":
            Mode_Money(self.tb, self.hosts, self.set_current_mode),
            #"ending":Mode_ending(self.tb, self.hosts, self.set_current_mode),
        }
        self.dashboard = dashboard.init()
        self.current_mode_name = self.mode_names.WAITING_FOR_CONNECTIONS
        self.current_mode = self.modes["waiting_for_connections"]
        self.current_mode.begin()
        self.start()