Things started working.
This commit is contained in:
parent
b8f6969b53
commit
44f82cec94
|
|
@ -224,9 +224,9 @@ class RdsDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
||||||
|
|
||||||
|
|
||||||
class CwSkimmerDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
class CwSkimmerDemodulator(ServiceDemodulator, DialFrequencyReceiver):
|
||||||
def __init__(self, sampleRate: int = 12000, charCount: int = 8):
|
def __init__(self, sampleRate: int = 12000, charTotal: int = 64, charCount: int = 1):
|
||||||
self.sampleRate = sampleRate
|
self.sampleRate = sampleRate
|
||||||
self.parser = CwSkimmerParser()
|
self.parser = CwSkimmerParser(charTotal)
|
||||||
workers = [
|
workers = [
|
||||||
Convert(Format.FLOAT, Format.SHORT),
|
Convert(Format.FLOAT, Format.SHORT),
|
||||||
CwSkimmerModule(sampleRate, charCount),
|
CwSkimmerModule(sampleRate, charCount),
|
||||||
|
|
|
||||||
|
|
@ -893,7 +893,7 @@ CwSkimmerMessagePanel.prototype.supportsMessage = function(message) {
|
||||||
|
|
||||||
CwSkimmerMessagePanel.prototype.render = function() {
|
CwSkimmerMessagePanel.prototype.render = function() {
|
||||||
$(this.el).append($(
|
$(this.el).append($(
|
||||||
'<table>' +
|
'<table width="100%">' +
|
||||||
'<thead><tr>' +
|
'<thead><tr>' +
|
||||||
'<th class="frequency">Freq</th>' +
|
'<th class="frequency">Freq</th>' +
|
||||||
'<th class="data">Message</th>' +
|
'<th class="data">Message</th>' +
|
||||||
|
|
@ -904,27 +904,33 @@ CwSkimmerMessagePanel.prototype.render = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
CwSkimmerMessagePanel.prototype.pushMessage = function(msg) {
|
CwSkimmerMessagePanel.prototype.pushMessage = function(msg) {
|
||||||
|
// Must have some text
|
||||||
|
if (!msg.text) return;
|
||||||
|
|
||||||
// Find existing frequency
|
// Find existing frequency
|
||||||
var j = this.freqs.indexOf(msg.freq);
|
var j = this.freqs.indexOf(msg.freq);
|
||||||
|
|
||||||
if (j >= 0) {
|
if (j >= 0) {
|
||||||
// Update existing entry
|
// Update existing entry
|
||||||
this.texts[j] = msg.text;
|
this.texts[j] = (this.texts[j] + msg.text).slice(-64);
|
||||||
} else {
|
} else {
|
||||||
// Add a new entry
|
// Add a new entry
|
||||||
this.freqs.push(msg.freq);
|
this.freqs.push(msg.freq);
|
||||||
this.texts.push(msg.text);
|
this.texts.push(msg.text);
|
||||||
// Limit the number of active frequencies
|
// Limit the number of active frequencies
|
||||||
if (this.freqs.length > 10) {
|
// if (this.freqs.length > 16) {
|
||||||
this.freqs.pop();
|
// this.freqs.shift();
|
||||||
this.texts.pop();
|
// this.texts.shift();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate table body
|
// Generate table body
|
||||||
var body = '';
|
var body = '';
|
||||||
for (j = 0 ; j < this.freqs.length ; j++) {
|
for (j = 0 ; j < this.freqs.length ; j++) {
|
||||||
body += '<tr><td>' + this.freqs[j] + '</td><td>' + this.texts[j] + '</td></tr>\n';
|
body +=
|
||||||
|
'<tr style="color:black;background-color:' + (j&1? '#E0FFE0':'#FFFFFF') +
|
||||||
|
';"><td style="text-align:right;">' + Math.round(this.freqs[j]/10)/100 +
|
||||||
|
'</td><td style="font-family:monospace;white-space:nowrap;">' +
|
||||||
|
this.texts[j] + '</td></tr>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign new table body
|
// Assign new table body
|
||||||
|
|
|
||||||
|
|
@ -417,10 +417,9 @@ class EasParser(TextParser):
|
||||||
|
|
||||||
|
|
||||||
class CwSkimmerParser(TextParser):
|
class CwSkimmerParser(TextParser):
|
||||||
def __init__(self, charTotal: int = 32, service: bool = False):
|
def __init__(self, charTotal: int = 64, service: bool = False):
|
||||||
self.reLine = re.compile("^(\d+):\s*(.*)$")
|
self.reLine = re.compile("^(\d+):(.+)$")
|
||||||
self.charTotal = charTotal
|
self.charTotal = charTotal
|
||||||
self.cwCache = {}
|
|
||||||
# Construct parent object
|
# Construct parent object
|
||||||
super().__init__(filePrefix="CW", service=service)
|
super().__init__(filePrefix="CW", service=service)
|
||||||
|
|
||||||
|
|
@ -434,12 +433,6 @@ class CwSkimmerParser(TextParser):
|
||||||
if r is not None:
|
if r is not None:
|
||||||
freq = int(r.group(1))
|
freq = int(r.group(1))
|
||||||
text = r.group(2)
|
text = r.group(2)
|
||||||
# Add up newly decoded characters
|
|
||||||
if freq in self.cwCache:
|
|
||||||
text = self.cwCache[freq] + text
|
|
||||||
# Truncate received text to charTotal
|
|
||||||
text = text if len(text) <= self.charTotal else text[:self.charTotal]
|
|
||||||
self.cwCache[freq] = text
|
|
||||||
# Compose output
|
# Compose output
|
||||||
out = { "mode": "CW", "text": text }
|
out = { "mode": "CW", "text": text }
|
||||||
# Add frequency, if known
|
# Add frequency, if known
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue