嵌入式编程模型 | 建造者模式

一、建造者模式

建造者模式(Builder Pattern)属于对象创建型模式,它将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。

通过将复杂对象的构造过程抽象出来,使用统一的构建接口来构建不同配置的对象,实现构建与表示的解耦。

在嵌入式系统中,该模式尤其适用于:

  • 复杂设备初始化
  • 多配置硬件抽象
  • 分步骤资源配置

建造者模式核心结构包含如下部分:

  • 产品类(Product):被构建的复杂对象
  • 抽象建造者(Builder):定义构建产品的抽象接口
  • 具体建造者(Concrete Builder):实现抽象建造者接口,构建具体产品
  • 指挥者(Director):调用建造者来构建产品,控制构建过程

二、嵌入式应用案例

1、嵌入式设备配置框图

C++实现5G协议数据包封装:高性能网络编程与协议栈解析实战 在网络编程与通信协议开发中,数据包构造与解析是核心基础技术,其原理涉及字节序处理、位域操作和协议字段编码。通过精确控制内存布局和序列化过程,可以实现高性能、低延迟的数据处理,这对于5G网络仿真、协议分析工具和边缘计算场景具有重要技术价值。本文聚焦于使用C++实现轻量级5G协议数据包封装类,深入探讨了**位域映射**和**网络字节序**处理等关键实现细节,为开发网络模拟器、测试工具及底层通信模块提供了实用的工程实践参考。 阅读详情

相关推荐

android嵌入式开发环境搭建,2024最新腾讯Android面试分享

AndroidAndroid各个版本的特性(例如6.0,动态权限)ANR的原因Android中进程间通信的方式和对比AsyncTask的实现原理及优缺点Handler机制自定义view三部曲,流程(或者实际场景题,例如实现一个表盘,怎么做)FrameWork层次结构Activity生命周期(A跳转到B,A和B中生命周期的执行顺序)Dvlik、ART、JVM三种虚拟机的区别能不能在非UI线程更新UIService和IntentService的区别。

2401_84414990的博客 1352

【嵌入式】【科普】设计模式思维导图

设计模式

孙中奇 901

嵌入式C语言设计模式 --- 前言

重构嵌入式 C 语言开发的思维模式

EmbedIoT Studio 1605

嵌入式C设计模式---前言

设计模式解决系统设计问题;高效率、高质量、低风险的应对各种各类变化;关注“抽象”和“隔离”。

weixin_42162924的博客 1133

Qt HTTP客户端工程化封装:从QNetworkAccessManager到高可用网络层设计

HTTP客户端是连接应用与后端服务的核心组件,其设计质量直接影响应用的稳定性和开发效率。在Qt框架中,QNetworkAccessManager提供了基础的HTTP能力,但在工程实践中,直接使用它常面临异步回调嵌套、生命周期管理复杂、代码重复和可测试性差等挑战。通过引入建造者模式、拦截器链和Promise/Future等设计模式,可以将网络请求模块化、可配置化,实现统一的错误处理、日志记录和认证管理。这种工程化封装的价值在于提升代码可维护性、增强应用健壮性,并支持团队协作规范。在桌面应用、嵌入式系统及需要频

weixin_33563728的博客 293

关键词‖旋变传感器

旋转变压器(以下简称旋变)安装在永磁同步驱动电机的非传动端,其作用是检测转子的位置和速度。目前,通常采采用结构简单、坚固耐用、环境适应性好的磁阻式旋变作为位置传感器。

m0_72345077的博客 2166

单片机欠压保护、欠压复位的用法及作用

一. 前言 使用编程环境 :KEIL mdk4 单片机 : NRF24LE1   二. 分析 查询各开发芯片的数据手册,一般在电源管理或者复位设置章节中。以下NRF24LE1为例: Power supply supervisor(电源监控): 电源主管在开机时对系统进行初始化,对即将发生的情况提供预警当电源电压过低而不能安全运行时,系统处于复位状态。 电源管理框图如下:   ...

城南花已开的博客 8404

解决MATLAB2020B关于找不到vs2019C++编译器问题

解决MATLAB2020B关于找不到vs2019C++编译器问题

wcm2577的博客 7610

Proteus仿真实战:基于IIC驱动SSD1306的0.96英寸OLED显示方案解析

本文详细解析了在Proteus仿真环境中基于IIC驱动SSD1306的0.96英寸OLED显示方案。从硬件搭建、IIC接口连接、软件驱动移植到常见问题排查,提供了全面的实战指导,帮助开发者快速实现OLED显示功能并优化性能。

weixin_28724661的博客 781

实验记录 | 如何拆分scATAC-seq数据成为单个细胞?(1、解决barcode问题)

在师兄的帮助下,我得到了师兄筛选过的细胞的barcode的数据,那么接下来我想根据这些barcode,将来源于同一个barcode的细胞的reads提取出来,这个还是一个蛮有技术含量的事情的,因为上次我有使用过perl的脚本进行提取,最后的实验结果很糟糕,故而这件事情一直搁置到现在,没有继续去做(我的脚本的编写能力还是有待于加强,可能是刚刚喝了奶茶,和老妈弟弟聊了好多闲话,很开心,觉得在某种程度上休息够了,对于工作也是一种非常快乐和积极的状态了)。 0。前期失败尝试回顾 ...

weixin_40640700的博客 1890

Qt代码-软件商店

ui->statusBar->showMessage(QString("%1 已卸载").arg(app["name"].toString()));ui->statusBar->showMessage(QString("开始下载 %1...").arg(app["name"].toString()));QString("%1 已下载完成,是否立即安装?ui->statusBar->showMessage(QString("%1 下载完成").arg(app["name"].toString()));

寒寒豆豆软件公司的博客 117

备战2025数学建模国赛(算法46):多目标优化

本篇博客将深入浅出地介绍多目标优化的核心概念、主流算法,并重点结合一个数学建模竞赛的经典案例,提供完整的Python代码实现,助你在未来的竞赛中游刃有余。它通过寻找帕累托最优解集,完美地诠释了“鱼与熊掌不可兼得”的权衡思想,为最终决策提供科学依据。这些问题都包含多个相互冲突的目标,传统的单目标优化方法(如梯度下降、单纯形法)对此无能为力,因为它们无法同时优化多个目标。在数学建模竞赛中,我们面临的绝大多数问题都不是单一的“最好”,而是充满权衡与妥协的“最优”。记住,成功的建模不仅在于解出问题,更在于清晰地。

YOLO 289

NVIDIA Isaac ROS - 入门教程(一)

欢迎访问 Isaac ROS,这是一套硬件加速、高性能、低延迟的 ROS 2 软件包,用于制造自主机器人,充分利用 Jetson 和其他英伟达平台的强大功能。英伟达 Jetson 平台运行在基于 Ubuntu Linux 的 JetPack 操作系统上。JetPack 5.x 是在 Ubuntu 20.04 Focal 的基础上构建的,这意味着由 ROS 2 Buildfarm 为 Ubuntu 22.04 Jammy 构建的 ROS 2 Humble 的 Debian 包不受支持。由于官方 ROS 2 B

机器人控制与仿真应用 5728

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

上一篇: 嵌入式编程模型 | 数据驱动编程
下一篇: 嵌入式编程模型 | 原型模式
嵌入式大杂烩
博客等级 码龄10年 4321粉丝 461原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式大杂烩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址