| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 | 
							- <?php
 
- # 定义几个常用的选项
 
- $option = array
 
- (
 
- 	1 => '可用',
 
- 	2 => '不可用',
 
- );
 
- $front = array
 
- (
 
- 	1 => '可用',
 
- 	2 => '不可用',
 
- );
 
- $show_type = array
 
- (
 
- 	1 => '数据区',
 
- 	2 => '状态区',
 
- 	100 => '不显示',
 
- );
 
- $type = array
 
- (
 
- 	1 => '否',
 
- 	2 => '是',
 
- );
 
- $status = array
 
- (
 
- 	1 => '显式',
 
- 	2 => '隐式',
 
- );
 
- $oper = array
 
- (
 
- 	'open' => '启动',
 
- 	'close' => '关闭',
 
- 	'other' => '普通指令',
 
- 	'set' => '设备设置',
 
- 	'device' => '设备状态码',
 
- 	//'none' => '非直接发送指令',
 
- 	//'camera' => '摄像头',
 
- );
 
- $id = Dever::input('where_id');
 
- $element = Dever::input('option_element_id');
 
- $code = function() use ($id, $element)
 
- {
 
- 	$array = array(-1 => array('name' => '非互斥命令码'));
 
- 	$code = Dever::load('device/code-getAll', array('option_id' => $id, 'option_element_id' => $element));
 
- 	if($code)
 
- 	{
 
- 		$array += $code;
 
- 	}
 
- 	return $array;
 
- };
 
- $next_code = function() use ($id, $element)
 
- {
 
- 	$array = array(-1 => array('name' => '无下级命令码'));
 
- 	$code = Dever::load('device/code-getAll', array('option_id' => $id, 'option_element_id' => $element));
 
- 	if($code)
 
- 	{
 
- 		$array += $code;
 
- 	}
 
- 	return $array;
 
- };
 
- $proxy_code = function() use ($id, $element)
 
- {
 
- 	$array = array(-1 => array('name' => '无代理命令码'));
 
- 	$code = Dever::load('device/code-getAll', array('option_id' => $id, 'option_element_id' => $element));
 
- 	if($code)
 
- 	{
 
- 		$array += $code;
 
- 	}
 
- 	return $array;
 
- };
 
- $main_code = function() use ($id, $element)
 
- {
 
- 	$array = array(-1 => array('name' => '无主任务命令码'));
 
- 	$code = Dever::load('device/code-getAll', array('option_id' => $id, 'option_element_id' => $element));
 
- 	if($code)
 
- 	{
 
- 		$array += $code;
 
- 	}
 
- 	return $array;
 
- };
 
- return array
 
- (
 
- 	# 表名
 
- 	'name' => 'code',
 
- 	# 显示给用户看的名称
 
- 	'lang' => '命令码设置',
 
- 	'menu' => false,
 
- 	'start' => array
 
- 	(
 
- 		'update' => 'device/code.save',
 
- 	),
 
- 	'end' => array
 
- 	(
 
- 		'insert' => 'device/code.save',
 
- 	),
 
- 	# 数据结构
 
- 	'struct' => array
 
- 	(
 
- 		'id' 		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '命令码ID',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '',
 
- 			'match' 	=> 'is_numeric',
 
- 			'search'	=> 'order',
 
- 			'order'		=> 'desc',
 
- 			//'list'		=> true,
 
- 		),
 
- 		
 
- 		'name'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-32',
 
- 			'name' 		=> '操作名称',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入操作名称',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'text',
 
- 			'search'	=> 'fulltext',
 
- 			'list'		=> true,
 
- 		),
 
- 		
 
- 		'oper'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-32',
 
- 			'name' 		=> '操作方式-前台根据这个来判断具体的命令码,请准确选择,如果选择非直接发送指令,那么下述发送指令不会立刻发送,需要等到条件满足时才会发送,比如旋转圈数',
 
- 			'default' 	=> 'other',
 
- 			'desc' 		=> '操作方式',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'radio',
 
