Mini Kabibi Habibi
-- PELCOP��Э���Ҫ����У�閬��һ�����������λ�ֽ������
local Protocol = {};
-- ��ʾ�ֵ������16��10����(��Сֵ�����ֵ)
Protocol.Attr =
{
-- Э�����ʾ���,���ܳ���16�ַ�
Name = "PELCOP1",
-- ָ�����̨Э�黹�Ǿ���Э��
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, 0x1F, 0xaf, 0x00,",
TileDown = "0xa0, 0x00, 0x00, 0x10, 0x00, 0x1F, 0xaf, 0x00,",
PanLeft = "0xa0, 0x00, 0x00, 0x04, 0x2f, 0x00, 0xaf, 0x00,",
PanRight = "0xa0, 0x00, 0x00, 0x02, 0x2f, 0x00, 0xaf, 0x00,",
LeftUp = "0xa0, 0x00, 0x00, 0x0c, 0x2f, 0x00, 0xaf, 0x00,",
LeftDown = "0xa0, 0x00, 0x00, 0x14, 0x2f, 0x00, 0xaf, 0x00,",
RightUp = "0xa0, 0x00, 0x00, 0x0a, 0x2f, 0x00, 0xaf, 0x00,",
RightDown = "0xa0, 0x00, 0x00, 0x12, 0x2f, 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",
-- �ƹ�
LightOn = "0xa0, 0x00, 0x50, 0x00, 0x00, 0x00, 0xaf,0x00",
LightOff = "0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf,0x00",
-- Ԥ�õ��������ã�����ת��)
SetPreset = "0xa0, 0x00, 0x00, 0x03, 0x00, 0x21, 0xaf, 0x00",
ClearPreset = "0xa0, 0x00, 0x00, 0x05, 0x00, 0x21, 0xaf, 0x00",
GoToPreset = "0xa0, 0x00, 0x00, 0x07, 0x00, 0x21, 0xaf, 0x00",
-- ˮƽ�ת����Ԥ�����õı߽��м�ת��
SetLeftLimit = "0xa0, 0x00, 0x00, 0x11, 0x00, 0x21, 0xaf, 0x00",
SetRightLimit = "0xa0, 0x00, 0x00, 0x13, 0x00, 0x21, 0xaf, 0x00",
AutoScanOn = "0xa0, 0x00, 0x00, 0x1B, 0x00, 0x21, 0xaf, 0x00",
AutoScanOff = "0xa0, 0x00, 0x00, 0x1D, 0x00, 0x21, 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, 0x21, 0xaf, 0x00,",
AuxOff = "0xa0, 0x00, 0x00, 0x0b, 0x00, 0x21, 0xaf, 0x00,",
Position = "0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,0x00, 0xff",
},
Stop =
{
TileUp = "0xa0, 0x0, 0x00, 0x0, 0x0, 0x0, 0xaf,0x0,",
TileDown = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0",
PanLeft = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0",
PanRight = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0",
LeftUp = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
LeftDown = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
RightUp = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
RightDown = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
ZoomWide = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
ZoomTele = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
FocusNear = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
FocusFar = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
IrisSmall = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
IrisLarge = "0xa0,0x0,0x00,0x0,0x0, 0x0, 0xaf,0x0,",
},
}
Protocol.Checksum = function (s)
if s[1] ~= 0x3a then
local value = s[2];
for i = 3, 6 do
value = bits.bxor(value,s[i]);
end;
s[8] = math.mod(value, 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 then
s[6] = ver;
s[5] = hor;
end;
return s;
end;
Protocol.PositionProcess = function(s, hor, ver, zoom)
-- ����ֻ������ٶ�λ����
local max_pos_zoom = 16;
if s[1] == 0x3a then
s[4] = bits.band(hor,0xff00)/256;
s[5] = bits.band(hor, 0xff);
s[6] = bits.band(ver,0xff00)/256;
s[7] = bits.band(ver,0xff);
if zoom == 0 then
s[8] = 0;
else
if math.abs(zoom) > max_pos_zoom then
s[8] = max_pos_zoom;
else
s[8] = math.abs(zoom);
end;
s[8] = zoom > 0 and s[8] or 0x80 + s[8];
end
s[9] = math.mod((s[2] + s[3] + s[4] + s[5] + s[6] + s[7] + s[8]), 256);
return s;
end;
end;
--[[
--����ĺ���ǿ�ѡ�ģ�������������̲Ŵ�û�еĻ���ǧ��Ҫ���������ɽ������
Protocol.CamAddrProcess = function(s, addr)
-- ����ĵ�ַ0����camaddr 1
s[Protocol.CommandAttr.AddrPos] = addr;
return s;
end;
Protocol.MonAddrProcess = function(s, addr)
return s;
end;
Protocol.SpeedProcess = function(s, arg1, arg2)
return s;
end;
Protocol.PresetProcess = function(s, arg1, arg2))
return s;
end;
--]]
return Protocol;