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

local Protocol = {};

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

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

Protocol.Command = 
{
	-- д����Э��ʱֻ����16���ƻ��ַ���ʾ,û�еĻ���ע�͵�
	Start= 
	{
		--д��������, ���ϣ����£����ϣ�����
		TileUp 		= "0xA0, 0x00, 0x00, 0x08, 0x00, 0x00, 0xAF, 0x00",
		TileDown 	= "0xA0, 0x00, 0x00, 0x10, 0x00, 0x00, 0xAF, 0x00",
		PanLeft 	= "0xA0, 0x00, 0x00, 0x04, 0x00, 0x00, 0xAF, 0x00",
		PanRight 	= "0xA0, 0x00, 0x00, 0x02, 0x00, 0x00, 0xAF, 0x00",
		LeftUp 		= "0xA0, 0x00, 0x00, 0x0C, 0x00, 0x00, 0xAF, 0x00",
		LeftDown 	= "0xA0, 0x00, 0x00, 0x14, 0x00, 0x00, 0xAF, 0x00",
		RightUp		= "0xA0, 0x00, 0x00, 0x0A, 0x00, 0x00, 0xAF, 0x00",
		RightDown 	= "0xA0, 0x00, 0x00, 0x12, 0x00, 0x00, 0xAF, 0x00",

		ZoomWide 	= "0xA0, 0x00, 0x00, 0x40, 0x00, 0x00, 0xAF, 0x00",
		ZoomTele 	= "0xA0, 0x00, 0x00, 0x20, 0x00, 0x00, 0xAF, 0x00",
		FocusNear	= "0xA0, 0x00, 0x02, 0x00, 0x00, 0x00, 0xAF, 0x00",
		FocusFar 	= "0xA0, 0x00, 0x01, 0x00, 0x00, 0x00, 0xAF, 0x00",
		IrisSmall 	= "0xA0, 0x00, 0x08, 0x00, 0x00, 0x00, 0xAF, 0x00",
		IrisLarge 	= "0xA0, 0x00, 0x04, 0x00, 0x00, 0x00, 0xAF, 0x00",
			
		-- Ԥ�õ��������ã�����ת��)
		SetPreset 	= "0xA0, 0x00, 0x00, 0x03, 0x00, 0x00, 0xAF, 0x00",
		--ClearPreset	= "0xA0, 0x00, 0x00, 0x05, 0x00, 0x00, 0xAF, 0x00",
		GoToPreset 	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x00, 0xAF, 0x00",
			
		-- ˮƽ�ת��
		--[[
		AutoPanOn	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x63, 0xAF, 0x00",
		AutoPanOff	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x60, 0xAF, 0x00",
		--]]
			
		-- �Զ�ɨ�裬��Ԥ�����õı߽��м�ת��
		--[[
		SetLeftLimit 	= "0xA0, 0x00, 0x00, 0x03, 0x00, 0x5C, 0xAF, 0x00",
		SetRightLimit	= "0xA0, 0x00, 0x00, 0x03, 0x00, 0x5D, 0xAF, 0x00",
		AutoScanOn 	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x46, 0xAF, 0x00",
		AutoScanOff	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x60, 0xAF, 0x00",
		--]]
		
		AuxOn 		= "0xA0, 0x00, 0x00, 0x09, 0x00, 0xff, 0xAF, 0x00",
		AuxOff 		= "0xA0, 0x00, 0x00, 0x0B, 0x00, 0xff, 0xAF, 0x00",
	},
	Stop = 
	{
		TileUp 		= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		TileDown 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		PanLeft 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		PanRight 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		LeftUp 		= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		LeftDown 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		RightUp		= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		RightDown 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		
		ZoomWide 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		ZoomTele 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		FocusNear 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		FocusFar 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		IrisSmall 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
		IrisLarge 	= "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00",
	},
}

Protocol.Checksum = function (s)
	local value = s[1];
	for i = 2, 7 do
		value = bits.bxor(value,s[i]);
	end;
	s[8] = math.mod(value, 256);
	return s;
end;

Protocol.SpeedProcess = function(s, ver, hor)
	if s[4] ~= 0x00 and ver ~= 0x00 then
	s[6] = ver;
	end;
	if s[4] ~= 0x00 and hor ~= 0x00 then
	s[5] = hor;
	end;
	return s;
end;

Protocol.AuxProcess = function(s,num)
        if s[6] == 0xff then 
           local NewAux = math.mod(num,8)
              if NewAux == 0 then
              NewAux = 8;
              else
              NewAux = math.mod(num,8);
              end;
        s[6] = NewAux;
        end;
        return s;
end

return Protocol;