当前位置: 首页 > news >正文

应急推进器和辅助推进器诊断函数封装

2025年6月21-22日工作日志


一、主要工作内容

  1. 诊断函数封装与优化

    • 初步完成了EMERGENCY_AUXILIARY_PROPULSION类的封装,统一管理主推进器的诊断逻辑和阈值配置。

    • 实现功能:

      • 时序检查:封装checkOutputTimingcheckFeedbackTiming,支持动态阈值配置。
      • 状态诊断:完成RPM、电压、电流、温度等参数的解析与状态检查(如checkRPMStatuscheckVoltageStatus)。
      • 故障检测:封装补偿器液位、伸缩机构状态、接近开关等故障检测逻辑(如checkFaultBits1Status)。
    • 新增功能:

      • 支持通过set/get方法动态调整阈值(如setTimingThresholds)。

      • 提供数据解析工具函数(如parseRPMparseVoltage)。

        #pragma once#include <cstdint>
        #include <string>
        #include <array>class MAIN_PROPULSION_CAN {
        public:// 阈值配置结构体struct TimingThresholds {int64_t output_no_response;    // 无输出阈值(微秒)int64_t output_too_fast;      // 输出过快阈值(微秒)int64_t output_too_slow;      // 输出过慢阈值(微秒)int64_t feedback_normal;      // 反馈正常阈值(微秒)int64_t feedback_slow;       // 反馈较慢阈值(微秒)int64_t feedback_no_response; // 无反馈阈值(微秒)};struct RPMThresholds {int16_t min_rpm;            // 最小转速int16_t max_rpm;            // 最大转速bool allow_negative;        // 是否允许负转速
        };struct VoltageThresholds {uint16_t min_voltage;      // 最小电压值 (0V)uint16_t max_voltage;      // 最大电压值 (根据实际系统设置)uint16_t high_voltage_threshold; // 高电压阈值
        };struct CurrentThresholds {uint16_t max_current;      // 最大电流值 (255A)
        };struct TemperatureThresholds {uint8_t max_motor_temp;    // 电机最高温度 (150℃)uint8_t max_driver_temp;   // 驱动器最高温度 (150℃)
        };// 阈值设置
        static void setTimingThresholds(const TimingThresholds& thresholds);
        static void setRPMThresholds(const RPMThresholds& thresholds);
        static void setVoltageThresholds(const VoltageThresholds& thresholds);
        static void setCurrentThresholds(const CurrentThresholds& thresholds);
        static void setTemperatureThresholds(const TemperatureThresholds& thresholds);// 阈值获取
        static TimingThresholds getCurrentThresholds();
        static RPMThresholds getCurrentRPMThresholds();
        static VoltageThresholds getCurrentVoltageThresholds();
        static CurrentThresholds getCurrentCurrentThresholds();
        static TemperatureThresholds getCurrentTemperatureThresholds();// 状态检查
        static int checkOutputTiming(int64_t timeInterval);
        static int checkFeedbackTiming(int64_t timeBack);
        static bool checkRPM(int16_t rpm, std::string& message);
        static int checkRPMStatus(const uint8_t* data, size_t offset);// 数据解析
        static int16_t parseRPM(const uint8_t* data, size_t offset);
        static uint16_t parseVoltage(const uint8_t data[], size_t offset);
        static uint8_t parseCurrent(const uint8_t data[], size_t offset);
        static uint8_t parseMotorTemperature(const uint8_t data[], size_t offset);
        static uint8_t parseDriverTemperature(const uint8_t data[], size_t offset);// 状态检查
        static int checkVoltageStatus(const uint8_t data[], size_t offset);
        static int checkCurrentStatus(const uint8_t data[], size_t offset);
        static int checkMotorTempStatus(const uint8_t data[],size_t motor_temp_offset);
        static int checkDriverTempStatus(const uint8_t data[],size_t driver_temp_offset);//320223
        // 状态反馈帧处理
        static uint8_t parseCompensatorLevel(const uint8_t* data, size_t offset);
        static uint8_t parseExtensionStatus(const uint8_t* data, size_t offset);
        static uint8_t parseProximitySwitches(const uint8_t* data, size_t offset);
        static uint8_t parseFaultBits1(const uint8_t* data, size_t offset);
        static uint8_t parseFaultBits2(const uint8_t* data, size_t offset);// 状态检查
        static int checkCompensatorLevelStatus(const uint8_t* data, size_t offset);
        static int checkExtensionStatus(const uint8_t* data, size_t offset);
        static int checkProximitySwitchesStatus(const uint8_t* data, size_t offset);
        static int checkFaultBits1Status(const uint8_t* data, size_t offset);
        static int checkFaultBits2Status(const uint8_t* data, size_t offset);private:static TimingThresholds currentTimingThresholds;static RPMThresholds currentRPMThresholds;static VoltageThresholds currentVoltageThresholds;static CurrentThresholds currentCurrentThresholds;static TemperatureThresholds currentTemperatureThresholds;
        };
        
  2. 辅助推进器与应急推进器封装

    • 初步完成EMERGENCY_AUXILIARY_PROPULSION_CAN类的封装。
    • 复用主推进器的诊断逻辑,调整部分阈值和状态检查规则(如应急推进器的RPM允许范围更广)。
  3. 代码可移植性改进

    • 将硬件相关参数(如CAN接口名称、缓冲区大小)通过常量定义集中管理。
    • 使用标准C++库(如<array><chrono>)替代平台特定代码。

