successfully send the data of spice and simulation to the background

main
ColsonZhang 2021-03-16 20:46:30 +08:00
parent 26208b7050
commit 46d65a33b9
6 changed files with 39 additions and 8 deletions

View File

@ -64,6 +64,7 @@ app.py ----服务器的主程序
* 新增成功将spice网表和simulation设置参数传入后端
* 待解决1前端代码冗杂缺乏层次
* 待解决2需要在后端根据传入参数进行电路仿真 并将仿真结果传递回前端
* 待解决3将常用的单位转换为pyspice能够识别的单位string to specfic unit
* 2021年2月9号前端更新
* 发现bug: 当schematic中没有组件时spice的parse函数抛出错误

Binary file not shown.

View File

@ -46,4 +46,8 @@ class Simulator_CZ :
if(sim_type == 'transient'):
parameter["step_time"] = 0
pass
def unit_transform(value_raw):
pass

View File

@ -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

View File

@ -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<properties.length; i++){
@ -1181,7 +1181,7 @@ function showOutline(graph)
{
var node = ParseSpice(graph.getModel());
var circuit = NormalizeXML(node);
let spice = ExtractSpice_2(circuit);
let spice = ExtractSpice_2(circuit);
var data = new Object();
data["name"] = "Spice";
@ -1263,7 +1263,7 @@ function showOutline(graph)
var input = document.createElement('input');
input.setAttribute('name', the_mode['key'][j]);
input.setAttribute("class","simulator_input")
input.setAttribute("class","simulator_input");
input.setAttribute('type', "text");
input.setAttribute('value', the_mode['value'][j] );
td_input.appendChild(input);
@ -1275,8 +1275,12 @@ function showOutline(graph)
var confirm = document.createElement('button');
confirm.setAttribute("type","submit");
confirm.setAttribute('onclick',"Simulator('"+sim_mode[i] +"')");
// confirm.onclick = function(){ Simulator(sim_mode[i]); };
confirm.setAttribute("class",sim_mode[i]);
// confirm.setAttribute('onclick',"Simulator('"+sim_mode[i] +"'; ");
confirm.onclick = function(){
let spice = get_spice(graph);
Simulator(this.className,spice);
};
confirm.innerHTML = "Confirm";
table.appendChild(confirm);