From 26208b70504b17aae89ee305686b2301ddd70d1b Mon Sep 17 00:00:00 2001 From: ColsonZhang <784278850@qq.com> Date: Tue, 16 Mar 2021 19:09:58 +0800 Subject: [PATCH] successfully send the data of spice and simulation to the background --- README.md | 5 ++ app.py | 1 + handler/__pycache__/spice.cpython-36.pyc | Bin 2499 -> 2907 bytes handler/simulation.py | 49 +++++++++++++ handler/spice.py | 11 ++- static/schematic/css/tab.css | 44 +++++++++++ static/spice/bokeh_02.js | 24 +++--- template/schematic/schematic.html | 89 ++++++++++++++++++++--- 8 files changed, 201 insertions(+), 22 deletions(-) create mode 100644 handler/simulation.py create mode 100644 static/schematic/css/tab.css diff --git a/README.md b/README.md index 9e489c3..51c24eb 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,11 @@ app.py ----服务器的主程序 ## 更新日志 +* 2021年3月16号,前端+后端更新 + + * 新增:成功将spice网表和simulation设置参数传入后端 + * 待解决1:前端代码冗杂,缺乏层次 + * 待解决2:需要在后端根据传入参数进行电路仿真, 并将仿真结果传递回前端 * 2021年2月9号,前端更新 * 发现bug: 当schematic中没有组件时,spice的parse函数抛出错误 diff --git a/app.py b/app.py index d8ae518..2c7136a 100644 --- a/app.py +++ b/app.py @@ -23,6 +23,7 @@ class Application(tornado.web.Application): #引入Application类,重写方 (r'/spice4',spice.Spice_4_Handler), (r'/test',main.TestHandler), (r'/spice',spice.SpiceHandler), + (r'/simulation',spice.SimulationHandler), ] settings = dict( debug = False, #调试模式,修改后自动重启服务,不需要自动重启,生产情况下切勿开启,安全性 diff --git a/handler/__pycache__/spice.cpython-36.pyc b/handler/__pycache__/spice.cpython-36.pyc index def80ffb97e1bfb186881deca99fec26db712458..d71e48037124b472ef164dd9b361f1a83fe23690 100644 GIT binary patch delta 693 zcmaJ+&rcIU6rMM;yPe%o*jg+Yfe>1MY|D>e69R;Y1rm)1(Qwj>CC(mdfHt!=k*3B& ziJS<5ci@OzJeqhg;fh{7aR-hZx$r0WrV^+oILZ6wn{VFxzL}rNlT{WER66$IxjA|~a{S!u>thpEZ>ZER`s6c3+Hk~kV(+IXs z8Qx`}+rS+>aFY2RLwgC#MdT4M?t#~=T593n&ka|~5f<$=Bwb^!wP+@83Z{o~7ZmV9UN z+%8h<3uoB0=5fs_WUmd#(e!AGL$2xYAl4E#fnQ?(aTuiO@k2!1n3tE!@Qp&kRCWf2#|%h-1;};);^GMtmHXLJSb`Zeg*KjGV`O1gP*9kB zk#Q@d+vIj8eYW7#qO#PY$y=G;Ox9v;VU(V{p4FLAZL%!4xKNP_P`@O|3??AK!BnI& zxq-uZay*+Cqv~V>E)`Zaps>>9%WRGi4Qxf~Kmmox0&M=18`%@MRe`)BW)Q&wSFSZ# zlmn_vk= + + + + @@ -752,6 +773,50 @@ function ajax_message(data) { }); } +// 由于ajax传递参数时,无法直接进行List的传递,故将属性List转换为了string然后进行传递 +function Simulator(sim_type){ + + // var properties = []; + var properties_send = ""; + var sel = $("#"+sim_type+" input"); + + // alert(sim_type); + + sel.each(function(){ + var new_element = {}; + var n = $(this)[0].name; + var v = $(this)[0].value; + + properties_send += n + "=" + v + ";"; + // new_element[n] = v ; + // properties.push(new_element); + }); + + + var data = new Object(); + data["sim_type"] = sim_type; + data["properties"] = properties_send; + // data['spice'] = spice; + // alert(spice); + + // for(var i=0; i @@ -832,8 +897,6 @@ function showProperties(graph,cell) } }; - - @@ -1141,15 +1204,20 @@ function showOutline(graph) var frame = document.createElement('div'); frame.setAttribute('id','bokeh_02'); + // var x = document.createElement('script'); + // x.setAttribute('src','static/spice/bokeh_02.js'); + // frame.appendChild(x); + var div_tab = document.createElement('div'); div_tab.setAttribute('class','tab'); - let sim_mode = ['transient', 'dc', 'ac']; + + var sim_mode = ['transient', 'dc', 'ac']; - let sim_mode_content = { + var sim_mode_content = { 'transient': { "key" :[ 'step_time', 'end_time', 'start_time','max_time','use_initial_condition'], - "value" :[ '', '', '0', 'None', 'False'] + "value" :[ '0.1 us', '20 us', '0', 'None', 'False'] }, 'dc': { "key" :[ "src","start","stop","step"], @@ -1200,13 +1268,15 @@ function showOutline(graph) input.setAttribute('value', the_mode['value'][j] ); td_input.appendChild(input); - form_div .appendChild(td_input); + form_div.appendChild(td_input); table.appendChild(form_div); } + var confirm = document.createElement('button'); confirm.setAttribute("type","submit"); - confirm.setAttribute('onclick',"Simulation('"+sim_mode[i] +"')"); + confirm.setAttribute('onclick',"Simulator('"+sim_mode[i] +"')"); + // confirm.onclick = function(){ Simulator(sim_mode[i]); }; confirm.innerHTML = "Confirm"; table.appendChild(confirm); @@ -1214,12 +1284,9 @@ function showOutline(graph) div_mode.appendChild(table); frame.appendChild(div_mode); - } + }; - var x = document.createElement('script'); - x.setAttribute('src','static/spice/bokeh_02.js'); - frame.appendChild(x); var w = document.body.clientWidth; var h = (document.body.clientHeight || document.documentElement.clientHeight);