Show Mode in DXCluster (preparation for passing it to the gate)

This commit is contained in:
int2001
2025-08-13 16:53:09 +00:00
parent d15a2e56a2
commit 2bca0332db
3 changed files with 61 additions and 16 deletions

View File

@@ -69,6 +69,7 @@ class Dxcluster_model extends CI_Model {
continue;
}
$singlespot->band=$spotband;
$singlespot->mode=$this->get_mode($singlespot);
if (($band != 'All') && ($band != $spotband)) { continue; }
if (($mode != 'All') && ($mode != $this->modefilter($singlespot, $mode))) { continue; }
$datetimecurrent = new DateTime("now", new DateTimeZone('UTC')); // Today's Date/Time
@@ -134,6 +135,25 @@ class Dxcluster_model extends CI_Model {
// We need to build functions that check the frequency limit
// Right now this is just a proof of concept to determine mode
function get_mode($spot) {
if ($this->Frequency2Mode($spot->frequency) != '') {
return $this->Frequency2Mode($spot->frequency);
}
// Fallbacks using message keywords
if (isset($spot->message)) {
$message = strtolower($spot->message);
if (strpos($message, 'cw') !== false) {
return 'cw';;
}
if ((strpos($message, 'ft8') !== false || strpos($message, 'rtty') !== false || strpos($message, 'sstv') !== false)) {
return 'digi';;
}
}
return '';
}
function modefilter($spot, $mode) {
$mode = strtolower($mode); // Normalize case
@@ -155,22 +175,36 @@ class Dxcluster_model extends CI_Model {
return false;
}
public function Frequency2Mode($frequency) {
// Ensure frequency is in Hz if input is in kHz
if ($frequency < 1_000_000) {
$frequency *= 1000;
}
foreach ($this->bandedges as $band) {
if ($frequency >= $band['frequencyfrom'] && $frequency < $band['frequencyto']) {
return $band['mode'];
}
}
return '';
}
public function isFrequencyInMode($frequency, $mode) {
// Ensure frequency is in Hz if input is in kHz
if ($frequency < 1_000_000) {
$frequency *= 1000;
}
// Ensure frequency is in Hz if input is in kHz
if ($frequency < 1_000_000) {
$frequency *= 1000;
}
foreach ($this->bandedges as $band) {
if (strtolower($band['mode']) === strtolower($mode)) {
if ($frequency >= $band['frequencyfrom'] && $frequency < $band['frequencyto']) {
return true;
}
}
}
foreach ($this->bandedges as $band) {
if (strtolower($band['mode']) === strtolower($mode)) {
if ($frequency >= $band['frequencyfrom'] && $frequency < $band['frequencyto']) {
return true;
}
}
}
return false;
}
return false;
}
public function dxc_qrg_lookup($qrg, $maxage = 120) {
$this->load->helper(array('psr4_autoloader'));

View File

@@ -132,6 +132,7 @@
<th style="width:150px;"><?= __("Spotter"); ?></th>
<th><?= __("Message"); ?></th>
<th><?= __("Last Worked"); ?></th>
<th><?= __("Mode"); ?></th>
</tr>
</thead>

View File

@@ -26,7 +26,13 @@ $(function() {
$(td).addClass("spotted_call");
$(td).attr( "title", lang_click_to_prepare_logging);
}
}
},
{
'targets': 8,
'createdCell': function (td, cellData, rowData, row, col) {
$(td).addClass("mode");
}
},
],
"language": {
url: getDataTablesLanguageUrl(),
@@ -117,6 +123,7 @@ $(function() {
} else {
data[0].push('');
}
data[0].push(single.mode || '');
if (oldtable.length > 0) {
let update=false;
oldtable.each( function (srow) {
@@ -233,15 +240,18 @@ $(function() {
let ready_listener = true;
let call=this.innerText;
let qrg=''
let mode='';
if (this.parentNode.parentNode.className.indexOf('spotted_call')>=0) {
qrg=this.parentNode.parentNode.parentNode.cells[1].textContent*1000;
mode=this.parentNode.parentNode.parentNode.cells[8].textContent;
} else {
qrg=this.parentNode.parentNode.cells[1].textContent*1000;
mode=this.parentNode.parentNode.cells[8].textContent;
}
try {
irrelevant=fetch(CatCallbackURL + '/'+qrg).catch(() => {
openedWindow = window.open(CatCallbackURL + '/' + qrg);
irrelevant=fetch(CatCallbackURL + '/'+qrg+'/'+mode).catch(() => {
openedWindow = window.open(CatCallbackURL + '/' + qrg + '/' + mode);
openedWindow.close();
});
} finally {}