使用C#对zaber阶段进行编程,但在我的代码中得到空变量错误;var速度“;

使用C#对zaber阶段进行编程,但在我的代码中得到空变量错误;var速度“;,c#,zaber,C#,Zaber,我得到的var速度值为空。简单的错误,我不知道如何修复。有什么建议吗?设备和所有设备的初始化成功您需要先定义设备和轴,然后才能获得轴的设置 之后: using System; using Zaber.Motion; using Zaber.Motion.Ascii; namespace ZaberMotion { class Program { static Axis x_axis; static Device devi

我得到的var速度值为空。简单的错误,我不知道如何修复。有什么建议吗?设备和所有设备的初始化成功

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

之后:

    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.");

麦克唐纳

扎伯技术公司


mike@zaber.com

x_轴有值吗?它是我在线性阶段上的运动轴应该是这样的,还是它实际上有一个非空值?我的x_轴是我的位置,可以容纳许多值这是x_轴的含义,但是你给它赋值了吗?我看不到你张贴的代码。我说的值不是“x=10”,而是Axis的一个实例
device1 = deviceList[0];
x_axis = device1.GetAxis(1);