Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rudern
物联大师
提交
631e3fa0
物
物联大师
项目概览
rudern
/
物联大师
通知
4
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
物
物联大师
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
631e3fa0
编写于
11月 23, 2020
作者:
J
Jason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
改用树级结构,简单,界面复杂,并删除冗余
上级
c89cc97e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
212 deletion
+29
-212
models/element.go
models/element.go
+10
-12
models/project.go
models/project.go
+19
-69
models/template.go
models/template.go
+0
-50
web/api/router.go
web/api/router.go
+0
-81
未找到文件。
models/element.go
浏览文件 @
631e3fa0
...
...
@@ -13,6 +13,8 @@ type Element struct {
Model
string
`json:"model"`
//型号
Version
string
`json:"version"`
//版本
Variables
[]
ElementVariable
`json:"variables"`
//变量
Created
time
.
Time
`json:"created" storm:"created"`
}
...
...
@@ -23,22 +25,18 @@ type Element struct {
// input 输入寄存器(4读多个)
type
ElementVariable
struct
{
ID
int
`json:"id"`
Variable
`storm:"inline"`
Extend
uint16
`json:"extend"`
//扩展长度 默认0,如果大于1,自动在别名基础上添加数字后缀,比如 s s1 s2 s3 ...
Created
time
.
Time
`json:"created" storm:"created"`
Extend
uint16
`json:"extend"`
//扩展长度 默认0,如果大于1,自动在别名基础上添加数字后缀,比如 s s1 s2 s3 ...
}
type
Variable
struct
{
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//默认别名,用于编程
Code
uint8
`json:"code"`
//功能码
Offset
uint16
`json:"offset"`
//偏移
Type
string
`json:"type"`
Unit
string
`json:"unit"`
//单位
Scale
float32
`json:"scale"`
//倍率,比如一般是 整数÷10,得到
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//默认别名,用于编程
Code
uint8
`json:"code"`
//功能码
Offset
uint16
`json:"offset"`
//偏移
Type
string
`json:"type"`
Unit
string
`json:"unit"`
//单位
Scale
float32
`json:"scale"`
//倍率,比如一般是 整数÷10,得到
//Default string `json:"default"`
ReadOnly
bool
`json:"read_only"`
//只读
...
...
models/project.go
浏览文件 @
631e3fa0
...
...
@@ -13,91 +13,41 @@ type Project struct {
Disabled
bool
`json:"disabled"`
Created
time
.
Time
`json:"created" storm:"created"`
}
type
ProjectLink
struct
{
ID
int
`json:"id"`
ProjectId
int
`json:"project_id"`
LinkId
int
`json:"link_id"`
Name
string
`json:"name"`
Protocol
string
`json:"protocol"`
Created
time
.
Time
`json:"created" storm:"created"`
}
type
ProjectElement
struct
{
ID
int
`json:"id"`
//ProjectId int `json:"project_id"`
ElementId
int
`json:"element_id"`
ProjectLinkId
int
`json:"project_link_id"`
LinkId
int
`json:"link_id"`
Protocol
string
`json:"protocol"`
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//别名,用于编程
Slave
uint8
`json:"slave"`
//从站号
Variables
[]
ProjectVariable
`json:"variables"`
Validators
[]
ProjectValidator
`json:"validators"`
Functions
[]
ProjectFunction
`json:"functions"`
Strategies
[]
ProjectStrategy
`json:"strategies"`
Created
time
.
Time
`json:"created" storm:"created"`
}
type
ProjectVariable
struct
{
ID
int
`json:"id"`
//ProjectId int `json:"project_id"`
//ElementId int `json:"element_id"`
ProjectElementId
int
`json:"project_element_id"`
Element
string
`json:"element"`
//uuid
Variable
`storm:"inline"`
//TODO 添加采样周期
Created
time
.
Time
`json:"created" storm:"created"`
}
type
ProjectValidator
struct
{
ID
int
`json:"id"`
ProjectId
int
`json:"project_id"`
Alert
string
`json:"alert"`
Expression
string
`json:"expression"`
//表达式,检测变量名
Created
time
.
Time
`json:"created" storm:"created"`
Alert
string
`json:"alert"`
Expression
string
`json:"expression"`
//表达式,检测变量名
}
type
ProjectFunction
struct
{
ID
int
`json:"id"`
ProjectId
int
`json:"project_id"`
Name
string
`json:"name"`
//项目功能脚本唯一,供外部调用
Description
string
`json:"description"`
Script
string
`json:"script"`
//javascript
Created
time
.
Time
`json:"created" storm:"created"`
}
type
ProjectFunctionOperator
struct
{
ID
int
`json:"id"`
//ProjectId int `json:"project_id"`
FunctionId
string
`json:"function_id"`
VariableId
string
`json:"variable_id"`
Value
interface
{}
`json:"value"`
Created
time
.
Time
`json:"created" storm:"created"`
}
type
ProjectJob
struct
{
ID
int
`json:"id"`
ProjectId
int
`json:"project_id"`
FunctionId
string
`json:"function_id"`
Name
string
`json:"name"`
Cron
string
`json:"cron"`
Created
time
.
Time
`json:"created" storm:"created"`
ID
int
`json:"id"`
Name
string
`json:"name"`
//项目功能脚本唯一,供外部调用
Description
string
`json:"description"`
Script
string
`json:"script"`
//javascript
Operators
map
[
string
]
interface
{}
`json:"operators"`
}
type
ProjectStrategy
struct
{
ID
int
`json:"id"`
ProjectId
int
`json:"project_id"`
FunctionId
string
`json:"function_id"`
Name
string
`json:"name"`
Expression
string
`json:"expression"`
//触发条件 表达式,检测变量名
Created
time
.
Time
`json:"created" storm:"created"`
Name
string
`json:"name"`
Cron
string
`json:"cron"`
Expression
string
`json:"expression"`
//触发条件 表达式,检测变量名
Script
string
`json:"script"`
//javascript
Operators
map
[
string
]
interface
{}
`json:"operators"`
}
//
//type Script struct {
// source string
// variables []string
// script *otto.Script
//}
models/template.go
已删除
100644 → 0
浏览文件 @
c89cc97e
package
models
type
Template
struct
{
UUID
string
`json:"uuid"`
//唯一码,自动生成
Name
string
`json:"name"`
Description
string
`json:"description"`
Version
string
`json:"version"`
Links
[]
TemplateLink
`json:"links"`
Validators
[]
TemplateValidator
Functions
[]
TemplateFunction
Job
[]
TemplateJob
Strategies
[]
TemplateStrategy
}
type
TemplateLink
struct
{
Name
string
`json:"name"`
Protocol
string
`json:"protocol"`
Elements
[]
TemplateElement
`json:"elements"`
}
type
TemplateElement
struct
{
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//别名,用于编程
Slave
uint8
`json:"slave"`
//从站号
Variables
[]
Variable
`json:"variables"`
}
type
TemplateValidator
struct
{
Alert
string
`json:"alert"`
Expression
string
`json:"expression"`
//表达式,检测变量名
}
type
TemplateFunction
struct
{
Name
string
`json:"name"`
//项目功能脚本唯一,供外部调用
Description
string
`json:"description"`
Script
string
`json:"script"`
//javascript
}
type
TemplateJob
struct
{
Cron
string
`json:"cron"`
Function
string
`json:"function"`
}
type
TemplateStrategy
struct
{
Expression
string
`json:"expression"`
//触发条件 表达式,检测变量名
Function
string
`json:"function"`
}
web/api/router.go
浏览文件 @
631e3fa0
...
...
@@ -128,77 +128,6 @@ func RegisterRoutes(app *mux.Router) {
//app.HandleFunc("/project/{id}/export", projectExport).Methods("GET")
//app.HandleFunc("/project/{id}/deploy", projectDeploy).Methods("GET")
//项目链接
mod
=
reflect
.
TypeOf
(
models
.
ProjectLink
{})
node
:=
store
.
From
(
"link"
)
app
.
HandleFunc
(
"/project/{id}/links"
,
curdApiListById
(
node
,
mod
,
"project_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/links", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/link"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/link/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/link/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/link/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//项目元件
mod
=
reflect
.
TypeOf
(
models
.
ProjectElement
{})
node
=
store
.
From
(
"element"
)
app
.
HandleFunc
(
"/project/{id}/elements"
,
curdApiListById
(
node
,
mod
,
"project_link_id"
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/link/{id}/elements"
,
curdApiListById
(
node
,
mod
,
"link_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/elements", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/element"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/element/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/element/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/element/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//项目变量
mod
=
reflect
.
TypeOf
(
models
.
ProjectVariable
{})
node
=
store
.
From
(
"variable"
)
app
.
HandleFunc
(
"/project/{id}/variables"
,
curdApiListById
(
node
,
mod
,
"project_element_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/variables", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/variable"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/variable/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/variable/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/variable/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//项目检查
mod
=
reflect
.
TypeOf
(
models
.
ProjectValidator
{})
node
=
store
.
From
(
"validator"
)
app
.
HandleFunc
(
"/project/{id}/validators"
,
curdApiListById
(
node
,
mod
,
"project_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/validators", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/validator"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/validator/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/validator/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/validator/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//项目功能
mod
=
reflect
.
TypeOf
(
models
.
ProjectFunction
{})
node
=
store
.
From
(
"function"
)
app
.
HandleFunc
(
"/project/{id}/functions"
,
curdApiListById
(
node
,
mod
,
"project_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/functions", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/function"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/function/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/function/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/function/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//项目任务
mod
=
reflect
.
TypeOf
(
models
.
ProjectJob
{})
node
=
store
.
From
(
"job"
)
app
.
HandleFunc
(
"/project/{id}/jobs"
,
curdApiListById
(
node
,
mod
,
"project_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/jobs", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/job"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/job/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/job/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/job/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//项目策略
mod
=
reflect
.
TypeOf
(
models
.
ProjectStrategy
{})
node
=
store
.
From
(
"strategy"
)
app
.
HandleFunc
(
"/project/{id}/strategies"
,
curdApiListById
(
node
,
mod
,
"project_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/project/strategies", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/project/strategy"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/project/strategy/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/project/strategy/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/project/strategy/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
//元件管理
mod
=
reflect
.
TypeOf
(
models
.
Element
{})
store
=
db
.
DB
(
"element"
)
...
...
@@ -208,16 +137,6 @@ func RegisterRoutes(app *mux.Router) {
app
.
HandleFunc
(
"/element/{id}"
,
curdApiModify
(
store
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/element/{id}"
,
curdApiGet
(
store
,
mod
))
.
Methods
(
"GET"
)
//元件变量
mod
=
reflect
.
TypeOf
(
models
.
ElementVariable
{})
node
=
store
.
From
(
"variable"
)
app
.
HandleFunc
(
"/element/{id}/variables"
,
curdApiListById
(
node
,
mod
,
"project_id"
))
.
Methods
(
"POST"
)
//app.HandleFunc("/element/variables", curdApiList(node,mod)).Methods("POST")
app
.
HandleFunc
(
"/element/variable"
,
curdApiCreate
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"POST"
)
app
.
HandleFunc
(
"/element/variable/{id}"
,
curdApiDelete
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"DELETE"
)
app
.
HandleFunc
(
"/element/variable/{id}"
,
curdApiModify
(
node
,
mod
,
nil
,
nil
))
.
Methods
(
"PUT"
,
"POST"
)
app
.
HandleFunc
(
"/element/variable/{id}"
,
curdApiGet
(
node
,
mod
))
.
Methods
(
"GET"
)
}
type
Reply
struct
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录