使用 C# 对 zaber 阶段进行编程,但在我的“var speed”代码中出现空变量错误

问题描述

    using System;
    using zaber.Motion;
    using zaber.Motion.Ascii;
    namespace zaberMotion
    {

    class Program
     {
    static Axis x_axis;
    static Device device1;
   
      public static void Main(string[] args)
      {
        Library.EnableDeviceDbStore();

        using (var connection = Connection.OpenSerialPort("COM3"))
        {
            var deviceList = connection.DetectDevices();
            Console.WriteLine($"Found {deviceList.Length} devices.");
            


            var speed = x_axis.Settings.Get("maxspeed",Units.VeLocity_MillimetresPerSecond);

            Console.WriteLine("Maximum speed [mm/s]: {0}",speed);

            x_axis.Settings.Set("maxspeed",speed /9.0,Units.VeLocity_MillimetresPerSecond);

            }
         }
       }
      }

我得到了一个无功速度的空值。简单的错误我不确定如何解决。有小费吗?设备初始化,一切顺利

解决方法

您需要先定义设备和轴,然后才能获得轴的设置。

之后:

var deviceList = connection.DetectDevices();
Console.WriteLine($"Found {deviceList.Length} devices.");

包括:

device1 = deviceList[0];
x_axis = device1.GetAxis(1);

麦克麦克唐纳

Zaber 技术

mike@zaber.com

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...