/* 基于bokeh.js库文件 使用该文件前请现在html加载相关js文件*/ // 仿真结果数据 var SimResult = {} ; var Flag_Refresh = {"transient":false,"dc":false,"ac":false} ; var color_store = ["blue","brown","cyan","green","orange","pink","purple","red","whitesmoke","yellow"]; function openMode(evt, tabMode, ducument_ID) { var i, tabcontent, tablinks; var the_document = document.getElementById(ducument_ID); tabcontent = the_document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = the_document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(tabMode).style.display = "block"; evt.currentTarget.className += " active"; }; function plotPoint_tran() { if(Flag_Refresh['transient'] == true){ the_source['transient'].data.x = []; the_source['transient'].data.y = []; the_source['transient'].data.color = []; console.log("Flag_Refresh = true !"); var the_nodes_name = SimResult['transient']["nodes_name"]; var the_x = SimResult['transient']["time"]; for(var i=0; i < the_nodes_name.length; i++){ var the_y = SimResult['transient']["nodes"][the_nodes_name[i]] ; the_source['transient'].data.x.push(the_x); the_source['transient'].data.y.push(the_y); the_source['transient'].data.color.push(color_store[i%color_store.length]); } the_source['transient'].change.emit(); } else{ alert("The information has not been updated !!!"); } }; function plotPoint_dc() { if(Flag_Refresh['dc'] == true){ the_source['dc'].data.x = []; the_source['dc'].data.y = []; the_source['dc'].data.color = []; console.log("Flag_Refresh = true !"); var the_nodes_name = SimResult['dc']["nodes_name"]; var the_x = SimResult['dc']["sweep"]; for(var i=0; i < the_nodes_name.length; i++){ var the_y = SimResult['dc']["nodes"][the_nodes_name[i]] ; the_source['dc'].data.x.push(the_x); the_source['dc'].data.y.push(the_y); the_source['dc'].data.color.push(color_store[i%color_store.length]); } the_source['dc'].change.emit(); } else{ alert("The information has not been updated !!!"); } }; function plotPoint_ac() { if(Flag_Refresh['ac'] == true){ the_source['ac']["gain"].data.x = []; the_source['ac']["gain"].data.y = []; the_source['ac']["gain"].data.color = []; the_source['ac']["phase"].data.x = []; the_source['ac']["phase"].data.y = []; the_source['ac']["phase"].data.color = []; var the_nodes_name = SimResult['ac']["nodes_name"]; var the_x = SimResult['ac']["frequency"]; for(var i=0; i < the_nodes_name.length; i++){ var the_gain = SimResult['ac']["nodes_gain"][the_nodes_name[i]] ; var the_phase = SimResult['ac']["nodes_phase"][the_nodes_name[i]] ; the_source['ac']["gain"].data.x.push(the_x); the_source['ac']["gain"].data.y.push(the_gain); the_source['ac']["gain"].data.color.push(color_store[i%color_store.length]); the_source['ac']["phase"].data.x.push(the_x); the_source['ac']["phase"].data.y.push(the_phase); the_source['ac']["phase"].data.color.push(color_store[i%color_store.length]); } the_source['ac']["gain"].change.emit(); the_source['ac']["phase"].change.emit(); } else{ alert("The information has not been updated !!!"); } }; function PlotSimulationResult(sim_type){ if(sim_type == "transient"){ plotPoint_tran(); } else if(sim_type == "dc"){ plotPoint_dc(); } else if(sim_type == 'ac'){ plotPoint_ac(); } }; function requestSimInfo(sim_type){ var data = new Object(); var sim_result ; data["sim_type"] = sim_type; // console.log(sim_type); // console.log(data); $.ajax({ type: 'POST', url: "/getsiminfo", data: data, async:false, // 必须关闭异步!!! dataType: "json", success: function (siminfo) { console.log("load sim result successfully !!"); sim_result = siminfo; }, error: function(){ alert('ajax post failed !!!'); } }); console.log(sim_result); return sim_result ; }; function Callback_Refresh(sim_type){ SimResult[sim_type] = requestSimInfo(sim_type); Flag_Refresh[sim_type] = true; }; // bokeh组件相关变量 var bokeh_plot = {} ; var the_source = {} ; // 添加 Tab 组件 var sim_mode = ['transient', 'dc', 'ac']; var div_node = document.createElement('div'); var div_tab = document.createElement('div'); div_tab.setAttribute('class','tab'); div_node.appendChild(div_tab); var frame = $("#show_result"); frame.append(div_node); for(var i=0; i