diff --git a/README.md b/README.md index ac305e6..7a3833b 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,12 @@ ## 更新日志 +* 2021年2月8号,前端更新 + + * 优化了schematic电路图提取spice网表功能 + * 新增加了多种电源器件 + * 初步实验了将提取出来的spice网表送进spice仿真器中执行仿真的结果 + * ![avatar](./Schematic/schematic4.png) * 2021年2月2日,前端更新 * 增加电路spice网表提取功能 diff --git a/Schematic/schematic4.png b/Schematic/schematic4.png new file mode 100644 index 0000000..d5c9ce4 Binary files /dev/null and b/Schematic/schematic4.png differ diff --git a/Schematic/template/icon_ee/vac.ico b/Schematic/template/icon_ee/vac.ico new file mode 100644 index 0000000..d8fbbef Binary files /dev/null and b/Schematic/template/icon_ee/vac.ico differ diff --git a/Schematic/template/icon_ee/vdc.ico b/Schematic/template/icon_ee/vdc.ico new file mode 100644 index 0000000..a010588 Binary files /dev/null and b/Schematic/template/icon_ee/vdc.ico differ diff --git a/Schematic/template/icon_ee/vsin.ico b/Schematic/template/icon_ee/vsin.ico new file mode 100644 index 0000000..b136d89 Binary files /dev/null and b/Schematic/template/icon_ee/vsin.ico differ diff --git a/Schematic/template/schematic.html b/Schematic/template/schematic.html index 0e699e4..69b7405 100644 --- a/Schematic/template/schematic.html +++ b/Schematic/template/schematic.html @@ -128,23 +128,33 @@ { var Value_raw = cell.getValue(); var Value_att = ParseAttribute(Value_raw); - var Value_show = Value_att['name'] == 'unknown' ? '' : Value_att['name']; + var Value_show = ''; + if(Value_att['Name'] == 'unknown'){ + if(Value_att['name'] != 'unknown'){ + Value_show = Value_att['name']; + } + } + else{ + Value_show = Value_att['Name']; + } + + // var Value_show = Value_att['name'] == 'unknown' ? '' : Value_att['name']; return Value_show; }; // 暂时不允许在此进行修改 var cellLabelChanged = graph.cellLabelChanged; - graph.cellLabelChanged = function(cell, newValue, autoSize) + graph.cellLabelChanged = function(cell, new_value, autoSize) { - // if (mxUtils.isNode(cell.value)) - // { - // // Clones the value for correct undo/redo - // var elt = cell.value.cloneNode(true); - // elt.setAttribute('label', newValue); - // newValue = elt; - // } - // cellLabelChanged.apply(this, arguments); + + // // Clones the value for correct undo/redo + // var elt = cell.value.cloneNode(true); + + // newValue = elt; + // autoSize = false; + + // cellLabelChanged.apply(this, arguments); }; graph.getTooltipForCell = function(cell) @@ -180,14 +190,17 @@ addVertex_2('icon_ee/res.ico', 80, 30, 'shape=resistor;verticalLabelPosition=top;verticalAlign=bottom','Name=R;Value=10 Ohm;'); addVertex_2('icon_ee/cap.ico', 40, 30, 'shape=capacitor;verticalLabelPosition=top;verticalAlign=bottom','Name=C;Value=10 pF;'); - addVertex_2('icon_ee/nmos.ico', 60, 60, 'shape=n_mosfet;verticalLabelPosition=top;verticalAlign=bottom','Name=NMOS;Length=100nm;Width=20nm;'); - addVertex_2('icon_ee/pmos.ico', 60, 60, 'shape=p_mosfet;verticalLabelPosition=top;verticalAlign=bottom','Name=PMOS;Length=100nm;Width=20nm;'); - addVertex_2('icon_ee/vdd.ico', 40, 30, 'shape=vdd;verticalLabelPosition=top;verticalAlign=bottom','Name=Vdd;Value=10 V;'); - addVertex_2('icon_ee/gnd.ico', 40, 40, 'shape=gnd;verticalLabelPosition=top;verticalAlign=bottom','Name=Gnd;'); + addVertex_2('icon_ee/nmos.ico', 60, 60, 'shape=n_mosfet;verticalLabelPosition=top;verticalAlign=bottom','Name=M_NMOS;Length=100nm;Width=20nm;'); + addVertex_2('icon_ee/pmos.ico', 60, 60, 'shape=p_mosfet;verticalLabelPosition=top;verticalAlign=bottom','Name=M_PMOS;Length=100nm;Width=20nm;'); + addVertex_2('icon_ee/vdd.ico', 40, 30, 'shape=vdd;verticalLabelPosition=top;verticalAlign=bottom','Name=Vdd;'); + addVertex_2('icon_ee/gnd.ico', 40, 40, 'shape=gnd;verticalLabelPosition=bottom;verticalAlign=top','Name=Gnd;'); addVertex_2('icon_ee/pin.ico', 40, 40, 'shape=pin;verticalLabelPosition=top;verticalAlign=bottom','Name=Pin;'); addVertex_2('icon_ee/pout.ico', 40, 40, 'shape=pout;verticalLabelPosition=top;verticalAlign=bottom','Name=Pout;'); - + addVertex_2('icon_ee/vdc.ico', 40, 40, 'shape=vdc;labelPosition=left;align=right','Name=Vdc;DC=1 V;'); + addVertex_2('icon_ee/vac.ico', 40, 40, 'shape=vac;labelPosition=left;align=right','Name=Vac;DC=0 V;ACMAG=1 V;ACPHASE=0 deg;'); + addVertex_2('icon_ee/vsin.ico', 40, 40, 'shape=vsin;labelPosition=left;align=right','Name=Vsin;V0=0 V;VA=1 V;FREQ=1k Hz;TD=0 ;THEAT=0 ;PHASE=0 ;'); + toolbar.addLine(); click_handler(graph); @@ -220,8 +233,8 @@ // 获取属性 function ParseAttribute(value) { - value = value||"name=unknown;" ; - value = value.toLowerCase(); + value = value||"Name=unknown;" ; + // value = value.toLowerCase(); var attribute = {} ; v = value.replace(" ",""); var v_split = v.split(";"); @@ -379,7 +392,7 @@ function NormalizeXML(info){ if(temp['type'] == 'vdd'){ temp['port'] = {'vdd': 'vdd'}; temp['port_keys'] = ['vdd']; - temp['value'] = {'voltage': info['elements'][i]['value']['Value']}; + // temp['value'] = {'voltage': info['elements'][i]['value']['Value']}; } else if(temp['type'] == 'gnd'){ temp['port'] = {'gnd': 'gnd'}; @@ -408,6 +421,29 @@ function NormalizeXML(info){ temp['port'] = {'pout': 'pout'}; temp['port_keys'] = ['pout']; } + else if(temp['type'] == 'vdc'){ + temp['port'] = {'pos': 'pos', 'neg':'neg'}; + temp['port_keys'] = ['pos','neg']; + temp['value'] = {'DC': info['elements'][i]['value']['DC'] } + } + else if(temp['type'] == 'vac'){ + temp['port'] = {'pos': 'pos', 'neg':'neg'}; + temp['port_keys'] = ['pos','neg']; + temp['value'] = {'ACMAG': info['elements'][i]['value']['ACMAG'], + 'ACPHASE': info['elements'][i]['value']['ACPHASE'], + 'DC':info['elements'][i]['value']['DC']} + } + else if(temp['type'] == 'vsin'){ + temp['port'] = {'pos': 'pos', 'neg':'neg'}; + temp['port_keys'] = ['pos','neg']; + temp['value'] = {'V0': info['elements'][i]['value']['V0'], + 'VA': info['elements'][i]['value']['VA'], + 'FREQ': info['elements'][i]['value']['FREQ'], + 'TD': info['elements'][i]['value']['TD'], + 'THEAT': info['elements'][i]['value']['THEAT'], + 'PHASE': info['elements'][i]['value']['PHASE'] + } + } circuit.push(temp); } @@ -473,23 +509,50 @@ function NormalizeXML(info){ } } + let count = 1 ; + let node_str = ''; + let flag_gnd = false; for(var i=0; i + + + + @@ -2199,7 +2519,7 @@ Adds oval markers for edge-to-edge connections. return ports2; }; - // ... except for n mosfet + // for n mosfet var ports_resistor = new Array(); ports_resistor['pos'] = {x: 0, y: 0.5, perimeter: true, constraint: 'west'}; ports_resistor['neg'] = {x: 1, y: 0.5, perimeter: true, constraint: 'east'}; @@ -2209,7 +2529,7 @@ Adds oval markers for edge-to-edge connections. return ports_resistor; }; - // ... except for n mosfet + // for n mosfet var ports_nmosfet = new Array(); ports_nmosfet['gate'] = {x: 0, y: 0.5, perimeter: true, constraint: 'west'}; ports_nmosfet['drain'] = {x: 1, y: 0.25, perimeter: true, constraint: 'east'}; @@ -2218,7 +2538,7 @@ Adds oval markers for edge-to-edge connections. N_Mosfet_Shape.prototype.getPorts = function(){ return ports_nmosfet; }; - // ... except for p mosfet + // for p mosfet var ports_pmosfet = new Array(); ports_pmosfet['gate'] = {x: 0, y: 0.5, perimeter: true, constraint: 'west'}; ports_pmosfet['source'] = {x: 1, y: 0.25, perimeter: true, constraint: 'east'}; @@ -2227,14 +2547,14 @@ Adds oval markers for edge-to-edge connections. P_Mosfet_Shape.prototype.getPorts = function(){ return ports_pmosfet; }; - // ... except for vdd + // for vdd var ports_vdd = new Array(); ports_vdd['vdd'] = {x: 0.5, y: 1, perimeter: true, constraint: 'south'}; Vdd_Shape.prototype.getPorts = function(){ return ports_vdd; }; - // ... except for gnd + // for gnd var ports_gnd = new Array(); ports_gnd['gnd'] = {x: 0.5, y: 0, perimeter: true, constraint: 'north'}; @@ -2242,7 +2562,7 @@ Adds oval markers for edge-to-edge connections. return ports_gnd; }; - // ... except for capatiance + // for capatiance var ports_capatiance = new Array(); ports_capatiance['pos'] = {x: 0.0, y: 0.5, perimeter: true, constraint: 'west'}; ports_capatiance['neg'] = {x: 1.0, y: 0.5, perimeter: true, constraint: 'east'}; @@ -2251,20 +2571,48 @@ Adds oval markers for edge-to-edge connections. return ports_capatiance; }; - // ... except for capatiance + // for port_pin var ports_pin = new Array(); ports_pin['pin'] = {x: 1.0, y: 0.5, perimeter: true, constraint: 'east'}; Pin_Shape.prototype.getPorts = function(){ return ports_pin; }; - // ... except for capatiance + // for port_out var ports_pout = new Array(); ports_pout['pout'] = {x: 0.0, y: 0.5, perimeter: true, constraint: 'west'}; Pout_Shape.prototype.getPorts = function(){ return ports_pout; }; + // for Vdc + var ports_vdc = new Array(); + ports_vdc['pos'] = {x: 0.5, y: 0.0, perimeter: true, constraint: 'north'}; + ports_vdc['neg'] = {x: 0.5, y: 1.0, perimeter: true, constraint: 'south'}; + + Vdc_Shape.prototype.getPorts = function(){ + return ports_vdc; + }; + // for Vac + var ports_vac = new Array(); + ports_vac['pos'] = {x: 0.5, y: 0.0, perimeter: true, constraint: 'north'}; + ports_vac['neg'] = {x: 0.5, y: 1.0, perimeter: true, constraint: 'south'}; + + Vac_Shape.prototype.getPorts = function(){ + return ports_vac; + }; + + // for Vsin + var ports_vsin = new Array(); + ports_vsin['pos'] = {x: 0.5, y: 0.0, perimeter: true, constraint: 'north'}; + ports_vsin['neg'] = {x: 0.5, y: 1.0, perimeter: true, constraint: 'south'}; + + Vsin_Shape.prototype.getPorts = function(){ + return ports_vsin; + }; + + +