Exemplo n.º 1
0
    def __init__(self, model, channel=0, one_channel=True, max_show_time=60):
        super(ShowRunner,
              self).__init__(name="ShowRunner")  # set up the thread
        self.model = model  # Hex class within hex.py
        self.running = True
        self.max_show_time = max_show_time
        self.show_runtime = 0
        self.time_since_reset = 0
        self.external_restart = False  # External trigger to restart show (only for Channel 2)
        self.channel = channel
        self.one_channel = one_channel  # Boolean
        self.num_channels = 1 if one_channel else 2
        self.time_frame_start = datetime.datetime.now()
        self.time_frame_end = datetime.datetime.now()

        # map of names -> show constructors
        show_channel = channel if not self.one_channel else None
        self.shows = dict(shows.load_shows(show_channel))
        self.randseq = shows.random_shows(show_channel)

        # current show object & frame generator
        self.show = None
        self.framegen = None
        self.prev_show = None
        self.show_params = None
Exemplo n.º 2
0
    def __init__(self, model, queue, max_showtime=240, fail_hard=True):
        super(ShowRunner, self).__init__(name="ShowRunner")
        self.model = model
        self.queue = queue

        self.fail_hard = fail_hard
        self.running = True
        self.max_show_time = max_showtime
        self.show_runtime = 0

        # map of names -> show ctors
        self.shows = dict(shows.load_shows())
        self.randseq = shows.random_shows()
        self.show_params = False

        # current show object & frame generator
        self.show = None
        self.framegen = None
        self.prev_show = None

        # current show parameters

        # show speed multiplier - ranges from 0.5 to 2.0
        # 1.0 is normal speed
        # lower numbers mean faster speeds, higher is slower
        self.speed_x = 1.0
Exemplo n.º 3
0
    def __init__(self, model, simulator, queue, max_showtime=1000):
        super(ShowRunner, self).__init__(name="ShowRunner")
        self.model = model
        self.simulator = simulator
        self.queue = queue

        self.running = True
        self.max_show_time = max_showtime
        self.show_runtime = 0

        # map of names -> show ctors
        self.shows = dict(shows.load_shows())
        self.randseq = shows.random_shows()

        # current show object & frame generator
        self.show = None
        self.framegen = None

        # current show parameters

        # show speed multiplier - ranges from 0.1 to 10
        # 1.0 is normal speed
        # lower numbers mean faster speeds, higher is slower
        self.speed_x = 1.0

        # Percent brightness
        self.brightness_x = 100
Exemplo n.º 4
0
    def __init__(self, model, simulator, queue, max_showtime=1000):
        super(ShowRunner, self).__init__(name="ShowRunner")
        self.model = model
        self.simulator = simulator
        self.queue = queue

        self.running = True
        self.max_show_time = max_showtime
        self.show_runtime = 0

        # map of names -> show ctors
        self.shows = dict(shows.load_shows())
        self.randseq = shows.random_shows()

        # current show object & frame generator
        self.show = None
        self.framegen = None

        # current show parameters

        # video is off at the start
        self.video = False

        # show speed multiplier - ranges from 0.1 to 10
        # 1.0 is normal speed
        # lower numbers mean faster speeds, higher is slower
        self.speed_x = 1.0

        # brightness - ranges from 5 to 100%
        # 100% is initial value
        self.brightness_x = 100
Exemplo n.º 5
0
    def __init__(self, model, simulator, max_showtime=1000, channel=0):
        super(ShowRunner, self).__init__(name="ShowRunner")
        self.model = model
        self.simulator = simulator
        self.running = True
        self.max_show_time = max_showtime
        self.show_runtime = 0
        self.time_since_reset = 0
        self.channel = channel
        self.lock = threading.Lock()  # Prevent overlapping messages

        # map of names -> show constructors
        self.shows = dict(shows.load_shows())
        self.randseq = shows.random_shows()

        # current show object & frame generator
        self.show = None
        self.framegen = None
        self.prev_show = None
        self.show_params = None
Exemplo n.º 6
0
    def __init__(self, model, simulator, max_showtime=1000, channel=0):
        super(ShowRunner, self).__init__(name="ShowRunner")
        self.model = model
        self.simulator = simulator
        self.running = True
        self.max_show_time = max_showtime
        self.show_runtime = 0
        self.time_since_reset = 0
        self.channel = channel
        self.lock = threading.Lock()  # Prevent overlapping messages

        # map of names -> show constructors
        self.shows = dict(shows.load_shows())
        self.randseq = shows.random_shows()

        # current show object & frame generator
        self.show = None
        self.framegen = None
        self.prev_show = None
        self.show_params = None
