dever 4 years ago
parent
commit
2bcbd1836d

+ 6 - 5
admin/page/modbus.py

@@ -37,7 +37,7 @@ class server_update_path(Load):
 			path = '/modbus/server'
 			,label = (u'服务名称',u'服务类型',u'服务地址',u'服务端口')
 			,update = ('name-input-required','server_type-select-required','server_host-input-required','server_port-input-required')
-			,update_server_type = [{'id':1,'name':'tcp'},{'id':2,'name':'rtu'}]
+			,update_server_type = Demeter.service('core', 'modbus').server_type()
 		)
 		self.one('modbus_server')
 		self.show('update')
@@ -116,11 +116,12 @@ class device_update_path(Load):
 	def get(self):
 		self.set(
 			path = '/modbus/device'
-			,label = (u'设备名称',u'选择分组',u'设备类型',u'从机id',u'寄存器类型',u'寄存器地址',u'寄存器长度',u'单位',u'计算公式')
-			,update = ('name-input-required','group_id-select-required','slave_type-select-required','slave_id-input-','register_type-select-','register_address-input-','register_length-input-','unit-input-','exp-text--{n}为当前数据')
+			,label = (u'设备名称',u'选择分组',u'设备类型',u'从机id',u'寄存器类型',u'寄存器地址',u'寄存器长度',u'单位',u'计算公式',u'数据类型',u'可选项')
+			,update = ('name-input-required','group_id-select-required','slave_type-select-required','slave_id-input-','register_type-select-','register_address-input-','register_length-input-','unit-input-','exp-text--{n}为当前数据','data_type-select-','data_option-text--多个换行隔开')
 			,update_group_id = self.service('common').list('modbus_device_group')
-			,update_slave_type = [{'id':1,'name':'读取'},{'id':2,'name':'写入'},{'id':3,'name':'拍照'},{'id':4,'name':'摄像'}]
-			,update_register_type = [{'id':1,'name':'线圈寄存器'},{'id':2,'name':'离散输入寄存器'},{'id':3,'name':'保持寄存器'},{'id':4,'name':'输入寄存器'}]
+			,update_slave_type = Demeter.service('core', 'modbus').slave_type()
+			,update_register_type = Demeter.service('core', 'modbus').register_type()
+			,update_data_type = Demeter.service('core', 'modbus').data_type()
 		)
 		self.one('modbus_device')
 		self.show('update')

+ 0 - 20
model/device_gateway.py

@@ -1,20 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    demeter database
-    name:device_gateway.py
-    author:rabin
-"""
-from .__load__ import *
-
-class Device_gateway(Model):
-	__table__ = 'device_gateway'
-	__comment__ = '设备网关管理'
-	id = Fields(type='uuid', primaryKey=True, comment='网关ID', uuid='farm_id')
-	farm_id = Fields(type='int', default='setting.farm', comment='园区ID', match='not')
-	name = Fields(type='varchar(50)', comment='网关名')
-	hardware_id = Fields(type='bigint', comment='硬件id', match='number|硬件id必须是数字')
-	pic = Fields(type='varchar(255)', comment='设备分布图纸')
-	camera = Fields(type='varchar(500)', comment='摄像头实时流地址')
-	stat = Fields(type='boolean', default='False', comment='是否显示趋势图')
-	state = Fields(type='boolean', default='True', comment='数据存在状态')
-	cdate = Fields(type='int', default='time', comment='创建时间')

+ 0 - 1
model/device_set_condition.py

@@ -12,7 +12,6 @@ class Device_set_condition(Model):
 	id = Fields(type='uuid', primaryKey=True, comment='设置ID', uuid='farm_id')
 	farm_id = Fields(type='int', default='setting.farm', comment='园区ID', match='not')
 	devices = Fields(type='text', comment='设备id')
-	gateway_id = Fields(type='uuid', comment='设备条件里的网关id')
 	device_id = Fields(type='uuid', comment='设备条件里的设备id')
 	oper = Fields(type='smallint', comment='操作')
 	condition = Fields(type='smallint', comment='条件')

+ 0 - 18
model/device_type.py

@@ -1,18 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    demeter database
-    name:device_type.py
-    author:rabin
-"""
-from .__load__ import *
-
-class Device_type(Model):
-	__table__ = 'device_type'
-	__comment__ = '设备类型'
-	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='设备类型ID')
-	name = Fields(type='varchar(50)', comment='设备类型名')
-	key = Fields(type='varchar(50)', comment='设备标识', unique=True)
-	unit = Fields(type='varchar(20)', comment='设备单位')
-	exp = Fields(type='varchar(300)', comment='表达式')
-	state = Fields(type='boolean', default='True', comment='数据存在状态')
-	cdate = Fields(type='int', default='time', comment='创建时间')