- 			'option'	=> $oper,
 
- 			'search'	=> 'fulltext',
 
- 			'list'		=> true,
 
- 		),
 
- 		
 
- 		'element_id'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '所属元件',
 
- 			'default' 	=> Dever::input('option_element_id'),
 
- 			'desc' 		=> '请选择所属元件',
 
- 			'match' 	=> 'is_numeric',
 
- 			'update'	=> 'hidden',
 
- 		),
 
- 		'type'		=> array
 
- 		(
 
- 			'type' 		=> 'tinyint-1',
 
- 			'name' 		=> '是否数据指令-数据指令用于数据计算,可根据数据记录,进行公式或者其他方式计算',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择是否数据指令',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $type,
 
- 			'update'	=> 'radio',
 
- 			//'list'		=> true,
 
- 			# 开启显示控制,可以控制下边的表单
 
- 			'show'		=> 'type',
 
- 		),
 
- 		'data'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-500',
 
- 			'name' 		=> '数据指令名称-仅用于数据计算,根据以下填写的计算公式,计算出数据,本字段为该数据的名称,如水压,多个名称请用@隔开',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入数据指令名称',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'textarea',
 
- 			//'search'	=> 'fulltext',
 
- 			//'list'		=> true,
 
- 			'show'		=> array('type_2'),
 
- 		),
 
- 		'gs'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-200',
 
- 			'name' 		=> '数据计算公式-根据该公式计算出当前回传回得数据,{b}为本次回传数据,多个请用@隔开',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入数据计算公式',
 
- 			'match' 	=> 'is_string',
 
- 			'update'	=> 'textarea',
 
- 			//'search'	=> 'fulltext',
 
- 			//'list'		=> true,
 
- 			'show'		=> array('type_2'),
 
- 		),
 
- 		
 
- 		'dw'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-200',
 
- 			'name' 		=> '数据单位-显示出来的数据单位,多个请用@隔开',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '显示出来的数据单位',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'textarea',
 
- 			//'search'	=> 'fulltext',
 
- 			//'list'		=> true,
 
- 			'show'		=> array('type_2'),
 
- 		),
 
- 		
 
- 		//100102(.*)@200203(.*)||00 10@01 20||阀门1状态(1开0关) 阀门1通电时间(10ms)@阀门2状态(1开0关) 阀门2通电时间(10ms)||01=开&00=关@time
 
- 		'send'		=> array
 
- 		(
 
- 			'type' 		=> 'text-255',
 
- 			'name' 		=> '发送指令-多个指令用换行隔开,如果有后续指令[如at指令],请用|AT|隔开,会依次向服务器发送这些指令,如果选择设备设置,此处的变量请用(.*)代替,如10 01 03(.*)03 03,带上||则为后续设置,此时多个指令用@隔开,注意与换行的区别',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入发送指令',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'textarea',
 
- 			'list_name'	=> '指令',
 
- 			'list'		=> '"发送:{send}<br />接收:{receive}" . ({type} != 1 ? "<br />数据指令:{data}" : "")',
 
- 			//'list'		=> 'table',
 
- 			'modal'		=> '查看详情',
 
- 		),
 
- 		
 
- 		'send_name'		=> array
 
- 		(
 
- 			'type' 		=> 'text-255',
 
- 			'name' 		=> '发送指令对应的名称-如果定义了这个,则会取代上述"操作名称",多个指令名称用换行隔开,除非直接发送指令外,其他指令均需和上边的发送指令一一对应',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入发送指令名称',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'textarea',
 
- 		),
 
- 		
 
- 		'receive'		=> array
 
- 		(
 
- 			'type' 		=> 'text-255',
 
- 			'name' 		=> '固定接收指令-多个指令用换行隔开,注意,本指令可用于数据计算,必须写入固定的接收指令部分,变化部分请用(.*)代替,如0103020000b844,可将0000b844替换为(.*),加|为配置信息,第一为取多少个数据(4个字节为一个数据)',
 
- 			'default' 	=> '',
 
- 			'desc' 		=> '请输入接收指令',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'textarea',
 
- 			//'list'		=> true,
 
- 		),
 
