a big imporvement

This commit is contained in:
ColsonZhang 2021-02-08 16:05:18 +08:00
parent fa2a96f87e
commit a92af48237
447 changed files with 289 additions and 94083 deletions

View File

@ -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仿真器中执行仿真的结果
* ![avatar](./Schematic/schematic4.png)
* ![avatar](./doc/schematic4.png)
* 2021年2月2日前端更新
* 增加电路spice网表提取功能
* 但是spice网表的具体格式仍存在一些小问题需要与spice语法规则做进一步的校准
* 另外,元件的名称需要增加自动调整功能,来保证所有元件名称的唯一性
* ![avatar](./Schematic/schematic3.png)
* ![avatar](./doc/schematic3.png)
* 2021年2月1日前端更新
* 发现bug拖拽元件时发现连线无法跟着移动
* 增加了对xml格式文件的电路解析info
* 将电路具体的解析info转换为spice网表电路功能待开发
* ![avatar](./Schematic/schematic2.png)
* ![avatar](./doc/schematic2.png)
* 2021年1月31日前端更新
* 增加了元件属性修改功能,增加了对属性的解析
@ -80,7 +90,7 @@
* 增加了按下delete键删除元素的功能
* 发现了一些bug例如当进行FlipH和FlipV时端口无法跟着进行翻转
* 当前的功能界面如下图所示
* ![avatar](./Schematic/schematic.png)
* ![avatar](./doc/schematic.png)
* 2021年1月28日前端更新
* 增加了一些功能控件,完成基本雏形

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

View File

@ -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传进去完成初始化

View File

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 126 KiB

View File

Before

Width:  |  Height:  |  Size: 237 KiB

After

Width:  |  Height:  |  Size: 237 KiB

View File

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

View File

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

56
handler/spice.py Normal file
View 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')

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 434 KiB

After

Width:  |  Height:  |  Size: 434 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Some files were not shown because too many files have changed in this diff Show More