+ 2 - 0
model/modbus_device.py

@@ -18,6 +18,8 @@ class Modbus_device(Model):
 	register_type = Fields(type='int', comment='寄存器类型')
 	register_address = Fields(type='varchar(100)', comment='寄存器地址')
 	register_length = Fields(type='varchar(50)', comment='寄存器长度')
+	data_type = Fields(type='int', comment='数据类型')
+	data_option = Fields(type='text', comment='数据类型选项')
 	exp = Fields(type='varchar(100)', comment='计算公式')
 	unit = Fields(type='varchar(10)', comment='单位')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')

+ 0 - 1
runtime/postgresql/device_gateway

@@ -1 +0,0 @@
-[["cdate", 1], ["stat", 1], ["farm_id", 1], ["camera", 1], ["pic", 1], ["id", 1], ["hardware_id", 1], ["state", 1], ["name", 1]]

+ 1 - 1
runtime/postgresql/device_info

@@ -1 +1 @@
-[["value", 1], ["operdate", 1], ["cxtype", 1], ["gateway_id", 1], ["udate", 1], ["id", 1], ["cdate", 1], ["cxdate", 1], ["hardware_type", 1], ["cxnum", 1], ["status", 1], ["state", 1], ["name", 1], ["type_id", 1], ["oper", 1], ["exp", 1], ["max", 1], ["hardware_id", 1], ["min", 1], ["inorder", 1], ["farm_id", 1]]
+[["min", 1], ["value", 1], ["cxdate", 1], ["max", 1], ["device_id", 1], ["state", 1], ["operdate", 1], ["id", 1], ["cdate", 1], ["server_id", 1], ["farm_id", 1], ["cxtype", 1], ["cxnum", 1], ["status", 1], ["name", 1], ["oper", 1], ["inorder", 1], ["udate", 1]]

+ 0 - 1
runtime/postgresql/device_type

@@ -1 +0,0 @@
-[["state", 1], ["unit", 1], ["cdate", 1], ["key", 1], ["id", 1], ["exp", 1], ["name", 1]]

+ 1 - 1
runtime/postgresql/farm

@@ -1 +1 @@
-[["tel", 1], ["master_name", 1], ["pic", 1], ["name", 1], ["address", 1], ["cdate", 1], ["master_pic", 1], ["info", 1], ["welcome", 1], ["location", 1], ["state", 1], ["gateway", 1], ["id", 1]]
+[["cdate", 1], ["master_name", 1], ["tel", 1], ["welcome", 1], ["gateway", 1], ["id", 1], ["address", 1], ["info", 1], ["location", 1], ["state", 1], ["pic", 1], ["master_pic", 1], ["name", 1]]

+ 0 - 1
runtime/postgresql/farm_product

@@ -1 +0,0 @@
-[["yields", 1], ["pic", 1], ["id", 1], ["state", 1], ["name", 1], ["charact", 1], ["notice", 1], ["area", 1], ["status", 1], ["cdate", 1], ["farm_id", 1]]

+ 0 - 1
runtime/postgresql/farm_user

@@ -1 +0,0 @@
-[["id", 1], ["state", 1], ["password", 1], ["username", 1], ["farm_id", 1], ["cdate", 1], ["mobile", 1]]

+ 0 - 1
runtime/postgresql/farm_work

@@ -1 +0,0 @@
-[["cdate", 1], ["land_id", 1], ["workdate", 1], ["pic", 1], ["amount", 1], ["id", 1], ["category_id", 1], ["farm_id", 1], ["state", 1], ["method_id", 1]]

+ 0 - 1
runtime/postgresql/farm_work_category

@@ -1 +0,0 @@
-[["cdate", 1], ["id", 1], ["farm_id", 1], ["name", 1], ["state", 1]]

+ 0 - 1
runtime/postgresql/farm_work_land

@@ -1 +0,0 @@
-[["id", 1], ["state", 1], ["cdate", 1], ["name", 1], ["farm_id", 1]]

