/// <summary> /// 拧紧机消息接收 /// </summary> /// <param name="msg"></param> private void OnTightenMessage(OpMessage msg) { try { _logger.Info($"接收到拧紧机信息{msg.SequenceNumber}"); if (msg.SequenceNumber == 0061)//SequenceNumber就是Mid { client.LastTighteningResultDataAcknowledge(); ReadLastTightenData(msg); } else if (msg.SequenceNumber == 0052) { client.VehicleIdNumberAcknowledge(); string vinnumber = msg.Get <string>("VinNumber").Trim(); ReadVinNumber(vinnumber); } else if (msg.SequenceNumber == 0005) { _logger.Debug("接收到拧紧机0005消息,消息体含命令:" + msg.Get <string>("MidAccepted")); } } catch (Exception ex) { _logger.Error("OnTightenMessage", ex); } }
/// <summary> /// 读取拧紧数据 /// </summary> /// <param name="msg"></param> private void ReadLastTightenData(OpMessage msg) { try { TighteningResultModel result = new TighteningResultModel(); result.EngineCode = msg.Get <string>("VinNumber").Trim(); result.Torque = !decimal.TryParse(msg.Get <string>("Torque"), out decimal torque) ? -1 : torque / 100.0m; result.Angle = !decimal.TryParse(msg.Get <string>("Angle"), out decimal angle) ? -1 : angle; result.Result = !int.TryParse(msg.Get <string>("TighteningStatus"), out int status3) ? -1 : status3; result.ResultTime = result.CreateTime = DateTime.Now; DisplayData(result); SaveTightenData(result); } catch (Exception ex) { _logger.Error("ReadLastTightenData", ex); } }