diff --git a/examples/ShowPlayer.h b/examples/ShowPlayer.h index 0ae885dbf0..1a095382d6 100644 --- a/examples/ShowPlayer.h +++ b/examples/ShowPlayer.h @@ -76,7 +76,6 @@ class ShowPlayer { return m_frame_count; } - private: ola::client::OlaClientWrapper m_client; ShowLoader m_loader; diff --git a/examples/ShowRecorder.cpp b/examples/ShowRecorder.cpp index 3221ffc444..6dcc00d630 100644 --- a/examples/ShowRecorder.cpp +++ b/examples/ShowRecorder.cpp @@ -47,9 +47,11 @@ using std::vector; ShowRecorder::ShowRecorder(const string &filename, - const vector &universes) + const vector &universes, + const unsigned int duration) : m_saver(filename), m_universes(universes), + m_duration(duration), m_frame_count(0) { } @@ -71,6 +73,12 @@ int ShowRecorder::Init() { return ola::EXIT_CANTCREAT; } + if (m_duration != 0) { + m_client.GetSelectServer()->RegisterSingleTimeout( + m_duration * 1000, + ola::NewSingleCallback(this, &ShowRecorder::Stop)); + } + m_client.GetClient()->SetDMXCallback( ola::NewCallback(this, &ShowRecorder::NewFrame)); @@ -99,6 +107,8 @@ int ShowRecorder::Record() { * Stop recording */ void ShowRecorder::Stop() { + // TODO(Peter): This should really write the current delay out at the end if + // we're looping m_client.GetSelectServer()->Terminate(); } diff --git a/examples/ShowRecorder.h b/examples/ShowRecorder.h index 3abb021205..4bbffb9c4c 100644 --- a/examples/ShowRecorder.h +++ b/examples/ShowRecorder.h @@ -37,7 +37,8 @@ class ShowRecorder { public: ShowRecorder(const std::string &filename, - const std::vector &universes); + const std::vector &universes, + const unsigned int duration); ~ShowRecorder(); int Init(); @@ -50,6 +51,7 @@ class ShowRecorder { ola::client::OlaClientWrapper m_client; ShowSaver m_saver; std::vector m_universes; + unsigned int m_duration; ola::Clock m_clock; uint64_t m_frame_count; diff --git a/examples/ola-client.cpp b/examples/ola-client.cpp index f6eeab53c9..00789773fe 100644 --- a/examples/ola-client.cpp +++ b/examples/ola-client.cpp @@ -83,7 +83,9 @@ typedef struct { OlaUniverse::merge_mode merge_mode; // the merge mode string cmd; // argv[0] string uni_name; // universe name + bool blackout; string dmx; // DMX string + bool extended; ola::port_priority_mode priority_mode; // port priority mode uint8_t priority_value; // port priority value bool list_plugin_ids; @@ -142,14 +144,18 @@ void ListPorts(const vector &ports, bool input) { /* * This is called when we receive universe results from the client * @param list_ids_only show ids only + * @param extended show extended info about each universe * @param universes a vector of OlaUniverses */ void DisplayUniverses(SelectServer *ss, bool list_ids_only, + bool extended, const Result &result, const vector &universes) { vector::const_iterator iter; + string divider = string(58 + (extended ? 41 : 0), '-'); + if (!result.Success()) { cerr << result.Error() << endl; ss->Terminate(); @@ -161,20 +167,42 @@ void DisplayUniverses(SelectServer *ss, cout << iter->Id() << endl; } } else { - cout << setw(5) << "Id" << "\t" << setw(30) << "Name" << "\t\tMerge Mode" - << endl; - cout << "----------------------------------------------------------" - << endl; + cout << setw(5) << "Id" << "\t" << setw(30) << "Name" << "\t"; + if (extended) { + cout << setw(10); + } else { + // By default keep the double tab for backwards compatibility of anyone + // parsing the shell, not that we'd recommend that + cout << "\t"; + } + cout << "Merge Mode"; + if (extended) { + cout << "\t" << setw(11) << "Input Ports" << "\t" << setw(12) + << "Output Ports" << "\t" << setw(11) << "RDM Devices"; + } + cout << endl; + cout << divider << endl; for (iter = universes.begin(); iter != universes.end(); ++iter) { cout << setw(5) << iter->Id() << "\t" << setw(30) << iter->Name() - << "\t\t" - << (iter->MergeMode() == OlaUniverse::MERGE_HTP ? "HTP" : "LTP") - << endl; + << "\t"; + if (extended) { + cout << setw(10); + } else { + // By default keep the double tab for backwards compatibility of anyone + // parsing the shell, not that we'd recommend that + cout << "\t"; + } + cout << (iter->MergeMode() == OlaUniverse::MERGE_HTP ? "HTP" : "LTP"); + if (extended) { + cout << "\t" << setw(11) << iter->InputPortCount() << "\t" << setw(12) + << iter->OutputPortCount() << "\t" << setw(11) + << iter->RDMDeviceCount(); + } + cout << endl; } - cout << "----------------------------------------------------------" << - endl; + cout << divider << endl; } ss->Terminate(); @@ -297,6 +325,8 @@ void InitOptions(options *opts) { opts->uni = INVALID_VALUE; opts->plugin_id = ola::OLA_PLUGIN_ALL; opts->help = false; + opts->blackout = false; + opts->extended = false; opts->list_plugin_ids = false; opts->list_universe_ids = false; opts->patch_action = ola::client::PATCH; @@ -357,15 +387,17 @@ void ParseOptions(int argc, char *argv[], options *opts) { }; static struct option long_options[] = { + {"blackout", no_argument, 0, 'b'}, {"dmx", required_argument, 0, 'd'}, + {"extended", no_argument, 0, 'e'}, {"help", no_argument, 0, 'h'}, {"ltp", no_argument, 0, 'l'}, {"name", required_argument, 0, 'n'}, {"plugin-id", required_argument, 0, 'p'}, {"state", required_argument, 0, 's'}, + {"universe", required_argument, 0, 'u'}, {"list-plugin-ids", no_argument, 0, LIST_PLUGIN_IDS_OPTION}, {"list-universe-ids", no_argument, 0, LIST_UNIVERSE_IDS_OPTION}, - {"universe", required_argument, 0, 'u'}, {0, 0, 0, 0} }; @@ -373,7 +405,7 @@ void ParseOptions(int argc, char *argv[], options *opts) { int option_index = 0; while (1) { - c = getopt_long(argc, argv, "ld:n:u:p:s:hv", long_options, &option_index); + c = getopt_long(argc, argv, "ld:bn:u:p:s:hv", long_options, &option_index); if (c == -1) break; @@ -381,9 +413,15 @@ void ParseOptions(int argc, char *argv[], options *opts) { switch (c) { case 0: break; + case 'b': + opts->blackout = true; + break; case 'd': opts->dmx = optarg; break; + case 'e': + opts->extended = true; + break; case 'h': opts->help = true; break; @@ -614,6 +652,7 @@ void DisplayUniverseInfoHelp(const options &opts) { "Shows info on the active universes in use.\n" "\n" " -h, --help Display this help message and exit.\n" + " --extended Show port counts and RDM devices too.\n" " --list-universe-ids List universe Ids only.\n" << endl; } @@ -656,7 +695,8 @@ void DisplayUniverseMergeHelp(const options &opts) { * Help message for set dmx */ void DisplaySetDmxHelp(const options &opts) { - cout << "Usage: " << opts.cmd << " --universe --dmx \n" + cout << "Usage: " << opts.cmd << " --universe [ --dmx ] " + "[ --blackout ]\n" "\n" "Sets the DMX values for a universe.\n" "\n" @@ -665,6 +705,7 @@ void DisplaySetDmxHelp(const options &opts) { " -d, --dmx Comma separated DMX values, e.g. " "0,255,128 sets first channel to 0, second channel to 255" " and third channel to 128.\n" + " -b, --blackout Send a universe to blackout instead.\n" << endl; } @@ -728,8 +769,8 @@ void DisplayHelpAndExit(const options &opts) { /* * Send a fetch device info request - * @param client the ola client - * @param opts the const options + * @param client the ola client + * @param opts the const options */ int FetchDeviceInfo(OlaClientWrapper *wrapper, const options &opts) { SelectServer *ss = wrapper->GetSelectServer(); @@ -809,11 +850,32 @@ int FetchPluginState(OlaClientWrapper *wrapper, const options &opts) { } +/* + * Send a fetch universe info request + * @param client the ola client + * @param opts the const options + */ +int FetchUniverseInfo(OlaClientWrapper *wrapper, const options &opts) { + SelectServer *ss = wrapper->GetSelectServer(); + OlaClient *client = wrapper->GetClient(); + if (opts.extended && opts.list_universe_ids) { + // These are mutually exclusive + DisplayUniverseInfoHelp(opts); + exit(1); + } + + client->FetchUniverseList(NewSingleCallback(&DisplayUniverses, + ss, + opts.list_universe_ids, + opts.extended)); + return 0; +} + /* * send a set name request * @param client the ola client - * @param opts the const options + * @param opts the const options */ int SetUniverseName(OlaClientWrapper *wrapper, const options &opts) { SelectServer *ss = wrapper->GetSelectServer(); @@ -831,7 +893,7 @@ int SetUniverseName(OlaClientWrapper *wrapper, const options &opts) { /* * send a set name request * @param client the ola client - * @param opts the const options + * @param opts the const options */ int SetUniverseMergeMode(OlaClientWrapper *wrapper, const options &opts) { @@ -857,9 +919,16 @@ int SendDmx(OlaClientWrapper *wrapper, const options &opts) { SelectServer *ss = wrapper->GetSelectServer(); OlaClient *client = wrapper->GetClient(); ola::DmxBuffer buffer; - bool status = buffer.SetFromString(opts.dmx); + bool status = false; + if (opts.blackout) { + status = buffer.Blackout(); + } else { + status = buffer.SetFromString(opts.dmx); + } - if (opts.uni < 0 || !status || buffer.Size() == 0) { + // A dmx string and blackout are mutually exclusive + if (opts.uni < 0 || !status || (opts.blackout && !opts.dmx.empty()) || + buffer.Size() == 0) { DisplaySetDmxHelp(opts); exit(1); } @@ -945,9 +1014,7 @@ int main(int argc, char *argv[]) { FetchPluginState(&ola_client, opts); break; case UNIVERSE_INFO: - ola_client.GetClient()->FetchUniverseList( - NewSingleCallback(&DisplayUniverses, - ola_client.GetSelectServer(), opts.list_universe_ids)); + FetchUniverseInfo(&ola_client, opts); break; case UNIVERSE_NAME: SetUniverseName(&ola_client, opts); diff --git a/examples/ola-recorder.cpp b/examples/ola-recorder.cpp index f0d8467f5d..491e1c5173 100644 --- a/examples/ola-recorder.cpp +++ b/examples/ola-recorder.cpp @@ -55,9 +55,10 @@ DEFINE_default_bool(verify_playback, true, DEFINE_s_string(universes, u, "", "A comma separated list of universes to record"); DEFINE_s_uint32(delay, d, 0, "The delay in ms between successive iterations."); -DEFINE_uint32(duration, 0, "Total playback time (seconds); the program will " - "close after this time has elapsed. This " - "option overrides the iteration option."); +DEFINE_uint32(duration, 0, "Total playback time (seconds) to play or record " + "for; the program will close after this time has " + "elapsed. This option overrides the iteration " + "option during playback."); // 0 means infinite looping DEFINE_s_uint32(iterations, i, 1, "The number of times to repeat the show, 0 means unlimited. " @@ -97,14 +98,18 @@ int RecordShow() { universes.push_back(universe); } - ShowRecorder show_recorder(FLAGS_record.str(), universes); + ShowRecorder show_recorder(FLAGS_record.str(), universes, FLAGS_duration); int status = show_recorder.Init(); if (status) return status; { ola::thread::SignalThread signal_thread; - cout << "Recording, hit Control-C to end" << endl; + cout << "Recording, "; + if (FLAGS_duration != 0) { + cout << "will stop automatically after " << FLAGS_duration << "s, or "; + } + cout << "hit Control-C to end" << endl; signal_thread.InstallSignalHandler( SIGINT, ola::NewCallback(TerminateRecorder, &show_recorder)); signal_thread.InstallSignalHandler( diff --git a/man/ola_recorder.1 b/man/ola_recorder.1 index d8bf3756d5..5e52dfb64e 100644 --- a/man/ola_recorder.1 +++ b/man/ola_recorder.1 @@ -34,8 +34,8 @@ Print .B ola_recorder version information .IP "--duration " -Total playback time (seconds); the program will close after this time has -elapsed. This option overrides the iterations option. +Total playback time (seconds) to play or record for; the program will close +after this time has elapsed. This option overrides the iterations option. .IP "--start " Time (milliseconds) in show file to start playback from. .IP "--stop " diff --git a/man/ola_set_dmx.1 b/man/ola_set_dmx.1 index 0de61b95f7..89f95379bb 100644 --- a/man/ola_set_dmx.1 +++ b/man/ola_set_dmx.1 @@ -4,7 +4,7 @@ ola_set_dmx \- Sets the DMX values for a universe. .SH SYNOPSIS .B ola_set_dmx -\fI--universe --dmx \fR +\fI--universe [ --dmx ] [ --blackout ]\fR .SH DESCRIPTION Sets the DMX values for a universe. .TP @@ -15,3 +15,7 @@ Display this help message and exit. .TP \fB\-d\fR, \fB\-\-dmx\fR Comma separated DMX values, e.g. 0,255,128 sets first channel to 0, second channel to 255 and third channel to 128. +.HP +\fB\-b\fR, \fB\-\-blackout\fR +Send a universe to blackout instead. +.TP diff --git a/man/ola_uni_info.1 b/man/ola_uni_info.1 index 1d98df751b..49bc541f92 100644 --- a/man/ola_uni_info.1 +++ b/man/ola_uni_info.1 @@ -9,6 +9,8 @@ displays the universe name and merge mode for the active universes in olad(1). .SH OPTIONS .IP "-h, --help" Display the help message. +.IP "--extended" +Show port counts and RDM devices too. .IP "--list-universe-ids" Just list the universe ids with no additional information. .SH SEE ALSO