Skip to content

Commit

Permalink
Add 1.5.1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcprince committed Jul 12, 2021
1 parent 39ce602 commit d9ae6fa
Show file tree
Hide file tree
Showing 8 changed files with 296 additions and 133 deletions.
38 changes: 35 additions & 3 deletions constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,45 @@ exports.packetLengthVersions = [{
packetLength: 62
}];

const FIRMWARE_OFFICIAL_RELEASE = 0;
const FIRMWARE_OFFICIAL_RELEASE_CANDIDATE = 1;
const FIRMWARE_CUSTOM_EQUIVALENT = 2;
const FIRMWARE_UNSUPPORTED = 3;
exports.FIRMWARE_OFFICIAL_RELEASE = FIRMWARE_OFFICIAL_RELEASE;
exports.FIRMWARE_OFFICIAL_RELEASE_CANDIDATE = FIRMWARE_OFFICIAL_RELEASE_CANDIDATE;
exports.FIRMWARE_CUSTOM_EQUIVALENT = FIRMWARE_CUSTOM_EQUIVALENT;
exports.FIRMWARE_UNSUPPORTED = FIRMWARE_UNSUPPORTED;

const EQUIVALENCE_REGEX = /E[0-9]+\.[0-9]+\.[0-9]+/g;
exports.EQUIVALENCE_REGEX = EQUIVALENCE_REGEX;

/* Remove trailing digit and check if description is in list of supported firmware descriptions */

