Skip to content

Commit c523d13

Browse files
committed
add receiver index to output and -v now applies to all receivers, -v+ only the last one
1 parent d6cfa41 commit c523d13

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

Source/Application/Main.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ int main(int argc, char *argv[])
275275
bool timeout_nomsg = false, list_devices_JSON = false, no_run = false, show_copyright = true;
276276
int own_mmsi = -1;
277277
int cb = -1;
278+
bool verbose = false;
278279

279280
Config c(_receivers, nrec, msg, json, screen, servers, own_mmsi);
280281
extern IO::OutputMessage *commm_feed;
@@ -398,9 +399,17 @@ int main(int argc, char *argv[])
398399
break;
399400
case 'v':
400401
Assert(count <= 1, param);
401-
receiver.verbose = true;
402-
if (count == 1)
403-
screen.verboseUpdateTime = Util::Parse::Integer(arg1, 1, 3600);
402+
if (param.length() == 3 && param[2] == '+') {
403+
// -v+ applies to last receiver only, no time parameter
404+
Assert(count == 0, param, "no parameters allowed with -v+");
405+
receiver.verbose = true;
406+
} else {
407+
// -v or -v* applies to all receivers (after loop)
408+
Assert(param.length() == 2 || (param.length() == 3 && param[2] == '*'), param, "invalid verbose option");
409+
verbose = true;
410+
if (count == 1)
411+
screen.verboseUpdateTime = Util::Parse::Integer(arg1, 1, 3600);
412+
}
404413
break;
405414
case 'O':
406415
Assert(count == 1, param);
@@ -752,6 +761,13 @@ int main(int argc, char *argv[])
752761
ptr += count + 1;
753762
}
754763

764+
// Apply verbose setting to all receivers
765+
if (verbose) {
766+
for (auto &r : _receivers) {
767+
r->verbose = true;
768+
}
769+
}
770+
755771
if (show_copyright)
756772
printVersion();
757773

@@ -793,7 +809,7 @@ int main(int argc, char *argv[])
793809

794810
r.setupDevice();
795811
// set up the decoding model(s), group is the last output group used
796-
r.setupModel(group);
812+
r.setupModel(group, i);
797813

798814
// set up all the output and connect to the receiver outputs
799815
for (auto &o : msg)

Source/Application/Receiver.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ std::unique_ptr<AIS::Model> &Receiver::addModel(int m)
166166
return models.back();
167167
}
168168

169-
void Receiver::setupModel(int &group)
169+
void Receiver::setupModel(int &group, int idx)
170170
{
171+
receiver_index = idx;
171172
auto* device = deviceManager.getDevice();
172173
// if nothing defined, create one model
173174
if (!models.size())
@@ -251,7 +252,7 @@ void Receiver::play()
251252
ss << "Device : " << device->getProduct() << "\n"
252253
<< "Settings : " << device->Get() << "\n";
253254
for (int i = 0; i < models.size(); i++)
254-
ss << "Model #" + std::to_string(i) << " -> (Src: " << std::to_string(Util::Helper::lsb(models[i]->Output().out.getGroupOut()) + 1)
255+
ss << "Model #" + std::to_string(receiver_index) + "-" + std::to_string(i) << " -> (Src: " << std::to_string(Util::Helper::lsb(models[i]->Output().out.getGroupOut()) + 1)
255256
<< ", Grp: " + std::to_string(models[i]->Output().out.getGroupOut()) + "): [" + models[i]->getName() + "] " + models[i]->Get() << "\n";
256257

257258
Info() << ss.str();

Source/Application/Receiver.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Receiver
5454
bool timing = false;
5555

5656
int sample_rate = 0, bandwidth = 0, ppm = 0, own_mmsi = -1;
57+
int receiver_index = -1;
5758
FLOAT32 station_lat = LAT_UNDEFINED;
5859
FLOAT32 station_lon = LON_UNDEFINED;
5960

@@ -107,13 +108,13 @@ class Receiver
107108
std::unique_ptr<AIS::Model> &Model(int i) { return models[i]; }
108109
int Count() { return models.size(); }
109110

110-
void setup(int &g)
111+
void setup(int &g, int idx)
111112
{
112113
setupDevice();
113-
setupModel(g);
114+
setupModel(g, idx);
114115
}
115116
void setupDevice();
116-
void setupModel(int &g);
117+
void setupModel(int &g, int idx);
117118

118119
void play();
119120
void stop();

0 commit comments

Comments
 (0)