Exemplo n.º 7
0
    def go_web(self):
        """Run with the web interface"""
        logging.info("Running with web interface")

        show_names = [name for (name, cls) in shows.load_shows()]
        print(f'shows: {show_names}')

        cherrypy.engine.subscribe('stop', self.stop)

        config = {
            'global': {
                'server.socket_host': '0.0.0.0',
                'server.socket_port': 9990,
                # 'engine.timeout_monitor.on' : True,
                # 'engine.timeout_monitor.frequency' : 240,
                # 'response.timeout' : 60*15
            }
        }

        # this method blocks until KeyboardInterrupt
        cherrypy.quickstart(TriangleWeb(self.queue, self.runner, show_names),
                            '/',
                            config=config)
Exemplo n.º 8
0
                        help='turn off the DMX controller')
    parser.add_argument('--onechannel',
                        action='store_true',
                        default=False,
                        help='remove dual shows')
    parser.add_argument('shows',
                        metavar='show_name',
                        type=str,
                        nargs='*',
                        help='name of show (or shows) to run')

    args = parser.parse_args()

    if args.list:
        print("Available shows:")
        print(', '.join([show[0] for show in shows.load_shows(channel=None)]))
        sys.exit(0)

    if args.onechannel:
        num_channels = 1
        FADE_TIME = max([FADE_TIME, SHOW_TIME / 2.0])
    else:
        num_channels = 2

    # ToDo: Remove this
    num_channels = 1
    FADE_TIME = max([FADE_TIME, SHOW_TIME / 2.0])

    dmx_runner = get_dmx_runner(args.bind) if not args.dmxoff else None

    channel_runner = ChannelRunner(channels=set_up_channels(
Exemplo n.º 9
0
                        type=str,
                        nargs='*',
                        help='name of show (or shows) to run')
    parser.add_argument(
        '--fail-hard',
        type=bool,
        default=True,
        help=
        "For production runs, when shows fail, the show runner moves to the next show"
    )

    args = parser.parse_args()

    if args.list:
        logging.info("Available shows: %s",
                     ', '.join([name for (name, cls) in shows.load_shows()]))
        sys.exit(0)

    if args.simulator:
        sim_host = "localhost"
        sim_port = 4444
        logging.info(f'Using TriSimulator at {sim_host}:{sim_port}')

        model = SimulatorModel(sim_host,
                               port=sim_port,
                               model_json='./data/pixel_map.json')
        triangle_grid = triangle_grid.make_tri(model, 11)
    else:
        logging.info("Starting SACN")
        from model.sacn_model import sACN
        model = sACN(max_dmx=800, model_json="./data/pixel_map.json")
Exemplo n.º 10
0
        help='Maximum number of seconds a show will run (default {})'.format(
            SHOW_TIME))
    parser.add_argument('--list',
                        action='store_true',
                        help='List available shows')
    parser.add_argument('shows',
                        metavar='show_name',
                        type=str,
                        nargs='*',
                        help='name of show (or shows) to run')

    args = parser.parse_args()

    if args.list:
        print("Available shows:")
        print(', '.join([s[0] for s in shows.load_shows()]))
        sys.exit(0)

    sim_host = "localhost"
    sim_port = 4444  # base port number

    print("Using Square Simulator at {}:{}-{}".format(
        sim_host, sim_port, sim_port + NUM_CHANNELS - 1))

    from model.simulator import SimulatorModel
    # Get ready for DUAL channels
    # Each channel (app) has its own ShowRunner and SimulatorModel
    channels = []  # array of channel objects
    for i in range(NUM_CHANNELS):
        model = SimulatorModel(sim_host, i, port=sim_port + i)
        full_square = square.load_squares(model)
