Beispiel #1
0
        private void _connect_Click(object sender, EventArgs e)
        {
            try
            {
                string portName = this.PortName;
                if (Properties.Resources.PORT_AUTOSEL == portName)
                {
                    try
                    {
                        portName      = SkytraqController.AutoSelectPort();
                        this.PortName = portName;
                    }
                    catch
                    {
                        _posrts.Items.Remove(portName);
                        MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                _port = new SkytraqController(portName);
                MyEnviroment.LatestPortName = portName;
                _port.OnRead += _port_OnRead;

                // Version情報
                SoftwareVersion sv = _port.SoftwareVersion;
                _kernelVersion.Text = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.KernelVersion >> 16) & 0x00ff), ((sv.KernelVersion >> 8) & 0x00ff), (sv.KernelVersion & 0x00ff));
                _ODMVersion.Text    = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.ODMVersion >> 16) & 0x00ff), ((sv.ODMVersion >> 8) & 0x00ff), (sv.ODMVersion & 0x00ff));
                _Revision.Text      = string.Format("{0:D2}/{1:D2}/{2:D2}", ((sv.Revision >> 16) & 0x00ff), ((sv.Revision >> 8) & 0x00ff), (sv.Revision & 0x00ff));

                // バッファーサイズ
                BufferStatus bs          = _port.GetBufferStatus();
                UInt16       usedSectors = bs.TotalSectors;
                usedSectors          -= bs.FreeSectors;
                _bufferStatus.Maximum = bs.TotalSectors;
                _bufferStatus.Value   = usedSectors;

                // ボタンを制御
                _connect.Enabled  = false;
                _download.Enabled = true;
                _posrts.Enabled   = false;

                if (bs.TotalSectors == bs.FreeSectors)
                {
                    _download.Enabled = false;
                    MessageBox.Show(Properties.Resources.MSG3, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format(Properties.Resources.MSG4, ex.Message), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #2
0
        private void _connect_Click(object sender, EventArgs e)
        {
            try
            {
                string portName = this.PortName;
                if (Properties.Resources.PORT_AUTOSEL == portName)
                {
                    try
                    {
                        portName      = SkytraqController.AutoSelectPort();
                        this.PortName = portName;
                    }
                    catch
                    {
                        _posrts.Items.Remove(portName);
                        MessageBox.Show(Properties.Resources.MSG1, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }
                _port = new SkytraqController(portName);
                MyEnviroment.LatestPortName = portName;

                // Version情報
                SoftwareVersion sv = _port.SoftwareVersion;
                _kernelVersion.Text = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.KernelVersion >> 16) & 0x00ff), ((sv.KernelVersion >> 8) & 0x00ff), (sv.KernelVersion & 0x00ff));
                _ODMVersion.Text    = string.Format("{0:D2}.{1:D2}.{2:D2}", ((sv.ODMVersion >> 16) & 0x00ff), ((sv.ODMVersion >> 8) & 0x00ff), (sv.ODMVersion & 0x00ff));
                _Revision.Text      = string.Format("{0:D2}/{1:D2}/{2:D2}", ((sv.Revision >> 16) & 0x00ff), ((sv.Revision >> 8) & 0x00ff), (sv.Revision & 0x00ff));

                // バッファ情報
                _bs = _port.GetBufferStatus();
                if (0 != _bs.Time)
                {
                    _thresholdType.SelectedIndex = 0;
                }
                else
                {
                    if (0 != _bs.Distance)
                    {
                        _thresholdType.SelectedIndex = 1;
                    }
                    else
                    {
                        _bs.Time = 5;
                        _thresholdType.SelectedIndex = 0;
                    }
                }
                _speed.Value = _bs.Speed;

                _thresholdType.Enabled = true;
                _threshold.Enabled     = true;
                _speed.Enabled         = true;
                _update.Enabled        = true;
            }
            catch (Exception ex)
            {
                _thresholdType.Enabled = false;
                _threshold.Enabled     = false;
                _speed.Enabled         = false;
                _update.Enabled        = false;

                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }