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

MongoDB在自动化设备上的应用示例

发现MongoDB特别适合自动化检测数据的存储。。。

例如一个晶圆检测项目,定义其数据结构如下

#pragma once
#include <vector>
#include <QString>
#include <QRectF>
#include <string>
#include <memory>class tpoWafer;
class tpoDie;
class tpoDefect;class tpoWafer
{
public:std::vector<std::shared_ptr<tpoDie>>Layouts; //晶圆的layoutQRectF MaskArea;QString WaferID;QString BatchID;QString ProductID;QString StepID;QString LotID;QString EqpID;QString UnitID;QString OperatorID;QString RecipeName;QString RecipeID;int TotalDie;int OKDie;int NGDie;int TotalDefect;double Mark_x;double Mark_y;QString Judge;QString WarningLevel;int WariningCode;QString StartTime;QString EndTime;int ImageCount;QString ImagePath;
};class tpoDie
{
public:std::vector<std::shared_ptr<tpoDefect>>InspectedDefect; //检测到的缺陷double die_x;double die_y;double die_width;double die_height;double die_type;int die_model;
};class tpoDefect
{
public:int id = -1;double x = 0;double y = 0;double gray = 0;double height = 0;double width = 0;double size = 0;double roundness = 1;int type = -1;int judge = 0;QRectF bounding = QRectF(0, 0, 1, 1);bool visible = true;bool skip = false;int inspect_type = 1;int flag = -1;
};

如果用的是结构型数据库存储数据,就需要在数据库中建立3个表,wafer table,die table defect table,还要用外键进行关联。

而在MongoDB这类非关系型数据库中这些都不需要,只需按照定义的数据结构把数据写成类似json文件的domcument存到数据中就可以了。最最重要的是,当数据结构改变了,增加或者减少存储的数据时完全不需要改数据库表,这个在关系型数据库中就不行了。

bool tpoWafer::write_to_database(bsoncxx::builder::stream::document& doc)
{int idx = 0;doc <<"MaskArea_x" + std::to_string(idx) << MaskArea.x() <<"MaskArea_y" + std::to_string(idx) << MaskArea.y() <<"MaskArea_width" + std::to_string(idx) << MaskArea.width() << "MaskArea_height" + std::to_string(idx) << MaskArea.height() <<"WaferID" + std::to_string(idx) << WaferID.toStdString() <<"BatchID" + std::to_string(idx) << BatchID.toStdString() <<"ProductID" + std::to_string(idx) << ProductID.toStdString() <<"StepID" + std::to_string(idx) << StepID.toStdString() <<"LotID" + std::to_string(idx) << LotID.toStdString() <<"EqpID" + std::to_string(idx) << EqpID.toStdString() <<"UnitID" + std::to_string(idx) << UnitID.toStdString() <<"OperatorID" + std::to_string(idx) << OperatorID.toStdString() <<"RecipeName" + std::to_string(idx) << RecipeName.toStdString() <<"RecipeID" + std::to_string(idx) << RecipeID.toStdString() <<"TotalDie" + std::to_string(idx) << TotalDie <<"OKDie" + std::to_string(idx) << OKDie <<"NGDie" + std::to_string(idx) << NGDie <<"TotalDefect" + std::to_string(idx) << TotalDefect <<"Mark_x" + std::to_string(idx) << Mark_x <<"Mark_y" + std::to_string(idx) << Mark_y <<"Judge" << Judge.toStdString() <<"WarningLevel" + std::to_string(idx) << WarningLevel.toStdString() <<"WariningCode" + std::to_string(idx) << WariningCode <<"StartTime" + std::to_string(idx) << StartTime.toStdString() <<"EndTime" + std::to_string(idx) << EndTime.toStdString() <<"ImageCount" + std::to_string(idx) << ImageCount <<"ImagePath" + std::to_string(idx) << ImagePath.toStdString();for (int i = 0; i < Layouts.size(); i++){Layouts[i]->write_to_database(doc, i);}return true;
}bool tpoDefect::write_to_database(bsoncxx::builder::stream::document& doc, int idx)
{doc << "defect_info"+ std::to_string(idx) << bsoncxx::builder::stream::open_document <<"id"+ std::to_string(idx) << id <<"x" + std::to_string(idx) << x <<"t" + std::to_string(idx) << y <<"gray" + std::to_string(idx) << gray <<"height" + std::to_string(idx) << height <<"width" + std::to_string(idx) << width <<"size" + std::to_string(idx) << size <<"roundness" + std::to_string(idx) << roundness <<"type" + std::to_string(idx) << type <<"judge" + std::to_string(idx) << judge <<"bounding_x" + std::to_string(idx) << bounding.x() <<"bounding_y" + std::to_string(idx) << bounding.y() <<"bounding_width" + std::to_string(idx) << bounding.width() <<"bounding_height" + std::to_string(idx) << bounding.height() <<"visible" + std::to_string(idx) << visible <<"skip" + std::to_string(idx) << skip <<"inspect_type" + std::to_string(idx) << inspect_type <<"flag" << flag;doc << bsoncxx::builder::stream::close_document;return false;
}bool tpoDie::write_to_database(bsoncxx::builder::stream::document& doc, int idx)
{doc << "die_info" + std::to_string(idx) <<bsoncxx::builder::stream::open_document<<"die_x" + std::to_string(idx) << die_x <<"die_y" + std::to_string(idx) << die_y <<"die_width" + std::to_string(idx) << die_width <<"die_height" + std::to_string(idx) << die_height <<"die_type" + std::to_string(idx) << die_type <<"die_model" + std::to_string(idx) << die_model <<"die_id" + std::to_string(idx) << die_id.toStdString();for (int i = 0; i < InspectedDefect.size(); i++){InspectedDefect[i]->write_to_database(doc, i);     }doc << bsoncxx::builder::stream::close_document;return true;
}