exports.isSupportedFirmwareDescription = (desc) => {
exports.getFirmwareClassification = (desc) => {

/* If official firmware or a release candidate of the official firmware */

if (desc === 'AudioMoth-Firmware-Basic') {

return FIRMWARE_OFFICIAL_RELEASE;

}

if (desc.replace(/-RC\d+$/, '-RC') === 'AudioMoth-Firmware-Basic-RC') {

return FIRMWARE_OFFICIAL_RELEASE_CANDIDATE;

}

const foundEquivalence = desc.match(EQUIVALENCE_REGEX);

if (foundEquivalence) {

return FIRMWARE_CUSTOM_EQUIVALENT;

const supportedFirmwareDescs = ['AudioMoth-Firmware-Basic', 'AudioMoth-Firmware-Basic-RC'];
}

return supportedFirmwareDescs.includes(desc.replace(/\d+$/, ''));
return FIRMWARE_UNSUPPORTED;

};

Expand Down
4 changes: 2 additions & 2 deletions expansion/expansion.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="tab-content" style="margin-top: 4px;">

<!-- Duration-based -->
<div role="tabpanel" class="tab-pane fade in active show" id="duration-tab" role="tabpanel">
<div role="tabpanel" class="tab-pane active show" id="duration-tab" role="tabpanel">

<div class="row" style="margin-top: 5px;">
<div style="border: #cdcdcd thin solid; margin-left: 15px; width: 543px;">
Expand Down Expand Up @@ -106,7 +106,7 @@
</div>

<!-- Event-based -->
<div role="tabpanel" class="tab-pane fade in" id="event-tab" role="tabpanel">
<div role="tabpanel" class="tab-pane" id="event-tab" role="tabpanel">

<div class="row" style="margin-top: 5px;">
<div style="border: #cdcdcd thin solid; margin-left: 15px; width: 543px;">
Expand Down
58 changes: 29 additions & 29 deletions expansion/uiExpansion.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ function updateFileMaxLengthUI (elementClass, checkbox) {

function expandFiles () {

let successCount, errorCount, cancelled, response, filePath, fileContent, maxLength, outputPath, prefix, errorFileLocation;

if (!files) {

return;
Expand All @@ -172,16 +170,20 @@ function expandFiles () {

const maxLengthRadioName = expansionType === 'DURATION' ? 'duration-max-length-radio' : 'event-max-length-radio';

successCount = 0;
errorCount = 0;
let successCount = 0;
let errorCount = 0;
const errors = [];
const errorFiles = [];

var errorFilePath;

let maxLength = null;

for (let i = 0; i < files.length; i++) {

/* If progress bar is closed, the expansion task is considered cancelled. This will contact the main thread and ask if that has happened */

cancelled = electron.ipcRenderer.sendSync('poll-expansion-cancelled');
const cancelled = electron.ipcRenderer.sendSync('poll-expansion-cancelled');

if (cancelled) {

Expand Down Expand Up @@ -225,10 +227,10 @@ function expandFiles () {

/* Check if the optional prefix/output directory setttings are being used. If left as null, expander will put expanded file(s) in the same directory as the input with no prefix */

outputPath = outputCheckbox.checked ? outputDir : null;
prefix = (prefixCheckbox.checked && prefixInput.value !== '') ? prefixInput.value : null;
const outputPath = outputCheckbox.checked ? outputDir : null;
const prefix = (prefixCheckbox.checked && prefixInput.value !== '') ? prefixInput.value : null;

response = audiomothUtils.expand(files[i], outputPath, prefix, expansionType, maxLength, generateSilentFiles, alignToSecondTransitions, (progress) => {
const response = audiomothUtils.expand(files[i], outputPath, prefix, expansionType, maxLength, generateSilentFiles, alignToSecondTransitions, (progress) => {

electron.ipcRenderer.send('set-expansion-bar-progress', i, progress, path.basename(files[i]));

Expand All @@ -240,50 +242,48 @@ function expandFiles () {

} else {

/* Keep track of the errors to write to the log at the end */
/* Add error to log file */

errorCount++;
errors.push(response.error);
errorFiles.push(files[i]);

electron.ipcRenderer.send('set-expansion-bar-error', path.basename(files[i]));

ui.sleep(3000);
if (errorCount === 1) {

}
const errorFileLocation = outputCheckbox.checked ? outputDir : path.dirname(errorFiles[0]);

}
errorFilePath = path.join(errorFileLocation, 'ERRORS.TXT');

/* Build error file */
}

if (errorCount > 0) {
let fileContent = '';

errorFileLocation = outputCheckbox.checked ? outputDir : path.dirname(errorFiles[0]);
for (let j = 0; j < errorCount; j++) {

filePath = path.join(errorFileLocation, 'ERRORS.TXT');
fileContent += path.basename(errorFiles[j]) + ' - ' + errors[j] + '\n';

fileContent = '';
}

for (let j = 0; j < errorCount; j++) {
try {

fileContent += path.basename(errorFiles[j]) + ' - ' + errors[j] + '\n';
fs.writeFileSync(errorFilePath, fileContent);

}
console.log('Error summary written to ' + errorFilePath);

try {
} catch (err) {

fs.writeFileSync(filePath, fileContent);
console.error(err);
electron.ipcRenderer.send('set-expansion-bar-completed', successCount, errorCount, true);
return;

} catch (err) {
}

console.error(err);
electron.ipcRenderer.send('set-expansion-bar-completed', successCount, errorCount, true);
return;
ui.sleep(3000);

}

console.log('Error summary written to ' + filePath);

}

/* Notify main thread that expansion is complete so progress bar is closed */
Expand All @@ -300,7 +300,7 @@ electron.ipcRenderer.on('expansion-summary-closed', enableUI);

function updateInputDirectoryDisplay (directoryArray) {

if (directoryArray.length === 0 || !directoryArray) {
if (!directoryArray || directoryArray.length === 0) {

fileLabel.innerHTML = 'No AudioMoth T.WAV files selected.';
expandButton.disabled = true;
Expand Down
56 changes: 27 additions & 29 deletions expansion/uiSplit.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,24 +100,24 @@ function enableUI () {

function splitFiles () {

let successCount, errorCount, cancelled, response, filePath, fileContent, maxLength, outputPath, prefix, errorFileLocation;

if (!files) {

return;

}

successCount = 0;
errorCount = 0;
let successCount = 0;
let errorCount = 0;
const errors = [];
const errorFiles = [];

let errorFilePath;

for (let i = 0; i < files.length; i++) {

/* If progress bar is closed, the split task is considered cancelled. This will contact the main thread and ask if that has happened */

cancelled = electron.ipcRenderer.sendSync('poll-split-cancelled');
const cancelled = electron.ipcRenderer.sendSync('poll-split-cancelled');

if (cancelled) {

Expand All @@ -131,7 +131,7 @@ function splitFiles () {

electron.ipcRenderer.send('set-split-bar-progress', i, 0, path.basename(files[i]));

maxLength = MAX_LENGTHS[ui.getSelectedRadioValue('max-length-radio')];
const maxLength = MAX_LENGTHS[ui.getSelectedRadioValue('max-length-radio')];

console.log('Splitting:', files[i]);
console.log('Maximum file length:', maxLength);
Expand All @@ -140,10 +140,10 @@ function splitFiles () {

/* Check if the optional prefix/output directory setttings are being used. If left as null, splitter will put file(s) in the same directory as the input with no prefix */

outputPath = outputCheckbox.checked ? outputDir : null;
prefix = (prefixCheckbox.checked && prefixInput.value !== '') ? prefixInput.value : null;
const outputPath = outputCheckbox.checked ? outputDir : null;
const prefix = (prefixCheckbox.checked && prefixInput.value !== '') ? prefixInput.value : null;

response = audiomothUtils.split(files[i], outputPath, prefix, maxLength, (progress) => {
const response = audiomothUtils.split(files[i], outputPath, prefix, maxLength, (progress) => {

electron.ipcRenderer.send('set-split-bar-progress', i, progress, path.basename(files[i]));

Expand All @@ -155,50 +155,48 @@ function splitFiles () {

} else {

/* Keep track of the errors to write to the log at the end */
/* Add error to log file */

errorCount++;
errors.push(response.error);
errorFiles.push(files[i]);

electron.ipcRenderer.send('set-split-bar-error', path.basename(files[i]));

ui.sleep(3000);
if (errorCount === 1) {

}
const errorFileLocation = outputCheckbox.checked ? outputDir : path.dirname(errorFiles[0]);

}
errorFilePath = path.join(errorFileLocation, 'ERRORS.TXT');

/* Build error file */
}

if (errorCount > 0) {
let fileContent = '';

errorFileLocation = outputCheckbox.checked ? outputDir : path.dirname(errorFiles[0]);
for (let j = 0; j < errorCount; j++) {

filePath = path.join(errorFileLocation, 'ERRORS.TXT');
fileContent += path.basename(errorFiles[j]) + ' - ' + errors[j] + '\n';

fileContent = '';
}

for (let j = 0; j < errorCount; j++) {
try {

fileContent += path.basename(errorFiles[j]) + ' - ' + errors[j] + '\n';
fs.writeFileSync(errorFilePath, fileContent);

}
console.log('Error summary written to ' + errorFilePath);

try {
} catch (err) {

fs.writeFileSync(filePath, fileContent);
console.error(err);
electron.ipcRenderer.send('set-split-bar-completed', successCount, errorCount, true);
return;

} catch (err) {
}

console.error(err);
electron.ipcRenderer.send('set-split-bar-completed', successCount, errorCount, true);
return;
ui.sleep(3000);

}

console.log('Error summary written to ' + filePath);

}

/* Notify main thread that split is complete so progress bar is closed */
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "AudioMoth-Config",
"version": "1.5.0",
"version": "1.5.1",
"description": "The configuration app for the AudioMoth acoustic monitoring device.",
"main": "main.js",
"author": "openacousticdevices.info",
Expand Down Expand Up @@ -45,6 +45,8 @@
},
"nsis": {
"createDesktopShortcut": true,
"oneClick": false,
"allowToChangeInstallationDirectory": true,
"artifactName": "AudioMothConfigurationAppSetup${version}.exe",
"shortcutName": "AudioMoth Configuration App",
"uninstallDisplayName": "AudioMoth Configuration App ${version}"
Expand All @@ -56,17 +58,17 @@
},
"devDependencies": {
"electron": "8.5.2",
"electron-builder": "^22.9.1",
"eslint": "^6.8.0",
"electron-builder": "^22.11.7",
"eslint": "^7.27.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^4.0.2"
},
"dependencies": {
"audiomoth-hid": "^2.1.0",
"audiomoth-utils": "^1.0.0",
"audiomoth-utils": "^1.0.3",
"bootstrap": "4.3.1",
"bootstrap-slider": "^10.6.2",
"electron-debug": "3.0.1",
Expand Down
Loading

0 comments on commit d9ae6fa

Please sign in to comment.