a big imporvement
46
README.md
@ -11,22 +11,26 @@
|
||||
|
||||
## 项目框架
|
||||
|
||||
### Schematic
|
||||
|
||||
能够绘制电路原理图的web前端代码,主要采用mxGraph代码构建。
|
||||
|
||||
#### 运行方法
|
||||
|
||||
进入`./Schematic`路径下
|
||||
|
||||
执行`python server.py`
|
||||
|
||||
在浏览器中打开`localhost:8000`进入文件服务器,在文件服务器中打开`./template/schematic.html`文件即可
|
||||
|
||||
### Server
|
||||
|
||||
整个项目的后端服务器代码,主要基于Tornado、Bokeh框架开发。
|
||||
|
||||
```
|
||||
+doc ----项目日志文件
|
||||
+handler ----项目服务器python文件
|
||||
+spice ----spice仿真测试文件
|
||||
+static ----静态文件
|
||||
...+login ----登录界面网页资源
|
||||
...+register ----注册界面网页资源
|
||||
...+schematic ----前端绘制电路图界面网页资源
|
||||
+template ----网页模板
|
||||
...+auth ----登录、注册界面网页
|
||||
...+schematic ----绘制电路图界面网页
|
||||
...+spice ----spice测试界面网页
|
||||
...index.html ----网站主页面网页
|
||||
requirements ----环境需求
|
||||
README.md ----用户须知
|
||||
app.py ----服务器的主程序
|
||||
```
|
||||
|
||||
## 环境配置
|
||||
|
||||
### Python环境
|
||||
@ -55,24 +59,30 @@
|
||||
|
||||
## 更新日志
|
||||
|
||||
* 2021年2月8号,前端更新,后端更新
|
||||
|
||||
* 优化了mos器件的描述方法
|
||||
* 增加了电源模型
|
||||
* 增加全局Vdd同步属性
|
||||
* 将前端schematic和后端server进行结合,成功将spice网表发送到后端服务器,并存储到数据库中
|
||||
* 2021年2月8号,前端更新
|
||||
|
||||
* 优化了schematic电路图提取spice网表功能
|
||||
* 新增加了多种电源器件
|
||||
* 初步实验了将提取出来的spice网表送进spice仿真器中执行仿真的结果
|
||||
* 
|
||||
* 
|
||||
* 2021年2月2日,前端更新
|
||||
|
||||
* 增加电路spice网表提取功能
|
||||
* 但是spice网表的具体格式仍存在一些小问题,需要与spice语法规则做进一步的校准
|
||||
* 另外,元件的名称需要增加自动调整功能,来保证所有元件名称的唯一性
|
||||
* 
|
||||
* 
|
||||
* 2021年2月1日,前端更新
|
||||
|
||||
* 发现bug,拖拽元件时,发现连线无法跟着移动
|
||||
* 增加了对xml格式文件的电路解析info
|
||||
* 将电路具体的解析info转换为spice网表电路功能待开发
|
||||
* 
|
||||
* 
|
||||
* 2021年1月31日,前端更新
|
||||
|
||||
* 增加了元件属性修改功能,增加了对属性的解析
|
||||
@ -80,7 +90,7 @@
|
||||
* 增加了按下delete键删除元素的功能
|
||||
* 发现了一些bug,例如当进行FlipH和FlipV时端口无法跟着进行翻转
|
||||
* 当前的功能界面如下图所示
|
||||
* 
|
||||
* 
|
||||
* 2021年1月28日,前端更新
|
||||
|
||||
* 增加了一些功能控件,完成基本雏形
|
||||
|
91957
Schematic/mxClient.js
1881
Schematic/mxClient.min.js
vendored
@ -1,14 +0,0 @@
|
||||
# 有用的mxgraph's demo
|
||||
|
||||
* dynamictoolbar.html
|
||||
* permissions.html
|
||||
* portrefs.html
|
||||
* showregion.html
|
||||
* standardsmode.html
|
||||
* toolbar.html
|
||||
* menustyle.html
|
||||
* touch.html
|
||||
* uiconfig.html
|
||||
* userobject.html
|
||||
* windows.html
|
||||
* wires.html
|
@ -1,73 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import tornado.httpserver
|
||||
import tornado.ioloop
|
||||
import tornado.log
|
||||
import tornado.web
|
||||
|
||||
|
||||
class IndexHandler(tornado.web.RequestHandler):
|
||||
|
||||
def get(self, path):
|
||||
path = os.path.normpath(path)
|
||||
if os.path.join(path, '').startswith(os.path.join('..', '')) or os.path.isabs(path):
|
||||
raise tornado.web.HTTPError(403)
|
||||
if not os.path.isdir(path):
|
||||
raise tornado.web.HTTPError(404)
|
||||
self.write('<html>\n<head><title>Index of /')
|
||||
escaped_title = tornado.web.escape.xhtml_escape(path if path != '.' else '')
|
||||
self.write(escaped_title)
|
||||
self.write('</title></head>\n<body>\n<h1>Index of /')
|
||||
self.write(escaped_title)
|
||||
self.write('</h1>\n<hr />\n<table>\n')
|
||||
for f in (['..'] if path != '.' else []) + sorted([i for i in os.listdir(path) if not i.startswith('.')]):
|
||||
self.write('<tr><td><a href="')
|
||||
absf = os.path.join(path, f)
|
||||
self.write(tornado.web.escape.url_escape(f).replace('+', '%20'))
|
||||
if os.path.isdir(absf):
|
||||
f += '/'
|
||||
self.write('/')
|
||||
self.write('">')
|
||||
self.write(tornado.web.escape.xhtml_escape(f))
|
||||
self.write('</a></td><td>')
|
||||
lstat_result = os.lstat(absf)
|
||||
self.write(tornado.web.escape.xhtml_escape(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(lstat_result.st_mtime))))
|
||||
self.write('</td><td align="right">')
|
||||
self.write(tornado.web.escape.xhtml_escape(str(lstat_result.st_size)))
|
||||
self.write('</td></tr>\n')
|
||||
self.finish('</table>\n<hr />\n<div>Powered by <a href="https://github.com/m13253/tornado-simple-http-server" target="_blank">TornadoSimpleHTTPServer</a></div></body>\n</html>\n')
|
||||
|
||||
|
||||
def main():
|
||||
listen_address = ''
|
||||
listen_port = 8000
|
||||
try:
|
||||
if len(sys.argv) == 2:
|
||||
listen_port = int(sys.argv[1])
|
||||
elif len(sys.argv) == 3:
|
||||
listen_address = sys.argv[1]
|
||||
listen_port = int(sys.argv[2])
|
||||
assert 0 <= listen_port <= 65535
|
||||
except (AssertionError, ValueError) as e:
|
||||
raise ValueError('port must be a number between 0 and 65535')
|
||||
tornado.log.enable_pretty_logging()
|
||||
application = tornado.web.Application(
|
||||
[
|
||||
('/(.*/)', IndexHandler),
|
||||
('/()', IndexHandler),
|
||||
('/(.*)', tornado.web.StaticFileHandler, {'path': '.', 'default_filename': ''}),
|
||||
],
|
||||
gzip=False,
|
||||
static_hash_cache=False,
|
||||
)
|
||||
http_server = tornado.httpserver.HTTPServer(application)
|
||||
http_server.listen(listen_port, listen_address)
|
||||
logging.info('Listening on %s:%s' % (listen_address or '[::]' if ':' not in listen_address else '[%s]' % listen_address, listen_port))
|
||||
tornado.ioloop.IOLoop.instance().start()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -1,50 +0,0 @@
|
||||
<mxGraphModel>
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
<mxCell id="4" value="Name=Vdd;Value=10 V;" style="shape=vdd;verticalLabelPosition=top;verticalAlign=bottom" vertex="1" parent="1">
|
||||
<mxGeometry x="380" y="60" width="40" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="5" value="Name=Gnd;" style="shape=gnd;verticalLabelPosition=top;verticalAlign=bottom" vertex="1" parent="1">
|
||||
<mxGeometry x="380" y="360" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="6" value="Name=NMOS;Length=100nm;Width=20nm;" style="shape=n_mosfet;verticalLabelPosition=top;verticalAlign=bottom" vertex="1" parent="1">
|
||||
<mxGeometry x="330" y="260" width="60" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="7" value="Name=PMOS;Length=100nm;Width=20nm;" style="shape=p_mosfet;verticalLabelPosition=top;verticalAlign=bottom" vertex="1" parent="1">
|
||||
<mxGeometry x="330" y="130" width="60" height="60" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="8" style="exitX=1;exitY=0.25;sourcePort=s;targetPort=s;" edge="1" parent="1" source="7" target="4">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9" style="exitX=1;exitY=0.75;sourcePort=d;targetPort=s;" edge="1" parent="1" source="7" target="6">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="400" y="270" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="10" style="exitX=1;exitY=0.75;sourcePort=d;targetPort=n;" edge="1" parent="1" source="6" target="5">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="11" style="exitX=0;exitY=0.5;sourcePort=g;targetPort=g;" edge="1" parent="1" source="6" target="7">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="12" value="Name=Pin;" style="shape=pin;verticalLabelPosition=top;verticalAlign=bottom" vertex="1" parent="1">
|
||||
<mxGeometry x="160" y="210" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="13" style="exitX=1;exitY=0.5;sourcePort=e;" edge="1" parent="1" source="12" target="11">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="330" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="14" value="Name=Pout;" style="shape=pout;verticalLabelPosition=top;verticalAlign=bottom" vertex="1" parent="1">
|
||||
<mxGeometry x="500" y="210" width="40" height="40" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="15" style="exitX=0;exitY=0.5;sourcePort=e;" edge="1" parent="1" source="14" target="9">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="400" y="230" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
@ -1,34 +0,0 @@
|
||||
from .main import AuthBaseHandler
|
||||
from .js import js_import, js_code_1
|
||||
import tornado.web
|
||||
# from bokeh.embed import server_document
|
||||
# from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
|
||||
|
||||
|
||||
class Spice_1_Handler(AuthBaseHandler):
|
||||
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice1.html')
|
||||
# script = server_document('http://localhost:5006/bkapp')
|
||||
# self.render('spice/spice1.html',script=script)
|
||||
|
||||
class Spice_2_Handler(AuthBaseHandler):
|
||||
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice2.html',js_import=js_import,js_code=js_code_1)
|
||||
|
||||
|
||||
class Spice_3_Handler(AuthBaseHandler):
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice3.html')
|
||||
|
||||
|
||||
class Spice_4_Handler(AuthBaseHandler):
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice4.html')
|
@ -16,11 +16,13 @@ class Application(tornado.web.Application): #引入Application类,重写方
|
||||
(r'/login',auth.LoginHandler),
|
||||
(r'/logout',auth.LogoutHandler),
|
||||
(r'/register',auth.RegisterHandler),
|
||||
(r'/schematic',spice.Schematic_Handler),
|
||||
(r'/spice1',spice.Spice_1_Handler),
|
||||
(r'/spice2',spice.Spice_2_Handler),
|
||||
(r'/spice3',spice.Spice_3_Handler),
|
||||
(r'/spice4',spice.Spice_4_Handler),
|
||||
(r'/test',main.TestHandler),
|
||||
(r'/spice',spice.SpiceHandler),
|
||||
]
|
||||
settings = dict(
|
||||
debug = False, #调试模式,修改后自动重启服务,不需要自动重启,生产情况下切勿开启,安全性
|
||||
@ -45,6 +47,8 @@ class Application(tornado.web.Application): #引入Application类,重写方
|
||||
}
|
||||
)
|
||||
|
||||
static_hash_cache=False
|
||||
|
||||
super(Application,self).__init__(handlers,**settings) #用super方法将父类的init方法重新执行一遍,然后将handlers和settings传进去,完成初始化
|
||||
|
||||
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 237 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
BIN
handler/__pycache__/spice.cpython-36.pyc
Normal file
56
handler/spice.py
Normal file
@ -0,0 +1,56 @@
|
||||
from .main import AuthBaseHandler
|
||||
from .js import js_import, js_code_1
|
||||
import tornado.web
|
||||
from .MongoDB import *
|
||||
# from bokeh.embed import server_document
|
||||
# from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
|
||||
class SpiceHandler(AuthBaseHandler):
|
||||
|
||||
@tornado.web.authenticated #@tornado.web.authenticated装饰器包裹get方法时,表示这个方法只有在用户合法时才会调用,authenticated装饰器会调用get_current_user()方法获取current_user的值,若值为False,则重定向到登录url装饰器判断有没有登录,如果没有则跳转到配置的路由下去,但是要在app.py里面设置login_url
|
||||
def post(self,*args,**kwargs):
|
||||
username = self.get_current_user()
|
||||
message = self.get_argument('spice')
|
||||
|
||||
print('SpiceHandler: '+username+' '+message)
|
||||
Mongo.connect(DataBase='example',Collection=username)
|
||||
Mongo.update(behavior=message,tags='spice')
|
||||
|
||||
self.write("success")
|
||||
|
||||
|
||||
|
||||
|
||||
class Schematic_Handler(AuthBaseHandler):
|
||||
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('schematic/schematic.html')
|
||||
|
||||
|
||||
class Spice_1_Handler(AuthBaseHandler):
|
||||
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice1.html')
|
||||
# script = server_document('http://localhost:5006/bkapp')
|
||||
# self.render('spice/spice1.html',script=script)
|
||||
|
||||
class Spice_2_Handler(AuthBaseHandler):
|
||||
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice2.html',js_import=js_import,js_code=js_code_1)
|
||||
|
||||
|
||||
class Spice_3_Handler(AuthBaseHandler):
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice3.html')
|
||||
|
||||
|
||||
class Spice_4_Handler(AuthBaseHandler):
|
||||
@tornado.web.authenticated
|
||||
def get(self,*args,**kwargs):
|
||||
self.render('spice/spice4.html')
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 434 KiB After Width: | Height: | Size: 434 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
BIN
static/schematic/editors/images/actor.gif
Normal file
After Width: | Height: | Size: 75 B |
BIN
static/schematic/editors/images/alignbottom.gif
Normal file
After Width: | Height: | Size: 358 B |
BIN
static/schematic/editors/images/aligncenter.gif
Normal file
After Width: | Height: | Size: 357 B |
BIN
static/schematic/editors/images/alignleft.gif
Normal file
After Width: | Height: | Size: 373 B |
BIN
static/schematic/editors/images/alignmiddle.gif
Normal file
After Width: | Height: | Size: 351 B |
BIN
static/schematic/editors/images/alignright.gif
Normal file
After Width: | Height: | Size: 377 B |
BIN
static/schematic/editors/images/aligntop.gif
Normal file
After Width: | Height: | Size: 358 B |
BIN
static/schematic/editors/images/arrow.gif
Normal file
After Width: | Height: | Size: 469 B |
BIN
static/schematic/editors/images/bell.png
Normal file
After Width: | Height: | Size: 3.4 KiB |
BIN
static/schematic/editors/images/bg.gif
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
static/schematic/editors/images/block_end.gif
Normal file
After Width: | Height: | Size: 65 B |
BIN
static/schematic/editors/images/block_start.gif
Normal file
After Width: | Height: | Size: 64 B |
BIN
static/schematic/editors/images/bold.gif
Normal file
After Width: | Height: | Size: 859 B |
BIN
static/schematic/editors/images/bottom.gif
Normal file
After Width: | Height: | Size: 848 B |
BIN
static/schematic/editors/images/box.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
static/schematic/editors/images/camera.gif
Normal file
After Width: | Height: | Size: 278 B |
BIN
static/schematic/editors/images/center.gif
Normal file
After Width: | Height: | Size: 163 B |
BIN
static/schematic/editors/images/classic_end.gif
Normal file
After Width: | Height: | Size: 80 B |
BIN
static/schematic/editors/images/classic_start.gif
Normal file
After Width: | Height: | Size: 82 B |
BIN
static/schematic/editors/images/cloud.gif
Normal file
After Width: | Height: | Size: 220 B |
BIN
static/schematic/editors/images/cmp-bg.gif
Normal file
After Width: | Height: | Size: 830 B |
BIN
static/schematic/editors/images/collapse.gif
Normal file
After Width: | Height: | Size: 195 B |
BIN
static/schematic/editors/images/connect.gif
Normal file
After Width: | Height: | Size: 860 B |
BIN
static/schematic/editors/images/connector.gif
Normal file
After Width: | Height: | Size: 954 B |
BIN
static/schematic/editors/images/console.gif
Normal file
After Width: | Height: | Size: 582 B |
BIN
static/schematic/editors/images/copy.gif
Normal file
After Width: | Height: | Size: 615 B |
BIN
static/schematic/editors/images/cube_green.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
static/schematic/editors/images/cut.gif
Normal file
After Width: | Height: | Size: 540 B |
BIN
static/schematic/editors/images/cylinder.gif
Normal file
After Width: | Height: | Size: 870 B |
BIN
static/schematic/editors/images/delete.gif
Normal file
After Width: | Height: | Size: 538 B |
BIN
static/schematic/editors/images/diagram.gif
Normal file
After Width: | Height: | Size: 294 B |
BIN
static/schematic/editors/images/diamond_end.gif
Normal file
After Width: | Height: | Size: 81 B |
BIN
static/schematic/editors/images/diamond_start.gif
Normal file
After Width: | Height: | Size: 82 B |
BIN
static/schematic/editors/images/doubleellipse.gif
Normal file
After Width: | Height: | Size: 88 B |
BIN
static/schematic/editors/images/down.gif
Normal file
After Width: | Height: | Size: 325 B |
BIN
static/schematic/editors/images/draw/drawbg.jpg
Normal file
After Width: | Height: | Size: 8.2 KiB |
BIN
static/schematic/editors/images/draw/drawbgcolor.jpg
Normal file
After Width: | Height: | Size: 556 B |
BIN
static/schematic/editors/images/draw/drawfooter.jpg
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
static/schematic/editors/images/draw/drawheader.jpg
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
static/schematic/editors/images/draw/mxlogo.jpg
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
static/schematic/editors/images/dude3.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
static/schematic/editors/images/earth.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
static/schematic/editors/images/ellipse.gif
Normal file
After Width: | Height: | Size: 121 B |
BIN
static/schematic/editors/images/entity.gif
Normal file
After Width: | Height: | Size: 74 B |
BIN
static/schematic/editors/images/expand.gif
Normal file
After Width: | Height: | Size: 190 B |
BIN
static/schematic/editors/images/fillcolor.gif
Normal file
After Width: | Height: | Size: 127 B |
BIN
static/schematic/editors/images/fit.gif
Normal file
After Width: | Height: | Size: 148 B |
BIN
static/schematic/editors/images/font.gif
Normal file
After Width: | Height: | Size: 580 B |