Exemplo n.º 1
0
        public QSO create(string callsign, string myCallsign, decimal freq, string mode, string rstRcvd, string rstSnt, string comments, DateTime?timestamp = null)
        {
            QSO qso = new QSO {
                _ts       = (timestamp == null ? DateTime.UtcNow : (DateTime)timestamp).ToString("yyyy-MM-dd HH:mm:ss"),
                _myCS     = myCallsign,
                _band     = Band.fromFreq(freq),
                _freq     = QSO.formatFreq(freq),
                _mode     = mode,
                _cs       = callsign,
                _snt      = rstSnt,
                _rcv      = rstRcvd,
                _freqRx   = freq.ToString(),
                _no       = no++,
                _loc      = tnxlog.loc,
                _comments = comments,
                _qth      = new string[TnxlogConfig.QthFieldCount]
            };

            for (int field = 0; field < TnxlogConfig.QthFieldCount; field++)
            {
                qso._qth[field] = tnxlog.getQthFieldValue(field);
            }
            return(qso);
        }
Exemplo n.º 2
0
        public QSO fromADIF(string adif, string[] qthFields = null, string commentField = "COMMENT")
        {
            string date = getAdifField(adif, "QSO_DATE");
            string time = getAdifField(adif, "TIME_OFF");

            if (string.IsNullOrEmpty(time))
            {
                time = getAdifField(adif, "TIME_ON");
            }
            string myCs = getAdifField(adif, "STATION_CALLSIGN");

            if (string.IsNullOrEmpty(myCs))
            {
                myCs = getAdifField(adif, "OPERATOR");
            }
            string  adifFreq = QSO.FixSeparator(getAdifField(adif, "FREQ"));
            decimal freq     = Convert.ToDecimal(adifFreq, System.Globalization.NumberFormatInfo.InvariantInfo) * 1000;
            string  band     = Band.fromFreq(freq);
            string  mode     = getAdifField(adif, "MODE");
            string  submode  = getAdifField(adif, "SUBMODE");

            if (!string.IsNullOrEmpty(submode) && Mode.Names.Contains(submode))
            {
                mode = submode;
            }
            if (Mode.DefFreq.ContainsKey(mode))
            {
                decimal defFreq = Mode.DefFreq[mode].FirstOrDefault(item => Band.fromFreq(item) == band);
                if (defFreq != 0)
                {
                    freq = defFreq;
                }
            }
            QSO qso = new QSO
            {
                _ts      = $"{date.Substring(0, 4)}-{date.Substring(4, 2)}-{date.Substring(6, 2)} {time.Substring(0, 2)}:{time.Substring(2, 2)}:00",
                _myCS    = myCs,
                freq     = QSO.formatFreq(freq),
                _mode    = mode,
                _cs      = getAdifField(adif, "CALL"),
                _snt     = getAdifField(adif, "RST_SENT"),
                _rcv     = getAdifField(adif, "RST_RCVD"),
                _freqRx  = getAdifField(adif, "FREQ"),
                _no      = no++,
                _loc     = tnxlog.loc,
                _loc_rcv = getAdifField(adif, "GRIDSQUARE"),
                _qth     = new string[TnxlogConfig.QthFieldCount]
            };

            for (int field = 0; field < TnxlogConfig.QthFieldCount; field++)
            {
                if (qthFields != null)
                {
                    if (!string.IsNullOrEmpty(qthFields[field]))
                    {
                        qso._qth[field] = getAdifField(adif, qthFields[field]);
                    }
                }
                else
                {
                    qso._qth[field] = tnxlog.getQthFieldValue(field);
                }
            }
            if (!string.IsNullOrEmpty(commentField))
            {
                qso._comments = getAdifField(adif, commentField);
            }
            return(qso);
        }
Exemplo n.º 3
0
 public async Task postFreq(decimal freq)
 {
     await httpService.postFreq(QSO.formatFreq(freq));
 }