rabin 7 years ago
parent
commit
ec3755d8d2
4 changed files with 15 additions and 8 deletions
  1. 2 2
      cron.py
  2. 1 1
      front/static/pc/js/main.js
  3. 4 1
      model/device_mul_queue.py
  4. 8 4
      service/device.py

+ 2 - 2
cron.py

@@ -23,7 +23,7 @@ def switch(value):
 def device():
 	while 1:
 		model = Demeter.model('device_info')
-		cur = Demeter.time() - 500
+		cur = Demeter.time() - 1200
 		model.cdate.assgin(cur, '<=')
 		model.status = True
 		data = model.select()
@@ -68,7 +68,7 @@ def mulQueue():
 		model = Demeter.model('device_mul_queue')
 
 		model.status = 1
-		data = model.select(type='fetchone', order='device_id asc')
+		data = model.select(type='fetchone', order='inorder asc,device_id asc')
 		service = Demeter.service('device')
 
 		# 查看当前有没有正在执行的设备,如果有,不能继续执行了

+ 1 - 1
front/static/pc/js/main.js

@@ -271,7 +271,7 @@ var Farm =
 
 	,CreateLoop : function() {
 		if (!this.loop) {
-			this.loop = setInterval("Farm.Load()", 1500);
+			this.loop = setInterval("Farm.Load()", 1000);
 		}
 	}
 

+ 4 - 1
model/device_mul_queue.py

@@ -20,4 +20,7 @@ class Device_mul_queue(Model):
 	operdate = Fields(type='int', comment='操作时间')
 	oper = Fields(type='varchar(500)', comment='操作说明')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')
-	cdate = Fields(type='int', default='time', comment='创建时间')
+	cdate = Fields(type='int', default='time', comment='创建时间')
+	inorder = Fields(type='int', default='0', comment='设备的排序', match='number|排序必须是数字')
+
+	#ALTER TABLE device_mul_queue ADD inorder int default 100; 

+ 8 - 4
service/device.py

@@ -8,7 +8,7 @@
 from demeter.core import *
 from demeter.mqtt import *
 class Device(object):
-
+	type_info = []
 	# 新增网关时,增加状态和电源
 	def upGatewayStatus(self, farm_id, gateway_id, hardware_id):
 		if hardware_id and gateway_id > 0:
@@ -62,6 +62,7 @@ class Device(object):
 			queue_model.device_id = info['id']
 			queue_model.status = 1
 			queue_model.value = switch
+			queue_model.inorder = info['inorder']
 			queue_model.insert()
 			return
 		
@@ -148,8 +149,8 @@ class Device(object):
 		oper = ''
 		type_model = Demeter.model('device_type')
 		type_model.id = type_id
-		type_info = type_model.select(type='fetchone')
-		if type_info['unit'] == 'button':
+		self.type_info = type_model.select(type='fetchone')
+		if self.type_info['unit'] == 'button':
 			if switch == 1:
 				oper = '升起'
 			elif switch == 2:
@@ -175,7 +176,10 @@ class Device(object):
 				model.status = 1
 				model.device_id = info['id']
 				oper = self.msg(info['type_id'], v['value']) + msg
+			#判断是不是卷帘类的按钮,如果是,要等15秒。。
+			if self.type_info['unit'] == 'button':
+				sleep(15)
 			if state:
 				model.update(status=2, oper=oper, operdate=Demeter.time())
 			else:
-				model.update(status=3, oper=oper, operdate=Demeter.time())
+				model.update(status=3, oper=oper, operdate=Demeter.time())