对每个数据结构写一个write document的方法,最后只需要调用wafer的write_to_database方法就能把wafer的每个die的详细信息记录到表中,包括每个die中的缺陷详细信息。

写到数据库中的数据结构是这样的,结构一目了然,wafer中带着die的信息和自身的一些详细信息,die中又有defect的详细信息。

而且这个数据库查询效率奇高,实测千万级的数据,添加了索引之后能在0.1秒之内查询到结果。

相关文章:

MongoDB在自动化设备上的应用示例

发现MongoDB特别适合自动化检测数据的存储。。。 例如一个晶圆检测项目&#xff0c;定义其数据结构如下 #pragma once #include <vector> #include <QString> #include <QRectF> #include <string> #include <memory>class tpoWafer; class tp…...

draggable插件——实现元素的拖动排序——拖动和不可拖动的两种情况处理

最近在写后台管理系统的时候&#xff0c;遇到一个需求&#xff0c;就是关于拖动排序的功能。 我之前是写过一个关于拖动表格的功能&#xff0c;此功能可以实现表格中的每一行数据上下拖动实现排序的效果。 vue——实现表格的拖拽排序功能——技能提升 但是目前我这边的需求是…...

Redux的使用

到如今redux的已经不是react程序中必须的一部分内容了&#xff0c; 我们应该在本地需要大量更新全局变量时才使用它! redux vs reducer reducer的工作机制&#xff1a; 手动构造action对象传入dispatch函数中 dispatch函数将 action传入reducer当中 reducer结合当前state与a…...

【JAVA】Java高级:多数据源管理与Sharding:数据分片(Sharding)技术的实现与实践

大规模分布式系统&#xff0c;数据存储和管理变得越来越复杂。随着用户数量和数据量的急剧增加&#xff0c;单一数据库往往难以承载如此庞大的负载。这时&#xff0c;数据分片&#xff08;Sharding&#xff09;技术应运而生。数据分片是一种将数据水平切分到多个数据库实例的技…...

ASP.NET Core 9.0 静态资产传递优化 (MapStaticAssets )

一、结论 &#x1f4a2;先看结论吧&#xff0c; MapStaticAssets 在大多数情况下可以替换 UseStaticFiles&#xff0c;它已针对为应用在生成和发布时了解的资产提供服务进行了优化。 如果应用服务来自其他位置&#xff08;如磁盘或嵌入资源&#xff09;的资产&#xff0c;则应…...

LeetCode刷题day18——贪心

LeetCode刷题day18——贪心 135. 分发糖果分析&#xff1a; 406. 根据身高重建队列分析&#xff1a;for (auto& p : people) 昨天写了一道&#xff0c;今天写了一道&#xff0c;都有思路&#xff0c;却不能全整对。昨天和小伙伴聊天&#xff0c;说是因为最近作业多&#xf…...

MATLAB Simulink® - 智能分拣系统

系列文章目录 前言 本示例展示了如何在虚幻引擎 环境中对四种不同形状的标准 PVC 管件实施半结构化智能分拣。本示例使用 Universal Robots UR5e cobot 执行垃圾箱拣选任务&#xff0c;从而成功检测并分类物体。cobot 的末端执行器是一个吸力抓手&#xff0c;它使 cobot 能够拾…...

linuxCNC(五)HAL驱动的指令介绍

