Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
rudern
物联大师
提交
5f40c73d
物
物联大师
项目概览
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 搜索 >>
提交
5f40c73d
编写于
10月 28, 2020
作者:
J
Jason
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
项目和模板 整理完成,共用一套结构(现存问题:修改了变量,自动更新项目比较麻烦)
上级
c2da5100
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
103 deletion
+59
-103
models/device.go
models/device.go
+0
-31
models/element.go
models/element.go
+3
-15
models/project.go
models/project.go
+49
-26
models/template.go
models/template.go
+0
-25
models/tunnel.go
models/tunnel.go
+7
-6
未找到文件。
models/device.go
已删除
100644 → 0
浏览文件 @
c2da5100
package
models
import
"time"
type
Device
struct
{
ID
int
`json:"id"`
TunnelId
int
`json:"tunnel_id"`
LinkId
int
`json:"link_id"`
ProjectId
int
`json:"project_id"`
Name
string
`json:"name"`
Description
string
`json:"description"`
Serial
string
`json:"serial"`
//定位,或手动选择
Longitude
float64
`json:"longitude"`
Latitude
float64
`json:"latitude"`
Created
time
.
Time
`json:"created" storm:"created"`
Updated
time
.
Time
`json:"updated" storm:"updated"`
}
//默认WGS84标准,GCJ02、BD09都需要转换
type
Location
struct
{
ID
int
`json:"id"`
DeviceId
int
`json:"device_id"`
Latitude
float64
`json:"latitude"`
//纬度
Longitude
float64
`json:"longitude"`
//经度
//Altitude float64 `json:"altitude"` //高度 单位m
Created
time
.
Time
`json:"created" storm:"created"`
}
models/element.go
浏览文件 @
5f40c73d
...
...
@@ -2,14 +2,6 @@ package models
import
"time"
type
Address
struct
{
Area
string
`json:"area"`
//区域 类似 S I O Q WR ……
Slave
uint8
`json:"slave"`
//从站号 modbus
Offset
uint16
`json:"offset"`
ReadCode
uint8
`json:"read_code"`
WriteCode
uint8
`json:"write_code"`
}
type
Element
struct
{
ID
int
`json:"id"`
Name
string
`json:"name"`
...
...
@@ -21,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"`
Updated
time
.
Time
`json:"updated" storm:"updated"`
}
...
...
@@ -32,9 +26,6 @@ type Element struct {
// hold 保持寄存器(3读多个、6写单个、16写多个,--23读写多个--)
type
ElementVariable
struct
{
ID
int
`json:"id"`
ElementId
int
`json:"element_id"`
Name
string
`json:"name"`
//Alias string `json:"alias"` //别名,用于编程
Area
string
`json:"area"`
...
...
@@ -42,11 +33,8 @@ type ElementVariable struct {
Type
string
`json:"type"`
Unit
string
`json:"unit"`
//单位
Scale
float32
`json:"scale"`
//倍率,比如一般是 整数÷10,得到
Scale
float32
`json:"scale"`
//倍率,比如一般是 整数÷10,得到
Default
string
`json:"default"`
ReadOnly
bool
`json:"read_only"`
//只读
Created
time
.
Time
`json:"created" storm:"created"`
Updated
time
.
Time
`json:"updated" storm:"updated"`
}
models/project.go
浏览文件 @
5f40c73d
...
...
@@ -3,40 +3,63 @@ package models
import
"time"
type
Project
struct
{
ProjectTemplate
`storm:"inline"`
TemplateId
int
`json:"template_id"`
LinkBinds
[]
int
`json:"link_binds"`
}
type
ProjectTemplate
struct
{
ID
int
`json:"id"`
Name
string
`json:"name"`
Description
string
`json:"description"`
Origin
string
`json:"origin"`
//模板ID
UUID
string
`json:"uuid"`
//唯一码,自动生成
//UUID string `json:"uuid"` //唯一码,自动生成
Version
string
`json:"version"`
Disabled
bool
`json:"disabled"`
Elements
[]
struct
{
ElementId
int
`json:"element_id"`
LinkId
int
`json:"link_id"`
Slave
uint8
`json:"slave"`
//从站号
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//别名,用于编程
Variables
[]
struct
{
VariableId
int
`json:"variable_id"`
Alias
string
`json:"alias"`
//别名,用于编程
Correct
float32
`json:"correct"`
//校准
}
}
Jobs
[]
struct
{
Name
string
`json:"name"`
Cron
string
`json:"cron"`
Script
string
`json:"script"`
//javascript
}
Strategies
[]
struct
{
Name
string
`json:"name"`
Script
string
`json:"script"`
//javascript
}
Links
[]
ProjectLink
`json:"links"`
Elements
[]
ProjectElement
`json:"elements"`
Jobs
[]
ProjectJob
`json:"jobs"`
Strategies
[]
ProjectStrategy
`json:"strategies"`
Created
time
.
Time
`json:"created" storm:"created"`
Updated
time
.
Time
`json:"updated" storm:"updated"`
}
type
ProjectLink
struct
{
Name
string
`json:"name"`
Protocol
string
`json:"protocol"`
}
type
ProjectElement
struct
{
ElementId
int
`json:"element_id"`
Link
int
`json:"link"`
//链接号:0,1,2,3
Slave
uint8
`json:"slave"`
//从站号
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//别名,用于编程
Variables
[]
ProjectElementVariable
`json:"variables"`
}
type
ProjectElementVariable
struct
{
ElementVariable
`storm:"inline"`
Name
string
`json:"name"`
Alias
string
`json:"alias"`
//别名,用于编程
Correct
float32
`json:"correct"`
//校准
}
type
ProjectJob
struct
{
Name
string
`json:"name"`
Cron
string
`json:"cron"`
Script
string
`json:"script"`
//javascript
}
type
ProjectStrategy
struct
{
Name
string
`json:"name"`
Script
string
`json:"script"`
//javascript
}
models/template.go
已删除
100644 → 0
浏览文件 @
c2da5100
package
models
type
Template
struct
{
Name
string
`json:"name"`
Description
string
`json:"description"`
Version
string
`json:"version"`
Elements
[]
TemplateElement
`json:"elements"`
Jobs
[]
TemplateJob
`json:"jobs"`
Strategies
[]
TemplateStrategy
`json:"strategies"`
}
type
TemplateJob
struct
{
Name
string
`json:"name"`
Cron
string
`json:"cron"`
Script
string
`json:"script"`
//javascript
}
type
TemplateStrategy
struct
{
Name
string
`json:"name"`
Script
string
`json:"script"`
//javascript
}
type
TemplateElement
struct
{
}
models/tunnel.go
浏览文件 @
5f40c73d
...
...
@@ -3,9 +3,7 @@ package models
import
"time"
type
Tunnel
struct
{
ID
int
`json:"id"`
ProjectId
int
`json:"project_id"`
//模型ID
ID
int
`json:"id"`
Name
string
`json:"name"`
Type
string
`json:"type"`
//tcp-server tcp-client udp-server udp-client serial
Addr
string
`json:"addr"`
...
...
@@ -23,7 +21,10 @@ type Tunnel struct {
Disabled
bool
`json:"disabled"`
Active
bool
`json:"active"`
Active
bool
`json:"active"`
TemplateId
int
`json:"template_id"`
//模板ID
Created
time
.
Time
`json:"created" storm:"created"`
Updated
time
.
Time
`json:"updated" storm:"updated"`
}
...
...
@@ -31,7 +32,8 @@ type Tunnel struct {
type
Link
struct
{
ID
int
`json:"id"`
TunnelId
int
`json:"tunnel_id"`
ProjectId
int
`json:"project_id"`
//模型ID,默认继承自Tunnel
ProjectId
int
`json:"project_id"`
//项目ID
Serial
string
`json:"serial" storm:"index"`
Addr
string
`json:"addr"`
...
...
@@ -40,4 +42,3 @@ type Link struct {
Online
time
.
Time
`json:"online"`
Created
time
.
Time
`json:"created" storm:"created"`
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录