Ejemplo n.º 1
0
 private void BtnSerial_Click(object sender, EventArgs e)
 {
     using (var frm = new FormSerialSettings())
     {
         Visible = false;
         var dialogResult = frm.ShowDialog(this);
         if (dialogResult == DialogResult.OK)
         {
             if (_serialDelegate != null)
             {
                 _serialDelegate.DynamicInvoke();
             }
         }
     }
     Visible = true;
     return;
 }
Ejemplo n.º 2
0
        private bool RModuleWrapperConnect()
        {
            string portName = Properties.Settings.Default.RModemPort;
            string baudRate = Properties.Settings.Default.RModemBaudRate;

            bool tryConnect = true;

            while (tryConnect)
            {
                if (string.IsNullOrEmpty(portName))
                {
                    using (var frm = new FormSerialSettings())
                    {
                        if (frm.ShowDialog(this) != DialogResult.OK)
                        {
                            return(false);
                        }
                    }
                    portName = Properties.Settings.Default.RModemPort;
                    baudRate = Properties.Settings.Default.RModemBaudRate;
                    if (string.IsNullOrEmpty(portName))
                    {
                        return(false);
                    }
                }
                tryConnect = !_rModuleWrapper.TryConnect(portName, baudRate);
                if (tryConnect)
                {
                    MessageBox.Show("Не удается инициализировать радиомодем на порту " + portName,
                                    "Ошибка инициализации радиомодуля (" + _rModuleWrapper.InitError + ")", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    portName = string.Empty;
                }
            }
            _rModuleWrapper.OnPortError += RModuleWrapper_OnPortError;
//            _rModuleWrapper.OnDataReceived += RModule_OnDataReceived;
            return(true);
        }