Question
Can I accelerate two different, non-buddied sensors in the same SDK script?
Answer
Sensor Model | G2xxx |
Firmware Version | 3.x, 4.x, 5x, 6x |
SDK Version | 6.1-6.3 |
Yes this is possible to do with the Gocator SDK. This article will outline how to accelerate multiple line profiler sensor’s (not buddied) while using the SDK.
For the SDK initial setup for our sensors please see the below video.
https://www.youtube.com/watch?v=Gh9qfK0Nz5A'
The segment of code below is what we will use to accelerate two sensors from the SDK separately. This code is for C# and we will want to copy paste this code into the AcceleratorRecieveMeasurement.cs example present in the C# sample code folder.
/*
* AcceleratorReceiveMeasurement.cs
*
* Gocator 2000 Sample
* Copyright (C) 2011-2019 by LMI Technologies Inc.
*
* Licensed under The MIT License.
* Redistributions of files must retain the above copyright notice.
*
* Purpose: Demonstrates the simple use of the Accelerator by connecting to a sensor and receiving a measurement.
* This allows processing to be performed on the PC rather than on the sensor.
*/
using System;
using Lmi3d.GoSdk;
using Lmi3d.Zen;
using Lmi3d.Zen.Io;
using Lmi3d.GoSdk.Messages;
using Lmi3d.GoSdk.AcceleratorMgr;
using System.Threading;
static class Constants
{
public const string SENSOR_IP1 = "192.168.1.12"; // IP of the sensor used for sensor connection GoSystem_FindSensorByIpAddress() call.
public const string SENSOR_IP2 = "192.168.1.15"; // IP of sensor 2
}
namespace AcceleratorReceiveMeasurement
{
class AcceleratorReceiveMeasurement
{
static int Main(string[] args)
{
try
{
KApiLib.Construct();
GoSdkLib.Construct();
GoSystem system = new GoSystem();
GoSensor sensor1, sensor2;
KIpAddress ipAddress1 = KIpAddress.Parse(Constants.SENSOR_IP1);
KIpAddress ipAddress2 = KIpAddress.Parse(Constants.SENSOR_IP2);
GoDataSet dataSet = new GoDataSet();
sensor1 = system.FindSensorByIpAddress(ipAddress1);
sensor2 = system.FindSensorByIpAddress(ipAddress2);
GoAcceleratorMgr goAcceleratorMgr = new GoAcceleratorMgr();
// create connection to system
goAcceleratorMgr.SetSystem(system);
// start Accelerator manager
goAcceleratorMgr.Start();
//Set Parameters for Acceleration
GoAcceleratorMgrSensorParam goAcceleratorMgrSensorParam1 = new GoAcceleratorMgrSensorParam();
GoAccelSensorPortAllocPorts ports1 = new GoAccelSensorPortAllocPorts();
GoAcceleratorMgrSensorParam goAcceleratorMgrSensorParam2 = new GoAcceleratorMgrSensorParam();
GoAccelSensorPortAllocPorts ports2 = new GoAccelSensorPortAllocPorts();
goAcceleratorMgrSensorParam1.PlatformIpAddress = KIpAddress.AnyV4;
goAcceleratorMgrSensorParam1.Ports = ports1;
goAcceleratorMgrSensorParam2.PlatformIpAddress = KIpAddress.AnyV4;
goAcceleratorMgrSensorParam2.Ports = ports2;
//Accelerate two sensors
goAcceleratorMgr.Accelerate(sensor1.Id, goAcceleratorMgrSensorParam1);
goAcceleratorMgr.Accelerate(sensor2.Id, goAcceleratorMgrSensorParam2);
//Check accelerated status of sensor1
for (UInt32 i = 0; i < 30; i++)
{
GoSensorAccelState kStatus1 = sensor1.AccelerationState;
if (kStatus1 == 2)
{
Console.WriteLine("Sensor1 Accelerated");
break;
}
else
{
Console.WriteLine("Waiting for Sensor1 Accelerated...");
}
Thread.Sleep(1000);
}
//Check accelerated status of sensor2
for (UInt32 i = 0; i < 30; i++)
{
GoSensorAccelState kStatus2 = sensor2.AccelerationState;
if (kStatus2 == 2)
{
Console.WriteLine("Sensor2 Accelerated");
break;
}
else
{
Console.WriteLine("Waiting for Sensor2 Accelerated...");
}
Thread.Sleep(1000);
}
system.Refresh();
sensor1.Connect();
sensor2.Connect();
system.EnableData(true);
system.Start();
// refer to SetupMeasurement.cs for setting up of the measurement tools
dataSet = system.ReceiveData(300000);
for (uint i = 0; i < dataSet.Count; i++)
{
GoDataMsg dataObj = (GoDataMsg)dataSet.Get(i);
switch (dataObj.MessageType)
{
case GoDataMessageType.Stamp:
{
GoStampMsg stampMsg = (GoStampMsg)dataObj;
for (uint j = 0; j < stampMsg.Count; j++)
{
GoStamp stamp = stampMsg.Get(j);
Console.WriteLine("Frame Index = {0}", stamp.FrameIndex);
Console.WriteLine("Time Stamp = {0}", stamp.Timestamp);
Console.WriteLine("Encoder Value = {0}", stamp.Encoder);
}
}
break;
case GoDataMessageType.Measurement:
{
GoMeasurementMsg measurementMsg = (GoMeasurementMsg)dataObj;
for (uint k = 0; k < measurementMsg.Count; ++k)
{
GoMeasurementData measurementData = measurementMsg.Get(k);
Console.WriteLine("ID: {0}", measurementMsg.Id);
Console.WriteLine("Value: {0}", measurementData.Value);
Console.WriteLine("Decision: {0}", measurementData.Decision);
}
}
break;
}
}
system.Stop();
//stop acceleration
goAcceleratorMgr.Decelerate(sensor1.Id);
goAcceleratorMgr.Decelerate(sensor2.Id);
}
catch (KException ex)
{
Console.WriteLine("Error: {0}", ex.ToString());
}
// wait for ENTER key
Console.WriteLine("\nPress ENTER to continue");
while (Console.ReadKey().Key != ConsoleKey.Enter) { }
return 1;
}
}
}
This code will most likely not run out of the box depending on your references. If we need to adjust the references then you will be greeted with this error "-989":
In order to get rid of this error we need to do two things. First, we must recompile the GoSdk-2019. This can be found at the following directory in the SDK:
Once this solution is open rebuild it:
At this point we are going to move some of the generated files. File will be generated to the following directory:
We are going to copy all files out of this directory and copy them into the directory present in the C# samples folder called bin->win64d.
The final product should look something like this.
We are then going to manually reference two specific .dlls files out of this folder. First go to the AcceleratorRecieveMeasurement project in visual studio and go to references. Right click and click add reference:
From there click browse:
Then go to the bin->Win64d folder present in the C# samples. The same folder we copied files into.
The two files we want to reference out of this folder are as follows:
After adding these files click "OK". Then our references for AcceleratorRecieveMeasurement should now look like the below image. You may have to remove the previous references to these files if they were already present before we added the new ones.
At this point we should be able to run the program and accelerate two separate, non-buddies sensors:
A few things to note regarding troubleshooting if it is not working.
1. Ensure we have the correct IP address set for both sensors.
2. Make sure there are no firewall restrictions that are present on your computer.
3. Both sensors need to be powered on able to transmit data via Goctor protocol.
To be able to distinguish the data that is being sent over from these two sensors is based on the ID number of the device. This way we know which data came from which sensor as the SDK is receiving it.
Comments
0 comments
Please sign in to leave a comment.