Example #1
0
        private void ClientThread(object o)
        {
            TcpClient    client = (TcpClient)o;
            BinaryReader br     = new BinaryReader(client.GetStream());

            while (!_stopClients)
            {
                try
                {
                    HRDMessageBlock msg = HRDMessage.BytesToHRDMessage(br);

                    if (msg.nSize == 0)
                    {
                        break;
                    }

                    HRDTCPEventArgs e = new HRDTCPEventArgs(client, msg);

                    if (HRDTCPEvent != null)
                    {
                        HRDTCPEvent(this, e);
                    }
                }
                catch
                {
                }
            }
            _parent.SetNotifyIconText("MiniDeluxe - Running (" + --_connectionCount + " connections)");
        }
Example #2
0
        void ProcessHRDTCPSetCommand(String s, BinaryWriter bw)
        {
            Debug(String.Format("SET COMMAND: {0}", s));

            if (s.Contains("SET DROPDOWN"))
            {
                SetDropdown(s);
            }
            else if (s.Contains("SET FREQUENCIES-HZ"))
            {
                Match m = Regex.Match(s, "FREQUENCIES-HZ (\\d+) (\\d+)");
                if (!m.Success)
                {
                    return;
                }
                String vfoa = String.Format("{0:00000000000}", long.Parse(m.Groups[1].Value));
                String vfob = String.Format("{0:00000000000}", long.Parse(m.Groups[2].Value));
                if (vfoa != "00000000000")
                {
                    WriteCommand("ZZFA" + vfoa + ";");
                }
                if (vfob != "00000000000")
                {
                    WriteCommand("ZZFB" + vfob + ";");
                }
                _data.vfoa = vfoa;
                _data.vfob = vfob;
            }
            else if (s.Contains("SET BUTTON-SELECT"))
            {
                SetButton(s);
            }
            else if (s.Contains("SET FREQUENCY-HZ"))
            {
                Match m = Regex.Match(s, "FREQUENCY-HZ (\\d+)");
                if (!m.Success)
                {
                    return;
                }
                String vfoa = String.Format("{0:00000000000}", long.Parse(m.Groups[1].Value));
                if (vfoa != "00000000000")
                {
                    WriteCommand("ZZFA" + vfoa + ";");
                }
                _data.vfoa = vfoa;
            }
            // tell the program that the command executed OK, regardless if it did or not.
            bw.Write(HRDMessage.HRDMessageToByteArray("OK"));
        }
Example #3
0
 void ProcessHRDTCPGetCommand(String s, BinaryWriter bw)
 {
     if (s.Contains("GET ID"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray("Ham Radio Deluxe"));
     }
     else if (s.Contains("GET VERSION"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray("v5.23")); // W0DHB fix for v5.23
     }
     else if (s.Contains("GET FREQUENCY"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(_data.vfoa));
     }
     else if (s.Contains("GET RADIO"))
     {
         if (s.Contains("GET RADIOS"))
         {
             if (Properties.Settings.Default.SSDR)
             {
                 bw.Write(HRDMessage.HRDMessageToByteArray("9:SMART SDR"));
             }
             else
             {
                 bw.Write(HRDMessage.HRDMessageToByteArray("11:PowerSDR"));
             }
         }
         else
         {
             if (Properties.Settings.Default.SSDR)
             {
                 bw.Write(HRDMessage.HRDMessageToByteArray("SMART SDR"));
             }
             else
             {
                 bw.Write(HRDMessage.HRDMessageToByteArray("PowerSDR"));
             }
         }
     }
     else if (s.Contains("GET CONTEXT"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray("1"));
     }
     else if (s.Contains("GET FREQUENCIES"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(_data.vfoa + "-" + _data.vfob));
     }
     else if (s.Contains("GET DROPDOWN-TEXT"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(GetDropdownText(s)));
     }
     else if (s.Contains("GET DROPDOWN-LIST"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(GetDropdownList(s)));
     }
     else if (s.Contains("GET LOGBOOKUPDATES"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray("0"));
     }
     else if (s.Contains("GET BUTTONS"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(GetButtons()));
     }
     else if (s.Contains("GET SMETER-MAIN"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(String.Format("S{0},{0},1.5", 14 - int.Parse(_data.Smeter))));
     }
     else if (s.Contains("GET BUTTON-SELECT TX"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(_data.mox ? "1" : "0"));
     }
     else if (s.Contains("GET DROPDOWNS"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray(GetDropdowns()));
     }
     else if (s.Contains("GET VFO-COUNT"))
     {
         bw.Write(HRDMessage.HRDMessageToByteArray("2"));
     }
     else
     {
         bw.Write(HRDMessage.HRDMessageToByteArray("0"));
     }
 }