- 		'reorder'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '排序-数值越大越靠前',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请输入排序',
 
- 			'match' 	=> 'option',
 
- 			'update'	=> 'text',
 
- 			'search'	=> 'order',
 
- 			'list'		=> true,
 
- 			'order'		=> 'desc',
 
- 			'edit'		=> true,
 
- 		),
 
- 		'time'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '发送时间间隔-秒级别,默认为0不周期性发送,大于0则按照本时间间隔进行周期性发送指令,需要计划任务支持',
 
- 			'default' 	=> '0',
 
- 			'match' 	=> 'is_numeric',
 
- 			'desc' 		=> '请输入时间间隔',
 
- 			'update'	=> 'text',
 
- 			'list'		=> true,
 
- 			'edit'		=> true,
 
- 		),
 
- 		
 
- 		'code_id'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '互斥命令码-选择互斥的命令码,同时只能存在一个,如启动和关闭,启动命令码执行之后,关闭才能执行',
 
- 			'default' 	=> '-1',
 
- 			'desc' 		=> '互斥命令码',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $code,
 
- 			'update'	=> 'select',
 
- 			'list'		=> true,
 
- 			//'edit'		=> 'yes',
 
- 		),
 
- 		
 
- 		'next_code_id'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '下级命令码-选择下级命令码,则本次命令码在执行成功之后,会发送后续的下级命令码。适用于在关闭时,同时关闭多项命令码的操作。',
 
- 			'default' 	=> '-1',
 
- 			'desc' 		=> '下级命令码',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $next_code,
 
- 			//'update'	=> 'select',
 
- 			//'list'		=> true,
 
- 			//'edit'		=> 'yes',
 
- 		),
 
- 		
 
- 		'proxy_code_id'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '代理命令码-选择代理命令码,在执行该命令码时,同步执行代理命令码,注意和下级命令码不同,代理命令码不依托于执行状态。',
 
- 			'default' 	=> '-1',
 
- 			'desc' 		=> '代理命令码',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $proxy_code,
 
- 			//'update'	=> 'select',
 
- 			//'list'		=> true,
 
- 			//'edit'		=> 'yes',
 
- 		),
 
- 		
 
- 		'second'		=> array
 
- 		(
 
- 			'type' 		=> 'varchar-30',
 
- 			'name' 		=> '代理或下级命令码执行延时-单位为秒,添加后执行该命令码将会延时',
 
- 			'default' 	=> '0.5',
 
- 			'desc' 		=> '代理或下级命令码执行延时',
 
- 			'match' 	=> 'option',
 
- 			//'update'	=> 'text',
 
- 		),
 
- 		
 
- 		'main_code_id'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '主任务命令码-当当前命令码执行成功后无法区分状态时(比如很多命令码返回的命令码都是一个),可以启用主任务命令码来区分是哪个主进程',
 
- 			'default' 	=> '-1',
 
- 			'desc' 		=> '主任务命令码',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $main_code,
 
- 			//'update'	=> 'select',
 
- 			//'list'		=> true,
 
- 			//'edit'		=> 'yes',
 
- 		),
 
- 		
 
- 		'status'		=> array
 
- 		(
 
- 			'type' 		=> 'tinyint-1',
 
- 			'name' 		=> '命令码类型-显式命令码会在点击按钮后立刻发送,隐式命令码则不会立刻发送执行,一般是在下级命令码中设置为隐式命令码',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择状态',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $status,
 
- 			//'update'	=> 'radio',
 
- 			'list'		=> true,
 
- 			'edit'		=> true,
 
- 		),
 
- 		'show_type'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '显示位置',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择显示位置',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $show_type,
 
- 			'update'	=> 'radio',
 
- 			//'list'		=> true,
 
- 		),
 
- 		'state'		=> array
 
