Mini Kabibi Habibi
local Protocol = {};
-- ��ʾ�ֵ������16��10����(��Сֵ�����ֵ)
Protocol.Attr =
{
-- Э�����ʾ���,���ܳ���16�ַ���Ŀǰ�ݲ�֧������
Name = "General",
-- ָ�����̨Э�黹�Ǿ���Э�飬ʹ��"PTZ", "MATRIX"��ʾ
Type = "PTZ",
-- ��msΪ��λ
Internal = 200,
-- û�ж�Ӧ�ĵ�ַ��Χ���붼���0xff
-- ��̨��ַ��Χ
CamAddrRange = {0x01, 0xFF},
-- ���ӵ�ַ��Χ
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 = "0xff, 0x01, 0x00, 0x08, 0x00, 0x1f, 0x00,",
TileDown = "0xff, 0x01, 0x00, 0x10, 0x00, 0x00, 0x00,",
PanLeft = "0xff, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,",
PanRight = "0xff, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00,",
LeftUp = "0xff, 0x01, 0x00, 0x0c, 0x00, 0x00, 0x00,",
LeftDown = "0xff, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00,",
RightUp = "0xff, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00,",
RightDown = "0xff, 0x01, 0x00, 0x12, 0x00, 0x00, 0x00,",
ZoomWide = "0xff, 0x01, 0x00, 0x40, 0x00, 0x00, 0xc9",
ZoomTele = "0xff, 0x01, 0x00, 0x20, 0x00, 0x00, 0xa9",
FocusNear = "0xff, 0x01, 0x01, 0x00, 0x00, 0x00, 0x8a",
FocusFar = "0xff, 0x01, 0x00, 0x80, 0x00, 0x00, 0x09",
IrisSmall = "0xff, 0x01, 0x04, 0x00, 0x00, 0x00, 0x8d",
IrisLarge = "0xff, 0x01, 0x02, 0x00, 0x00, 0x00, 0x8b",
-- �ƹ�
LightOn = "0xff, 0x01, 0x88, 0x00, 0x00, 0x00, 0x00",
LightOff = "0xff, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00",
-- Ԥ�õ��������ã�����ת��)
SetPreset = "0xff, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00",
ClearPreset = "0xff, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00",
GoToPreset = "0xff, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00",
-- ˮƽ�ת��
AutoPanOn = "0xFF, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00",
AutoPanOff = "0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00",
-- �Զ�ɨ�裬��Ԥ�����õı߽��м�ת��
SetLeftLimit = "0xff, 0x01, 0x00, 0x11, 0x00, 0x00, 0x00",
SetRightLimit = "0xff, 0x01, 0x00, 0x13, 0x00, 0x00, 0x00",
AutoScanOn = "0xff, 0x01, 0x00, 0x1B, 0x00, 0x00, 0x00",
AutoScanOff = "0xff, 0x01, 0x00, 0x1D, 0x00, 0x00, 0x00",
-- �Զ�Ѳ��, �ֱ���76�ź�96��Ԥ�õ�.
StartTour = "0xff, 0x01, 0x00, 0x07, 0x00, 0x4C, 0x00",
StopTour = "0xff, 0x01, 0x00, 0x07, 0x00, 0x60, 0x00",
-- �켣Ѳ��, һ��ָģʽ(���ÿ�ʼ�����ý�������У�ֹͣ����ģʽ
SetPatternStart = "0xff, 0x01, 0x00, 0x1f, 0x00, 0x00, 0x00",
SetPatternStop = "0xff, 0x01, 0x00, 0x21, 0x00, 0x00, 0x00",
StartPattern = "0xff, 0x01, 0x00, 0x23, 0x00, 0x00, 0x00",
StopPattern = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
AuxOn = "0xff, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00",
AuxOff = "0xff, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00",
Position = "0x87, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00",
},
Stop =
{
TileUp = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
TileDown = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
PanLeft = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
PanRight = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
LeftUp = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
LeftDown = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
RightUp = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
RightDown = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
ZoomWide = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
ZoomTele = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
FocusNear = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
FocusFar = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
IrisSmall = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
IrisLarge = "0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,",
},
}
Protocol.Checksum = function (s)
s[7] = math.mod((s[2] + s[3] + s[4] + s[5] + s[6]), 256);
return s;
end;
Protocol.CamAddrProcess = function(s, addr)
local addr = math.mod(addr,256);
if s[1] ~= 0x87 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 = 32;
if s[1] == 0x87 then
s[5] = math.abs(hor);
s[6] = math.abs(ver);
if s[5] == 0 then
s[5] = 1;
end
if s[5] >= 100 then
s[5] = 0x63;
end
if s[6] == 0 then
s[6] = 1;
end
if s[6] >= 100 then
s[6] = 0x63;
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;
s[3] = zoom > 0 and s[3] or 0x80 + s[3];
end
end;
return s;
end;
return Protocol;