private bool ValidateParam()
        {
            SerialTerminalSettings settings = _terminalSettings;
            SerialTerminalParam    param    = _terminalParam;

            try {
                LogType            logtype     = (LogType)EnumDescAttribute.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);
                ISimpleLogSettings logsettings = null;
                if (logtype != LogType.None)
                {
                    logsettings = CreateSimpleLogSettings(logtype, _logFileBox.Text);
                    if (logsettings == null)
                    {
                        return(false);                  //動作キャンセル
                    }
                }

                param.Port = _portBox.SelectedIndex + 1;

                string autoExecMacroPath = null;
                if (_autoExecMacroPathBox.Text.Length != 0)
                {
                    autoExecMacroPath = _autoExecMacroPathBox.Text;
                }

                IAutoExecMacroParameter autoExecParams = param.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                if (autoExecParams != null)
                {
                    autoExecParams.AutoExecMacroPath = autoExecMacroPath;
                }

                settings.BeginUpdate();
                if (logsettings != null)
                {
                    settings.LogSettings.Reset(logsettings);
                }
                settings.Caption     = String.Format("COM{0}", param.Port);
                settings.BaudRate    = Int32.Parse(_baudRateBox.Text);
                settings.ByteSize    = (byte)(_dataBitsBox.SelectedIndex == 0? 7 : 8);
                settings.StopBits    = (StopBits)_stopBitsBox.SelectedIndex;
                settings.Parity      = (Parity)_parityBox.SelectedIndex;
                settings.FlowControl = (FlowControl)_flowControlBox.SelectedIndex;

                settings.Encoding = (EncodingType)_encodingBox.SelectedIndex;

                settings.LocalEcho  = _localEchoBox.SelectedIndex == 1;
                settings.TransmitNL = (NewLine)EnumDescAttribute.For(typeof(NewLine)).FromDescription(_newLineBox.Text, LogType.None);

                settings.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text);
                settings.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text);
                settings.EndUpdate();
                return(true);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(false);
            }
        }
Esempio n. 2
0
 public static SerialTerminalSettings CreateDefaultSerialTerminalSettings(string portName)
 {
     SerialTerminalSettings ts = new SerialTerminalSettings();
     ts.BeginUpdate();
     ts.Icon = SerialPortPlugin.Instance.LoadIcon();
     ts.Caption = portName;
     ts.EndUpdate();
     return ts;
 }
Esempio n. 3
0
 public static SerialTerminalSettings CreateDefaultSerialTerminalSettings(int port)
 {
     SerialTerminalSettings ts = new SerialTerminalSettings();
     ts.BeginUpdate();
     ts.Icon = SerialPortPlugin.Instance.LoadIcon();
     ts.Caption = String.Format("COM{0}", port);
     ts.EndUpdate();
     return ts;
 }
Esempio n. 4
0
        public static SerialTerminalSettings CreateDefaultSerialTerminalSettings(string portName)
        {
            SerialTerminalSettings ts = new SerialTerminalSettings();

            ts.BeginUpdate();
            ts.Icon    = SerialPortPlugin.Instance.LoadIcon();
            ts.Caption = portName;
            ts.EndUpdate();
            return(ts);
        }
Esempio n. 5
0
        public static SerialTerminalSettings CreateDefaultSerialTerminalSettings(int port)
        {
            SerialTerminalSettings ts = new SerialTerminalSettings();

            ts.BeginUpdate();
            ts.Icon    = SerialPortPlugin.Instance.LoadIcon();
            ts.Caption = String.Format("COM{0}", port);
            ts.EndUpdate();
            return(ts);
        }
Esempio n. 6
0
        private bool ValidateParam()
        {
            SerialTerminalSettings settings = _terminalSettings;
            SerialTerminalParam    param    = _terminalParam;

            try {
                LogType            logtype     = ((EnumListItem <LogType>)_logTypeBox.SelectedItem).Value;
                ISimpleLogSettings logsettings = null;
                if (logtype != LogType.None)
                {
                    logsettings = CreateSimpleLogSettings(logtype, _logFileBox.Text);
                    if (logsettings == null)
                    {
                        return(false); //動作キャンセル
                    }
                }

                param.PortName = _portBox.SelectedItem as string;
                if (param.PortName == null)
                {
                    return(false);
                }

                string autoExecMacroPath = null;
                if (_autoExecMacroPathBox.Text.Length != 0)
                {
                    autoExecMacroPath = _autoExecMacroPathBox.Text;
                }

                IAutoExecMacroParameter autoExecParams = param.GetAdapter(typeof(IAutoExecMacroParameter)) as IAutoExecMacroParameter;
                if (autoExecParams != null)
                {
                    autoExecParams.AutoExecMacroPath = autoExecMacroPath;
                }

                settings.BeginUpdate();
                if (logsettings != null)
                {
                    settings.LogSettings.Reset(logsettings);
                }
                settings.Caption     = param.PortName;
                settings.BaudRate    = Int32.Parse(_baudRateBox.Text);
                settings.ByteSize    = (byte)(_dataBitsBox.SelectedIndex == 0 ? 7 : 8);
                settings.StopBits    = ((EnumListItem <StopBits>)_stopBitsBox.SelectedItem).Value;
                settings.Parity      = ((EnumListItem <Parity>)_parityBox.SelectedItem).Value;
                settings.FlowControl = ((EnumListItem <FlowControl>)_flowControlBox.SelectedItem).Value;

                settings.Encoding = ((EnumListItem <EncodingType>)_encodingBox.SelectedItem).Value;

                settings.LocalEcho  = _localEchoBox.SelectedIndex == 1;
                settings.TransmitNL = ((EnumListItem <NewLine>)_newLineBox.SelectedItem).Value;

                settings.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text);
                settings.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text);
                settings.EndUpdate();
                return(true);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(false);
            }
        }