CN115408968A - A construction method and system based on SVG virtual circuit - Google Patents
A construction method and system based on SVG virtual circuit Download PDFInfo
- Publication number
- CN115408968A CN115408968A CN202211020803.4A CN202211020803A CN115408968A CN 115408968 A CN115408968 A CN 115408968A CN 202211020803 A CN202211020803 A CN 202211020803A CN 115408968 A CN115408968 A CN 115408968A
- Authority
- CN
- China
- Prior art keywords
- components
- virtual circuit
- component
- svg
- orthogonal line
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000010276 construction Methods 0.000 title claims description 27
- 230000003993 interaction Effects 0.000 claims abstract description 10
- 239000013598 vector Substances 0.000 claims description 60
- 238000010586 diagram Methods 0.000 claims description 20
- 238000012544 monitoring process Methods 0.000 claims description 10
- 238000012800 visualization Methods 0.000 claims description 10
- 230000002452 interceptive effect Effects 0.000 claims description 6
- 230000000007 visual effect Effects 0.000 claims description 5
- 230000000694 effects Effects 0.000 abstract description 5
- 238000000034 method Methods 0.000 abstract description 4
- 238000002474 experimental method Methods 0.000 description 7
- 238000004891 communication Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 5
- 230000008846 dynamic interplay Effects 0.000 description 4
- 238000004088 simulation Methods 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 230000007812 deficiency Effects 0.000 description 2
- 230000002093 peripheral effect Effects 0.000 description 2
- 101100394003 Butyrivibrio fibrisolvens end1 gene Proteins 0.000 description 1
- 206010070245 Foreign body Diseases 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 239000000126 substance Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/30—Circuit design
- G06F30/32—Circuit design at the digital level
- G06F30/33—Design verification, e.g. functional simulation or model checking
- G06F30/3308—Design verification, e.g. functional simulation or model checking using simulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/30—Circuit design
- G06F30/36—Circuit design at the analogue level
- G06F30/367—Design verification, e.g. using simulation, simulation program with integrated circuit emphasis [SPICE], direct methods or relaxation methods
Landscapes
- Engineering & Computer Science (AREA)
- Computer Hardware Design (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Evolutionary Computation (AREA)
- Geometry (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Microelectronics & Electronic Packaging (AREA)
- Processing Or Creating Images (AREA)
Abstract
本发明公开了一种基于SVG虚拟电路的构建方法及系统,包括以下步骤:基于SVG对元器件的元数据模型进行定义,生成对应的元器件;基于SVG对元器件间的前端组件进行定义,生成对应的前端组件;基于SVG对元器件的后台模型进行定义,生成对应的后台模型;根据元器件和前端组件搭建虚拟电路;接收到所后台模型发送的启动命令后,启动并运行虚拟电路;根据运行时后台模型返回的状态数据动态切换前端组件的状态,控制元器件之间的交互,从而模拟实际电路的运行情况;其中,在搭建虚拟电路时,包括:对元器件进行选择,根据选择的元器件进行自动连线,生成导线。本发明实现了降低真实电路与虚拟电路间运行效果差异的目的。
The invention discloses a method and system for constructing a virtual circuit based on SVG, comprising the following steps: defining metadata models of components based on SVG, and generating corresponding components; defining front-end components between components based on SVG, Generate the corresponding front-end components; define the background model of the component based on SVG, and generate the corresponding background model; build a virtual circuit according to the component and the front-end component; after receiving the startup command sent by the background model, start and run the virtual circuit; According to the state data returned by the background model at runtime, the state of the front-end components is dynamically switched, and the interaction between components is controlled, thereby simulating the operation of the actual circuit; among them, when building a virtual circuit, it includes: selecting components, according to the selection The components are automatically connected and wires are generated. The invention realizes the purpose of reducing the difference in operation effect between the real circuit and the virtual circuit.
Description
技术领域technical field
本发明涉及模拟仿真技术领域,具体涉及一种基于SVG虚拟电路的构建方法及系统。The invention relates to the technical field of simulation, in particular to a construction method and system based on an SVG virtual circuit.
背景技术Background technique
在教学中,实验有着非常重要的地位,可以提高学生的动手能力,也可以增强学生对知识的理解。但是传统实验元器件存在很多不足,比如购买和维护花费巨大、易损坏、存在安全隐患等,这些方面严重地限制了实验的普及以及实验的深入教学。与此同时,随着计算机和网络技术的发展,利用虚拟仿真模拟化学、物理、电工等实验的技术也日益成熟。虚拟仿真实验是虚拟仿真技术在教育领域的重要应用。虚拟仿真实验是指通过计算机、网络设备等模拟教学中的各种实验,虚拟仿真实验可以弥补传统教学设备的不足,是日后辅助教学的重要手段。In teaching, experiments play a very important role, which can improve students' hands-on ability and enhance students' understanding of knowledge. However, there are many deficiencies in traditional experimental components, such as huge purchase and maintenance costs, easy damage, and potential safety hazards. These aspects seriously limit the popularity of experiments and in-depth teaching of experiments. At the same time, with the development of computer and network technology, the technology of using virtual simulation to simulate chemical, physical, electrical and other experiments is becoming more and more mature. Virtual simulation experiment is an important application of virtual simulation technology in the field of education. Virtual simulation experiments refer to various experiments in simulated teaching through computers, network equipment, etc. Virtual simulation experiments can make up for the shortcomings of traditional teaching equipment and are an important means of assisting teaching in the future.
虚拟电路是虚拟仿真实验的重要组成部分,即是将实际的实验元器件和导线虚拟化,从而弥补了传统实验元器件的各种缺点以及解决安全隐患的问题,同时也可以用于验证电路理论知识。在对电路理论知识完成验证后,再基于虚拟电路对硬件进行搭建,既增加了实验的灵活性,又激发了学生的学习兴趣和学习成本,拓展了学生的学习范围,同时加深学生对教学内容的理解。Virtual circuit is an important part of virtual simulation experiment, which is to virtualize actual experimental components and wires, so as to make up for various shortcomings of traditional experimental components and solve potential safety hazards. It can also be used to verify circuit theory Knowledge. After verifying the theoretical knowledge of the circuit, the hardware is built based on the virtual circuit, which not only increases the flexibility of the experiment, but also stimulates the students' learning interest and learning cost, expands the learning scope of the students, and deepens the students' understanding of the teaching content. understanding.
但是现有技术搭建的虚拟电路无法对元器件之间的动态交互进行准确仿真,导致后期对真实电路进行搭建后,与虚拟电路的运行效果有较大差异。However, the virtual circuit built in the prior art cannot accurately simulate the dynamic interaction between components, which leads to a large difference in the operation effect of the virtual circuit after the real circuit is built later.
发明内容Contents of the invention
为了克服现有技术的不足,本发明提供一种基于SVG虚拟电路的构建方法及系统,用于解决现有技术搭建的虚拟电路无法对元器件之间的动态交互进行准确仿真的技术问题,从而实现降低真实电路与虚拟电路间运行效果差异的目的。In order to overcome the deficiencies of the prior art, the present invention provides a method and system for constructing a virtual circuit based on SVG, which is used to solve the technical problem that the virtual circuit built by the prior art cannot accurately simulate the dynamic interaction between components, thereby The purpose of reducing the difference in operation effect between the real circuit and the virtual circuit is realized.
为解决上述问题,本发明所采用的技术方案如下:In order to solve the above problems, the technical scheme adopted in the present invention is as follows:
一种基于SVG虚拟电路的构建方法,包括以下步骤:A construction method based on SVG virtual circuit, comprising the following steps:
基于SVG对元器件的元数据模型进行定义,生成对应的元器件;Define the metadata model of components based on SVG, and generate corresponding components;
基于SVG对元器件间的前端组件进行定义,生成对应的前端组件;Define the front-end components between components based on SVG, and generate the corresponding front-end components;
基于SVG对元器件的后台模型进行定义,生成对应的后台模型;Define the background model of components based on SVG, and generate the corresponding background model;
根据用户选择的所述元器件和所述前端组件,进行自动连线,生成导线,完成虚拟电路的搭建;According to the components and the front-end components selected by the user, perform automatic wiring, generate wires, and complete the construction of the virtual circuit;
接收到所述后台模型发送的启动命令后,启动并运行所述虚拟电路;After receiving the startup command sent by the background model, start and run the virtual circuit;
根据运行时所述后台模型返回的状态数据动态切换所述前端组件的状态,以控制所述元器件之间的交互,从而模拟实际电路的运行情况。The state of the front-end component is dynamically switched according to the state data returned by the background model during operation, so as to control the interaction between the components, thereby simulating the operation of the actual circuit.
作为本发明优选的实施方式,在对元器件的元数据模型进行定义时,包括:As a preferred embodiment of the present invention, when defining the metadata model of components, it includes:
对元器件的结构信息进行定义;Define the structural information of components;
对元器件的可视化信息进行定义;Define the visual information of components;
对元器件的功能部件信息进行定义;Define the functional part information of components;
对元器件的状态信息进行定义;Define the status information of components;
根据所述结构信息、所述可视化信息、所述功能部件信息以及所述状态信息生成元器件。A component is generated according to the structure information, the visualization information, the functional part information and the status information.
作为本发明优选的实施方式,在进行自动连线,生成导线时,包括:As a preferred embodiment of the present invention, when performing automatic wiring and generating wires, it includes:
获取起始元器件的起点坐标和结束元器件的终点坐标;Get the starting point coordinates of the starting component and the end point coordinates of the ending component;
并根据所述起始元器件的起点坐标和所述结束元器件的终点坐标得到直接向量;and obtain a direct vector according to the starting point coordinates of the starting component and the end point coordinates of the ending component;
根据所述直接向量得到所述正交线的起始方向和最终方向;obtaining the initial direction and the final direction of the orthogonal line according to the direct vector;
根据所述正交线的起始方向和所述正交线的最终方向确定拐点的数量,并得到拐点坐标;determining the number of inflection points according to the initial direction of the orthogonal line and the final direction of the orthogonal line, and obtaining the coordinates of the inflection points;
根据所述起始元器件的起点坐标、所述结束元器件的终点坐标、所述正交线的起始方向和最终方向以及所述拐点坐标,进行自动连线生成导线;performing automatic wiring to generate wires according to the starting point coordinates of the starting component, the ending point coordinates of the ending component, the starting direction and the final direction of the orthogonal line, and the coordinates of the inflection point;
其中,所述导线包括正交线。Wherein, the wires include orthogonal wires.
作为本发明优选的实施方式,在得到所述正交线的起始方向和最终方向时,包括:As a preferred embodiment of the present invention, when obtaining the initial direction and the final direction of the orthogonal line, it includes:
获取所述正交线的起点坐标和所述正交线的终点坐标;Obtaining the coordinates of the starting point of the orthogonal line and the coordinates of the end point of the orthogonal line;
根据所述正交线的起点坐标和所述起始元器件的起点坐标获得起点方向;obtaining the starting point direction according to the starting point coordinates of the orthogonal line and the starting point coordinates of the starting component;
根据所述正交线的终点坐标和所述结束元器件的终点坐标获得终点方向;obtaining an end point direction according to the end point coordinates of the orthogonal line and the end point coordinates of the end component;
在水平向量和竖直向量中挑选出与所述起点方向平行的向量,并判断与所述起点方向是否同向,若是,所述正交线的起始方向与挑选出来的向量同向,若否,所述正交线的起始方向与另一向量同向;Select a vector parallel to the starting point direction from the horizontal vector and the vertical vector, and judge whether it is in the same direction as the starting point direction, if so, the starting direction of the orthogonal line is in the same direction as the selected vector, if No, the starting direction of the orthogonal line is the same as another vector;
在水平向量和竖直向量中挑选出与所述终点方向平行的向量,并判断与所述终点方向是否同向,若是,所述正交线的终点方向与挑选出来的向量同向,若否,所述正交线的终点方向与另一向量同向;Select a vector parallel to the end point direction from the horizontal vector and the vertical vector, and judge whether it is in the same direction as the end point direction, if so, the end point direction of the orthogonal line is in the same direction as the selected vector, if not , the direction of the end point of the orthogonal line is in the same direction as another vector;
其中,所述直接向量包括水平向量和竖直向量。Wherein, the direct vectors include horizontal vectors and vertical vectors.
作为本发明优选的实施方式,在确定拐点的数量和得到拐点坐标时,包括:As a preferred embodiment of the present invention, when determining the quantity of inflection points and obtaining the coordinates of inflection points, it includes:
判断所述正交线的起始方向和所述正交线的最终方向是否同向,若是,则所述拐点数量为2,若否,则所述拐点数量为1;Judging whether the starting direction of the orthogonal line and the final direction of the orthogonal line are in the same direction, if so, the number of inflection points is 2, and if not, the number of inflection points is 1;
当所述拐点数量为1时,拐点坐标由公式1得到,所述公式1具体如下:When the number of inflection points is 1, the inflection point coordinates are obtained by
G=Z+Q (公式1);G=Z+Q (Formula 1);
其中,G为拐点坐标,Z为正交线起点坐标,Q为正交线的起始方向向量;Among them, G is the coordinate of the inflection point, Z is the coordinate of the starting point of the orthogonal line, and Q is the starting direction vector of the orthogonal line;
当所述拐点数量为2时,拐点坐标由公式2和公式3得到,所述公式2和所述公式3具体如下:When the number of inflection points is 2, the inflection point coordinates are obtained by
G1=Z+Q*0.5 (公式2);G 1 =Z+Q*0.5 (Formula 2);
G2=G1+F (公式3);G 2 =G 1 +F (Formula 3);
其中,G2为第二个拐点坐标,G1为第一个拐点坐标,F为水平向量和竖直向量中与正交线的起始方向垂直的向量。Among them, G 2 is the coordinate of the second inflection point, G 1 is the coordinate of the first inflection point, and F is the vector perpendicular to the starting direction of the orthogonal line among the horizontal vector and the vertical vector.
作为本发明优选的实施方式,在对后台模型进行定义时,包括:As a preferred embodiment of the present invention, when defining the background model, it includes:
对各所述元器件的名称进行定义;Define the name of each component;
对各所述元器件间的交互信息进行定义;Define the interaction information between the components;
根据所述交互信息定义返回数据。The return data is defined according to the interaction information.
作为本发明优选的实施方式,在完成虚拟电路的搭建后,包括:As a preferred embodiment of the present invention, after completing the construction of the virtual circuit, it includes:
所述后台模型接收到生成命令后,根据所述虚拟电路生成电路图和脚本文件;After the background model receives the generation command, it generates a circuit diagram and a script file according to the virtual circuit;
将所述电路图和所述脚本文件保存到可视化文件中。saving the circuit diagram and the script file into a visualization file.
作为本发明优选的实施方式,在运行所述虚拟电路时,包括:As a preferred embodiment of the present invention, when running the virtual circuit, it includes:
通过所述脚本文件中电路配置参数来动态启动所述虚拟电路;Dynamically start the virtual circuit through circuit configuration parameters in the script file;
通过所述脚本文件中电路配置参数来动态切换所述前端组件的状态;Dynamically switch the state of the front-end component through the circuit configuration parameters in the script file;
通过所述可视化文件展示所述前端组件和所述虚拟电路的运行状态。The running status of the front-end component and the virtual circuit is displayed through the visualization file.
作为本发明优选的实施方式,在动态切换前端组件的状态时,包括:As a preferred implementation of the present invention, when dynamically switching the status of the front-end components, it includes:
通过Vuex的监听工具遍历所有的脚本文件,以获取多个状态数据;Traverse all script files through Vuex's monitoring tool to obtain multiple state data;
通过所述Vuex的监听工具监听所述状态数据的变化状态,当监听到所述状态数据发生变化时,通过所述Vuex的监听工具重新获取所述状态数据,以更新所述状态数据;Monitor the change state of the state data through the monitoring tool of the Vuex, and reacquire the state data through the monitoring tool of the Vuex to update the state data when the state data changes are detected;
根据更新的状态数据切换所述前端组件的状态,以得到更新后的所述前端组件的状态。switching the state of the front-end component according to the updated state data, so as to obtain the updated state of the front-end component.
一种基于SVG虚拟电路的构建系统,包括:A construction system based on SVG virtual circuits, including:
前端,用于对元器件的元数据模型和元器件间的前端组件进行定义,生成对应的元器件和前端组件,并根据所述元器件和所述前端组件搭建虚拟电路,将所述虚拟电路的数据通过交互协议传送给服务端,通过websocket链接接收到来自服务端的启动命令、电路配置参数和状态数据,根据所述启动命令和电路配置参数启动并运行所述虚拟电路,根据所述状态数据动态切换所述前端组件的状态;The front end is used to define the metadata model of the components and the front-end components between the components, generate corresponding components and front-end components, and build a virtual circuit according to the components and the front-end components, and convert the virtual circuit to The data is transmitted to the server through the interactive protocol, and the startup command, circuit configuration parameters and status data from the server are received through the websocket link, and the virtual circuit is started and operated according to the startup command and circuit configuration parameters, and the virtual circuit is started and operated according to the status data. Dynamically switch the state of the front-end component;
服务端,接收到来自所述前端的虚拟电路的数据后,通过交互协议传送到后端,接收到来自后端的启动命令以及返回的电路配置参数和状态数据,并通过所述websocket链接传送给所述前端。The server, after receiving the data from the front-end virtual circuit, transmits it to the back-end through an interactive protocol, receives the start command from the back-end and the returned circuit configuration parameters and status data, and transmits it to the back-end through the websocket link. Describe the front end.
后端,用于对元器件的后台模型进行定义,生成对应的后台模型,并通过所述后台模型发出启动命令以及返回电路配置参数和状态数据到所述服务端。The backend is used to define the background model of the component, generate the corresponding background model, issue a startup command through the background model, and return circuit configuration parameters and status data to the server.
相比现有技术,本发明的有益效果在于:Compared with the prior art, the beneficial effects of the present invention are:
(1)本发明的虚拟电路基于SVG进行构建,可以实现任意缩放而不破坏图形的清晰度和细节;(1) The virtual circuit of the present invention is constructed based on SVG, which can realize arbitrary scaling without destroying the clarity and details of the graphics;
(2)SVG是基于XML标准设计的,可以与其它技术建立联系,从而扩大了本发明的适用面;(2) SVG is designed based on the XML standard, and can be connected with other technologies, thereby expanding the scope of application of the present invention;
(3)SVG可以用矩形、椭圆、圆形、直线、折线、多边形以及路径等元素描述矢量图形,具有强大的作图能力,能提高本发明仿真的准确性;(3) SVG can describe vector graphics with elements such as rectangles, ellipses, circles, straight lines, polylines, polygons and paths, has powerful drawing capabilities, and can improve the accuracy of the simulation of the present invention;
(4)本发明基于SVG可对元器件之间的动态交互进行准确仿真,从而有效降低与真实电路间运行效果的差异。(4) Based on the SVG, the present invention can accurately simulate the dynamic interaction between components, thereby effectively reducing the difference between the operation effect and the real circuit.
下面结合附图和具体实施方式对本发明作进一步详细说明。The present invention will be described in further detail below in conjunction with the accompanying drawings and specific embodiments.
附图说明Description of drawings
图1-是本发明实施例的基于SVG虚拟电路的构建方法步骤图;Fig. 1 - is the construction method step chart based on SVG virtual circuit of the embodiment of the present invention;
图2-是本发明实施例的元器件的结构信息定义图;Fig. 2 - is the structural information definition diagram of the components and parts of the embodiment of the present invention;
图3-是本发明实施例的元器件的可视化表示图;Fig. 3 - is the visual representation diagram of the components and parts of the embodiment of the present invention;
图4-是本发明实施例的元器件的元数据模型在串口通信助手上的显示图;Fig. 4-is the display diagram of the metadata model of the components and parts of the embodiment of the present invention on the serial port communication assistant;
图5-是本发明实施例的导线的元数据模型定义图;Fig. 5 - is the definition diagram of the metadata model of the wire of the embodiment of the present invention;
图6-是本发明实施例的导线的元数据模型在串口通信助手上的显示图;Fig. 6-is the display diagram of the metadata model of the wire of the embodiment of the present invention on the serial port communication assistant;
图7-是本发明实施例的导线结构示意图;Figure 7 - is a schematic diagram of the wire structure of an embodiment of the present invention;
图8-是本发明实施例的直接向量示意图;Figure 8 - is a direct vector schematic diagram of an embodiment of the present invention;
图9-是本发明实施例的导线拐点示意图;Figure 9 - is a schematic diagram of the inflection point of the wire according to the embodiment of the present invention;
图10-是本发明实施例的基于SVG虚拟电路的构建系统架构图。Fig. 10 - is the architecture diagram of the construction system based on the SVG virtual circuit of the embodiment of the present invention.
附图标号说明:1、前端;2、服务端;3、后端。Explanation of reference numerals: 1. Front end; 2. Server end; 3. Back end.
具体实施方式Detailed ways
本发明提供的基于SVG虚拟电路的构建方法,如图1所示,包括以下步骤:The construction method based on the SVG virtual circuit provided by the present invention, as shown in Figure 1, comprises the following steps:
步骤S1:基于SVG对元器件的元数据模型进行定义,生成对应的元器件;Step S1: Define the metadata model of the component based on SVG, and generate the corresponding component;
步骤S2:基于SVG对元器件间的前端组件进行定义,生成对应的前端组件;Step S2: Define front-end components between components based on SVG, and generate corresponding front-end components;
步骤S3:基于SVG对元器件的后台模型进行定义,生成对应的后台模型;Step S3: Define the background model of the component based on SVG, and generate the corresponding background model;
步骤S4:根据用户选择的元器件和前端组件,进行自动连线,生成导线,完成虚拟电路的搭建;Step S4: According to the components and front-end components selected by the user, perform automatic wiring, generate wires, and complete the construction of the virtual circuit;
步骤S5:接收到后台模型发送的启动命令后,启动并运行虚拟电路;Step S5: After receiving the startup command sent by the background model, start and run the virtual circuit;
步骤S6:根据运行时后台模型返回的状态数据动态切换前端组件的状态,以控制元器件之间的交互,从而模拟实际电路的运行情况。Step S6: Dynamically switch the state of the front-end components according to the state data returned by the background model at runtime to control the interaction between components, thereby simulating the operation of the actual circuit.
在上述步骤S1中,在对元器件的元数据模型进行定义时,包括:In the above step S1, when defining the metadata model of components, it includes:
对元器件的结构信息进行定义;Define the structural information of components;
对元器件的可视化信息进行定义;Define the visual information of components;
对元器件的功能部件信息进行定义;Define the functional part information of components;
对元器件的状态信息进行定义;Define the status information of components;
根据结构信息、可视化信息、功能部件信息以及状态信息生成元器件。Generate components based on structural information, visualization information, feature information, and status information.
进一步地,元器件的结构信息定义是一个json格式,如图2所示。Further, the structural information definition of components is in a json format, as shown in Figure 2.
其中,图2中的属性解释具体如下:Among them, the attribute explanation in Figure 2 is as follows:
component_id:元器件类型,唯一,同时在根据前端需要封装对应的组件(svg),用于调试过程中展示对应的状态;component_id: component type, unique, and at the same time package the corresponding component (svg) according to the needs of the front end, and use it to display the corresponding state during the debugging process;
kindof:元器件类别,用于区分元器件属于核或者外设,可选值“CPU”和“peripherals”;kindof: component category, used to distinguish components belonging to cores or peripherals, optional values "CPU" and "peripherals";
img:元器件封面图,即在电路图搭建中展示的图片;img: component cover image, that is, the image displayed in the circuit diagram construction;
name:元器件名称,考虑到用户在电路图中针对某一个元器件可能拖拽了多个,所以预设了name属性,用于区分同类别元器件中的哪一个;name: The name of the component. Considering that the user may drag and drop multiple components for a certain component in the circuit diagram, the name attribute is preset to distinguish which component of the same category;
cname:元器件中文名称,即是在元器件列表中显示的名称;cname: the Chinese name of the component, which is the name displayed in the component list;
aliasName:元器件在电路图上显示的别名,用于方便自定义名称;aliasName: the alias of the component displayed on the circuit diagram, which is used to facilitate the custom name;
version:元器件版本,某些元器件后续升级了,为了兼容旧实验中的老版本,所以预设了version属性;version: component version, some components have been upgraded later, in order to be compatible with the old version in the old experiment, the version attribute is preset;
docurl:有的元器件需要关联实现原理文档或者使用文档,所以预设了docurl属性;docurl: Some components need to be associated with implementation principle documents or usage documents, so the docurl attribute is preset;
width:元器件的宽度,默认读取元器件封面图的宽度,即在电路图搭建中元器件展示的宽度;Width: the width of the component, read the width of the cover image of the component by default, that is, the width of the component display in the circuit diagram construction;
height:元器件的高度,默认读取元器件封面图的高度,即在电路图搭建中元器件展示的高度;height: the height of the component, the height of the cover image of the component is read by default, that is, the height of the component displayed in the circuit diagram construction;
index:元器件引脚列表,即元器件什么地方展示引脚,同时需要为每个引脚设置唯一名称和连线方向(起始、结束);index: The list of component pins, that is, where the component displays the pins, and it is necessary to set a unique name and connection direction (start, end) for each pin;
x:该引脚相对元器件左上角的x坐标;x: the x coordinate of the pin relative to the upper left corner of the component;
y:该引脚相对元器件左上角的y坐标;y: The y coordinate of the pin relative to the upper left corner of the component;
name:该引脚名称,鼠标移上引脚会显示该名称;name: the name of the pin, the name will be displayed when the mouse moves over the pin;
direction:该引脚连线方向(起始、结束)。direction: The direction of the pin connection (start, end).
进一步地,参考SVG标准,用于对可视化信息进行定义的基本标签有<line>、<rect>、<circle>、<polyline>、<polygon>、<path>、<text>、<image>、<foreignObject>;其中,<line>表示直线,<rect>表示矩形,<circle>表示圆形,<polyline>表示折线,<polygon>表示多边形,<path>表示任意的曲线或折线,<text>表示插入的文本,<image>表示插入的图像。Further, referring to the SVG standard, the basic tags used to define visual information include <line>, <rect>, <circle>, <polyline>, <polygon>, <path>, <text>, <image>, <foreignObject>; Among them, <line> means straight line, <rect> means rectangle, <circle> means circle, <polyline> means polyline, <polygon> means polygon, <path> means any curve or polyline, <text> Indicates the inserted text, and <image> indicates the inserted image.
可视化信息由元器件的结构信息通过json自动处理成上面的几种基本标签进行表示,表示结果如图3所示。The visualized information is represented by the structural information of the components automatically processed into the above several basic tags through json, and the representation results are shown in Figure 3.
进一步地,元器件的功能部件包括引脚、显示面板等;进行定义时,例如通过串口通信助手的TX引脚需要连入STM32的PA10引脚上,同时STM32输出内容需要在显示面板(即串口通信助手组件)上显示,元器件的元数据模型通过串口通信助手进行显示,如图4所示。Further, the functional parts of components include pins, display panels, etc.; when defining, for example, the TX pin of the serial port communication assistant needs to be connected to the PA10 pin of STM32, and the output content of STM32 needs to be displayed on the display panel (that is, the serial port Communication assistant component), the metadata model of components is displayed through the serial communication assistant, as shown in Figure 4.
进一步地,虚拟仿真实验运行的过程中,某一元器件会根据返回的状态数据在不同的状态之间转换,比如开关有“开”和“关”两种状态,因此需要对元器件的状态信息进行定义。Furthermore, during the running of the virtual simulation experiment, a certain component will switch between different states according to the returned state data. For example, a switch has two states of "on" and "off", so the state information of the component is required to define.
在上述步骤S1中,在进行自动连线,生成导线时,包括:In the above step S1, when performing automatic wiring and generating wires, include:
获取起始元器件的起点坐标和结束元器件的终点坐标;Get the starting point coordinates of the starting component and the end point coordinates of the ending component;
并根据起始元器件的起点坐标和结束元器件的终点坐标得到直接向量;And get the direct vector according to the starting point coordinates of the starting component and the end point coordinates of the ending component;
根据直接向量得到正交线的起始方向和最终方向;Obtain the initial direction and final direction of the orthogonal line according to the direct vector;
根据正交线的起始方向和正交线的最终方向确定拐点的数量,并得到拐点坐标;Determine the number of inflection points according to the initial direction of the orthogonal line and the final direction of the orthogonal line, and obtain the coordinates of the inflection point;
根据起始元器件的起点坐标、结束元器件的终点坐标、正交线的起始方向和最终方向以及拐点坐标,进行自动连线生成导线;According to the starting point coordinates of the starting component, the end point coordinates of the ending component, the starting direction and the final direction of the orthogonal line and the coordinates of the inflection point, the wire is automatically connected and generated;
其中,导线包括正交线、起点延伸线以及终点延伸线,正交线包括起点坐标、终点坐标、起始方向以及最终方向,具体如图7所示。Wherein, the wire includes an orthogonal line, a starting point extension line, and an end point extension line, and the orthogonal line includes a starting point coordinate, an end point coordinate, a starting direction, and a final direction, as shown in FIG. 7 .
在生成导线时,还包括对导线的元数据模型进行定义,具体如图5所示。When the wire is generated, it also includes defining the metadata model of the wire, as shown in FIG. 5 .
其中,图5中的属性解释具体如下:Among them, the attribute explanation in Figure 5 is as follows:
from:起始元器件信息,包括元器件索引和元器件引脚索引;from: starting component information, including component index and component pin index;
to:结束元器件信息,包括元器件索引和元器件引脚索引;to: end component information, including component index and component pin index;
pointer:导线的几个拐点坐标;pointer: several inflection point coordinates of the wire;
concactArr:导线连接顺序。concactArr: wire connection sequence.
上述导线的元数据模型通过串口通信助手进行显示,具体如图6所示。The metadata model of the above wires is displayed through the serial communication assistant, as shown in Figure 6.
进一步地,在得到正交线的起始方向和最终方向时,包括:Further, when obtaining the initial direction and final direction of the orthogonal line, include:
获取正交线的起点坐标和正交线的终点坐标;Get the starting point coordinates of the orthogonal line and the end point coordinates of the orthogonal line;
根据正交线的起点坐标和起始元器件的起点坐标获得起点方向;Obtain the starting point direction according to the starting point coordinates of the orthogonal line and the starting point coordinates of the starting component;
根据正交线的终点坐标和结束元器件的终点坐标获得终点方向;Obtain the end point direction according to the end point coordinates of the orthogonal line and the end point coordinates of the end component;
在水平向量和竖直向量中挑选出与起点方向平行的向量,并判断与起点方向是否同向,若是,正交线的起始方向与挑选出来的向量同向,若否,正交线的起始方向与另一向量同向;Select the vector parallel to the starting point from the horizontal vector and vertical vector, and judge whether it is in the same direction as the starting point. If so, the starting direction of the orthogonal line is in the same direction as the selected vector. If not, the direction of the orthogonal line The starting direction is the same as the other vector;
在水平向量和竖直向量中挑选出与终点方向平行的向量,并判断与终点方向是否同向,若是,正交线的终点方向与挑选出来的向量同向,若否,正交线的终点方向与另一向量同向;Select the vector parallel to the end point direction from the horizontal vector and vertical vector, and judge whether it is in the same direction as the end point direction, if so, the end point direction of the orthogonal line is in the same direction as the selected vector, if not, the end point of the orthogonal line the direction is the same as the other vector;
其中,直接向量包括水平向量和竖直向量,如图8所示。Wherein, the direct vector includes a horizontal vector and a vertical vector, as shown in FIG. 8 .
更进一步地,在确定拐点的数量和得到拐点坐标时,包括:Furthermore, when determining the number of inflection points and obtaining the coordinates of inflection points, include:
判断正交线的起始方向和正交线的最终方向是否同向,若是,则拐点数量为2,若否,则拐点数量为1,如图9所示;Determine whether the initial direction of the orthogonal line and the final direction of the orthogonal line are in the same direction, if so, the number of inflection points is 2, if not, the number of inflection points is 1, as shown in Figure 9;
当拐点数量为1时,拐点坐标由公式1得到,公式1具体如下:When the number of inflection points is 1, the coordinates of the inflection point are obtained by
G=Z+Q (公式1);G=Z+Q (Formula 1);
其中,G为拐点坐标,Z为正交线起点坐标,Q为正交线的起始方向向量;Among them, G is the coordinate of the inflection point, Z is the coordinate of the starting point of the orthogonal line, and Q is the starting direction vector of the orthogonal line;
当拐点数量为2时,拐点坐标由公式2和公式3得到,公式2和公式3具体如下:When the number of inflection points is 2, the coordinates of the inflection points are obtained by
G1=Z+Q*0.5 (公式2);G 1 =Z+Q*0.5 (Formula 2);
G2=G1+F (公式3);G 2 =G 1 +F (Formula 3);
其中,G2为第二个拐点坐标,G1为第一个拐点坐标,F为水平向量和竖直向量中与正交线的起始方向垂直的向量。Among them, G 2 is the coordinate of the second inflection point, G 1 is the coordinate of the first inflection point, and F is the vector perpendicular to the starting direction of the orthogonal line among the horizontal vector and the vertical vector.
在上述步骤S3中,在对后台模型进行定义时,包括:In the above step S3, when defining the background model, it includes:
对各所述元器件的名称进行定义;Define the name of each component;
对各所述元器件间的交互信息进行定义;Define the interaction information between the components;
根据所述交互信息定义返回数据。The return data is defined according to the interaction information.
在上述步骤S5中,在完成虚拟电路的搭建后,包括:In the above step S5, after completing the construction of the virtual circuit, including:
后台模型接收到生成命令后,根据虚拟电路生成电路图和脚本文件;After the background model receives the generation command, it generates circuit diagrams and script files according to the virtual circuit;
将电路图和所述脚本文件保存到可视化文件中。Save the circuit diagram and said script file into a visualization.
在上述步骤S5中,在运行虚拟电路时,包括:In the above step S5, when running the virtual circuit, it includes:
通过脚本文件中电路配置参数来动态启动虚拟电路;Dynamically start the virtual circuit through the circuit configuration parameters in the script file;
通过脚本文件中电路配置参数来动态切换前端组件的状态;Dynamically switch the state of the front-end components through the circuit configuration parameters in the script file;
通过可视化文件展示前端组件和虚拟电路的运行状态。Display the running status of front-end components and virtual circuits through visualization files.
其中,脚本文件为config.cfg文件,可视化文件为view.json文件。Among them, the script file is the config.cfg file, and the visualization file is the view.json file.
进一步地,在动态切换前端组件的状态时,包括:Further, when dynamically switching the state of the front-end components, it includes:
通过Vuex的监听工具遍历所有的脚本文件,以获取多个状态数据;Traverse all script files through Vuex's monitoring tool to obtain multiple state data;
通过Vuex的监听工具监听状态数据的变化状态,当监听到状态数据发生变化时,通过Vuex的监听工具重新获取状态数据,以更新状态数据;Use the Vuex monitoring tool to monitor the status data change status. When the monitoring status data changes, re-acquire the status data through the Vuex monitoring tool to update the status data;
根据更新的状态数据切换前端组件的状态,以得到更新后的前端组件的状态。Switch the state of the front-end component according to the updated state data to obtain the updated state of the front-end component.
本发明提供的基于SVG虚拟电路的构建系统,如图10所示,包括:The construction system based on the SVG virtual circuit provided by the present invention, as shown in Figure 10, includes:
前端1,用于对元器件的元数据模型和元器件间的前端组件进行定义,生成对应的元器件和前端组件,并根据元器件和前端组件搭建虚拟电路,将虚拟电路的数据通过交互协议传送给服务端2,通过websocket链接接收到来自服务端2的启动命令、电路配置参数和状态数据,根据启动命令和电路配置参数启动并运行虚拟电路,根据状态数据动态切换前端组件的状态;Front-
服务端2,接收到来自前端1的虚拟电路的数据后,通过交互协议传送到后端3,接收到来自后端3的启动命令以及返回的电路配置参数和状态数据,并通过websocket链接传送给前端1。
后端3,用于对元器件的后台模型进行定义,生成对应的后台模型,并通过后台模型发出启动命令以及返回电路配置参数和状态数据到服务端2。The
相比现有技术,本发明的有益效果在于:Compared with the prior art, the beneficial effects of the present invention are:
(1)本发明的虚拟电路基于SVG进行构建,可以实现任意缩放而不破坏图形的清晰度和细节;(1) The virtual circuit of the present invention is constructed based on SVG, which can realize arbitrary scaling without destroying the clarity and details of the graphics;
(2)SVG是基于XML标准设计的,可以与其它技术建立联系,从而扩大了本发明的适用面;(2) SVG is designed based on the XML standard, and can be connected with other technologies, thereby expanding the scope of application of the present invention;
(3)SVG可以用矩形、椭圆、圆形、直线、折线、多边形以及路径等元素描述矢量图形,具有强大的作图能力,能提高本发明仿真的准确性;(3) SVG can describe vector graphics with elements such as rectangles, ellipses, circles, straight lines, polylines, polygons and paths, has powerful drawing capabilities, and can improve the accuracy of the simulation of the present invention;
(4)本发明基于SVG可对元器件之间的动态交互进行准确仿真,从而有效降低与真实电路间运行效果的差异。(4) Based on the SVG, the present invention can accurately simulate the dynamic interaction between components, thereby effectively reducing the difference between the operation effect and the real circuit.
上述实施方式仅为本发明的优选实施方式,不能以此来限定本发明保护的范围,本领域的技术人员在本发明的基础上所做的任何非实质性的变化及替换均属于本发明所要求保护的范围。The above-mentioned embodiment is only a preferred embodiment of the present invention, and cannot be used to limit the protection scope of the present invention. Any insubstantial changes and substitutions made by those skilled in the art on the basis of the present invention belong to the scope of the present invention. Scope of protection claimed.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211020803.4A CN115408968A (en) | 2022-08-24 | 2022-08-24 | A construction method and system based on SVG virtual circuit |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211020803.4A CN115408968A (en) | 2022-08-24 | 2022-08-24 | A construction method and system based on SVG virtual circuit |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115408968A true CN115408968A (en) | 2022-11-29 |
Family
ID=84162101
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211020803.4A Pending CN115408968A (en) | 2022-08-24 | 2022-08-24 | A construction method and system based on SVG virtual circuit |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115408968A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116644701A (en) * | 2023-05-09 | 2023-08-25 | 三峡高科信息技术有限责任公司 | SVG-based configurable circuit diagram generation method and system |
CN118365787A (en) * | 2024-04-19 | 2024-07-19 | 广州泓锐信息技术有限公司 | Virtual circuit visualization method and system |
-
2022
- 2022-08-24 CN CN202211020803.4A patent/CN115408968A/en active Pending
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116644701A (en) * | 2023-05-09 | 2023-08-25 | 三峡高科信息技术有限责任公司 | SVG-based configurable circuit diagram generation method and system |
CN116644701B (en) * | 2023-05-09 | 2024-01-16 | 三峡高科信息技术有限责任公司 | SVG-based configurable circuit diagram generation method and system |
CN118365787A (en) * | 2024-04-19 | 2024-07-19 | 广州泓锐信息技术有限公司 | Virtual circuit visualization method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11511188B2 (en) | Virtual scene recognition and interaction key position matching method for application and computing device | |
CN115408968A (en) | A construction method and system based on SVG virtual circuit | |
WO2015032282A1 (en) | Method and apparatus for testing hardware performance of electronic equipment | |
CN102651180B (en) | OSG-based (open scene graph-based) electric-electronic virtual experiment simulation system | |
CN102509485A (en) | Method for building virtual experiment information representation model | |
CN104462688B (en) | A kind of electric network information equipment operating simulation system | |
CN206075597U (en) | Transformer station's virtual reality Comprehensive Simulation Training System | |
CN107203432A (en) | A kind of method and system of remote control Android device | |
CN104461690B (en) | A kind of power equipment operating simulation system | |
CN113268303A (en) | Interface element configuration method and device, storage medium and electronic equipment | |
CN108763188A (en) | Text display method, device, equipment and storage medium | |
CN106846431B (en) | Unified Web graph drawing system supporting multiple expression forms | |
CN103678099B (en) | A kind of method and device realizing hardware platform and software platform communication | |
CN108959682B (en) | Method for establishing circuit virtual experiment | |
CN103970896A (en) | Method and system for graphic display based on scalable vector graphic continuous information | |
US20160171132A1 (en) | Simulation device and simulation program | |
CN112148241A (en) | Light processing method and device, computing equipment and storage medium | |
CN104932467B (en) | One kind being used for the central controlled method of program-controlled equipment | |
US10846061B2 (en) | Development environment for real-time application development | |
CN107562221A (en) | PS/2 keyboard and mouse interface online experiment methods based on FPGA online experiment platforms | |
CN113407044B (en) | Method, device, equipment and storage medium for simulating terminal handle input | |
WO2023213094A1 (en) | Dynamic data area selection method, system and device applied to integrated circuit device, and computer-readable storage medium | |
CN117910400B (en) | A data comparison and verification method, system, device and medium | |
JP2007226567A (en) | Circuit simulator and circuit simulation program | |
Sun et al. | User Interface Design and Interactive Experience Based on Virtual Reality |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |