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 0000000..6888ad5 Binary files /dev/null and b/handler/__pycache__/simulation.cpython-36.pyc differ diff --git a/handler/__pycache__/spice.cpython-36.pyc b/handler/__pycache__/spice.cpython-36.pyc index d71e480..2062b39 100644 Binary files a/handler/__pycache__/spice.cpython-36.pyc and b/handler/__pycache__/spice.cpython-36.pyc differ 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