add whirley and start cleaning output state

This commit is contained in:
2023-11-25 12:28:08 -06:00
parent 8e15949be7
commit c28c570258
3 changed files with 42 additions and 4 deletions
+8
View File
@@ -3763,6 +3763,11 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/lodash.merge": { "node_modules/lodash.merge": {
"version": "4.6.2", "version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -6176,6 +6181,9 @@
"name": "aas-lib", "name": "aas-lib",
"version": "0.1.0", "version": "0.1.0",
"license": "ISC", "license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
},
"devDependencies": {} "devDependencies": {}
}, },
"packages/webui": { "packages/webui": {
+30 -2
View File
@@ -1,10 +1,11 @@
/* eslint-disable no-bitwise */ /* eslint-disable no-bitwise */
const _ = require('lodash');
class Console { class Console {
constructor() { constructor() {
this.sportInitialized = false; this.sportInitialized = false;
this.state = { this.state = {
time: {}, time: {},
auxTime: {},
home: {}, home: {},
guest: {}, guest: {},
}; };
@@ -70,7 +71,8 @@ class Console {
break; break;
case 0x59: case 0x59:
this.sport = 'whirley'; this.sport = 'whirley';
throw new Error('Whirley is not implemented'); this.parseWhirley();
break;
case 0x67: case 0x67:
this.sport = 'segment'; this.sport = 'segment';
throw new Error('Segment is not implemented'); throw new Error('Segment is not implemented');
@@ -94,7 +96,13 @@ class Console {
} }
this.state.auxTime = this.latestPacket.buffer.subarray(8, 9).toString('hex'); this.state.auxTime = this.latestPacket.buffer.subarray(8, 9).toString('hex');
if (this.state.auxTime === 'aa') {
this.state.auxTime = '';
}
this.state.aux2Time = this.latestPacket.buffer.subarray(9, 10).toString('hex'); this.state.aux2Time = this.latestPacket.buffer.subarray(9, 10).toString('hex');
if (this.state.aux2Time === 'aa') {
this.state.aux2Time = '';
}
const hornBinaryFlags = this.latestPacket.buffer.at(4).toString(2).padStart(8, '0'); const hornBinaryFlags = this.latestPacket.buffer.at(4).toString(2).padStart(8, '0');
this.state.horn = hornBinaryFlags[0] === '1'; this.state.horn = hornBinaryFlags[0] === '1';
@@ -440,6 +448,26 @@ class Console {
} }
} }
parseWhirley() {
if (!this.sportInitialized) {
this.sportInitialized = true;
}
const propertiesToDelete = [
'home.timeouts',
'guest.timeouts',
'home.bonus',
'guest.bonus',
'home.doubleBonus',
'guest.doubleBonus',
'auxTime',
'aux2Time',
];
this.state.key = this.state.aux2Time;
this.state = _.omit(this.state, propertiesToDelete);
}
/** /**
* *
* @param {number} packedNumber * @param {number} packedNumber
+4 -2
View File
@@ -3,10 +3,12 @@
"version": "0.1.0", "version": "0.1.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"devDependencies": {},
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "", "author": "",
"license": "ISC" "license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
}
} }