successfully send the data of spice and simulation to the background
parent
26208b7050
commit
46d65a33b9
|
@ -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.
Binary file not shown.
|
@ -46,4 +46,8 @@ class Simulator_CZ :
|
|||
if(sim_type == 'transient'):
|
||||
parameter["step_time"] = 0
|
||||
pass
|
||||
|
||||
def unit_transform(value_raw):
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue