コード例 #1
0
        private void CalibrateDrive(object sender, EventArgs e)
        {
            ToolStripItem t = (ToolStripItem)sender;

            // Exit if no list entry has been selected
            if (dataGridView.SelectedRows.Count <= 0)
            {
                return;
            }

            _statusLabelText = "Starting calibration...";

            // Get IP-Address from list
            String motorIP = t.Name;

            // Connecto to HDrive
            HDrive.HDrive h1 = new HDrive.HDrive(0, IPAddress.Parse(motorIP.ToString()));
            if (!h1.Connect(1000, (a) => { }, HDriveTicket.HDriveTicket))
            {
                _statusLabelText = "Could not connect to drive";
                return;
            }

            HDriveMotionVariables mV = new HDriveMotionVariables();

            mV.ControlMode = OperationModes.Calibration;
            h1.GoToPosition(mV);
        }
コード例 #2
0
        private void BlinkDrive(object sender, EventArgs e)
        {
            ToolStripItem t = (ToolStripItem)sender;

            // Connecto to HDrive
            HDrive.HDrive h1 = new HDrive.HDrive(0, IPAddress.Parse(t.Name));
            if (!h1.Connect(1000, (a) => { }, HDriveTicket.HDriveTicket))
            {
                _statusLabelText = "Could not connect to drive";
                return;
            }

            // Set blink speed
            h1.WriteObject(4, 33, 5);

            // Release TCP connection to this drive
            h1.Close();
        }
コード例 #3
0
        private void updateBootloader(object sender, EventArgs e)
        {
            ToolStripItem t = (ToolStripItem)sender;


            // Exit if no list entry has been selected
            if (dataGridView.SelectedRows.Count <= 0)
            {
                return;
            }

            _statusLabelText = "Uploading bootLoader file...";

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                String storedPath = "";
                String serverIP   = "";
                if (Properties.Settings.Default.Properties.Cast <SettingsProperty>().Any(prop => prop.Name == "LastBootloaderFilePath"))
                {
                    storedPath = (string)Properties.Settings.Default.Properties["LastBootloaderFilePath"].DefaultValue;
                }
                else
                {
                    storedPath = "C:\\";
                    SettingsProperty prop = new SettingsProperty("LastBootloaderFilePath");
                    prop.PropertyType = typeof(string);
                    Properties.Settings.Default.Properties.Add(prop);
                    Properties.Settings.Default.Save();
                    Properties.Settings.Default.Properties["LastBootloaderFilePath"].DefaultValue = "c:\\";
                }

                // Read Server IP out of config file. This is mandatory for a correct FW upgrade
                if (Properties.Settings.Default.Properties.Cast <SettingsProperty>().Any(prop => prop.Name == "hostIP"))
                {
                    serverIP = (string)Properties.Settings.Default.Properties["hostIP"].DefaultValue;
                }
                else
                {
                    serverIP = "192.168.1.150";
                    SettingsProperty prop = new SettingsProperty("hostIP");
                    prop.PropertyType = typeof(string);
                    Properties.Settings.Default.Properties.Add(prop);
                    Properties.Settings.Default.Save();
                    Properties.Settings.Default.Properties["hostIP"].DefaultValue = serverIP;
                }


                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "HDrive bootLoader files (*.bin)|*.bin";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    Properties.Settings.Default.Properties["LastBootloaderFilePath"].DefaultValue = openFileDialog.FileName;
                    Properties.Settings.Default.Save();

                    _statusLabelText = "Uploading Boot loader...";

                    // Get IP-Address from list
                    String motorMAC = dataGridView.SelectedRows[0].Cells[1].Value.ToString();

                    // Connecto to HDrive
                    HDrive.HDrive h1 = new HDrive.HDrive(0, IPAddress.Parse(t.Name));
                    if (!h1.Connect(1000, (a) => { }, HDriveTicket.HDriveTicket))
                    {
                        _statusLabelText = "Could not connect to drive";
                        return;
                    }

                    // Enter bootLoader mode
                    h1.SwitchMode(SystemModes.BootloaderUpgrade);

                    // Run Bootloder-Update
                    try
                    {
                        Process uploader = System.Diagnostics.Process.Start("LMFlash.exe", " --quick-set=manual --interface=ethernet --net-config=" + serverIP + "," + t.Name + "," + motorMAC + " " + openFileDialog.FileName);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    // Release TCP connection to this drive
                    h1.Close();
                }
            }

            _statusLabelText = "Uploading Boot loader finished.";
        }