我想创建一个控制 Gocator 相机的 C# WPF SDK 应用程序。
当我将我的 SDK 应用程序 C# 与 GOCATOR 连接时,没有任何问题。但如果我尝试将同一应用程序与 GOCATOR ACCELERATOR 连接,应用程序将返回 -999 未定义错误。
我的GOCATOR IP是XXX.XXX.0.5,加速器的IP是XXX.XXX.0.145。我最后用它来连接 SDK 和 gocator(在加速器模式下)。我也尝试过与第一个,但结果是一样的。我也使用了所有通信协议,但没有任何积极结果。
我从示例中获取了代码。
public static void Accelerated () {
try {
KApiLib.Construct();
GoSdkLib.Construct();
Variables.System = new GoSystem();
Variables.Accelerator = new GoAccelerator();
Variables.IpAddress = KIpAddress.Parse(Constants.SENSOR_IP);
Variables.DataSet = new GoDataSet();
Variables.Accelerator.WebPort = Constants.WEB_PORT;
Variables.Accelerator.Start();
Variables.Sensor = Variables.System.FindSensorByIpAddress(Variables.IpAddress);
Variables.Accelerator.Attach(Variables.Sensor);
Variables.Sensor.Connect();
Console.WriteLine("Camera connected with ACCELERATOR.");
Variables.System.EnableData(true);
Variables.System.Start();
// Refer to <<SetupMeasurement.cs>> for setting up of the measurement tools.
Variables.DataSet = Variables.System.ReceiveData(30_000_000);
}
catch (Exception e) {
Exception(e);
}
}
此代码返回错误:
ERROR:
A problem has ocurred while attempting to establish a connection with the Gocator camera.
Error code: Lmi3d.Zen.KException: A Zen API error occurred (Error Not Found, -999).
en Lmi3d.Zen.Utils.Internal.KInternalUtils.Check(Int32 status)
en Lmi3d.GoSdk.GoSystem.FindSensorByIpAddress(KIpAddress address)
en Continental.Gocator.Accelerated() en D:\Projectes\4795_Continental\Programes\Continental\Continental\Gocator.cs:línea 73
Error message: A Zen API error occurred (Error Not Found, -999).
有什么想法吗?
谢谢!
经过与gocator厂家沟通,多次尝试,找到了解决方案。
由于我的无知,我犯了一些错误:
如果我们使用SDK,Gocator加速器必须处于停止模式
不可能有多个加速器正在运行。如果我为此使用特定程序,我将不会使用SDK加速器模式,反之亦然。错误代码对于这个问题非常具体,snif。
制造商对此没有具体说明:
- 在 SDK 中使用 IP 地址 127.0.0.1 i.s.o XXX.XXX.0.145
- 转到 Gocator 加速器。停止加速。在 IP 地址字段中选择“任意”。 XXX.XXX.0.145。然后再次启动加速并再次尝试使用127.0.0.1连接SDK。
我的代码在某些情况下是杂乱的,更新后的代码是:
try {
KApiLib.Construct();
GoSdkLib.Construct();
Variables.System = new GoSystem();
Variables.Accelerator = new GoAccelerator();
Variables.IpAddress = KIpAddress.Parse(Constants.SENSOR_IP);
Variables.DataSet = new GoDataSet();
Variables.Accelerator.WebPort = Constants.WEB_PORT;
Variables.Accelerator.Start();
Variables.Sensor = Variables.System.FindSensorById(Constants.ID);
Variables.Accelerator.Attach(Variables.Sensor);
Variables.Sensor.Connect();
Variables.System.EnableData(true);
Variables.System.Start();
Variables.DataSet = Variables.System.ReceiveData(30_000_000);
Variables.Collection_tools = Variables.Sensor.Tools;
ReadMessage();
}
catch (Exception e) {
return Exception(e);
}
finally {
Variables.System.Stop();
Variables.Accelerator.Stop();
Console.WriteLine("Finally");
}
return 0;
协议必须是GOCATOR。
目前这一切对我来说都有效。尽管如此,我愿意接受新的建议。