Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/ShowPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class ShowPlayer {
return m_frame_count;
}


private:
ola::client::OlaClientWrapper m_client;
ShowLoader m_loader;
Expand Down
12 changes: 11 additions & 1 deletion examples/ShowRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ using std::vector;


ShowRecorder::ShowRecorder(const string &filename,
const vector<unsigned int> &universes)
const vector<unsigned int> &universes,
const unsigned int duration)
: m_saver(filename),
m_universes(universes),
m_duration(duration),
m_frame_count(0) {
}

Expand All @@ -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));

Expand Down Expand Up @@ -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();
}

Expand Down
4 changes: 3 additions & 1 deletion examples/ShowRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
class ShowRecorder {
public:
ShowRecorder(const std::string &filename,
const std::vector<unsigned int> &universes);
const std::vector<unsigned int> &universes,
const unsigned int duration);
~ShowRecorder();

int Init();
Expand All @@ -50,6 +51,7 @@ class ShowRecorder {
ola::client::OlaClientWrapper m_client;
ShowSaver m_saver;
std::vector<unsigned int> m_universes;
unsigned int m_duration;
ola::Clock m_clock;
uint64_t m_frame_count;

Expand Down
109 changes: 88 additions & 21 deletions examples/ola-client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,14 +144,18 @@ void ListPorts(const vector<PortClass> &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 <OlaUniverse> &universes) {
vector<OlaUniverse>::const_iterator iter;

string divider = string(58 + (extended ? 41 : 0), '-');

if (!result.Success()) {
cerr << result.Error() << endl;
ss->Terminate();
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -357,33 +387,41 @@ 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}
};

int c;
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;

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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -656,7 +695,8 @@ void DisplayUniverseMergeHelp(const options &opts) {
* Help message for set dmx
*/
void DisplaySetDmxHelp(const options &opts) {
cout << "Usage: " << opts.cmd << " --universe <universe> --dmx <values>\n"
cout << "Usage: " << opts.cmd << " --universe <universe> [ --dmx <values> ] "
"[ --blackout ]\n"
"\n"
"Sets the DMX values for a universe.\n"
"\n"
Expand All @@ -665,6 +705,7 @@ void DisplaySetDmxHelp(const options &opts) {
" -d, --dmx <values> 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;
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
15 changes: 10 additions & 5 deletions examples/ola-recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. "
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions man/ola_recorder.1
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Print
.B ola_recorder
version information
.IP "--duration <uint32_t>"
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 <uint_32_t>"
Time (milliseconds) in show file to start playback from.
.IP "--stop <uint32_t>"
Expand Down
6 changes: 5 additions & 1 deletion man/ola_set_dmx.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ola_set_dmx \- Sets the DMX values for a universe.
.SH SYNOPSIS
.B ola_set_dmx
\fI--universe <universe> --dmx <values>\fR
\fI--universe <universe> [ --dmx <values> ] [ --blackout ]\fR
.SH DESCRIPTION
Sets the DMX values for a universe.
.TP
Expand All @@ -15,3 +15,7 @@ Display this help message and exit.
.TP
\fB\-d\fR, \fB\-\-dmx\fR <values>
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
2 changes: 2 additions & 0 deletions man/ola_uni_info.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down