Commit 27b1c4a9 张东亮

存储机构视频两分钟超时

1 个父辈 437aefa4
...@@ -295,7 +295,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -295,7 +295,7 @@ namespace OnlineStore.DeviceLibrary
System.Windows.Forms.MessageBoxButtons.OK); System.Windows.Forms.MessageBoxButtons.OK);
SetBoxStatus(DeviceStatus.None, RunStatus.Wait); SetBoxStatus(DeviceStatus.None, RunStatus.Wait);
MoveInfo.NewMove(MoveType.None); MoveInfo.NewMove(MoveType.None);
LogInfo($"复位 {MoveInfo.SLog} :因到位信号取消"); LogInfo($"复位 {MoveInfo.SLog} :因到位信号取消,{msg}");
return; return;
} }
SetWarnMsg(""); SetWarnMsg("");
...@@ -899,7 +899,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -899,7 +899,8 @@ namespace OnlineStore.DeviceLibrary
ComAxis_A.SuddenStop(); ComAxis_A.SuddenStop();
CloseAllAxis(); CloseAllAxis();
//停止记录
StopRecord();
} }
......
...@@ -74,6 +74,8 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,6 +74,8 @@ namespace OnlineStore.DeviceLibrary
{ {
SaveImage("box_B", cnt); SaveImage("box_B", cnt);
}); });
if ((DateTime.Now - dateTime).TotalMinutes > 2)
StopRecord();
} }
camera_event?.Invoke(new CameraArgs(name, bmp)); camera_event?.Invoke(new CameraArgs(name, bmp));
} }
...@@ -199,6 +201,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -199,6 +201,7 @@ namespace OnlineStore.DeviceLibrary
bool IsRecord = false; bool IsRecord = false;
int cnt = 0; int cnt = 0;
InOutPosInfo inOutPosInfo = null; InOutPosInfo inOutPosInfo = null;
DateTime dateTime = DateTime.Now;
/// <summary> /// <summary>
/// 开始记录 /// 开始记录
/// </summary> /// </summary>
...@@ -210,7 +213,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -210,7 +213,7 @@ namespace OnlineStore.DeviceLibrary
} }
else else
{ {
inOutPosInfo = MoveInfo.MoveParam.PosInfo; inOutPosInfo = MoveInfo.MoveParam.PosInfo.ToCopy();
} }
cnt = 0; cnt = 0;
string inputfolderA = Application.StartupPath + imgPath + "box_A\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + inOutPosInfo.PosId; string inputfolderA = Application.StartupPath + imgPath + "box_A\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + inOutPosInfo.PosId;
...@@ -219,6 +222,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -219,6 +222,7 @@ namespace OnlineStore.DeviceLibrary
string outputfolderB = Application.StartupPath + "\\Videos\\box_B\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + inOutPosInfo.PosId; string outputfolderB = Application.StartupPath + "\\Videos\\box_B\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + inOutPosInfo.PosId;
ffmpegA.SetParam(inputfolderA, outputfolderA, $"{DateTime.Now.ToString("hhmmss")}_{inOutPosInfo.barcode}.mp4"); ffmpegA.SetParam(inputfolderA, outputfolderA, $"{DateTime.Now.ToString("hhmmss")}_{inOutPosInfo.barcode}.mp4");
ffmpegB.SetParam(inputfolderB, outputfolderB, $"{DateTime.Now.ToString("hhmmss")}_{inOutPosInfo.barcode}.mp4"); ffmpegB.SetParam(inputfolderB, outputfolderB, $"{DateTime.Now.ToString("hhmmss")}_{inOutPosInfo.barcode}.mp4");
dateTime = DateTime.Now;
IsRecord = true; IsRecord = true;
} }
/// <summary> /// <summary>
...@@ -226,30 +230,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -226,30 +230,14 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
public void StopRecord() public void StopRecord()
{ {
if (!IsRecord)
return;
IsRecord = false; IsRecord = false;
LogUtil.info("监控视频开始转换");
Task task1 = ffmpegA.ConvertImgsToMp4(); Task task1 = ffmpegA.ConvertImgsToMp4();
Task task2 = ffmpegB.ConvertImgsToMp4(); Task task2 = ffmpegB.ConvertImgsToMp4();
Task.WaitAll(new Task[] { task1, task2 }, TimeSpan.FromMinutes(1)); Task.WaitAll(new Task[] { task1, task2 }, TimeSpan.FromMinutes(1));
Task.Factory.StartNew(delegate { LogUtil.info("监控视频转换完成");
try
{
System.IO.Directory.Delete(ffmpegA.InputFolder, true);
}
catch (Exception ex)
{
LogUtil.error($"删除文件夹失败:{ffmpegA.InputFolder}", ex);
}
});
Task.Factory.StartNew(delegate {
try
{
System.IO.Directory.Delete(ffmpegB.InputFolder, true);
}
catch (Exception ex)
{
LogUtil.error($"删除文件夹失败:{ffmpegB.InputFolder}", ex);
}
});
} }
#endregion #endregion
} }
...@@ -319,6 +307,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -319,6 +307,7 @@ namespace OnlineStore.DeviceLibrary
{ {
Task task = Task.Factory.StartNew(delegate Task task = Task.Factory.StartNew(delegate
{ {
StringBuilder sb = new StringBuilder(InputFolder);
using (Process p = new Process()) using (Process p = new Process())
{ {
//(1)设置要启动的应用程序 //(1)设置要启动的应用程序
...@@ -340,6 +329,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -340,6 +329,14 @@ namespace OnlineStore.DeviceLibrary
p.StandardInput.Close(); p.StandardInput.Close();
p.StandardError.ReadToEnd(); p.StandardError.ReadToEnd();
p.WaitForExit(); p.WaitForExit();
try
{
System.IO.Directory.Delete(sb.ToString(), true);
}
catch (Exception ex)
{
LogUtil.error($"删除文件夹失败:{sb.ToString()}", ex);
}
} }
}); });
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!