add some notes to READEME
parent
15ced25f74
commit
10a8ce7c7a
|
@ -0,0 +1,14 @@
|
||||||
|
## 有用的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
|
43
README.md
43
README.md
|
@ -1,22 +1,54 @@
|
||||||
# CZ_OpenSpice
|
# CZ_OpenSpice
|
||||||
|
|
||||||
# 项目简介
|
## 项目简介
|
||||||
|
|
||||||
本项目旨在搭建一个web版本的spice电路仿真平台。当前项目仍处于不断更新中。
|
本项目旨在搭建一个web版本的spice电路仿真平台。当前项目仍处于不断更新中。
|
||||||
|
|
||||||
# 项目框架
|
## 项目框架
|
||||||
|
|
||||||
## MyJade
|
### MyJade
|
||||||
|
|
||||||
能够绘制电路原理图的web前端代码,主要参考MIT的Jade项目。
|
能够绘制电路原理图的web前端代码,主要参考MIT的Jade项目。
|
||||||
|
|
||||||
## Server
|
### Server
|
||||||
|
|
||||||
整个项目的后端服务器代码,主要基于Tornado、Bokeh框架开发。
|
整个项目的后端服务器代码,主要基于Tornado、Bokeh框架开发。
|
||||||
|
|
||||||
# 更新日志
|
## 环境配置
|
||||||
|
|
||||||
|
### Python环境
|
||||||
|
|
||||||
|
需要使用`python>=3.6`,同时需要安装如下几个python包,可以通过`pip install pkg-name`的方法进行安装,例如 `pip install tornado`
|
||||||
|
|
||||||
|
* `tornado`
|
||||||
|
* `datetime`
|
||||||
|
* `pycket`
|
||||||
|
* `pymongo`
|
||||||
|
* `pymysql`
|
||||||
|
|
||||||
|
### 数据库
|
||||||
|
|
||||||
|
需要安装如下几个数据库,并进行配置,配置的信息在`./Server/handler/MongoDB.py`和
|
||||||
|
|
||||||
|
`./Server/handler/MysqlDB.py`中均有记录
|
||||||
|
|
||||||
|
* `redis`
|
||||||
|
* `mysql`
|
||||||
|
* `mongodb`
|
||||||
|
|
||||||
|
## 项目启动
|
||||||
|
|
||||||
|
进入`./Server/`路径,执行`python app.py`
|
||||||
|
|
||||||
|
## 更新日志
|
||||||
|
|
||||||
|
* 2021年1月26日,修复了一些小bug,增加了一些配置信息
|
||||||
|
|
||||||
|
* 增加了README的内容
|
||||||
|
* 再次测试代码,修复一些bug,例如注册时未往数据库中写入email等
|
||||||
|
* 把部分js代码单独提取出来到一个文件夹下面
|
||||||
* 2021年1月22日,进一步完善服务器基本框架。
|
* 2021年1月22日,进一步完善服务器基本框架。
|
||||||
|
|
||||||
* 基本尝试使用了BokehJS库的使用,计划用JS替代Python版本的Bokeh功能控件。
|
* 基本尝试使用了BokehJS库的使用,计划用JS替代Python版本的Bokeh功能控件。
|
||||||
* 尝试Plotly的使用,计划作为Bokeh的备选。
|
* 尝试Plotly的使用,计划作为Bokeh的备选。
|
||||||
* 尝试使用Javascript的Jquery库,利用ajax向服务器发送post请求传递信息。
|
* 尝试使用Javascript的Jquery库,利用ajax向服务器发送post请求传递信息。
|
||||||
|
@ -25,6 +57,7 @@
|
||||||
* 后续需要在项目管理方面进行梳理,当前代码库已经存在一定的混乱。
|
* 后续需要在项目管理方面进行梳理,当前代码库已经存在一定的混乱。
|
||||||
* 将代码库中的`font-awesome`css库从本地删去,改为线上CDN加载。
|
* 将代码库中的`font-awesome`css库从本地删去,改为线上CDN加载。
|
||||||
* 2021年1月20日,完成了服务器基本框架的搭建。实现的功能有:
|
* 2021年1月20日,完成了服务器基本框架的搭建。实现的功能有:
|
||||||
|
|
||||||
* 用户登录、认证、退出系统,新用户注册新账户
|
* 用户登录、认证、退出系统,新用户注册新账户
|
||||||
* 在mysql数据库中存储、更新用户基本信息
|
* 在mysql数据库中存储、更新用户基本信息
|
||||||
* 一个基本的仿真的app,功能为spice语言描述的电路传入后台,后台调用ngspice或xyce进行仿真(暂未对仿真结果进行处理,仅返回是否仿真成功)
|
* 一个基本的仿真的app,功能为spice语言描述的电路传入后台,后台调用ngspice或xyce进行仿真(暂未对仿真结果进行处理,仅返回是否仿真成功)
|
||||||
|
|
|
@ -6,7 +6,7 @@ from handler import main, auth, spice
|
||||||
# import _thread,threading
|
# import _thread,threading
|
||||||
# from spice import app_spice
|
# from spice import app_spice
|
||||||
|
|
||||||
define('port',default='8000',help='Listening port',type=int) #定义如何接受传进来的东西
|
define('port',default='9000',help='Listening port',type=int) #定义如何接受传进来的东西
|
||||||
|
|
||||||
|
|
||||||
class Application(tornado.web.Application): #引入Application类,重写方法,这样做的好处在于可以自定义,添加另一些功能
|
class Application(tornado.web.Application): #引入Application类,重写方法,这样做的好处在于可以自定义,添加另一些功能
|
||||||
|
@ -16,7 +16,7 @@ class Application(tornado.web.Application): #引入Application类,重写方
|
||||||
(r'/login',auth.LoginHandler),
|
(r'/login',auth.LoginHandler),
|
||||||
(r'/logout',auth.LogoutHandler),
|
(r'/logout',auth.LogoutHandler),
|
||||||
(r'/register',auth.RegisterHandler),
|
(r'/register',auth.RegisterHandler),
|
||||||
# (r'/spice',spice.Spice_1_Handler),
|
(r'/spice1',spice.Spice_1_Handler),
|
||||||
(r'/spice2',spice.Spice_2_Handler),
|
(r'/spice2',spice.Spice_2_Handler),
|
||||||
(r'/spice3',spice.Spice_3_Handler),
|
(r'/spice3',spice.Spice_3_Handler),
|
||||||
(r'/spice4',spice.Spice_4_Handler),
|
(r'/spice4',spice.Spice_4_Handler),
|
||||||
|
@ -60,3 +60,4 @@ if __name__ == '__main__': #当.py文件被直接运行时,代码块将被
|
||||||
app.listen(options.port) ##如果一个与define语句中同名的设置在命令行中被给出,那么它将成为全局的options的一个属性 即 options.port 相当于define的url的port
|
app.listen(options.port) ##如果一个与define语句中同名的设置在命令行中被给出,那么它将成为全局的options的一个属性 即 options.port 相当于define的url的port
|
||||||
print("Server start on port {}".format(str(options.port))) #提示服务启动占用端口
|
print("Server start on port {}".format(str(options.port))) #提示服务启动占用端口
|
||||||
tornado.ioloop.IOLoop.current().start() #执行ioloop
|
tornado.ioloop.IOLoop.current().start() #执行ioloop
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -52,11 +52,12 @@ class RegisterHandler(AuthBaseHandler):
|
||||||
print('registerpost')
|
print('registerpost')
|
||||||
|
|
||||||
username = self.get_argument('username','')
|
username = self.get_argument('username','')
|
||||||
|
email = self.get_argument('email','')
|
||||||
password1 = self.get_argument('password1','')
|
password1 = self.get_argument('password1','')
|
||||||
password2 = self.get_argument('password2','')
|
password2 = self.get_argument('password2','')
|
||||||
|
|
||||||
if username and password1 and (password1 == password2):
|
if username and password1 and (password1 == password2):
|
||||||
success = add_user(username,password1)
|
success = add_user(username,password1,email)
|
||||||
if success:
|
if success:
|
||||||
Mongo.connect(DataBase='example',Collection=username)
|
Mongo.connect(DataBase='example',Collection=username)
|
||||||
Mongo.update(behavior='register',tags='auth')
|
Mongo.update(behavior='register',tags='auth')
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
js_import = """
|
||||||
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.2.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-api-2.2.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-api-2.2.3.min.js"></script>
|
||||||
|
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
|
||||||
|
"""
|
||||||
|
|
||||||
|
js_code_1 = """
|
||||||
|
<script>
|
||||||
|
// create a data source to hold data
|
||||||
|
var source = new Bokeh.ColumnDataSource({
|
||||||
|
data: { x: [], y: [] }
|
||||||
|
});
|
||||||
|
|
||||||
|
// make a plot with some tools
|
||||||
|
var plot = Bokeh.Plotting.figure({
|
||||||
|
title:'Example of Random data',
|
||||||
|
tools: "pan,wheel_zoom,box_zoom,reset,save",
|
||||||
|
height: 300,
|
||||||
|
width: 300
|
||||||
|
});
|
||||||
|
|
||||||
|
// add a line with data from the source
|
||||||
|
plot.line({ field: "x" }, { field: "y" }, {
|
||||||
|
source: source,
|
||||||
|
line_width: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
// show the plot, appending it to the end of the current section
|
||||||
|
Bokeh.Plotting.show(plot);
|
||||||
|
|
||||||
|
function addPoint() {
|
||||||
|
// add data --- all fields must be the same length.
|
||||||
|
source.data.x.push(Math.random())
|
||||||
|
source.data.y.push(Math.random())
|
||||||
|
|
||||||
|
// notify the DataSource of "in-place" changes
|
||||||
|
source.change.emit()
|
||||||
|
}
|
||||||
|
|
||||||
|
function Callback_Button() {
|
||||||
|
addPoint();
|
||||||
|
var data = new Object();
|
||||||
|
data["name"] = "XerCis";
|
||||||
|
data["message"] = "This is the message from ajax(spice2) !";
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: "/test",
|
||||||
|
data: data,
|
||||||
|
success: function (response) {
|
||||||
|
alert(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
var addDataButton = document.createElement("Button");
|
||||||
|
addDataButton.appendChild(document.createTextNode("Add Some Data!!!"));
|
||||||
|
document.currentScript.parentElement.appendChild(addDataButton);
|
||||||
|
addDataButton.addEventListener("click", Callback_Button);
|
||||||
|
|
||||||
|
addPoint();
|
||||||
|
addPoint();
|
||||||
|
</script>
|
||||||
|
"""
|
|
@ -1,90 +1,25 @@
|
||||||
from .main import AuthBaseHandler
|
from .main import AuthBaseHandler
|
||||||
|
from .js import js_import, js_code_1
|
||||||
import tornado.web
|
import tornado.web
|
||||||
from bokeh.embed import server_document
|
# from bokeh.embed import server_document
|
||||||
# from jinja2 import Environment, FileSystemLoader
|
# from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Spice_1_Handler(AuthBaseHandler):
|
class Spice_1_Handler(AuthBaseHandler):
|
||||||
|
|
||||||
@tornado.web.authenticated
|
@tornado.web.authenticated
|
||||||
def get(self,*args,**kwargs):
|
def get(self,*args,**kwargs):
|
||||||
# env = Environment(loader=FileSystemLoader('template'))
|
self.render('spice/spice1.html')
|
||||||
# template = env.get_template('spice.html')
|
|
||||||
# script = server_document('http://localhost:5006/bkapp')
|
# script = server_document('http://localhost:5006/bkapp')
|
||||||
# self.write(template.render(script=script))
|
# self.render('spice/spice1.html',script=script)
|
||||||
|
|
||||||
script = server_document('http://localhost:5006/bkapp')
|
|
||||||
self.render('spice/spice1.html',script=script)
|
|
||||||
|
|
||||||
class Spice_2_Handler(AuthBaseHandler):
|
class Spice_2_Handler(AuthBaseHandler):
|
||||||
|
|
||||||
@tornado.web.authenticated
|
@tornado.web.authenticated
|
||||||
def get(self,*args,**kwargs):
|
def get(self,*args,**kwargs):
|
||||||
js_import = """
|
self.render('spice/spice2.html',js_import=js_import,js_code=js_code_1)
|
||||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.2.3.min.js"></script>
|
|
||||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.3.min.js"></script>
|
|
||||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.3.min.js"></script>
|
|
||||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-api-2.2.3.min.js"></script>
|
|
||||||
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-api-2.2.3.min.js"></script>
|
|
||||||
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
|
|
||||||
"""
|
|
||||||
js_code = """
|
|
||||||
<script>
|
|
||||||
// create a data source to hold data
|
|
||||||
var source = new Bokeh.ColumnDataSource({
|
|
||||||
data: { x: [], y: [] }
|
|
||||||
});
|
|
||||||
|
|
||||||
// make a plot with some tools
|
|
||||||
var plot = Bokeh.Plotting.figure({
|
|
||||||
title:'Example of Random data',
|
|
||||||
tools: "pan,wheel_zoom,box_zoom,reset,save",
|
|
||||||
height: 300,
|
|
||||||
width: 300
|
|
||||||
});
|
|
||||||
|
|
||||||
// add a line with data from the source
|
|
||||||
plot.line({ field: "x" }, { field: "y" }, {
|
|
||||||
source: source,
|
|
||||||
line_width: 2
|
|
||||||
});
|
|
||||||
|
|
||||||
// show the plot, appending it to the end of the current section
|
|
||||||
Bokeh.Plotting.show(plot);
|
|
||||||
|
|
||||||
function addPoint() {
|
|
||||||
// add data --- all fields must be the same length.
|
|
||||||
source.data.x.push(Math.random())
|
|
||||||
source.data.y.push(Math.random())
|
|
||||||
|
|
||||||
// notify the DataSource of "in-place" changes
|
|
||||||
source.change.emit()
|
|
||||||
}
|
|
||||||
|
|
||||||
function Callback_Button() {
|
|
||||||
addPoint();
|
|
||||||
var data = new Object();
|
|
||||||
data["name"] = "XerCis";
|
|
||||||
data["message"] = "This is the message from ajax(spice2) !";
|
|
||||||
$.ajax({
|
|
||||||
type: 'POST',
|
|
||||||
url: "/test",
|
|
||||||
data: data,
|
|
||||||
success: function (response) {
|
|
||||||
alert(response);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
var addDataButton = document.createElement("Button");
|
|
||||||
addDataButton.appendChild(document.createTextNode("Add Some Data!!!"));
|
|
||||||
document.currentScript.parentElement.appendChild(addDataButton);
|
|
||||||
addDataButton.addEventListener("click", Callback_Button);
|
|
||||||
|
|
||||||
addPoint();
|
|
||||||
addPoint();
|
|
||||||
</script>
|
|
||||||
"""
|
|
||||||
self.render('spice/spice2.html',js_import=js_import,js_code=js_code)
|
|
||||||
|
|
||||||
|
|
||||||
class Spice_3_Handler(AuthBaseHandler):
|
class Spice_3_Handler(AuthBaseHandler):
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
<h1>我的第一个标题</h1>
|
<h1>我的第一个标题</h1>
|
||||||
<p>我的第一个段落。</p>
|
<p>我的第一个段落。</p>
|
||||||
<p>当前用户 {{user}} </p>
|
<p>当前用户 {{user}} </p>
|
||||||
<form action="/spice" method="get">
|
<form action="/spice1" method="get">
|
||||||
<div><input type="submit" value="spice"></div>
|
<div><input type="submit" value="spice1"></div>
|
||||||
</form>
|
</form>
|
||||||
<form action="/spice2" method="get">
|
<form action="/spice2" method="get">
|
||||||
<div><input type="submit" value="spice2"></div>
|
<div><input type="submit" value="spice2"></div>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
in the User's Guide.
|
in the User's Guide.
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{% raw script %}
|
Hello,world !
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue