网站首页 > 基础教程 正文
在MBD的软件开发过程中,需要对模型及生成的代码进行版本管理。需要在MATLAB的Simulink的版本管理中撰写版本变更内容及版本号,可以更好的管理模型及功能开发生成的代码。今天主要是以实际的例子介绍Simulink模型的版本管理。
1.新建一个模型
在MATLAB中新建一个模型,根据实际的开发内容建立模型如图1和图2所示,建立一个低通滤波的子系统模型。
图1 新建Simulink模型
图2 低通滤波模型
图3 低通滤波子系统内部构建
2.查看模型的版本信息
在打开的Simulink模型的空白处,右键选择Model Properties属性,操作如图4所示。
图4 查看模型的版本信息
点击Info,可以查看和修改模型的版本信息,具体如图5所示。
1.Created by:模型创建的作者名称
2.Created on:模型创建的时间
3.Last saved by:模型上一次修改的作者名称
4.Last save on:模型上一次修改的时间
5.Model version:模块的版本号,此时可以修改。
图5 模型版本info
在图5中,取消勾线Read Only,即可修改模型的上述五种信息的内容,具体操作如6所示。例如修改模型的版本为1.0.0,之后点击Apply,即可修改模型的版本属性,修改之后可以勾选Read Only属性,之后点击Apply和Ok。
图6 可编辑版本信息属性
图7 修改模型属性
图8 版本信息设置保存
在修改好信息之后,点击模型时,在模型的预览窗口里面会显示模型的版本信息,具体如图9所示。
图9 模型的版本预览
可以在模型属性的Description中写上版本的变更内容,可以更好的将模型的变更范围确定,方便团队合作和开发后期的问题排查,具体操作如图10所示。
图10 模型的变更内容管理
3.生成代码
修改模型的配置,如图11和图12所示。
图11 模型的求解器配置
图12 模型生成代码配置
使用Embedded Coder生成嵌入式代码,具体操作如图13和图14所示。
图13 生成代码
图14 生成代码
此时生成的代码中的版本号则和在模型中设置的版本号一致,这样模型自动生成的代码和模型的版本号相关联起来,方便版本的变更管理和问题的排查,具体操作和结果如图15和图16所示。
图15 模型生成代码
图16 模型生成的程序文件清单
/*
* File: model_management.c
*
* Code generated for Simulink model 'model_management'.
*
* Model version : 1.0.0
* Simulink Coder version : 9.5 (R2021a) 14-Nov-2020
* C/C++ source code generated on : Sun Jul 7 15:31:00 2024
*
* Target selection: ert.tlc
* Embedded hardware selection: Intel->x86-64 (Windows64)
* Code generation objectives: Unspecified
* Validation result: Not run
*/
#include "model_management.h"
#include "model_management_private.h"
/* Real-time model */
static RT_MODEL_model_management_T model_management_M_;
RT_MODEL_model_management_T *const model_management_M = &model_management_M_;
/* Model step function */
void model_management_step(void)
{
/* Update absolute time for base rate */
/* The "clockTick0" counts the number of times the code of this task has
* been executed. The absolute time is the multiplication of "clockTick0"
* and "Timing.stepSize0". Size of "clockTick0" ensures timer will not
* overflow during the application lifespan selected.
*/
model_management_M->Timing.t[0] =
((time_T)(++model_management_M->Timing.clockTick0)) *
model_management_M->Timing.stepSize0;
{
/* Update absolute timer for sample time: [0.001s, 0.0s] */
/* The "clockTick1" counts the number of times the code of this task has
* been executed. The resolution of this integer timer is 0.001, which is the step size
* of the task. Size of "clockTick1" ensures timer will not overflow during the
* application lifespan selected.
*/
model_management_M->Timing.clockTick1++;
}
}
/* Model initialize function */
void model_management_initialize(void)
{
/* Registration code */
{
/* Setup solver object */
rtsiSetSimTimeStepPtr(&model_management_M->solverInfo,
&model_management_M->Timing.simTimeStep);
rtsiSetTPtr(&model_management_M->solverInfo, &rtmGetTPtr(model_management_M));
rtsiSetStepSizePtr(&model_management_M->solverInfo,
&model_management_M->Timing.stepSize0);
rtsiSetErrorStatusPtr(&model_management_M->solverInfo, (&rtmGetErrorStatus
(model_management_M)));
rtsiSetRTModelPtr(&model_management_M->solverInfo, model_management_M);
}
rtsiSetSimTimeStep(&model_management_M->solverInfo, MAJOR_TIME_STEP);
rtsiSetSolverName(&model_management_M->solverInfo,"FixedStepDiscrete");
rtmSetTPtr(model_management_M, &model_management_M->Timing.tArray[0]);
model_management_M->Timing.stepSize0 = 0.001;
}
/* Model terminate function */
void model_management_terminate(void)
{
/* (no terminate code required) */
}
/*
* File trailer for generated code.
*
* [EOF]
*/
当模型的内容变更时,我们需要及时的修改版本号,并在描述中记录变更的内容,方便进行及时的模型和代码进行同步。
本文内容来源于网络,仅供参考学习,如内容、图片有任何版权问题,请联系处理,24小时内删除。
作 者 | 郭志龙
编 辑 | 郭志龙
校 对 | 郭志龙
- 上一篇: 软件特攻队|C/C++程序员的自我修养(6)
- 下一篇: 超级好用的C++实用库之文件目录操作
猜你喜欢
- 2024-10-19 Python3 datetime模块指南:日期时间操作、时区管理与实战案例
- 2024-10-19 C++及数据结构复习笔记,类和对象很简单?为啥好多程序员还不会
- 2024-10-19 Linux时间和日期 linux 时间 表示方法
- 2024-10-19 C/C++的8种时间度量方式以及代码片段
- 2024-10-19 Python实战:使用 datetime模块处理时间日期的全方位指南
- 2024-10-19 C++编程的 42 条建议(四) c++编程100例
- 2024-10-19 mount with noatime - 合理关闭atime提高服务器性能
- 2024-10-19 linux下连续三次fork()——深度理解进程创建函数
- 2024-10-19 C函数time和clock的计时区别 c计时器函数
- 2024-10-19 win进程弹出Microsoft Visual C++ Runtime Library的解决办法
- 最近发表
- 标签列表
-
- gitpush (61)
- pythonif (68)
- location.href (57)
- tail-f (57)
- pythonifelse (59)
- deletesql (62)
- c++模板 (62)
- css3动画 (57)
- c#event (59)
- linuxgzip (68)
- 字符串连接 (73)
- nginx配置文件详解 (61)
- html标签 (69)
- c++初始化列表 (64)
- exec命令 (59)
- canvasfilltext (58)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- node教程 (59)
- console.table (62)
- c++time_t (58)
- phpcookie (58)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)