Example #1
0
        public QSO create(string xml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);
            XmlElement root = doc.DocumentElement;

            if (root.Name != "contactinfo")
            {
                return(null);
            }

            string mode = root.SelectSingleNode("mode").InnerText;

            if (mode.Equals("RTTY"))
            {
                mode = "FT8";
            }

            string snt = root.SelectSingleNode("snt").InnerText;
            string rcv = root.SelectSingleNode("rcv").InnerText;

            if (mode.Equals("FT8"))
            {
                snt = "-10";
                rcv = "-10";
            }

            return(new QSO {
                _ts = root.SelectSingleNode("timestamp").InnerText,
                _myCS = root.SelectSingleNode("mycall").InnerText,
                _band = root.SelectSingleNode("band").InnerText,
                _freq = QSO.formatFreq(root.SelectSingleNode("txfreq").InnerText),
                _mode = mode,
                _cs = root.SelectSingleNode("call").InnerText,
                _snt = snt,
                _rcv = snt,
                _freqRx = QSO.formatFreq(root.SelectSingleNode("rxfreq").InnerText),
                _oper = root.SelectSingleNode("operator").InnerText,
                _no = no++,
                _rda = settings.optionalColumns["RDA"].value,
                _rafa = settings.optionalColumns["RAFA"].value,
                _wff = settings.optionalColumns["WFF"].value,
                _loc = settings.optionalColumns["Locator"].value,
                _userFields = settings.getUserColumnsValues()
            });
        }
Example #2
0
        public FMain()
        {
#if DEBUG
            TextWriterTraceListener[] listeners = new TextWriterTraceListener[] {
                new TextWriterTraceListener("debug." + Guid.NewGuid() + ".log"),
                new TextWriterTraceListener(Console.Out)
            };
            foreach (TextWriterTraceListener listener in listeners)
            {
                listener.TraceOutputOptions |= TraceOptions.DateTime;
            }
            Trace.Listeners.AddRange(listeners);
            Trace.AutoFlush = true;
            Trace.TraceInformation("-----------------------START---------------------------------");
#endif
            config = new XmlConfigNS.XmlConfig <DXpConfig>();
            config.data.initialize();
            qsoFactory = new QSOFactory(config.data);
            InitializeComponent();
            udpListener.DataReceived += UDPDataReceived;
            udpListener.StartListener(12060);

            bsQSO = new BindingSource(blQSO, null);
            dgvQSO.AutoGenerateColumns = false;
            dgvQSO.DataSource          = bsQSO;
            for (int c = 0; c < DXpConfig.UserColumnsCount; c++)
            {
                UserColumnSettings cs  = config.data.userColumns != null && config.data.userColumns.Count > c ? config.data.userColumns[c] : null;
                DataGridViewColumn col = new DataGridViewTextBoxColumn();
                col.Name             = "userFieldColumn" + c.ToString();
                col.DataPropertyName = "userField" + c.ToString();
                col.Visible          = cs != null ? cs.show : false;
                col.HeaderText       = cs != null ? cs.name : "";
                dgvQSO.Columns.Add(col);
            }
            if (config.data.dgvQSOColumnsWidth != null)
            {
                for (int co = 0; co < dgvQSO.ColumnCount && co < config.data.dgvQSOColumnsWidth.Count(); co++)
                {
                    dgvQSO.Columns[co].Width = config.data.dgvQSOColumnsWidth[co];
                }
            }
            else
            {
                config.data.dgvQSOColumnsWidth = new List <int>();
            }
            if (config.data.dgvQSOColumnsWidth.Count < dgvQSO.ColumnCount)
            {
                for (int co = config.data.dgvQSOColumnsWidth.Count; co < dgvQSO.ColumnCount; co++)
                {
                    config.data.dgvQSOColumnsWidth.Add(dgvQSO.Columns[co].Width);
                }
                writeConfig();
            }

            bool       qsoEr;
            List <QSO> storedQSOs = ProtoBufSerialization.ReadListItems <QSO>(qsoFilePath, out qsoEr);
            if (storedQSOs.Count > 0)
            {
                Regex  reComaNoSpace   = new Regex(",(\\S)");
                string comaNoSpaceRepl = ", $1";
                Regex  reNoRegion      = new Regex("(\\w\\w)-(\\d\\d),\\s?(\\d\\d)");
                string noRegionRepl    = "$1-$2, $1-$3";
                Regex  reRDA           = new Regex("[A-Z][A-Z]-\\d\\d");
                foreach (QSO qso in storedQSOs)
                {
                    if (qso.freq.IndexOf('.') == -1)
                    {
                        qso.freq = QSO.formatFreq(qso.freq);
                        qsoEr    = true;
                    }
                    if (qso.rda != null)
                    {
                        MatchCollection rdaMatches = reRDA.Matches(qso.rda);
                        string          rda        = "";
                        if (rdaMatches.Count > 1)
                        {
                            qsoEr = true;
                        }
                        foreach (Match rdaMatch in rdaMatches)
                        {
                            if (rda != "")
                            {
                                rda += ", ";
                            }
                            rda += rdaMatch.Value;
                        }
                        qso.rda = rda;
                    }

                    /*
                     * if (qso.rda != null && reComaNoSpace.IsMatch(qso.rda))
                     * {
                     *  qso.rda = reComaNoSpace.Replace(qso.rda, comaNoSpaceRepl);
                     *  qsoEr = true;
                     * }
                     * if (qso.rda != null && reNoRegion.IsMatch(qso.rda))
                     * {
                     *  qso.rda = reNoRegion.Replace(qso.rda, noRegionRepl);
                     *  qsoEr = true;
                     * }*/
                    blQSO.Insert(0, qso);
                    updateQsoIndex(qso);
                }
                QSO lastQSO = storedQSOs.Last();
                if (lastQSO.rda == config.data.getOptionalColumnValue("RDA"))
                {
                    qsoFactory.no = lastQSO.no + 1;
                }
            }
            if (qsoEr)
            {
                ProtoBufSerialization.WriteList(qsoFilePath, storedQSOs, false);
            }
            config.data.optionalColumnValueChanged += optionalColumnValueChanged;
            gpsReader.locationChanged      += locationChanged;
            gpsReader.gpsConnectionChanged += gpsConnectionChanged;
            config.data.logIO += onLoggedIO;
            onLoggedIO(null, null);
            startGPSReader();
            http = new HTTPService(gpsReader, config.data);
            http.connectionStateChanged += onHTTPConnection;
            http.locationChanged        += locationChanged;
        }