예제 #1
0
        public void Stop()
        {
            _stopping = true;
            try
            {
                if (_timerShort != null)
                {
                    _timerShort.Stop();
                }
                if (_timerLong != null)
                {
                    _timerLong.Stop();
                }
                if (_cat != null)
                {
                    _cat.Close();
                }
                if (_server != null)
                {
                    _server.Close();
                }
                if (_riox != null)
                {
                    if (_riox.IsConnected)
                    {
                        _riox.SendCommand(new RIOXCommand("UnSub", "NONE"));
                    }
                    _riox.Close();
                }


                _cat        = null;
                _server     = null;
                _timerShort = null;
                _timerLong  = null;
                SetNotifyIconText("MiniDeluxe - Stopped");
            }
            catch (Exception e)
            {
                _notifyIcon.MessageBox("While stopping: " + e.Message + "\n" + e.StackTrace);
            }
            finally
            {
                _stopping = false;
            }
        }
예제 #2
0
        public void Start()
        {
            try
            {
                _data = new RadioData
                {
                    vfoa           = "0",
                    vfob           = "0",
                    Mode           = "99",
                    mox            = false,
                    DisplayMode    = "0",
                    Smeter         = "0",
                    dspfilters     = "",
                    dspfilterarray = new ArrayList
                    {
                        "6.0", "4.0", "2.6", "2.1", "1.0",
                        "500", "250", "100", "50", "25", "VAR1", "VAR2", "UNKN"
                    },
                };

                if (Properties.Settings.Default.SerialPortIdx == 0)
                {
                    // RIOX
                    try
                    {
                        Console.WriteLine("RIOX initializing");
                        _riox = new RIOX.RIOXClient(typeof(RIOXData), Properties.Settings.Default.RIOXIP, Properties.Settings.Default.RIOXPort);
                        _riox.ObjectReceivedEvent += new RIOX.RIOXClient.ObjectReceivedEventHandler(_riox_ObjectReceivedEvent);
                        _usingRIOX = true;
                    }
                    catch (Exception ex)
                    {
                        _notifyIcon.MessageBox("RIOX error: " + ex.Message + "\r\n" + ex.StackTrace);
                        throw ex;
                    }
                }
                else
                {
                    _cat                 = new CATConnector(new SerialPort(Properties.Settings.Default.SerialPort));
                    _timerShort          = new Timer(Properties.Settings.Default.HighInterval);
                    _cat.CATEvent       += CatcatEvent;
                    _timerShort.Elapsed += TimerShortElapsed;
                }

                _timerLong          = new Timer(Properties.Settings.Default.LowInterval);
                _timerLong.Elapsed += TimerLongElapsed;

                //_listenOnly = Properties.Settings.Default.ListenOnly;
                _server = new HRDTCPServer(this);
            }
            catch (Exception e)
            {
                _notifyIcon.MessageBox("While starting: " + e.Message + "\n" +
                                       "Server is disabled. Please check configuration.\nIf using RIOX mode, please make sure DDUtil is running.");
                ShowOptionsForm();
                return;
            }

            _server.HRDTCPEvent += ServerHRDTCPEvent;

            // Start the timers only if serial polling is enabled
            if (!_usingRIOX)
            {
                // write initial commands to the radio to fill in initial data
                WriteCommand("ZZIF;");
                WriteCommand("ZZFA;");
                WriteCommand("ZZFB;");
                WriteCommand("ZZBS;");
                WriteCommand("ZZDM;");
                WriteCommand("ZZGT;");
                WriteCommand("ZZPA;");
                WriteCommand("ZZFI;");

                _timerShort.Start();
                //_timerLong.Start();
            }
            else // using RIOX
            {
                // subscribe to what we want from DDUtil
                _riox.SendCommand(new RIOXCommand("UpDateType", "PSH:500"));
                //_riox.SendCommand(new RIOXCommand("UnSub", "NONE"));
                _riox.SendCommand(new RIOXCommand("Sub", "ZZIF;ZZFA;ZZFB;ZZBS;ZZDM;ZZGT;ZZPA;ZZFI;"));
            }

            _timerLong.Start();
            _server.Start();

            SetNotifyIconText("MiniDeluxe - Running (0 connections)");
        }
