Commit f256ab84 张东亮

添加监控相机保存

1 个父辈 15312fe1
...@@ -59,8 +59,10 @@ ...@@ -59,8 +59,10 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" /> <Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
...@@ -85,6 +87,7 @@ ...@@ -85,6 +87,7 @@
<Compile Include="manager\agvClient\AgvClient - 复制.cs" /> <Compile Include="manager\agvClient\AgvClient - 复制.cs" />
<Compile Include="manager\agvClient\AgvClient.cs" /> <Compile Include="manager\agvClient\AgvClient.cs" />
<Compile Include="manager\BufferDataManager.cs" /> <Compile Include="manager\BufferDataManager.cs" />
<Compile Include="manager\IPCameraHelper.cs" />
<Compile Include="manager\StoreManager.cs" /> <Compile Include="manager\StoreManager.cs" />
<Compile Include="deviceLibrary\RFID\RFIDManagercs.cs" /> <Compile Include="deviceLibrary\RFID\RFIDManagercs.cs" />
<Compile Include="manager\SServerManager.cs" /> <Compile Include="manager\SServerManager.cs" />
...@@ -207,6 +210,10 @@ ...@@ -207,6 +210,10 @@
<Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project> <Project>{43cdd09e-fcf3-4960-a01d-3bbfe9933122}</Project>
<Name>Common</Name> <Name>Common</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\ConfigHelper\ConfigHelper\ConfigHelper.csproj">
<Project>{290182db-d949-434e-9ff7-c59bde3f433a}</Project>
<Name>ConfigHelper</Name>
</ProjectReference>
<ProjectReference Include="..\DL.CV\DL.CV.csproj"> <ProjectReference Include="..\DL.CV\DL.CV.csproj">
<Project>{f0a7c33b-7db5-485b-8451-45955d756c2e}</Project> <Project>{f0a7c33b-7db5-485b-8451-45955d756c2e}</Project>
<Name>DL.CV</Name> <Name>DL.CV</Name>
......
using OnlineStore.Common;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration.Install;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class IPCameraHelper
{
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
static string appPath = AppDomain.CurrentDomain.BaseDirectory;
static string serviceFilePath = ConfigHelper.Config.Get("IPCamService_FilePath", $"{appPath}IPCamService\\IPCamService.exe");
static string serviceName = ConfigHelper.Config.Get("IPCamService_ServiceName", "IPCamService");
/// <summary>
/// 安装服务
/// </summary>
public static void InstallService()
{
if (!IsServiceExisted(serviceName))
{
InstallService(serviceFilePath);
LogUtil.info("安装监控相机服务");
ServiceStart(serviceName);
LogUtil.info("启动监控相机服务");
}
else
{
ServiceStart(serviceName);
LogUtil.info("启动监控相机服务");
}
}
static string baseDir = ConfigHelper.Config.Get("IPCameraService_HttpServer", "http://localhost:8088");
public static void StartRecord(string camName,string fileName="")
{
string url = $"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}";
string res=HttpHelper.Get(url);
LogUtil.info($"开始记录视频:{fileName},{res}");
}
public static void StopRecord(string camName)
{
string url = $"{baseDir}/cam/stopRecord?camName={camName}";
string res = HttpHelper.Get(url);
LogUtil.info($"停止记录视频:{res}");
}
//判断服务是否存在
static bool IsServiceExisted(string serviceName)
{
ServiceController[] services = ServiceController.GetServices();
foreach (ServiceController sc in services)
{
if (sc.ServiceName.ToLower() == serviceName.ToLower())
{
return true;
}
}
return false;
}
//安装服务
static void InstallService(string serviceFilePath)
{
try
{
using (AssemblyInstaller installer = new AssemblyInstaller())
{
installer.UseNewContext = true;
installer.Path = serviceFilePath;
IDictionary savedState = new Hashtable();
installer.Install(savedState);
installer.Commit(savedState);
}
}catch (Exception ex)
{
LogUtil.error("安装监控相机服务失败",ex);
}
}
//卸载服务
static void UninstallService(string serviceFilePath)
{
using (AssemblyInstaller installer = new AssemblyInstaller())
{
installer.UseNewContext = true;
installer.Path = serviceFilePath;
installer.Uninstall(null);
}
}
//启动服务
static void ServiceStart(string serviceName)
{
try
{
using (ServiceController control = new ServiceController(serviceName))
{
if (control.Status == ServiceControllerStatus.Stopped)
{
control.Start();
}
}
}catch (Exception ex)
{
LogUtil.error($"启动监控相机服务失败",ex);
}
}
//停止服务
static void ServiceStop(string serviceName)
{
using (ServiceController control = new ServiceController(serviceName))
{
if (control.Status == ServiceControllerStatus.Running)
{
control.Stop();
}
}
}
}
}
...@@ -74,6 +74,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -74,6 +74,7 @@ namespace OnlineStore.DeviceLibrary
CodeManager.LoadConfig(); CodeManager.LoadConfig();
BufferDataManager.InitData(); BufferDataManager.InitData();
IPCameraHelper.InstallService();
mainTimer.Enabled = true; mainTimer.Enabled = true;
canStart = true; canStart = true;
} }
......
...@@ -960,7 +960,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -960,7 +960,7 @@ namespace OnlineStore.DeviceLibrary
internal override void StopMove() internal override void StopMove()
{ {
StopRecord();
MoveInfo.EndMove(); MoveInfo.EndMove();
PullAxis_Updown.SuddenStop(); PullAxis_Updown.SuddenStop();
......
...@@ -82,17 +82,37 @@ namespace OnlineStore.DeviceLibrary ...@@ -82,17 +82,37 @@ namespace OnlineStore.DeviceLibrary
catch catch
{ } { }
} }
void StopCamera()
{
IsOpen = false;
camera.Close();
camera.Dispose();
}
public Bitmap AcqImage(string camName) public Bitmap AcqImage(string camName)
{ {
Bitmap bitmap = camera.GetImage(camName); Bitmap bitmap = camera.GetImage(camName);
return bitmap; return bitmap;
} }
public void StartRecord(string boxAFileName,string boxBFileName)
{
StartBoxARecord(boxAFileName);
StartBoxBRecord(boxBFileName);
}
public void StartBoxARecord(string filename)
{
IPCameraHelper.StartRecord(boxACamName, filename);
}
public void StartBoxBRecord(string filename)
{
IPCameraHelper.StartRecord(boxBCamName, filename);
}
public void StopBoxARecord()
{
IPCameraHelper.StopRecord(boxACamName);
}
public void StopBoxBRecord()
{
IPCameraHelper.StopRecord(boxBCamName);
}
public void StopRecord()
{
StopBoxARecord();
StopBoxBRecord();
}
} }
public class CameraArgs : EventArgs public class CameraArgs : EventArgs
{ {
...@@ -110,47 +130,4 @@ namespace OnlineStore.DeviceLibrary ...@@ -110,47 +130,4 @@ namespace OnlineStore.DeviceLibrary
Image = img; Image = img;
} }
} }
//partial class BoxEquip
//{
// public const string boxACamName = "box_A";
// public const string boxBCamName = "box_B";
// bool loadCameraState = false;
// void LoadCameraConfig(string id = "")
// {
// if (loadCameraState)
// return;
// string path = Application.StartupPath+@"\Config\IPCamera.json";
// if (!File.Exists(path))
// {
// LogUtil.error(Name + "找不到监控相机配置文件:" + path);
// }
// IPCameraManager.LoadConfig(path);
// loadCameraState = true;
// }
// public void RegisterCameraAGrabImage(ImageGrabbedEventHandler grabbedEventHandler)
// {
// IPCameraManager.GetCamera(boxACamName).ImageGrabbed += grabbedEventHandler;
// IPCameraManager.GetCamera(boxACamName).StartLive();
// }
// public void RegisterCameraBGrabImage(ImageGrabbedEventHandler grabbedEventHandler)
// {
// IPCameraManager.GetCamera(boxBCamName).ImageGrabbed += grabbedEventHandler;
// IPCameraManager.GetCamera(boxBCamName).StartLive();
// }
// public void UnRegisterCameraAGrabImage(ImageGrabbedEventHandler grabbedEventHandler)
// {
// IPCameraManager.GetCamera(boxACamName).ImageGrabbed -= grabbedEventHandler;
// IPCameraManager.GetCamera(boxACamName).StopLive();
// }
// public void UnRegisterCameraBGrabImage(ImageGrabbedEventHandler grabbedEventHandler)
// {
// IPCameraManager.GetCamera(boxBCamName).ImageGrabbed -= grabbedEventHandler;
// IPCameraManager.GetCamera(boxBCamName).StopLive();
// }
// void StartRecord() { }
// void StopRecord() { }
//}
} }
...@@ -459,7 +459,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -459,7 +459,14 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.EndMove(); MoveInfo.EndMove();
AutoInout.InOutEndProcess(this, MoveType.InStore); AutoInout.InOutEndProcess(this, MoveType.InStore);
} }
if (CheckASide())
{
StopBoxARecord();
}
else
{
StopBoxBRecord();
}
} }
else else
{ {
......
...@@ -321,6 +321,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -321,6 +321,14 @@ namespace OnlineStore.DeviceLibrary
break; break;
case StepEnum.SO_20_Finish: case StepEnum.SO_20_Finish:
SetBoxStatus(DeviceStatus.StoreOnline, RunStatus.Runing); SetBoxStatus(DeviceStatus.StoreOnline, RunStatus.Runing);
if (CheckASide())
{
StopBoxARecord();
}
else
{
StopBoxBRecord();
}
MoveInfo.EndMove(); MoveInfo.EndMove();
AutoInout.InOutEndProcess(this, MoveType.OutStore); AutoInout.InOutEndProcess(this, MoveType.OutStore);
break; break;
......
...@@ -1047,6 +1047,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -1047,6 +1047,7 @@ namespace OnlineStore.DeviceLibrary
{ {
return false; return false;
} }
StopRecord();
startInStoreTime = DateTime.Now; startInStoreTime = DateTime.Now;
LogInfo(" 启动入库【" + param.PosInfo.ToStr() + "】 "); LogInfo(" 启动入库【" + param.PosInfo.ToStr() + "】 ");
param.MoveP = new LineMoveP(Config, param.PosInfo.PosId); param.MoveP = new LineMoveP(Config, param.PosInfo.PosId);
...@@ -1054,9 +1055,22 @@ namespace OnlineStore.DeviceLibrary ...@@ -1054,9 +1055,22 @@ namespace OnlineStore.DeviceLibrary
MoveInfo.NewMove(MoveType.InStore, param); MoveInfo.NewMove(MoveType.InStore, param);
SetBoxStatus(DeviceStatus.InStoreExecute, RunStatus.Busy, param.PosInfo.PosId, param.PosInfo.barcode); SetBoxStatus(DeviceStatus.InStoreExecute, RunStatus.Busy, param.PosInfo.PosId, param.PosInfo.barcode);
if (param.PosInfoBack != null) if (param.PosInfoBack != null)
{
MoveInfo.NextMoveStep(StepEnum.SIB_00_StartInstore); MoveInfo.NextMoveStep(StepEnum.SIB_00_StartInstore);
StartRecord($"IN-{param.PosInfo.barcode}-{param.PosInfo.PosId}", $"IN-{param.PosInfoBack.barcode}-{param.PosInfoBack.PosId}");
}
else else
{
MoveInfo.NextMoveStep(StepEnum.SI_00_StartInstore); MoveInfo.NextMoveStep(StepEnum.SI_00_StartInstore);
if(CheckASide())
{
StartBoxARecord($"IN-{param.PosInfo.barcode}-{param.PosInfo.PosId}");
}
else
{
StartBoxBRecord($"IN-{param.PosInfo.barcode}-{param.PosInfo.PosId}");
}
}
AxisAlarmFlag = false; AxisAlarmFlag = false;
return true; return true;
} }
...@@ -1301,6 +1315,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -1301,6 +1315,14 @@ namespace OnlineStore.DeviceLibrary
LogInfo("启动出库【" + param.PosInfo.ToStr() + "】 "); LogInfo("启动出库【" + param.PosInfo.ToStr() + "】 ");
//LogInfo("LoadInoutParam:" + JsonHelper.SerializeObject(param.MoveP)); //LogInfo("LoadInoutParam:" + JsonHelper.SerializeObject(param.MoveP));
MoveInfo.NextMoveStep(StepEnum.SO_00_StartOutstore); MoveInfo.NextMoveStep(StepEnum.SO_00_StartOutstore);
if (CheckASide())
{
StartBoxARecord($"OUT-{param.PosInfo.barcode}-{param.PosInfo.PosId}");
}
else
{
StartBoxBRecord($"OUT-{param.PosInfo.barcode}-{param.PosInfo.PosId}");
}
AxisAlarmFlag = false; AxisAlarmFlag = false;
return true; return true;
} }
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
this.groupBox3 = new System.Windows.Forms.GroupBox(); this.groupBox3 = new System.Windows.Forms.GroupBox();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.groupDO = new System.Windows.Forms.GroupBox(); this.groupDO = new System.Windows.Forms.GroupBox();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.lblThisSta = new System.Windows.Forms.Label(); this.lblThisSta = new System.Windows.Forms.Label();
this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage3 = new System.Windows.Forms.TabPage(); this.tabPage3 = new System.Windows.Forms.TabPage();
...@@ -60,6 +62,7 @@ ...@@ -60,6 +62,7 @@
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.groupBox4.SuspendLayout(); this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout(); this.groupBox3.SuspendLayout();
this.groupDO.SuspendLayout();
this.tabControl1.SuspendLayout(); this.tabControl1.SuspendLayout();
this.tabPage3.SuspendLayout(); this.tabPage3.SuspendLayout();
this.groupBox5.SuspendLayout(); this.groupBox5.SuspendLayout();
...@@ -281,6 +284,8 @@ ...@@ -281,6 +284,8 @@
// //
this.groupDO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.groupDO.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.groupDO.Controls.Add(this.button2);
this.groupDO.Controls.Add(this.button1);
this.groupDO.Location = new System.Drawing.Point(414, 128); this.groupDO.Location = new System.Drawing.Point(414, 128);
this.groupDO.Name = "groupDO"; this.groupDO.Name = "groupDO";
this.groupDO.Size = new System.Drawing.Size(565, 381); this.groupDO.Size = new System.Drawing.Size(565, 381);
...@@ -288,6 +293,26 @@ ...@@ -288,6 +293,26 @@
this.groupDO.TabStop = false; this.groupDO.TabStop = false;
this.groupDO.Text = "IO操作测试"; this.groupDO.Text = "IO操作测试";
// //
// button2
//
this.button2.Location = new System.Drawing.Point(253, 59);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(146, 60);
this.button2.TabIndex = 1;
this.button2.Text = "手动停止监控保存";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(62, 59);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(146, 60);
this.button1.TabIndex = 0;
this.button1.Text = "手动开始监控保存";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// lblThisSta // lblThisSta
// //
this.lblThisSta.Dock = System.Windows.Forms.DockStyle.Fill; this.lblThisSta.Dock = System.Windows.Forms.DockStyle.Fill;
...@@ -598,6 +623,7 @@ ...@@ -598,6 +623,7 @@
this.groupBox1.PerformLayout(); this.groupBox1.PerformLayout();
this.groupBox4.ResumeLayout(false); this.groupBox4.ResumeLayout(false);
this.groupBox3.ResumeLayout(false); this.groupBox3.ResumeLayout(false);
this.groupDO.ResumeLayout(false);
this.tabControl1.ResumeLayout(false); this.tabControl1.ResumeLayout(false);
this.tabPage3.ResumeLayout(false); this.tabPage3.ResumeLayout(false);
this.groupBox5.ResumeLayout(false); this.groupBox5.ResumeLayout(false);
...@@ -657,6 +683,8 @@ ...@@ -657,6 +683,8 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel3;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4;
private System.Windows.Forms.Button btnHlhasReel; private System.Windows.Forms.Button btnHlhasReel;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
} }
} }
...@@ -562,6 +562,16 @@ namespace OnlineStore.XLRStore ...@@ -562,6 +562,16 @@ namespace OnlineStore.XLRStore
} }
} }
} }
private void button1_Click(object sender, EventArgs e)
{
boxBean.StartRecord("manual", "manual");
}
private void button2_Click(object sender, EventArgs e)
{
boxBean.StopRecord();
}
} }
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!