- 		(
 
- 			'type' 		=> 'tinyint-1',
 
- 			'name' 		=> '状态',
 
- 			'default' 	=> '1',
 
- 			'desc' 		=> '请选择状态',
 
- 			'match' 	=> 'is_numeric',
 
- 			'option' 	=> $option,
 
- 			'update'	=> 'radio',
 
- 			'list'		=> true,
 
- 		),
 
- 		
 
- 		'cdate'		=> array
 
- 		(
 
- 			'type' 		=> 'int-11',
 
- 			'name' 		=> '录入时间',
 
- 			'match' 	=> array('is_numeric', time()),
 
- 			'desc' 		=> '',
 
- 			# 只有insert时才生效
 
- 			'insert'	=> true,
 
- 			//'list'		=> 'date("Y-m-d H:i:s", {cdate})',
 
- 		),
 
- 	),
 
- 	'alter' => array
 
- 	(
 
- 		1 => array
 
- 		(
 
- 			array('update', 'data', 'data', 'varchar-255  数据指令名称'),//更新字段
 
- 		),
 
- 		2 => array
 
- 		(
 
- 			array('update', 'data', 'data', 'varchar-500  数据指令名称'),//更新字段
 
- 		),
 
- 		3 => array
 
- 		(
 
- 			array('update', 'gs', 'gs', 'varchar-500  公式'),//更新字段
 
- 		),
 
- 		'version' => 3,
 
- 	),
 
- 	
 
- 	# request 请求接口定义
 
- 	'request' => array
 
- 	(
 
- 		'info' => array
 
- 		(
 
- 			# 匹配的正则或函数 选填项
 
- 			'where' => array
 
- 			(
 
- 				'state' => 1,
 
- 				'id' => 'yes',
 
- 			),
 
- 			'type' => 'one',
 
- 		),
 
- 		# 取所有菜单
 
- 		'all' => array
 
- 		(
 
- 			'where' => array
 
- 			(
 
- 				'state' => 1,
 
- 				'element_id' => 'yes',
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('reorder` desc,`id', 'desc'),
 
- 			'col' => '*|id',
 
- 		),
 
- 		
 
- 		'getAll' => array
 
- 		(
 
- 			'option' => array
 
- 			(
 
- 				//'state' => 1,
 
- 				'id' => array('yes', '!='),
 
- 				'element_id' => 'yes',
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('reorder` desc,`id', 'desc'),
 
- 			'col' => '*|id',
 
- 		),
 
- 		'getIds' => array
 
- 		(
 
- 			'where' => array
 
- 			(
 
- 				'state' => 1,
 
- 				'type' => 2,
 
- 				'id' => array('yes', 'in'),
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('reorder` desc,`id', 'desc'),
 
- 			'col' => '*|id',
 
- 		),
 
- 		
 
- 		'getIdsData' => array
 
- 		(
 
- 			'where' => array
 
- 			(
 
- 				'state' => 1,
 
- 				'type' => 2,
 
- 				'id' => array('yes', 'in'),
 
- 			),
 
- 			'type' => 'all',
 
- 			'order' => array('reorder` desc,`id', 'desc'),
 
- 			'col' => 'id,data as name|id',
 
- 		),
 
- 		# 根据id获取
 
- 		'getData' => array
 
- 		(
 
- 			'where' => array
 
- 			(
 
- 				//'state' => 1,
 
- 				//'type' => 2,
 
- 				'element_id' => 'yes',
 
- 			),
 
- 			'type' => 'all',
 
- 			'col' => '*',
 
- 		),
 
- 		# 根据id获取
 
- 		'getDataByIds' => array
 
- 		(
 
- 			'where' => array
 
- 			(
 
- 				//'state' => 1,
 
- 				//'type' => 2,
 
- 				'id' => array('yes', 'in'),
 
- 			),
 
- 			'type' => 'all',
 
- 			'col' => '*',
 
- 		),
 
- 	),
 
- );
 
 
  |