From 46d65a33b9ad7abf0bd38fbe80b5e059c010bee3 Mon Sep 17 00:00:00 2001 From: ColsonZhang <784278850@qq.com> Date: Tue, 16 Mar 2021 20:46:30 +0800 Subject: [PATCH] successfully send the data of spice and simulation to the background --- README.md | 1 + handler/__pycache__/simulation.cpython-36.pyc | Bin 0 -> 1781 bytes handler/__pycache__/spice.cpython-36.pyc | Bin 2907 -> 3373 bytes handler/simulation.py | 4 +++ handler/spice.py | 26 ++++++++++++++++-- template/schematic/schematic.html | 16 +++++++---- 6 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 handler/__pycache__/simulation.cpython-36.pyc diff --git a/README.md b/README.md index 51c24eb..da64bee 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ app.py ----服务器的主程序 * 新增:成功将spice网表和simulation设置参数传入后端 * 待解决1:前端代码冗杂,缺乏层次 * 待解决2:需要在后端根据传入参数进行电路仿真, 并将仿真结果传递回前端 + * 待解决3:将常用的单位转换为pyspice能够识别的单位(string to specfic unit) * 2021年2月9号,前端更新 * 发现bug: 当schematic中没有组件时,spice的parse函数抛出错误 diff --git a/handler/__pycache__/simulation.cpython-36.pyc b/handler/__pycache__/simulation.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6888ad5b9aa86bc6600bedd1260fb13e11807507 GIT binary patch literal 1781 zcmZuy&2Aev5GJ|1(rPWas$(Z{+WDo9h0R zOQDgVoa}2}qPM=%UVF+b^wb%yq}Wci;BbaRa=!Vaz8MUn!C%wg9(M`(hurvi!2bxN zo&%9Y(v0MkQ;IyxSnhGp@m}WV0S_GSXPvyuyN(aC@ErGcvfezJM?6x|eD8|zzU=aW z3e@0=^8M#ThO&1}Wbcack7VbJ#L+vjM`GISztV*inSN;!qg4$newCFL=KfiwQ}x1W zmLPY>+N2AOD*EMQ_4xGr+0>MCm0I!Sj)xF+0}9odCBXkqh?i~w>U5b1o8CAKtT%$ulgC0!ON+ZezZ#~4Pv z55$r+y`pO(z!Ka+CowYttT)|s;|**4T4k@Az-pVRzlrIC`rp$JynAoDJvbY4@pGjL z7p2){Qpil1*?UZ*YT1NB=t5f|4iJw6NmoZVy%=qGq!hN`4`&RMbKwhMESXcE%$cO$ zf^ULt(vxQWje}H|HnHK6UGqW@=>)F@eofNr1c9fSg_DlpeO%Dj~ zndDF5(g`^a9OI(Xk^yXKde4;=?%w+#);!D3^eJ3Y ze+GomK0Tlz(2o1|DFew3wi@2bCJ49kxU1HOaE&H!7(|;wv=1eN9C=UMnEMll*kFCP zQNTundiw+y5Qjk=cR(7v^D7v22!v1{K!tSm=oX;6p_;_h;P$wS9aw<(LNt*OP~VFT z`MwZ;ERw9%7OLL}{?r4c04eb5KGS`C$-#>{jC;e>h#bHW;0j>FC+( zB(E}cUY1#Hufmwe#5eDi;>bk6->ESm6X8_XZj Ti5g3>52b@2mQd*VEM)%yGXT5@ literal 0 HcmV?d00001 diff --git a/handler/__pycache__/spice.cpython-36.pyc b/handler/__pycache__/spice.cpython-36.pyc index d71e48037124b472ef164dd9b361f1a83fe23690..2062b39ccc2963fc5393b6b31e12ec7e20a3737d 100644 GIT binary patch literal 3373 zcmbtWTW=dh6rS0OcjGvYow~VHTugz25lWk+fD}q8O%O<^ZbguQRnW5aY?DoQz3%Lq zwwC*pzV>e*@gMjl^U72ILZA4~_!7r03axF;**SA&&dhx0n=`Yuuu#14=bhg-<{A5k zP5dm>Z=hsp=0`~APi-0x}R7~fMC#$~E-|Dpc6h(; z7950sF-bVT_>bEd*d1Ac$JnsF3eq8ol@l@iw)&5Ji;CfN%}1zcIzCLm&{hA;HHybKsuXs(JP! zD#SC*FJc-FG%-!rOw{b0_bq%2;2v0ZOdK-=I5w;m`Zm?j-#pDUH;WQKf7}6wIx_8q zGLOPc&SAdZ987gGZTIGew#TUIpw#R2ZMleE4NF$>QMHrNelCM{b}yBQT!Kk1Q#VJh zP<@re8i`8~sys0&%cY)Iene*C%|K|>DI7F5t3WWL$niJa!MD&`ehJ1A5#+n*F6$)T zBXN<$`y@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)a1@gO_i?l@+k3( z(+oPvWSR+CL?RzmF}hBpJEQ7!_;g1$u~Ns9E!AqY zBmt`LUn~R_foiP_LG+Y`m~L0IJGzmVZ{M2rHjaxV#s{c^t;X@8vMy5iJaNjxKBN?M zI)*vAc2N2(Big_WX!{DjI`A=96upYB%tv@Yw3fmp{K|YS>s{w>ma)xb`vPpW^|rpH z?dFsw`7xroiX%z6eNv_Xj#e&2u^>Y?DTdNLwl?8K8QQv(Av#2~o>tMB=&4|IY&^B5 zs$|0UFhsbstn4I+29nCI%zl0@d9^e>#y4<^>%&92`tN1$fj*n{xghCdr}wj#q-I?^ jzU)h>yssvI40q|DFQ+Y9XD#M2&uKMU^_JW6&?^4|#Lz{T diff --git a/handler/simulation.py b/handler/simulation.py index 869fb18..02e34da 100644 --- a/handler/simulation.py +++ b/handler/simulation.py @@ -46,4 +46,8 @@ class Simulator_CZ : if(sim_type == 'transient'): parameter["step_time"] = 0 pass + + def unit_transform(value_raw): + pass + diff --git a/handler/spice.py b/handler/spice.py index 218420f..ad54cc6 100644 --- a/handler/spice.py +++ b/handler/spice.py @@ -2,6 +2,7 @@ from .main import AuthBaseHandler from .js import js_import, js_code_1 import tornado.web from .MongoDB import * +from .simulation import Simulator_CZ # from bokeh.embed import server_document # from jinja2 import Environment, FileSystemLoader @@ -23,14 +24,35 @@ class SimulationHandler(AuthBaseHandler): @tornado.web.authenticated def post(self,*args,**kwargs): sim_type = self.get_argument('sim_type') - properties = self.get_argument('properties') + properties_str = self.get_argument('properties') + spice = self.get_argument('spice') + + properties = properties_transform(properties_str) print("sim type:",sim_type) - print("property:",properties) + print("property:",properties_str) + print("spice :",spice) + + # simulator = Simulator_CZ() + # simulator.Get_Spice(spice) + self.write("success") + +def properties_transform(properties_str): + properties = {} + attributes = properties_str.split(";") + # print(attributes) + for attr in attributes: + if(attr != ''): + term = attr.split("=") + properties[term[0]] = term[1] + return properties + + + class Schematic_Handler(AuthBaseHandler): @tornado.web.authenticated diff --git a/template/schematic/schematic.html b/template/schematic/schematic.html index a8b9dbc..629c623 100644 --- a/template/schematic/schematic.html +++ b/template/schematic/schematic.html @@ -774,7 +774,7 @@ function ajax_message(data) { } // 由于ajax传递参数时,无法直接进行List的传递,故将属性List转换为了string然后进行传递 -function Simulator(sim_type){ +function Simulator(sim_type, spice){ // var properties = []; var properties_send = ""; @@ -796,7 +796,7 @@ function Simulator(sim_type){ var data = new Object(); data["sim_type"] = sim_type; data["properties"] = properties_send; - // data['spice'] = spice; + data['spice'] = spice; // alert(spice); // for(var i=0; i