二、代码修改示例(关键部分)

1. 诊断函数调用优化
// 原代码(分散调用)
Result_Buffer[i][packetIndex][8] = checkRPMStatus(g1_packet_buffer[i][packetIndex].data(), 26);
Result_Buffer[i][packetIndex][14] = checkVoltageStatus(g1_packet_buffer[i][packetIndex].data(), 30);// 封装后(通过类方法调用)
Result_Buffer[i][packetIndex][8] = MAIN_PROPULSION_CAN::checkRPMStatus(data, offset);
Result_Buffer[i][packetIndex][14] = MAIN_PROPULSION_CAN::checkVoltageStatus(data, offset);
2. 阈值动态配置示例
// 动态调整主推进器RPM阈值
MAIN_PROPULSION_CAN::RPMThresholds rpmThresholds = {-3000, 3000, true};
MAIN_PROPULSION_CAN::setRPMThresholds(rpmThresholds);

三、存在问题与下一步计划

  1. 未验证内容

    • 应急推进器封装代码(EMERGENCY_AUXILIARY_PROPULSION_CAN)尚未测试,可能存在阈值或解析逻辑错误。
    • 多线程环境下阈值动态调整的线程安全性需验证。
  2. 下一步任务

    • 验证可行性
      • 搭建测试环境,模拟CAN数据输入,验证应急推进器诊断逻辑的正确性。
      • 检查动态阈值修改是否实时生效。
    • 性能测试
      • 评估高负载下缓冲区(g_packet_buffer)的处理延迟。
    • 日志增强
      • 在诊断函数中添加详细错误日志输出,便于问题追踪。

四、其他备注

  • 提交代码至Git仓库,分支:feature/diagnostic-encapsulation
  • 进一步验证可行性。

作者wjj
联系方式:1816387198@qq.com


凡人修仙传:总会有办法的,他们世世代代生活在这里,毕竟凡人最擅长的就是坚强的活着。


http://www.lqws.cn/news/482437.html

相关文章:

  • 媒体AI关键技术研究
  • linux----------------进程VS线程
  • 零基础学习Redis(14) -- Spring中使用Redis
  • RA4M2开发IOT(9)----动态显示MEMS数据
  • 深入理解Spring MVC:构建灵活Web应用的基石
  • 【SQL语法汇总】
  • Python 商务数据分析—— NumPy 学习笔记Ⅰ
  • 由浅入深详解前缀树-Trie树
  • 数智管理学(二十四)
  • Flink Connector Kafka深度剖析与进阶实践指南
  • ELMo 说明解析及用法
  • Netty Channel 详解
  • 【递归,搜索与回溯算法】记忆化搜索(二)
  • 【CSS】CSS3媒体查询全攻略
  • 基于Vue.js的图书管理系统前端界面设计
  • 【分布式技术】Bearer Token以及MAC Token深入理解
  • 大模型应用:如何使用Langchain+Qwen部署一套Rag检索系统
  • 制造业B端登录页案例:生产数据安全入口的权限分级设计
  • AMAT P5000 CVDFDT CVDMAINT Precision 5000 Mark 操作 电气原理 PCB图 电路图等
  • 【Datawhale组队学习202506】YOLO-Master task03 IOU总结
  • 防御悬垂指针:C++的多维度安全实践指南
  • 【前后前】导入Excel文件闭环模型:Vue3前端上传Excel文件,【Java后端接收、解析、返回数据】,Vue3前端接收展示数据
  • hot100 -- 16.多维动态规划
  • 分布式ID生成方式及优缺点详解
  • Azure Devops
  • 时序数据库IoTDB的架构、安装启动方法与数据模式总结
  • 在线法律服务平台、AI法律问答、律师管理、案件管理、聊天、法律博客
  • ollama + dify 搭建本地知识库
  • MongoDB 8.0.10 windows11安装记录
  • Golang 中接口嵌套的详细说明和使用示例