Commit d18cdf56 authored by martin hou's avatar martin hou

fix: 增加对录音文件列表的状态跟踪

parent ea316278
...@@ -102,6 +102,7 @@ function Jensen(log, conn) { ...@@ -102,6 +102,7 @@ function Jensen(log, conn) {
let pid = 0; let pid = 0;
let recvable = false; let recvable = false;
let lastCommand = null; let lastCommand = null;
let fileListing = false;
let self = this; let self = this;
this.data = {}; this.data = {};
...@@ -195,6 +196,14 @@ function Jensen(log, conn) { ...@@ -195,6 +196,14 @@ function Jensen(log, conn) {
return true; return true;
} }
this.setFileListing = function (value) {
fileListing = value;
}
this.isFileListing = function () {
return fileListing;
}
this.sequence = function() { this.sequence = function() {
return this.sqidx ++; return this.sqidx ++;
} }
...@@ -842,16 +851,17 @@ Jensen.prototype.sendKeyCode = async function (mode, keyCode, seconds) ...@@ -842,16 +851,17 @@ Jensen.prototype.sendKeyCode = async function (mode, keyCode, seconds)
}; };
Jensen.prototype.listFiles = async function () { Jensen.prototype.listFiles = async function () {
this.setFileListing(true);
let tag = 'filelist-' + this.serialNumber; let tag = 'filelist-' + this.serialNumber;
if (this[tag] != null) return null; if (this[tag] != null) return this.setFileListing(false), null;
let fc = null; let fc = null;
if (typeof this.versionNumber == 'undefined' || this.versionNumber <= 327722) { if (typeof this.versionNumber == 'undefined' || this.versionNumber <= 327722) {
fc = await this.getFileCount(5); fc = await this.getFileCount(5);
if (fc == null) return null; if (fc == null) return this.setFileListing(false), null;
} }
if (fc && fc.count == 0) return null; if (fc && fc.count == 0) return this.setFileListing(false), null;
let self = this; let self = this;
// let tag = 'data_' + new Date().getTime(); // let tag = 'data_' + new Date().getTime();
...@@ -996,6 +1006,10 @@ Jensen.prototype.listFiles = async function () { ...@@ -996,6 +1006,10 @@ Jensen.prototype.listFiles = async function () {
} }
}); });
setTimeout(() => {
self.setFileListing(false);
}, 0);
return this.send(new Command(QUERY_FILE_LIST)); return this.send(new Command(QUERY_FILE_LIST));
}; };
...@@ -1362,6 +1376,8 @@ Jensen.prototype.getRealtimeSettings = async function () { ...@@ -1362,6 +1376,8 @@ Jensen.prototype.getRealtimeSettings = async function () {
return this.send(new Command(REALTIME_READ_SETTING)); return this.send(new Command(REALTIME_READ_SETTING));
}; };
Jensen.prototype.startRealtime = async function (channels, seconds) { Jensen.prototype.startRealtime = async function (channels, seconds) {
if (this.isFileListing()) return null;
if (this.busy()) return null;
return this.send(new Command(REALTIME_CONTROL).body([0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, channels & 0x03]), seconds); return this.send(new Command(REALTIME_CONTROL).body([0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, channels & 0x03]), seconds);
}; };
Jensen.prototype.pauseRealtime = async function (seconds) { Jensen.prototype.pauseRealtime = async function (seconds) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment