具体健康信息ID要在官方文档中查找health的ID值
public bool GoLoad()//加载Gocator
{
uint SensorID = uint.Parse(SystemParams.Camera3D.Foam.LMI3DFoamCameraSensorID);
KApiLib.Construct();
GoSdkLib.Construct();
system = new GoSystem();
dataSet = new GoDataSet();
try
{
sensor = system.FindSensorById(SensorID);//指定传感器的ID连接
// KIpAddress ipAddress = KIpAddress.Parse(ip);//指定传感器ip地址连接
if (sensor.State == GoState.Running)
{
sensor.Stop();
sensor.Disconnect();
};
sensor.Connect();
EncoderResolution = sensor.Transform.EncoderResolution;
TireInsideLength = sensor.Setup.GetSurfaceGeneration().FixedLengthLength;
// Debug.WriteLine($" GoMode.Surface; {GoMode.Surface}");
system.EnableData(true);//数据通道使能
system.SetDataHandler(onData);//异步接受数据
system.SetHealthHandler(onHealthData);
isGoLoad = true;
}
catch (Exception ex)
{
Log.Logger.Error($" 初始化失败!SensorID = {SensorID} Msg = {ex.Message}");
return false;
}
Log.Logger.Debug(" 初始化成功 SensorID=[{SensorID}] ", SensorID);
return true;
}
public static async void onHealthData(KObject data)
{
// Log.Logger.Debug($"接收3D涂胶相机onHealthData数据 ");
try
{
DataContext context = new DataContext();
GoDataSet dataSet = (GoDataSet)data;
for (UInt32 i = 0; i < dataSet.Count; i++)
{
GoHealthMsg dataObj = (GoHealthMsg)dataSet.Get(i);
for (UInt32 j = 0; j < dataObj.Count; j++)
{
GoIndicator gi = dataObj.Get(j);
if (gi.id == 1003)
{
if (EncoderValue != gi.value)
{
isSendEncoderValue = true;
EncoderValue = gi.value;
Log.Logger.Debug($" 编码器当前值 [{gi.value}] ");
foam3DEncoderModel.Value = EncoderValue.ToString();
foam3DEncoderModel.Msg = "工作中";
SignalRClient.GetInstance().SendMsg(GlobalConst.SignalRUser.Camera3DFoamEncoder, JsonConvert.SerializeObject(foam3DEncoderModel));
}
else
{
if (isSendEncoderValue)
{
isSendEncoderValue = false;
foam3DEncoderModel.Value = EncoderValue.ToString();
foam3DEncoderModel.Msg = "空闲中";
SignalRClient.GetInstance().SendMsg(GlobalConst.SignalRUser.Camera3DFoamEncoder, JsonConvert.SerializeObject(foam3DEncoderModel));
}
}
}
//if (gi.id == 2017)
//{
// Log.Logger.Debug($"uptiem = {gi.value} ");
//}
}
}
}
catch (Exception ex)
{
Log.Logger.Error($" onHealthData 出现异常 {ex.Message} ");
}
}