HAL驱动的构成 指令举例详解 从终端进入到HAL命令行&#xff0c;执行halrun&#xff0c;即可进入halcmd命令行 # halrun指令描述oadrt加载comoonent&#xff0c;loadrt threads name1 period1创建新线程loadusr halmeter加载万用表UI界面loadusr halscope加载示波器UI界面sho…...

STM32 进阶 定时器3 通用定时器 案例2:测量PWM的频率/周期

需求分析 上一个案例我们输出了PWM波&#xff0c;这个案例我们使用输入捕获功能&#xff0c;来测试PWM波的频率/周期。 把测到的结果通过串口发送到电脑&#xff0c;检查测试的结果。 如何测量 1、输入捕获功能主要是&#xff1a;测量输入通道的上升沿和下降沿 2、让第一个…...

第一节、电路连接【51单片机-TB6600驱动器-步进电机教程】

摘要&#xff1a;本节介绍如何搭建一个51单片机TB6600驱动器步进电机控制电路&#xff0c;所用材料均为常见的模块&#xff0c;简单高效的方式搭建起硬件环境 一、硬件清单 ①51单片机最小控制系统 ②USB转TTL模块 ③开关电源 ④TB6600步进电机驱动器 ⑤二相四线步进电机 ⑥电…...

【通俗理解】Koopman算符与非线性动力系统分析

【通俗理解】Koopman算符与非线性动力系统分析 关键词&#xff1a; #Koopman算符 Koopman Operator #非线性动力系统 Nonlinear Dynamical System #无穷维线性算子 Infinite-Dimensional Linear Operator #演化分析 Evolution Analysis #Bernard Koopman Bernard Koopman 第…...

mybatis plus打印sql日志

1、官方文档 使用配置 | MyBatis-Plus 2、日志实现 MyBatis-Plus 提供了多种日志实现&#xff08;log-impl&#xff09;&#xff0c;用于记录 SQL 语句和相关操作&#xff0c;帮助开发者进行调试和监控数据库操作。以下是一些可用的日志实现及其说明&#xff1a; StdOutImpl…...

ObjectMapper

ObjectMapper 是 Jackson 库中非常重要的一个类&#xff0c;它是 JSON 和 Java 对象之间进行序列化与反序列化的核心工具。ObjectMapper 的底层实现是基于 Jackson 的数据绑定模型&#xff0c;它将 Java 对象与 JSON 数据转换为互通格式。 1. ObjectMapper 的设计与核心功能 O…...

新增白名单赋予应用安装权限

目录 相关问题 具体实现 相关问题 安装app到/data/分区时&#xff0c;如何在安装阶段就赋予权限&#xff0c;无需请求权限 具体实现 frameworks/base/core/res/res/values/config.xml <!-- For whitelis apk --><string-array translatable"false" nam…...

传奇996_51——脱下装备,附加属性设为0

奶奶的lua怎么都修改不了&#xff0c;可以调用txt的 ; LINKPICKUPITEM ; ChangeitemaddvaLue -1 5 0 ; GETITEMADDVALUE 3 5 M10 ; SENDUPGRADEITEM ; SENDMSG 9 你的衣服附加了<$STR(M10)>点防御属性. 或者lua callscriptex(actor,“LINKPICKUPITEM”) callscriptex(…...

【Mac】安装Gradle

1、说明 Gradle 运行依赖 JVM&#xff0c;需要先安装JDK&#xff0c;Gradle 与 JDK的版本对应参见&#xff1a;Java Compatibility IDEA的版本也是有要求Gradle版本的&#xff0c;二者版本对应关系参见&#xff1a;Third-Party Software and Licenses 本次 Gradle 安装版本为…...

MySQL中的redoLog

在数据库系统中&#xff0c;redo log&#xff08;重做日志&#xff09;用于记录所有已提交事务的修改操作&#xff0c;它的主要目的是确保在系统崩溃或故障后&#xff0c;能够恢复数据库到崩溃前的状态。Redo log 记录的是事务修改的数据的具体操作&#xff0c;而不是数据本身。…...

Windows 安装 MySQL

1.下载 MySQL 安装包 访问&#xff1a;MySQL :: Download MySQL Installer选择适合的版本。推荐下载 MySQL Installer for Windows&#xff0c;该安装包包含所有必要的组件选择 Windows (x86, 32-bit), MSI Installer 或 Windows (x86, 64-bit), MSI Installer 2.运行安装程序…...

yocto的xxx.bb文件在什么时候会拷贝文件到build目录

在 Yocto 中&#xff0c;.bb 文件用于描述如何构建和安装一个软件包&#xff0c;而文件在构建过程中的拷贝操作通常会在某些特定的步骤中进行。具体来说&#xff0c;文件会在以下几个阶段被拷贝到 build 目录&#xff08;或者更准确地说&#xff0c;拷贝到目标目录 ${D}&#x…...