Exemplo n.º 11
0
if __name__ == '__main__':
    # Simulator must run in Processing to turn on lights
    import argparse

    parser = argparse.ArgumentParser(description='Roses Light Control')
    parser.add_argument('--max-time', type=float, default=float(SHOW_TIME),
                        help='Maximum number of seconds a show will run (default {})'.format(SHOW_TIME))
    parser.add_argument('--list', action='store_true', help='List available shows')
    parser.add_argument('shows', metavar='show_name', type=str, nargs='*',
                        help='name of show (or shows) to run')

    args = parser.parse_args()

    if args.list:
        print ("Available shows:")
        print (', '.join([s[0] for s in shows.load_shows()]))
        sys.exit(0)

    sim_host = "localhost"
    sim_port = 4444  # base port number

    print ("Using Rose Simulator at {}:{}-{}".format(sim_host, sim_port, sim_port + NUM_CHANNELS - 1))

    from model.simulator import SimulatorModel
    # Get ready for DUAL channels
    # Each channel (app) has its own ShowRunner and SimulatorModel
    channels = []  # array of channel objects
    for i in range(NUM_CHANNELS):
        model = SimulatorModel(sim_host, i, port=sim_port+i)
        full_rose = rose.load_roses(model)
        channels.append(RoseServer(full_rose, model, args))
Exemplo n.º 12
0
 def __init__(self, app):
     self.app = app
     self.runner = self.app.runner
     self.show_names = [s[0] for s in shows.load_shows()]
     self.redirect_home_html = "<script>setTimeout(function(){window.location='/'},3000)</script>"
     pass
Exemplo n.º 13
0
 def __init__(self, app):
     self.app = app
     self.runner = self.app.runner
     self.show_names = [s[0] for s in shows.load_shows()]
     self.redirect_home_html = "<script>setTimeout(function(){window.location='/'},3000)</script>"
     pass
Exemplo n.º 14
0
def test_load_shows():
    names = {name for (name, cls) in shows.load_shows()}
    assert {
        "LeftToRight", "LeftToRightAndBack", "OneByOne", "Random", "UpDown"
    }.issubset(names)
Exemplo n.º 15
0
    parser.add_argument('--onechannel',
                        action='store_true',
                        default=False,
                        help='remove dual shows')
    parser.add_argument('shows',
                        metavar='show_name',
                        type=str,
                        nargs='*',
                        help='name of show (or shows) to run')

    args = parser.parse_args()

    if args.list:
        print("Available shows:")
        print(', '.join(
            [show[0] for show in shows.load_shows(channel=None, path=None)]))
        sys.exit(0)

    if args.onechannel:
        num_channels = 1
        FADE_TIME = max([FADE_TIME, SHOW_TIME / 2.0])
    else:
        num_channels = 2

    dmx_runner = get_dmx_runner(args.bind) if not args.dmxoff else None

    channel_runner = ChannelRunner(channels=set_up_channels(
        num_channels, args.max_time),
                                   dmx_runner=dmx_runner,
                                   has_simulator=args.simulator,
                                   max_show_time=args.max_time)
Exemplo n.º 16
0
Arquivo: run.py Projeto: zrlram/leds
    def __init__(self, geometry, queue, cm, wc, max_showtime=60):
        super(ShowRunner, self).__init__(name="ShowRunner")

        self.profile = None
        self.do_profiling = False

        self.geometry = geometry
        self.queue = queue
        self.cm = cm
        self.wc = wc

        self.cm.add_listener(self)
        self.cm.show_runner = self 

        self.running = True
        self.max_show_time = max_showtime

        self.all_shows = dict(shows.load_shows())
        self.shows = {}
        self.overlay_shows = []
        self.random_eligible_shows = []
        self.show_states = {}

        for name in self.all_shows:
            _class = self.all_shows[name]

            # Overlays are ONLY overlays            
            if hasattr(_class, "show_type"):
                if _class.show_type == "overlay":
                    self.overlay_shows.append(name)
                    continue

            self.shows[name] = self.all_shows[name]

            ok_for_random = True
            if hasattr(_class, "ok_for_random"):
                ok_for_random = _class.ok_for_random

            if ok_for_random:
                self.random_eligible_shows.append(name)

        print "Shows: %s" % ', '.join([s for s in self.shows])
        print "Overlay shows: %s" % str(self.overlay_shows)
        print "Random eligible shows: %s" % str(self.random_eligible_shows)

        self.randseq = self.random_show_name()
        
        self.show = None                        # current show object 
        self.framegen = None                    # next frame... (next_frame)

        # And then ALSO an overlay show - OMG, so many shows!
        # This uses .model, the unmuted version
        self.overlay_show = None
        self.overlay_framegen = None

        # show speed multiplier - ranges from 0.5 to 2.0
        # 1.0 is normal speed
        # lower numbers mean faster speeds, higher is slower
        self.speed_x = 1.0

        self.cm.set_max_time(self.max_show_time)
        self.geometry.set_brightness(self.cm.brightness)