+ 0 - 1
runtime/postgresql/hardware_type

@@ -1 +0,0 @@
-[["state", 1], ["id", 1], ["cdate", 1], ["name", 1], ["key", 1]]

+ 1 - 1
runtime/postgresql/manage_admin

@@ -1 +1 @@
-[["mobile", 1], ["state", 1], ["cdate", 1], ["role_id", 1], ["password", 1], ["id", 1], ["username", 1]]
+[["username", 1], ["cdate", 1], ["id", 1], ["password", 1], ["role_id", 1], ["state", 1], ["mobile", 1]]

+ 0 - 1
runtime/postgresql/manage_log

@@ -1 +0,0 @@
-[["method", 1], ["state", 1], ["admin_id", 1], ["cdate", 1], ["data", 1], ["id", 1], ["model", 1]]

+ 1 - 1
runtime/postgresql/manage_role

@@ -1 +1 @@
-[["top", 1], ["state", 1], ["name", 1], ["cdate", 1], ["auth", 1], ["id", 1], ["oper", 1]]
+[["state", 1], ["cdate", 1], ["id", 1], ["top", 1], ["auth", 1], ["oper", 1], ["name", 1]]

+ 1 - 1
runtime/postgresql/modbus_device

@@ -1 +1 @@
-[["slave_type", 1], ["unit", 1], ["name", 1], ["register_length", 1], ["state", 1], ["farm_id", 1], ["slave_id", 1], ["cdate", 1], ["exp", 1], ["register_address", 1], ["group_id", 1], ["register_type", 1], ["id", 1]]
+[["slave_type", 1], ["slave_id", 1], ["data_option", 1], ["farm_id", 1], ["register_type", 1], ["name", 1], ["unit", 1], ["group_id", 1], ["exp", 1], ["state", 1], ["id", 1], ["cdate", 1], ["register_length", 1], ["data_type", 1], ["register_address", 1]]

+ 1 - 1
runtime/postgresql/modbus_device_group

@@ -1 +1 @@
-[["name", 1], ["state", 1], ["cdate", 1], ["farm_id", 1], ["key", 1], ["id", 1]]
+[["farm_id", 1], ["state", 1], ["cdate", 1], ["id", 1], ["key", 1], ["name", 1]]

+ 1 - 1
runtime/postgresql/modbus_server

@@ -1 +1 @@
-[["cdate", 1], ["server_port", 1], ["server_type", 1], ["id", 1], ["server_host", 1], ["state", 1], ["name", 1], ["farm_id", 1]]
+[["farm_id", 1], ["state", 1], ["cdate", 1], ["id", 1], ["server_host", 1], ["server_type", 1], ["name", 1], ["server_port", 1]]

+ 0 - 1
runtime/postgresql/msg_type

@@ -1 +0,0 @@
-[["state", 1], ["cdate", 1], ["push", 1], ["key", 1], ["id", 1], ["name", 1]]

+ 0 - 1
runtime/postgresql/notice_type

@@ -1 +0,0 @@
-[["state", 1], ["id", 1], ["cdate", 1], ["name", 1], ["key", 1]]

+ 20 - 6
service/modbus/core.py

@@ -3,9 +3,23 @@ from demeter.core import *
 
 class Core(object):
 
-	def register_type(self):
-		return [
-		{'id':1,'name':'线圈寄存器'}
-		,{'id':2,'name':'离散输入寄存器'}
-		,{'id':3,'name':'保持寄存器'}
-		,{'id':4,'name':'输入寄存器'}]
+    def register_type(self):
+        return [
+        {'id':1,'name':'线圈寄存器'}
+        ,{'id':2,'name':'离散输入寄存器'}
+        ,{'id':3,'name':'保持寄存器'}
+        ,{'id':4,'name':'输入寄存器'}]
+
+    def slave_type(self):
+        return [{'id':1,'name':'读取'},{'id':2,'name':'写入'},{'id':3,'name':'拍照'},{'id':4,'name':'摄像'}]
+
+    def data_type(self):
+        return [
+        {'id':1,'name':'输入框'}
+        ,{'id':2,'name':'单选框'}
+        ,{'id':3,'name':'多选框'}
+        ,{'id':4,'name':'按钮'}]
+
+
+    def server_type(self):
+        [{'id':1,'name':'tcp'},{'id':2,'name':'rtu'}]