signalk-race-control 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/index.js +17 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,10 +49,10 @@ and a live projected finishing order — during and after the race.
|
|
|
49
49
|
that name is added to any race. A boat that *is* VET-matched never has its TCF
|
|
50
50
|
carried over this way — it always starts from the default until you pick a VET
|
|
51
51
|
alternative or edit it again.
|
|
52
|
-
- **MMSI, remembered across races** — set once per boat (
|
|
53
|
-
from a live AIS/self vessel with a matching name),
|
|
54
|
-
cross-race registry: add a boat with the same name
|
|
55
|
-
|
|
52
|
+
- **MMSI and sail number, remembered across races** — set once per boat (MMSI can
|
|
53
|
+
also be picked up automatically from a live AIS/self vessel with a matching name),
|
|
54
|
+
both are remembered in a small cross-race registry: add a boat with the same name
|
|
55
|
+
in a later race and its MMSI and sail number fill in on their own.
|
|
56
56
|
- **Import a whole fleet from Manage2Sail** — off by default (`raceImportEnabled` in
|
|
57
57
|
the plugin's settings, alongside `vetEnabled`); once turned on, an **Import boats
|
|
58
58
|
from Manage2Sail** section lets you paste a Manage2Sail event URL, pick one or more
|
package/index.js
CHANGED
|
@@ -1335,9 +1335,10 @@ module.exports = function (app) {
|
|
|
1335
1335
|
|
|
1336
1336
|
// Races are kept by id so several can be planned ahead and reviewed after
|
|
1337
1337
|
// the fact, rather than a single race getting overwritten by Reset.
|
|
1338
|
-
// boatRegistry is a separate, cross-race name->MMSI/TCF
|
|
1339
|
-
// boat's MMSI or (for boats outside VET) TCF
|
|
1340
|
-
// applied automatically next time that name is
|
|
1338
|
+
// boatRegistry is a separate, cross-race name->MMSI/sail number/TCF
|
|
1339
|
+
// memory: once a boat's MMSI, sail number, or (for boats outside VET) TCF
|
|
1340
|
+
// is entered anywhere, it's applied automatically next time that name is
|
|
1341
|
+
// used in any race.
|
|
1341
1342
|
let state = { races: {}, order: [], currentRaceId: null, boatRegistry: {} };
|
|
1342
1343
|
let dataFile = null;
|
|
1343
1344
|
const scheduleTimers = new Map(); // raceId -> Timeout, for scheduledStart
|
|
@@ -1360,14 +1361,16 @@ module.exports = function (app) {
|
|
|
1360
1361
|
}
|
|
1361
1362
|
|
|
1362
1363
|
// Cross-race memory keyed by boat name, merging in whichever fields are
|
|
1363
|
-
// given (mmsi and/or tcf) without clobbering the
|
|
1364
|
-
// written here for boats outside the VET register — see the
|
|
1364
|
+
// given (mmsi, sailNumber, and/or tcf) without clobbering the others. tcf
|
|
1365
|
+
// is only ever written here for boats outside the VET register — see the
|
|
1366
|
+
// callers.
|
|
1365
1367
|
function upsertBoatRegistry(name, fields) {
|
|
1366
1368
|
if (!name) return;
|
|
1367
1369
|
const key = name.trim().toLowerCase();
|
|
1368
1370
|
const existing = state.boatRegistry[key] || { name: name.trim() };
|
|
1369
1371
|
existing.name = name.trim();
|
|
1370
1372
|
if (fields.mmsi) existing.mmsi = String(fields.mmsi).trim();
|
|
1373
|
+
if (fields.sailNumber) existing.sailNumber = String(fields.sailNumber).trim();
|
|
1371
1374
|
if (fields.tcf != null) existing.tcf = fields.tcf;
|
|
1372
1375
|
state.boatRegistry[key] = existing;
|
|
1373
1376
|
}
|
|
@@ -1376,11 +1379,6 @@ module.exports = function (app) {
|
|
|
1376
1379
|
return state.boatRegistry[(name || '').trim().toLowerCase()] || null;
|
|
1377
1380
|
}
|
|
1378
1381
|
|
|
1379
|
-
function lookupBoatRegistry(name) {
|
|
1380
|
-
const entry = getRegistryEntry(name);
|
|
1381
|
-
return entry ? entry.mmsi : null;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
1382
|
// vetEnabled is a plugin config setting (Server -> Plugin Config), not
|
|
1385
1383
|
// per-race and not editable from the webapp itself. Off by default — a
|
|
1386
1384
|
// fresh install (or one that's never touched this setting) treats every
|
|
@@ -2165,23 +2163,26 @@ module.exports = function (app) {
|
|
|
2165
2163
|
if (!name) {
|
|
2166
2164
|
return res.status(400).json({ error: 'name is required' });
|
|
2167
2165
|
}
|
|
2166
|
+
const registryEntry = getRegistryEntry(name);
|
|
2168
2167
|
const givenMmsi = ((req.body && req.body.mmsi) || '').toString().trim();
|
|
2169
|
-
const mmsi = givenMmsi ||
|
|
2168
|
+
const mmsi = givenMmsi || (registryEntry && registryEntry.mmsi) || null;
|
|
2170
2169
|
if (mmsi) upsertBoatRegistry(name, { mmsi });
|
|
2170
|
+
const givenSailNumber = ((req.body && req.body.sailNumber) || '').toString().trim();
|
|
2171
|
+
const sailNumber = givenSailNumber || (registryEntry && registryEntry.sailNumber) || null;
|
|
2172
|
+
if (sailNumber) upsertBoatRegistry(name, { sailNumber });
|
|
2171
2173
|
const defaultTcf = (plugin.options && plugin.options.defaultTcf) || 1.0;
|
|
2172
2174
|
// A remembered TCF only applies to boats outside VET — a VET-matched
|
|
2173
2175
|
// boat should be picked fresh from the register's own dropdown rather
|
|
2174
2176
|
// than silently carrying over a number from wherever it last raced.
|
|
2175
2177
|
let tcf = defaultTcf;
|
|
2176
|
-
if (!isVetMatch(name)) {
|
|
2177
|
-
|
|
2178
|
-
if (remembered && remembered.tcf != null) tcf = remembered.tcf;
|
|
2178
|
+
if (!isVetMatch(name) && registryEntry && registryEntry.tcf != null) {
|
|
2179
|
+
tcf = registryEntry.tcf;
|
|
2179
2180
|
}
|
|
2180
2181
|
const boat = {
|
|
2181
2182
|
id: makeBoatId(),
|
|
2182
2183
|
name,
|
|
2183
2184
|
mmsi: mmsi || null,
|
|
2184
|
-
sailNumber
|
|
2185
|
+
sailNumber,
|
|
2185
2186
|
tcf,
|
|
2186
2187
|
finishTime: null,
|
|
2187
2188
|
startTime: null,
|
|
@@ -2292,6 +2293,7 @@ module.exports = function (app) {
|
|
|
2292
2293
|
if (!boat) return res.status(404).json({ error: 'No such boat' });
|
|
2293
2294
|
const sailNumber = ((req.body && req.body.sailNumber) || '').toString().trim();
|
|
2294
2295
|
boat.sailNumber = sailNumber || null;
|
|
2296
|
+
if (boat.sailNumber) upsertBoatRegistry(boat.name, { sailNumber: boat.sailNumber });
|
|
2295
2297
|
saveState();
|
|
2296
2298
|
res.json(boat);
|
|
2297
2299
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "signalk-race-control",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "SignalK plugin and webapp for tracking elapsed and handicap-corrected (Time-on-Time) race time, with a per-boat editable TCF and boat names pulled from AIS when available.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|