网站首页 > 技术文章 正文
在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小时内删除。
作 者 | 郭志龙
编 辑 | 郭志龙
校 对 | 郭志龙
猜你喜欢
- 2024-12-16 FFmpeg功能命令集合(超详细) ffmpeg 命令大全
- 2024-12-16 1.2 动态链接库与API 动态链接库原理
- 2024-12-16 QT开发经验详解 qt开发gui
- 2024-12-16 16k Star!一个开源的命令行视频播放器
- 2024-12-16 Qt多线程编程之QThread qt多线程例子
- 2024-12-16 「某CMS漏洞」SQL注入漏洞分析 sql注入漏洞代码
- 2024-12-16 「3.Lazarus执行外部程序」3.TProcess
- 2024-12-16 Qt开发-Qt中的多线程编程 qt如何写多个线程
- 2024-12-16 k8s系列-06-containerd的基本操作
- 2024-12-16 网易视频云技术分享:Android 消息机制学习
- 最近发表
- 标签列表
-
- cmd/c (90)
- c++中::是什么意思 (84)
- 标签用于 (71)
- 主键只能有一个吗 (77)
- c#console.writeline不显示 (95)
- pythoncase语句 (88)
- es6includes (74)
- sqlset (76)
- apt-getinstall-y (100)
- node_modules怎么生成 (87)
- chromepost (71)
- flexdirection (73)
- c++int转char (80)
- mysqlany_value (79)
- static函数和普通函数 (84)
- el-date-picker开始日期早于结束日期 (76)
- js判断是否是json字符串 (75)
- c语言min函数头文件 (77)
- asynccallback (87)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- 无效的列索引 (74)