📄 u_prew_main.pas
字号:
procedure Tfrm_prew_Main.A_FileExecute(Sender: TObject);
begin
frm_prew_hf:=Tfrm_prew_hf.create(application);
frm_prew_hf.ShowModal;
end;
procedure Tfrm_prew_Main.SampleGrabber1Buffer(sender: TObject;
SampleTime: Double; pBuffer: Pointer; BufferLen: Integer);
begin
Im1.Canvas.Lock;
try
SampleGrabber1.GetBitmap(Im1.Picture.Bitmap, pBuffer, BufferLen);
im2.Picture.Bitmap:=im1.Picture.Bitmap;
im3.Picture.Bitmap:=im1.Picture.Bitmap;
im4.Picture.Bitmap:=im1.Picture.Bitmap;
im5.Picture.Bitmap:=im1.Picture.Bitmap;
im6.Picture.Bitmap:=im1.Picture.Bitmap;
im7.Picture.Bitmap:=im1.Picture.Bitmap;
im8.Picture.Bitmap:=im1.Picture.Bitmap;
im9.Picture.Bitmap:=im1.Picture.Bitmap;
finally
Im1.Canvas.Unlock;
// Im2.Canvas.Unlock;
// Im3.Canvas.Unlock;
// Im4.Canvas.Unlock;
// Im5.Canvas.Unlock;
// Im6.Canvas.Unlock;
// Im7.Canvas.Unlock;
// Im8.Canvas.Unlock;
// Im9.Canvas.Unlock;
end;
end;
procedure Tfrm_prew_Main.SpeedButton4Click(Sender: TObject);
begin
frm_Set_bfyy:=Tfrm_set_bfyy.Create(application);
frm_set_bfyy.ShowModal;
Bool_Lx;
Lx_ok1;
end;
procedure Tfrm_prew_main.Bool_Lx;
begin
data.G_Con.Open();
data.G_Rst.SQL.Clear;
data.G_Rst.SQL.Add('select * from SP_sjks');
data.G_Rst.ExecSQL;
data.G_Rst.Open;
while not data.G_Rst.Eof do
begin
if trim(data.G_Rst.FieldValues['sjks'])='1' then
m_bool_lx:=true
else
m_bool_lx:=false;
data.G_Rst.Next;
end;
data.G_Rst.Close;
data.G_Con.Close;
DatePD;
end;
procedure Tfrm_prew_Main.Timer2Timer(Sender: TObject);
var I:integer;
ZD1,ZD2:String;
BB:String;
begin
if m_bool_lx=false then exit; //录像功能是否被启动 如果没有什么都不执行,如果有,进行数据时间查看
//如果录像开始,则进行时间判断,如果到时间,或超时,则关闭
if M_bool_kslx then
begin
for I:=1 to 8 do
begin
if (lx_sj[i,1]<>'') and (lx_sj[i,2]<>'') then
begin
if (comparetime(strtotime(lx_sj[i,1]),now)<0) and (comparetime(strtotime(lx_sj[i,2]),now)<0) then
begin
//停止录像
if lx_ok[i]=false then//录像没有开始的
begin
M_bool_kslx:=false; //是否有录像正在录制过程中如果有,则关闭录像
A_Stop.Execute;
A_Play.Execute;
speedbutton5.Caption:='录像';
lx_ok[i]:=true;
end;
end;
end;
end;
exit;
end;
//计管时间,如果当前有记录时间,开始录像
for I:=1 to 8 do
begin
if (lx_sj[i,1]<>'') and (lx_sj[i,2]<>'') then
begin
if (comparetime(now,strtotime(lx_sj[i,1]))>=0) and (comparetime(strtotime(lx_sj[i,2]),now)>=0) then
//if (comparetime(now,strtotime('12:27:30'))<=0) and (comparetime(strtotime('12:57:39'),now)>=0) then
begin
//开始录像
if M_bool_kslx=false then //是否有录像正在录制过程中如果没有,则开始录像
begin
kslx;//
speedbutton5.Caption:='停止录像';
end;
end;
end;
end;
//lx_xj[1,1]
end;
procedure Tfrm_Prew_main.KSLX;
var AA:string;
begin
//开始录像
AA:='T'+formatdatetime('yyyy-mm-ddhhmmss',now);
CapFName:=G_Path+AA+'.avi';
//CapFName:='D:\lx\'+'asdfeeeeeee.avi';
m_bool_kslx:=true;
A_Stop.Execute;
A_Play.Execute;
end;
procedure Tfrm_Prew_main.DatePD;
var I:integer;
ZD1,ZD2:String;
BB:String;
begin
self.Timer2.Enabled:=false;
self.Timer2.Interval:=0;
speedbutton5.Caption:='录像';
//
NowWeek:=dayofweek(now)-1;
for i:=1 to 8 do
begin
lx_sj[i,1]:='';
lx_sj[i,2]:='';
dayboollx[i]:=false;
// LX_ok[i]:=false;
end;
//检测是否有要录的录像在当前时间
data.G_Con.Open();
data.G_Rst.SQL.Clear;
data.G_Rst.SQL.Add('select * from SP_sjb order by name_id');
data.G_Rst.ExecSQL;
data.G_Rst.Open;
while not data.G_Rst.Eof do
begin
//分别判断来证明是否有录像,如果有,进行时间判断
if trim(data.G_Rst.FieldValues['name'])='周一' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[1]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='周二' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[2]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='周三' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[3]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='周四' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[4]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='周五' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[5]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='周六' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[6]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='周日' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[7]:=true;
break;
end;
end;
end;
if trim(data.G_Rst.FieldValues['name'])='节假日' then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
if (trim(data.G_Rst.FieldValues[zd1])<>'') and (trim(data.G_Rst.FieldValues[zd2])<>'') then
begin
dayboollx[8]:=true;
break;
end;
end;
end;
data.G_Rst.Next;
end;
lx_now:=false;
for I:=1 to 6 do //今天是否有录像
if dayboollx[i] and (nowweek=i) then lx_now:=true;
if dayboollx[7] and (nowweek=0) then lx_now:=true;
//判断假期是否有值,如果有是否是今天
data.G_Con.Open();
data.G_Rst.SQL.Clear;
data.G_Rst.SQL.Add('select * from SP_sjb order by name_id');
data.G_Rst.ExecSQL;
data.G_Rst.Open;
if not data.G_Rst.Eof then
if dayboollx[8] then lx_now:=true;
data.G_Rst.Close;
data.G_Con.Close;
//判断如果有,则取录像的中间时间
if lx_now=false then exit;
//下面记录时间
if dayboollx[1] and (nowweek=1) then BB:='select * from sp_sjb where name='+quotedstr('周一');
if dayboollx[2] and (nowweek=2) then BB:='select * from sp_sjb where name='+quotedstr('周二');
if dayboollx[3] and (nowweek=3) then BB:='select * from sp_sjb where name='+quotedstr('周三');
if dayboollx[4] and (nowweek=4) then BB:='select * from sp_sjb where name='+quotedstr('周四');
if dayboollx[5] and (nowweek=5) then BB:='select * from sp_sjb where name='+quotedstr('周五');
if dayboollx[6] and (nowweek=6) then BB:='select * from sp_sjb where name='+quotedstr('周六');
if dayboollx[7] and (nowweek=0) then BB:='select * from sp_sjb where name='+quotedstr('周日');
if dayboollx[8] then BB:='select * from sp_sjb where name='+quotedstr('节假日');
data.G_Con.Open();
data.G_Rst.SQL.Clear;
data.G_Rst.SQL.Add(bb);
data.G_Rst.ExecSQL;
data.G_Rst.Open;
if not data.G_Rst.Eof then
begin
for i:=1 to 8 do
begin
zd1:='sj'+inttostr(i)+'1';
zd2:='sj'+inttostr(i)+'2';
lx_sj[i,1]:=data.G_Rst.FieldValues[zd1];
lx_sj[i,2]:=data.G_Rst.FieldValues[zd2];
end;
end;
data.G_Rst.Close;
data.G_Con.Close;
for i:=1 to 8 do
begin
if trim(lx_sj[i,2])<>'' then
if (comparetime(strtotime(lx_sj[i,2]),now)<0) then
begin
lx_ok[i]:=true;
end;
end;
self.Timer2.Interval:=1000;
self.Timer2.Enabled:=true;
end;
procedure Tfrm_prew_main.Lx_ok1;
var i:integer;
begin
for i:=1 to 8 do
begin
LX_ok[i]:=false;
end;
end;
procedure Tfrm_prew_Main.FormCreate(Sender: TObject);
begin
Lx_ok1;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -