add a new idea

main
ColsonZhang 2021-03-18 20:54:06 +08:00
parent 5046ffb4cc
commit 3b6d299816
4 changed files with 61 additions and 0 deletions

View File

@ -59,6 +59,9 @@ app.py ----服务器的主程序
## 更新日志
* 2021年3月18号后端更新
* idea & todo仿真结果数据可视化的基本思路为在后端的python代码中用一个自定义类封装的simulation result data container来容纳数据并新增一个用于处理get/post请求的处理函数当前端需要这些相关数据时通过ajax发送过去同时前端使用bokehjs封装一个通用的结果显示的“示波器”向服务器后端发送请求接收相关数据并展示结果。
* 2021年3月17号后端更新
* 新增根据前端传入的电路数据和仿真参数进行参数转换调用pyspice执行电路仿真

View File

@ -0,0 +1,8 @@
class Sim_Data_Container :
def __init__(self):
self.analysis = None
def load_analysis(self,analysis):
self.analysis = analysis

View File

@ -3,9 +3,11 @@ from .js import js_import, js_code_1
import tornado.web
from .MongoDB import *
from .simulation import Simulator_CZ
from .sim_data_container import Sim_Data_Container
# from bokeh.embed import server_document
# from jinja2 import Environment, FileSystemLoader
Container_SimResult = Sim_Data_Container()
class SpiceHandler(AuthBaseHandler):

View File

@ -0,0 +1,48 @@
/* bokeh.js
使用该文件前请现在html加载相关js文件*/
// create a data source to hold data
var source = new Bokeh.ColumnDataSource({
data: { x: [], y: [] }
});
// make a plot with some tools
var plot = Bokeh.Plotting.figure({
title:'Example of Random data',
tools: "pan,wheel_zoom,box_zoom,reset,save",
height: 300,
width: 300
});
// add a line with data from the source
plot.line({ field: "x" }, { field: "y" }, {
source: source,
line_width: 2
});
// show the plot, appending it to the end of the current section
Bokeh.Plotting.show(plot,'#bokeh_01');
function addPoint() {
// add data --- all fields must be the same length.
source.data.x.push(Math.random())
source.data.y.push(Math.random())
// notify the DataSource of "in-place" changes
source.change.emit()
}
function Callback_Button() {
addPoint();
}
var addDataButton = document.createElement("Button");
addDataButton.appendChild(document.createTextNode("Add Some Data!!!"));
document.currentScript.parentElement.appendChild(addDataButton);
addDataButton.addEventListener("click", Callback_Button);
addPoint();
addPoint();