예제 #1
0
        private void _update_Click(object sender, EventArgs e)
        {
            try
            {
                UInt32 time     = 0;
                UInt32 distance = 0;
                UInt32 speed    = (UInt32)_speed.Value;

                if (1 == _thresholdType.SelectedIndex)
                {
                    distance = (UInt32)_threshold.Value;
                }
                else
                {
                    time = (UInt32)_threshold.Value;
                }

                BufferStatus bs = new BufferStatus(0, 0, time, distance, speed, true);

                _port.SetLogConfigure(bs);

                MessageBox.Show(Properties.Resources.MSG2, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                _threshold.Enabled = false;
                _speed.Enabled     = false;
                _update.Enabled    = false;

                MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #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;
                _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);
            }
        }
예제 #3
0
        /// <summary>
        /// 設定情報の更新
        /// </summary>
        /// <param name="bs">設定情報</param>
        public void SetLogConfigure(BufferStatus bs)
        {
            Payload p = new Payload(MessageID.Configuration_Data_Logging_Criteria, new byte[] {
                0xff, 0xff, 0xff, 0xff, // max time
                0x00, 0x00, 0x00, 0x00, // min time
                0xff, 0xff, 0xff, 0xff, // max distance
                0x00, 0x00, 0x00, 0x00, // min distance
                0xff, 0xff, 0xff, 0xff, // max speed
                0x00, 0x00, 0x00, 0x00, // min speed
                0x01,                   // datalog enale
                0x00                    // reserved
            });

            // canwayの動きを参考にして、両方が0ならTimeを5とする
            if (0 == bs.Distance && 0 == bs.Time)
            {
                bs.Time = 5;
            }

            p.Body[4] = (byte)(0x000000ff & (bs.Time >> 24));
            p.Body[5] = (byte)(0x000000ff & (bs.Time >> 16));
            p.Body[6] = (byte)(0x000000ff & (bs.Time >> 8));
            p.Body[7] = (byte)(0x000000ff & (bs.Time >> 0));

            p.Body[12] = (byte)(0x000000ff & (bs.Distance >> 24));
            p.Body[13] = (byte)(0x000000ff & (bs.Distance >> 16));
            p.Body[14] = (byte)(0x000000ff & (bs.Distance >> 8));
            p.Body[15] = (byte)(0x000000ff & (bs.Distance >> 0));

            p.Body[20] = (byte)(0x000000ff & (bs.Speed >> 24));
            p.Body[21] = (byte)(0x000000ff & (bs.Speed >> 16));
            p.Body[22] = (byte)(0x000000ff & (bs.Speed >> 8));
            p.Body[23] = (byte)(0x000000ff & (bs.Speed >> 0));

            if (RESULT.RESULT_ACK != this.waitSendResult(p))
            {
                throw new Exception("設定の書き込みに失敗");
            }
        }
예제 #4
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);
            }
        }