예제 #3
0
        public void Stop()
        {
            _stopping = true;
            try
            {
                if (_timerShort != null) _timerShort.Stop();
                if (_timerLong != null) _timerLong.Stop();
                if (_cat != null) _cat.Close();
                if (_server != null) _server.Close();
                if (_riox != null)
                {
                    if (_riox.IsConnected) _riox.SendCommand(new RIOXCommand("UnSub", "NONE"));
                    _riox.Close();
                }

                _cat = null;
                _server = null;
                _timerShort = null;
                _timerLong = null;
                SetNotifyIconText("MiniDeluxe - Stopped");
            }
            catch (Exception e)
            {
                _notifyIcon.MessageBox("While stopping: " + e.Message + "\n" + e.StackTrace);
            }
            finally
            {
                _stopping = false;
            }
        }
예제 #4
0
        public void Start()
        {
            try
            {
                _data = new RadioData
                {
                    vfoa = "0",
                    vfob = "0",
                    Mode = "99",
                    mox = false,
                    DisplayMode = "0",
                    Smeter = "0",
                    dspfilters = "",
                    dspfilterarray = new ArrayList
                                         {
                                         "6.0","4.0","2.6","2.1","1.0",
                                         "500","250","100","50","25","VAR1","VAR2","UNKN"
                                         },
                };

                if (Properties.Settings.Default.SerialPortIdx == 0)
                {
                    // RIOX
                    try
                    {
                        Console.WriteLine("RIOX initializing");
                        _riox = new RIOX.RIOXClient(typeof(RIOXData), Properties.Settings.Default.RIOXIP, Properties.Settings.Default.RIOXPort);
                        _riox.ObjectReceivedEvent += new RIOX.RIOXClient.ObjectReceivedEventHandler(_riox_ObjectReceivedEvent);
                        _usingRIOX = true;
                    }
                    catch (Exception ex)
                    {
                        _notifyIcon.MessageBox("RIOX error: " + ex.Message + "\r\n" + ex.StackTrace);
                        throw ex;
                    }
                }
                else
                {
                    _cat = new CATConnector(new SerialPort(Properties.Settings.Default.SerialPort));
                    _timerShort = new Timer(Properties.Settings.Default.HighInterval);
                    _cat.CATEvent += CatcatEvent;
                    _timerShort.Elapsed += TimerShortElapsed;
                }

                _timerLong = new Timer(Properties.Settings.Default.LowInterval);
                _timerLong.Elapsed += TimerLongElapsed;

                //_listenOnly = Properties.Settings.Default.ListenOnly;
                _server = new HRDTCPServer(this);

            }
            catch (Exception e)
            {
                _notifyIcon.MessageBox("While starting: " + e.Message + "\n" +
                                       "Server is disabled. Please check configuration.\nIf using RIOX mode, please make sure DDUtil is running.");
                ShowOptionsForm();
                return;
            }

            _server.HRDTCPEvent += ServerHRDTCPEvent;

            // Start the timers only if serial polling is enabled
            if (!_usingRIOX)
            {
                // write initial commands to the radio to fill in initial data
                WriteCommand("ZZIF;");
                WriteCommand("ZZFA;");
                WriteCommand("ZZFB;");
                WriteCommand("ZZBS;");
                WriteCommand("ZZDM;");
                WriteCommand("ZZGT;");
                WriteCommand("ZZPA;");
                WriteCommand("ZZFI;");

                _timerShort.Start();
                //_timerLong.Start();
            }
            else // using RIOX
            {
                // subscribe to what we want from DDUtil
                _riox.SendCommand(new RIOXCommand("UpDateType", "PSH:500"));
                //_riox.SendCommand(new RIOXCommand("UnSub", "NONE"));
                _riox.SendCommand(new RIOXCommand("Sub","ZZIF;ZZFA;ZZFB;ZZBS;ZZDM;ZZGT;ZZPA;ZZFI;"));
            }

            _timerLong.Start();
            _server.Start();

            SetNotifyIconText("MiniDeluxe - Running (0 connections)");
        }