Mini Kabibi Habibi

Current Path : C:/Program Files/Smart Professional Surveillance System/PC-NVR/Common/Lua/ptz/
Upload File :
Current File : C:/Program Files/Smart Professional Surveillance System/PC-NVR/Common/Lua/ptz/WV-CS850I.lua

local Protocol = {};

-- ��ʾ�ֵ������16��10����(��Сֵ�����ֵ)
Protocol.Attr = 
{
	-- Э�����ʾ���,���ܳ���16�ַ���Ŀǰ�ݲ�֧������
	Name = "WV-CS850I",	
		
	-- ָ�����̨Э�黹�Ǿ���Э�飬ʹ��"PTZ", "MATRIX"��ʾ
	Type = "PTZ",
	
	-- ��msΪ��λ
	Internal = 200,
				
	-- û�ж�Ӧ�ĵ�ַ��Χ���붼���0xff
	-- ��̨��ַ��Χ--
	CamAddrRange 		= {1, 99}, 
	-- ���ӵ�ַ��Χ--
	MonAddrRange		= {1, 96},	
	-- Ԥ�õ㷶Χ--
	PresetRange 		= {0xff, 0xff},
	-- �Զ�Ѳ����·��Χ
	TourRange		= {0xff, 0xff},
	-- �켣��·��Χ
	PatternRange		= {0x01, 0x3f},
	-- ��ֱ�ٶȷ�Χ--
	TileSpeedRange 		= {0x00, 0x07},
	-- ˮƽ�ٶȷ�Χ--
	PanSpeedRange 		= {0x00, 0x07},
	
	-- �����Χ
	AuxRange 		= {0x01, 0x04},
}

Protocol.CommandAttr =
{
	-- Э������Ҫ���ĵ�λ�ã���LUA�±��ʾ�����±�ӣ���ʼ,��10���Ʊ�ʾ
	AddrPos 			= 4, 
	PresetPos 			= 23, 
	TileSpeedPos 			= 24,
	PanSpeedPos 			= 23,
	AuxPos 				= 6,
}

Protocol.Command = 
{
	-- д����Э��ʱֻ����16���ƻ��ַ���ʾ,û�еĻ���ע�͵�
	Start= 
	{
		--д��������, ���ϣ����£����ϣ�����
		TileUp 		= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', 'A', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		TileDown	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', 'E', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		PanLeft 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', '8', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03", 
		PanRight 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', 'C', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		LeftUp 		= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', '9', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		LeftDown 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', 'F', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		RightUp		= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', 'B', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		RightDown = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '3', '6', 'D', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",

		ZoomWide 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', 'C', 0x03",
		ZoomTele 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', '8', 0x03",
		FocusNear	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', 'E', 0x03",
		FocusFar 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', 'A', 0x03",

		IrisSmall 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '0', '0', '2', 0x03",
		IrisLarge 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '0', '0', '3', 0x03",
			
		-- �Զ�ɨ�裬��Ԥ�����õı߽��м�ת��
		SetLeftLimit 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '3', '0', '6', 0x03",
		SetRightLimit	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '3', '0', '7', 0x03",
		AutoScanOn	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '3', '0', '0', 0x03",
		AutoScanOff	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '3', '0', '1', 0x03",	
			
		-- �Զ�Ѳ����һ��ָ��Ԥ�õ�֮��Ѳ��
		StartTour 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '4', '9', '0', 0x03",
		StopTour 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '4', '9', '1', 0x03",
			
		-- �켣Ѳ��, һ��ָģʽ(���ÿ�ʼ�����ý�������У�ֹͣ����ģʽ
		SetPatternStart = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '5', '4', '0', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
		SetPatternStop 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '5', '4', '2', ':', '2', '0', '2', '1', '5', '4', '3', 0x03",
		StartPattern 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '4', '0', '0', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",

	
		-- �˵���ز��
		Menu = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', 'C', '0', 0x03",
		MenuExit = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', 'C', '1', 0x03",
		MenuEnter = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', '4', '0', 0x03",
		MenuEsc = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', '4', '1', 0x03",
		
		MenuUp = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', '4', '2', 0x03",
		MenuDown = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', '4', '4', 0x03",
		MenuLeft = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', '4', '5', 0x03",
		MenuRight = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '9', '4', '3', 0x03",
	

	},
	Stop = 
	{
		TileUp 		= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		TileDown 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		PanLeft 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		PanRight 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		LeftUp 		= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		LeftDown 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		RightUp		= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		RightDown = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '3', '2', '4', 0x03",
		
		ZoomWide 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '2', '2', '4', 0x03",
		ZoomTele 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '2', '2', '4', 0x03",
		FocusNear = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '2', '2', '4', 0x03",
		FocusFar 	= "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '2', '2', '4', 0x03",
		IrisSmall = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '0', '0', '4', 0x03",
		IrisLarge = "0x02, 'A', 'D', '0', '0', ';', 'G', 'C', '7', ':', '0', '0', '2', '1', '0', '0', '4', 0x03",
	},
}

Protocol.Checksum = function (s)
	return s;
end;

Protocol.CamAddrProcess = function(s, addr)
	local newaddr = math.mod(addr, 100);
	local i    = math.floor(newaddr/10);
	local j    = math.mod(newaddr, 10);
	s[Protocol.CommandAttr.AddrPos] = i + 0x30;
	s[Protocol.CommandAttr.AddrPos + 1] = j + 0x30;

	return s;
end;

Protocol.SpeedProcess = function(s, ver, hor)
	if table.getn(s) > 18 then
		s[Protocol.CommandAttr.TileSpeedPos] = ver + 0x30;
		s[Protocol.CommandAttr.PanSpeedPos] = hor + 0x30;
	end;
	
	return s;
end;

Protocol.PatternProcess = function(s, arg)
	local hex_table = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
	if s[23] == 88 then
		local i = math.mod(arg, 16);
		local j = math.floor(arg / 16);
		s[Protocol.CommandAttr.PresetPos] = string.byte(hex_table[j + 1]);
		s[Protocol.CommandAttr.PresetPos + 1] = string.byte(hex_table[i + 1]);
	end;
	
	return s;
end;

return Protocol;