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/SANTACHI.lua

--[[
����SANTACHI��
1 Э����û�и���Ԥ�õ�ı�ŷ�Χ.
2 Э���и�����һ�StartTourָ��, ����û��AddTour DeleteTour ClearTour StopTour. ���ܲ��ȷ, ��Դ˹�����ʱ���.
--]]
local Protocol = {};

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

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

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

		ZoomWide 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', 'C', 0x03",
		ZoomTele 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', '8', 0x03",
		FocusNear	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', 'E', 0x03",
		FocusFar 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '2', '2', 'A', 0x03",
		IrisSmall 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', 'F', ':', '0', '0', '2', '1', '0', '0', '3', ':', '2', '0', '2', '1', '2', '1', '3', 0x03",
		IrisLarge 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', 'F', ':', '0', '0', '2', '1', '0', '0', '2', ':', '2', '0', '2', '1', '2', '1', '2', 0x03",
			
		-- Ԥ�õ��������ã�����ת��)
		SetPreset 	= "0x02, 'A', 'D', 'X', 'X', 'S', 'P', 'X', 'Y', 0x03",
		GoToPreset 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '4', '0', '0', ':', '2', '0', '2', '2', 'X', 'Y', '0', 0x03",
			
		-- �Զ�ɨ�裬��Ԥ�����õı߽��м�ת��
		SetLeftLimit 	= "0x02, 'A', 'D', 'X', 'X', 'S', 'P', '3', '3', 0x03",
		SetRightLimit	= "0x02, 'A', 'D', 'X', 'X', 'S', 'P', '3', '4', 0x03",
		AutoScanOn 	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', 'F', ':', '2', '0', '2', '1', '4', '0', '0', ':', '2', '0', '2', '2', '3', '3', '0', 0x03",
		AutoScanOff	= "0x02, 'A', 'D', 'X', 'X', ';', 'G', 'C', '7', ':', '2', '0', '2', '1', '3', '2', '4', 0x03",

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

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

Protocol.CamAddrProcess = function(s, addr)
	--����ַ��λ�ֿ�����ת�����ַ������4��5�ֽ�.
	local gg = math.mod(addr, 10) + 0x30;
	local ss = math.floor(addr / 10) + 0x30;
	s[Protocol.CommandAttr.AddrPos] = ss;
	s[Protocol.CommandAttr.AddrPos + 1] = gg;
	
	return s;
end;

Protocol.SpeedProcess = function(s, ver, hor)
	--���ٶ�ת�����ַ�������Ӧ��λ��.
	if table.getn(s) > 18 then
		local newver = ver + 0x30;
		local newhor = hor + 0x30
		s[Protocol.CommandAttr.TileSpeedPos] = newver;
		s[Protocol.CommandAttr.PanSpeedPos] = newhor;
	end;
	
	return s;
end;

Protocol.PresetProcess = function(opttable, arg1)
	--����SetPreset��GotoPresetָ����Ԥ�õ�����ڵ�λ�ò�ͬ, ���Ҫ���Դ�
	local gg = math.mod(arg1, 10) + 0x30;
	local ss = math.floor(arg1 / 10) + 0x30;
	if table.getn(opttable) > 10 then
		--GotoPreset, Ԥ�õ��ŷֱ��ڵ�23��24�ֽ�.
		opttable[23] = ss;
		opttable[24] = gg;
	else
		--SetPreset, Ԥ�õ��ŷֱ��ڵ�8��9�ֽ�.
		opttable[8] = ss;
		opttable[9] = gg;
	end;

	return opttable;
end;

return Protocol;