gocator获取系统健康信息

具体健康信息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} ");
           } 
       }

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值