add some notes to READEME

main
ColsonZhang 2021-01-26 20:47:02 +08:00
parent 15ced25f74
commit 10a8ce7c7a
11 changed files with 134 additions and 84 deletions

14
MyJade/reademe.md Normal file
View File

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

View File

@ -1,22 +1,54 @@
# CZ_OpenSpice
# 项目简介
## 项目简介
本项目旨在搭建一个web版本的spice电路仿真平台。当前项目仍处于不断更新中。
# 项目框架
## 项目框架
## MyJade
### MyJade
能够绘制电路原理图的web前端代码主要参考MIT的Jade项目。
## Server
### Server
整个项目的后端服务器代码主要基于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日进一步完善服务器基本框架。
* 基本尝试使用了BokehJS库的使用计划用JS替代Python版本的Bokeh功能控件。
* 尝试Plotly的使用计划作为Bokeh的备选。
* 尝试使用Javascript的Jquery库利用ajax向服务器发送post请求传递信息。
@ -25,6 +57,7 @@
* 后续需要在项目管理方面进行梳理,当前代码库已经存在一定的混乱。
* 将代码库中的`font-awesome`css库从本地删去改为线上CDN加载。
* 2021年1月20日完成了服务器基本框架的搭建。实现的功能有
* 用户登录、认证、退出系统,新用户注册新账户
* 在mysql数据库中存储、更新用户基本信息
* 一个基本的仿真的app功能为spice语言描述的电路传入后台后台调用ngspice或xyce进行仿真暂未对仿真结果进行处理仅返回是否仿真成功

View File

@ -6,7 +6,7 @@ from handler import main, auth, spice
# import _thread,threading
# 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类重写方法这样做的好处在于可以自定义添加另一些功能
@ -16,7 +16,7 @@ class Application(tornado.web.Application): #引入Application类重写方
(r'/login',auth.LoginHandler),
(r'/logout',auth.LogoutHandler),
(r'/register',auth.RegisterHandler),
# (r'/spice',spice.Spice_1_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),
@ -60,3 +60,4 @@ if __name__ == '__main__': #当.py文件被直接运行时代码块将被
app.listen(options.port) ##如果一个与define语句中同名的设置在命令行中被给出那么它将成为全局的options的一个属性 即 options.port 相当于define的url的port
print("Server start on port {}".format(str(options.port))) #提示服务启动占用端口
tornado.ioloop.IOLoop.current().start() #执行ioloop

Binary file not shown.

View File

@ -52,11 +52,12 @@ class RegisterHandler(AuthBaseHandler):
print('registerpost')
username = self.get_argument('username','')
email = self.get_argument('email','')
password1 = self.get_argument('password1','')
password2 = self.get_argument('password2','')
if username and password1 and (password1 == password2):
success = add_user(username,password1)
success = add_user(username,password1,email)
if success:
Mongo.connect(DataBase='example',Collection=username)
Mongo.update(behavior='register',tags='auth')

66
Server/handler/js.py Normal file
View File

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

View File

@ -1,90 +1,25 @@
from .main import AuthBaseHandler
from .js import js_import, js_code_1
import tornado.web
from bokeh.embed import server_document
# from bokeh.embed import server_document
# from jinja2 import Environment, FileSystemLoader
class Spice_1_Handler(AuthBaseHandler):
@tornado.web.authenticated
def get(self,*args,**kwargs):
# env = Environment(loader=FileSystemLoader('template'))
# template = env.get_template('spice.html')
self.render('spice/spice1.html')
# script = server_document('http://localhost:5006/bkapp')
# self.write(template.render(script=script))
script = server_document('http://localhost:5006/bkapp')
self.render('spice/spice1.html',script=script)
# self.render('spice/spice1.html',script=script)
class Spice_2_Handler(AuthBaseHandler):
@tornado.web.authenticated
def get(self,*args,**kwargs):
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 = """
<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)
self.render('spice/spice2.html',js_import=js_import,js_code=js_code_1)
class Spice_3_Handler(AuthBaseHandler):

View File

@ -8,8 +8,8 @@
<h1>我的第一个标题</h1>
<p>我的第一个段落。</p>
<p>当前用户 {{user}} </p>
<form action="/spice" method="get">
<div><input type="submit" value="spice"></div>
<form action="/spice1" method="get">
<div><input type="submit" value="spice1"></div>
</form>
<form action="/spice2" method="get">
<div><input type="submit" value="spice2"></div>

View File

@ -14,7 +14,7 @@
in the User's Guide.
</div>
<div>
{% raw script %}
Hello,world !
</div>
</body>
</html>