Ubuntu Server 22.04.5 LTS重启后IP被重置问题

Ubuntu Server 22.04.5 LTS重启后IP被重置问题 最近在使用Ubuntu Server 22.04做项目开发测试时发现每次重启和关机后&#xff0c;所设置的静态IP地址都会回复到安装系统时所设置的ip Ubuntu Server 22.04 官网下载地址&#xff1a;Ubuntu官方下载地址 对虚拟机下安装Ubuntu感…...

label-studio的使用教程(导入本地路径)

文章目录 1. 准备环境2. 脚本启动2.1 Windows2.2 Linux 3. 安装label-studio机器学习后端3.1 pip安装(推荐)3.2 GitHub仓库安装 4. 后端配置4.1 yolo环境4.2 引入后端模型4.3 修改脚本4.4 启动后端 5. 标注工程5.1 创建工程5.2 配置图片路径5.3 配置工程类型标签5.4 配置模型5.…...

基于FPGA的PID算法学习———实现PID比例控制算法

基于FPGA的PID算法学习 前言一、PID算法分析二、PID仿真分析1. PID代码2.PI代码3.P代码4.顶层5.测试文件6.仿真波形 总结 前言 学习内容&#xff1a;参考网站&#xff1a; PID算法控制 PID即&#xff1a;Proportional&#xff08;比例&#xff09;、Integral&#xff08;积分&…...

PHP和Node.js哪个更爽?

先说结论&#xff0c;rust完胜。 php&#xff1a;laravel&#xff0c;swoole&#xff0c;webman&#xff0c;最开始在苏宁的时候写了几年php&#xff0c;当时觉得php真的是世界上最好的语言&#xff0c;因为当初活在舒适圈里&#xff0c;不愿意跳出来&#xff0c;就好比当初活在…...

通过Wrangler CLI在worker中创建数据库和表

官方使用文档&#xff1a;Getting started Cloudflare D1 docs 创建数据库 在命令行中执行完成之后&#xff0c;会在本地和远程创建数据库&#xff1a; npx wranglerlatest d1 create prod-d1-tutorial 在cf中就可以看到数据库&#xff1a; 现在&#xff0c;您的Cloudfla…...

Vue2 第一节_Vue2上手_插值表达式{{}}_访问数据和修改数据_Vue开发者工具

文章目录 1.Vue2上手-如何创建一个Vue实例,进行初始化渲染2. 插值表达式{{}}3. 访问数据和修改数据4. vue响应式5. Vue开发者工具--方便调试 1.Vue2上手-如何创建一个Vue实例,进行初始化渲染 准备容器引包创建Vue实例 new Vue()指定配置项 ->渲染数据 准备一个容器,例如: …...

剑指offer20_链表中环的入口节点

链表中环的入口节点 给定一个链表&#xff0c;若其中包含环&#xff0c;则输出环的入口节点。 若其中不包含环&#xff0c;则输出null。 数据范围 节点 val 值取值范围 [ 1 , 1000 ] [1,1000] [1,1000]。 节点 val 值各不相同。 链表长度 [ 0 , 500 ] [0,500] [0,500]。 …...

Android Bitmap治理全解析:从加载优化到泄漏防控的全生命周期管理

引言 Bitmap&#xff08;位图&#xff09;是Android应用内存占用的“头号杀手”。一张1080P&#xff08;1920x1080&#xff09;的图片以ARGB_8888格式加载时&#xff0c;内存占用高达8MB&#xff08;192010804字节&#xff09;。据统计&#xff0c;超过60%的应用OOM崩溃与Bitm…...

Java 二维码

Java 二维码 **技术&#xff1a;**谷歌 ZXing 实现 首先添加依赖 <!-- 二维码依赖 --><dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.5.1</version></dependency><de…...

Selenium常用函数介绍

目录 一&#xff0c;元素定位 1.1 cssSeector 1.2 xpath 二&#xff0c;操作测试对象 三&#xff0c;窗口 3.1 案例 3.2 窗口切换 3.3 窗口大小 3.4 屏幕截图 3.5 关闭窗口 四&#xff0c;弹窗 五&#xff0c;等待 六&#xff0c;导航 七&#xff0c;文件上传 …...

【从零开始学习JVM | 第四篇】类加载器和双亲委派机制(高频面试题)

前言&#xff1a; 双亲委派机制对于面试这块来说非常重要&#xff0c;在实际开发中也是经常遇见需要打破双亲委派的需求&#xff0c;今天我们一起来探索一下什么是双亲委派机制&#xff0c;在此之前我们先介绍一下类的加载器。 目录 ​编辑 前言&#xff1a; 类加载器 1. …...