feat(relays): follow the entry Band selector when there is no CAT link
Relay automatic control and the band-change outbound rows both hang off the rig state, which is right when there IS a rig: changing Band in the entry strip pushes a QSY, the new state comes back through the CAT callback, and the relays follow from there — which is why this works for anyone with rig control. Without a CAT connection nothing is pushed and nothing comes back, so a station whose rig OpsLog does not control changed band and the antenna switch sat exactly where it was. Reported as automatic control not working; it was never told the band had changed. The entry selector now says so itself, but only when the CAT push did not happen, and never when the band or frequency lock is on: a lock means the entry is deliberately decoupled from the rig, and moving an antenna to match a contact logged from last year is worse than doing nothing. The frequency is passed as unknown on that path — a band selector gives a band and nothing else, and rules written on a frequency RANGE are left alone rather than evaluated against a made-up dial reading. The de-duplication of "is this a new band" is now shared by both sources, so a station that has both does not command its switch twice for one QSY. Also: the same credit line as the QSL e-mail now closes the default recording e-mail body, on the same terms — a default in the template, so a stored one is untouched.
This commit is contained in:
+38
-11
@@ -102,27 +102,54 @@ func (a *App) udpTriggerBandChange(s cat.RigState) {
|
||||
if a.udp == nil {
|
||||
return
|
||||
}
|
||||
band := strings.ToLower(strings.TrimSpace(s.Band))
|
||||
if band == "" || !s.Connected {
|
||||
if !s.Connected {
|
||||
return
|
||||
}
|
||||
lastTriggerBandMu.Lock()
|
||||
changed := band != lastTriggerBand
|
||||
if changed {
|
||||
lastTriggerBand = band
|
||||
a.emitBandChangeTrigger(s.Band, s.Mode, s.FreqHz)
|
||||
}
|
||||
|
||||
// noteBandChange normalises a band and reports whether it is a NEW one.
|
||||
//
|
||||
// The state is shared by both sources on purpose. The rig reports a band change
|
||||
// and so does the entry strip, and on a station that has both, one QSY produces
|
||||
// both — an antenna switch must be commanded once, not twice.
|
||||
func noteBandChange(raw string) (string, bool) {
|
||||
band := strings.ToLower(strings.TrimSpace(raw))
|
||||
if band == "" {
|
||||
return "", false
|
||||
}
|
||||
lastTriggerBandMu.Unlock()
|
||||
lastTriggerBandMu.Lock()
|
||||
defer lastTriggerBandMu.Unlock()
|
||||
if band == lastTriggerBand {
|
||||
return band, false
|
||||
}
|
||||
lastTriggerBand = band
|
||||
return band, true
|
||||
}
|
||||
|
||||
// emitBandChangeTrigger fires the band-change rows, once per NEW band.
|
||||
//
|
||||
// Split out of the rig-state path because the rig is not the only thing that
|
||||
// changes band: a station with no CAT link changes it in the QSO entry strip,
|
||||
// and that is just as much a band change to the antenna switch on the other end
|
||||
// of the message. The de-duplication is shared, so the two sources cannot
|
||||
// double-fire between them.
|
||||
func (a *App) emitBandChangeTrigger(rawBand, mode string, freqHz int64) {
|
||||
if a.udp == nil {
|
||||
return
|
||||
}
|
||||
band, changed := noteBandChange(rawBand)
|
||||
if !changed {
|
||||
return
|
||||
}
|
||||
f := map[string]string{
|
||||
"band": band,
|
||||
"band_m": bandMetres(band),
|
||||
"mode": s.Mode,
|
||||
"mode": mode,
|
||||
}
|
||||
if s.FreqHz > 0 {
|
||||
f["freq_hz"] = strconv.FormatInt(s.FreqHz, 10)
|
||||
f["freq_mhz"] = fmt.Sprintf("%.6f", float64(s.FreqHz)/1e6)
|
||||
if freqHz > 0 {
|
||||
f["freq_hz"] = strconv.FormatInt(freqHz, 10)
|
||||
f["freq_mhz"] = fmt.Sprintf("%.6f", float64(freqHz)/1e6)
|
||||
}
|
||||
a.udp.EmitTrigger(udp.TriggerBandChange, f)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user