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/PelcoP-HK.lua

local Protocol = {};

-- ��ʾ�ֵ������16��10����(��Сֵ�����ֵ)
Protocol.Attr = 
{
		-- Э�����ʾ���,���ܳ���16�ַ�
		Name = "PELCOP-HK",	
		
		-- ָ�����̨Э�黹�Ǿ���Э��
		Type = "PTZ",
		
		-- ��msΪ��λ
		Internal = 200,
			
		-- ��̨��ַ��Χ
		CamAddrRange 		= {0x01, 0x1F}, 
		-- ���ӵ�ַ��Χ
		MonAddrRange		= {0x00, 0xFF},	
		-- Ԥ�õ㷶Χ
		PresetRange 		= {0x00, 0xFF},
		-- �Զ�Ѳ����·��Χ
			TourRange			= {0x01, 0x01},
		-- �켣��·��Χ
		PatternRange			= {0x01, 0x01},
		-- ��ֱ�ٶȷ�Χ
		TileSpeedRange 		= {0x01, 0x3F},
		-- ˮƽ�ٶȷ�Χ
		PanSpeedRange 		= {0x01, 0x3F},
		
		-- �����Χ
		AuxRange 			= {0x01, 0x08},
}

Protocol.CommandAttr =
{
	-- Э������Ҫ���ĵ�λ�ã���LUA�±��ʾ�����±�ӣ���ʼ
	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",			
			
		-- �Զ�ɨ�裬��Ԥ�����õı߽��м�ת��
		SetLeftLimit 	= "0xA0, 0x00, 0x00, 0x03, 0x00, 0x5C, 0xAF, 0x00",
		SetRightLimit	= "0xA0, 0x00, 0x00, 0x03, 0x00, 0x5D, 0xAF, 0x00",
		AutoScanOn 	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x63, 0xAF, 0x00",
		AutoScanOff	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x60, 0xAF, 0x00",
		
		StartTour 	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x4C, 0xaf, 0x00",
		StopTour 	= "0xA0, 0x00, 0x00, 0x07, 0x00, 0x60, 0xaf, 0x00",
		
		-- �켣Ѳ��, һ��ָģʽ(���ÿ�ʼ�����ý�������У�ֹͣ����ģʽ
--[[
		SetPatternStart = "0xA0, 0x00, 0x00, 0x1f, 0x00, 0x21, 0xaf, 0x00",
		SetPatternStop 	= "0xA0, 0x00, 0x00, 0x21, 0x00, 0x21, 0xaf, 0x00",
		StartPattern 	= "0xA0, 0x00, 0x00, 0x23, 0x00, 0x21, 0xaf, 0x00",
    StopPattern     = "0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, 0x00,",
--]]
		
		AuxOn 	= "0xA0, 0x00, 0x00, 0x09, 0x00, 0x00, 0xaf, 0x00,",
		AuxOff 	= "0xA0, 0x00, 0x00, 0x0b, 0x00, 0x00, 0xaf, 0x00,",
		
		-- ����������������Լ������ض���Ϣ���������ض���Ϣ������
		Position = "0xA0, 0x00, 0x00, 0x33, 0x00, 0x00, 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)
	if s[1] ~= 0x3a then
		s[8] = math.mod((s[1] + s[2] + s[3] + s[4] + s[5] + s[6] + s[7]), 256);
	end;
	return s;
end;


Protocol.CamAddrProcess = function(s, addr)
	local addr = math.mod(addr,256);
	if s[1] ~= 0x3a then
		s[Protocol.CommandAttr.AddrPos] = addr;
	else
		s[2] = addr;
	end;
	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.SetTourProcess = function(s, tour, preset)
	if s[1] ~= 0x3a then
		s[4] = tour;
		s[5] = preset;
	end;
	return s;
end;

Protocol.TourProcess = function(s, tour)
	if s[1] ~= 0x3a then
		s[4] = tour;
	end;
	return s;	
end;

Protocol.PositionProcess = function(s, hor, ver, zoom)
	-- ����ֻ������ٶ�λ����
	local max_pos_zoom = 16;
	if hor < 0 then
		s[5] = bits.bor(bits.band(hor*128/8192,0x7f),0x80);
	else
		s[5] = bits.band(hor*128/8192,0x7f);
	end;
	
	if ver < 0 then
		s[6] = bits.bor(bits.band(ver*128/8192,0x7f),0x80);
	else
		s[6] = bits.band(ver*128/8192,0x7f);
	end;
	
	if zoom <= 0 then
		s[3] = 0;
	else
		if math.abs(zoom) > max_pos_zoom then
			s[3] = max_pos_zoom; 
		else		
				s[3] = math.abs(zoom);
		end;
	end;
	
	return s;
end;
--[[
����ĺ���ǿ�ѡ�ģ����������⴦���̲Ŵ򿪣�û�еĻ���ǧ��Ҫ�򿪣��������ɽ������
Protocol.MonAddrProcess = function(s, addr)
	return s;
end;

Protocol.SpeedProcess = function(s, arg1, arg2)
	return s;
end;

Protocol.PresetProcess = function(s, arg)
	return s;
end;
--]]


return Protocol;