fprime-component-implementation
它能做什么
它指导 AI 填充已批准 FPP 模型所生成的处理函数。适用于为 F Prime 组件编写 C++ 代码的工程师。
适用场景
- ✓当 F Prime 组件的 FPP 模型已获批准,需要编写 C++ 代码时。
- ✓当你需要为组件填充命令或端口处理函数时。
- ✓当你希望 C++ 代码遵循 F Prime 的风格和设计规则时。
技能链接
https://github.com/nasa/fprime/blob/devel/.github/skills/fprime-component-implementation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“FPP 模型已获批准。请帮我为这个 F Prime 组件编写 C++ 处理函数。”
每周 5 个新技能,1 分钟读完。
工作原理
AI 会在组件自身的类中实现这些自动生成的处理函数,并遵循 F Prime 的风格指南和设计规则。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Skill: F Prime Component Implementation (C++)
Implementation fills in the handler stubs generated from the FPP model. The autocoder produces base classes with pure-virtual handlers; you implement the derived class.
For the full reference on autocoded functions (port handlers, command handlers, telemetry, events, parameters, initialization), see Autocoded Functions and Component Classes.
Use F Prime design patterns where possible — standard solutions exist for common needs:
- Rate Group Pattern —
docs/user-manual/design-patterns/rate-group.md - Health Checking —
docs/user-manual/design-patterns/health-checking.md - Manager-Worker —
docs/user-manual/design-patterns/manager-worker.md - Application-Manager-Driver —
docs/user-manual/design-patterns/app-man-drv.md - Common Port Patterns —
docs/user-manual/design-patterns/common-port-patterns.md
Follow F Prime Style Guidelines for naming and code style.
Prerequisites
The FPP model must be confirmed (see
fprime-component-design-fpp) and C++ design rules
(fprime-cpp-design, CPP-1 through CPP-37) are mandatory.
The confirmed requirements and FPP model should provide all the
information needed for implementation.
Step-by-Step Process
Step 1 — Generate Implementation Stubs
fprime-util impl
This produces <Component>-template.cpp and <Component>-template.hpp
files. If this is the first time:
mv <Component>-template.cpp <Component>.cpp
mv <Component>-template.hpp <Component>.hpp
If iterating on an existing design, copy new handler stubs from the template into your existing files.
Step 2 — Implement Handlers
Implement all pure-virtual handlers generated from the FPP model. See Autocoded Functions for handler naming conventions, argument types, and the full API provided by the base class.
Key rules to follow during implementation:
- No dynamic memory after construction (CPP-1) — size all arrays at compile time
- Fixed-size types:
U32,FwSizeType, etc. (CPP-3, CPP-28) - No STL containers — use
Fw/DataStructuresor fixed arrays (CPP-22, CPP-25) - No
FW_ASSERTon untrusted inputs (CPP-4) — validate and return an error response instead - All variables initialized (CPP-19)
Fw::Stringoverchar*(CPP-24)- Every command handler must call
cmdResponse_out— omitting it hangs the command in the dispatcher - Events for each command (CPP-37) — add an event that describes what the command did, including the command arguments. This is frequently forgotten and is very useful for recreating what happened.
- One event emission per call site (CPP-36) — never emit the same event with the same argument set from two places; use a distinct event or a site-identifying argument.
- Mark copy/move as deleted for components (CPP-17)
Step 3 — Build and Fix Errors
fprime-util build
Iterate until compilation succeeds. Common issues:
- Missing
#includefor types used in handlers - Incorrect argument types (check the generated base class)
- Missing
cmdResponse_outcall in command handlers
Step 4 — Review Against C++ Design Rules
Before considering implementation complete, verify compliance with
fprime-cpp-design (CPP-1 through CPP-37).
Anti-Patterns
- Using
FW_ASSERTon command arguments or hardware inputs - Forgetting
cmdResponse_out(command will hang in dispatcher) - Command handlers that emit no event describing what the command did (CPP-37)
- The same event emitted from several sites with indistinguishable arguments (CPP-36)
- Using
new/deletein handler code - Using
std::string,std::vector, or other STL containers - Leaving member variables uninitialized
- Implementing behavior not covered by a requirement
常见问题
处理函数是什么?
自动代码生成器会生成它们作为桩函数,你需要填入组件的实际行为。
代码必须遵循哪些规则?
该技能说明,F Prime C++ 设计规则在实现中是强制性的。
我可以跳过 FPP 模型吗?
不可以。该技能要求在开始实现之前,先确认 FPP 模型。
详情
作者的原始描述
C++ implementation phase of F Prime component development. Guides the agent through implementing handler functions generated from the FPP model. Must follow fprime-cpp-design rules (CPP-1 through CPP-37). Trigger when the FPP model is confirmed and the next step is to write the C++ implementation. Keywords: F Prime, C++, implementation, handler, component, flight software, autocoded.
repo: nasa/fprime
热度
- GitHub 星标
- 12k
- 排名
- #11496
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
fprime-cmake-build-system
12k帮你的智能体通过 F Prime 项目的 CMake 层,为飞行软件项目添加模块、构建目标和平台设置。
fprime-component-design-fpp
12k帮你的智能体把已批准的 F Prime 组件需求,转化为一个描述其端口、命令、事件和遥测的 FPP 模型。
fprime-component-development
12k帮你的智能体引导 F Prime 组件经历每个开发阶段,从需求一直到集成测试。
fprime-component-integration-test
12k帮你的智能体为 F Prime 组件编写可复用的 pytest 集成测试,并在实时部署环境中运行。