Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO908-XLRStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 097668dc
由
张东亮
编写于
2023-03-30 11:04:01 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
监控相机换为独立程序
1 个父辈
43914347
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
56 行增加
和
113 行删除
source/DeviceLibrary/deviceLibrary/IPCameraHelper.cs
source/DeviceLibrary/manager/StoreManager.cs
source/DeviceLibrary/storeBean/boxBean/BoxEquip_Camera.cs
source/XLRStoreClient/FrmXLRStore.Designer.cs
source/XLRStoreClient/FrmXLRStore.cs
source/XLRStoreClient/boxForm/FrmBoxEquip.Designer.cs
source/XLRStoreClient/boxForm/FrmBoxEquip.cs
source/DeviceLibrary/deviceLibrary/IPCameraHelper.cs
查看文件 @
097668d
...
@@ -3,6 +3,8 @@ using System;
...
@@ -3,6 +3,8 @@ using System;
using
System.Collections
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Configuration.Install
;
using
System.Configuration.Install
;
using
System.Diagnostics
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.ServiceProcess
;
using
System.ServiceProcess
;
using
System.Text
;
using
System.Text
;
...
@@ -13,31 +15,33 @@ namespace OnlineStore.DeviceLibrary
...
@@ -13,31 +15,33 @@ namespace OnlineStore.DeviceLibrary
public
class
IPCameraHelper
public
class
IPCameraHelper
{
{
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
//"E:\\Codes\\CSharp-Workspace\\MyProject\\WindowsService\\IPCamService\\bin\\Debug\\IPCamService.exe"
static
string
appPath
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
static
string
baseDir
=
ConfigHelper
.
Config
.
Get
(
"IPCamService_HttpServer"
,
"http://localhost:8088"
);
static
string
serviceFilePath
=
ConfigHelper
.
Config
.
Get
(
"IPCamService_FilePath"
,
$
"{appPath}IPCamService\\IPCamService.exe"
);
public
static
void
StartIPCamService
()
static
string
serviceName
=
ConfigHelper
.
Config
.
Get
(
"IPCamService_ServiceName"
,
"IPCamService"
);
/// <summary>
/// 安装服务
/// </summary>
public
static
void
InstallService
()
{
{
if
(!
IsServiceExisted
(
serviceName
))
string
appFilePath
=
ConfigHelper
.
Config
.
Get
(
"IPCamService_FilePath"
,
@"D:\IPCamera"
);
if
(
Directory
.
Exists
(
appFilePath
))
{
{
InstallService
(
serviceFilePath
);
var
exe
=
"IPCamera.exe"
;
LogUtil
.
info
(
"安装监控相机服务"
);
try
ServiceStart
(
serviceName
);
{
LogUtil
.
info
(
"启动监控相机服务"
);
Process
process
=
new
Process
();
process
.
StartInfo
=
new
ProcessStartInfo
();
process
.
StartInfo
.
FileName
=
exe
;
process
.
StartInfo
.
WorkingDirectory
=
appFilePath
;
process
.
Start
();
LogUtil
.
info
(
$
"启动软件:{appFilePath}\\{exe}"
);
}
}
else
catch
(
Exception
ex
)
{
{
ServiceStart
(
serviceName
);
LogUtil
.
error
(
$
"启动软件失败:{appFilePath}\\{exe}"
,
ex
);
LogUtil
.
info
(
"启动监控相机服务"
);
}
}
}
}
static
string
baseDir
=
ConfigHelper
.
Config
.
Get
(
"IPCameraService_HttpServer"
,
"http://localhost:8088"
);
}
public
static
void
StartRecord
(
string
camName
,
string
fileName
=
""
)
public
static
void
StartRecord
(
string
camName
,
string
fileName
=
""
)
{
{
Task
.
Factory
.
StartNew
(
delegate
{
Task
.
Factory
.
StartNew
(
delegate
{
string
url
=
$
"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}"
;
string
url
=
$
"{baseDir}/cam/startRecord?camName={camName}&filename={fileName}"
;
string
res
=
HttpHelper
.
Get
(
url
);
string
res
=
HttpHelper
.
Get
(
url
);
LogUtil
.
info
(
$
"开始记录视频:{fileName},{res}"
);
LogUtil
.
info
(
$
"开始记录视频:{fileName},{res}"
);
...
@@ -46,88 +50,13 @@ namespace OnlineStore.DeviceLibrary
...
@@ -46,88 +50,13 @@ namespace OnlineStore.DeviceLibrary
}
}
public
static
void
StopRecord
(
string
camName
)
public
static
void
StopRecord
(
string
camName
)
{
{
Task
.
Factory
.
StartNew
(
delegate
{
Task
.
Factory
.
StartNew
(
delegate
{
string
url
=
$
"{baseDir}/cam/stopRecord?camName={camName}"
;
string
url
=
$
"{baseDir}/cam/stopRecord?camName={camName}"
;
string
res
=
HttpHelper
.
Get
(
url
);
string
res
=
HttpHelper
.
Get
(
url
);
LogUtil
.
info
(
$
"停止记录视频:{res}"
);
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
();
}
}
}
}
}
}
}
source/DeviceLibrary/manager/StoreManager.cs
查看文件 @
097668d
...
@@ -111,7 +111,7 @@ namespace OnlineStore.DeviceLibrary
...
@@ -111,7 +111,7 @@ namespace OnlineStore.DeviceLibrary
//CSVPositionReader<DrawerPosition>.AddCSVFile(drawConfigFile);
//CSVPositionReader<DrawerPosition>.AddCSVFile(drawConfigFile);
XLRStore
=
new
XLRStoreBean
(
Config
,
inputConfig
,
boxConfig
);
XLRStore
=
new
XLRStoreBean
(
Config
,
inputConfig
,
boxConfig
);
IPCameraHelper
.
Install
Service
();
IPCameraHelper
.
StartIPCam
Service
();
LogUtil
.
info
(
"加载 完成!"
);
LogUtil
.
info
(
"加载 完成!"
);
return
true
;
return
true
;
}
}
...
...
source/DeviceLibrary/storeBean/boxBean/BoxEquip_Camera.cs
查看文件 @
097668d
...
@@ -39,15 +39,15 @@ namespace OnlineStore.DeviceLibrary
...
@@ -39,15 +39,15 @@ namespace OnlineStore.DeviceLibrary
}
}
void
StartCamera
()
void
StartCamera
()
{
{
camera
.
Open
(
"box_A"
);
//
camera.Open("box_A");
camera
.
Open
(
"box_B"
);
//
camera.Open("box_B");
IsOpen
=
true
;
//
IsOpen = true;
camerathread
[
0
]
=
new
Thread
(
new
ParameterizedThreadStart
(
startMonitor
));
//
camerathread[0] = new Thread(new ParameterizedThreadStart(startMonitor));
camerathread
[
0
].
IsBackground
=
true
;
//
camerathread[0].IsBackground = true;
camerathread
[
0
].
Start
(
"box_A"
);
//
camerathread[0].Start("box_A");
camerathread
[
1
]
=
new
Thread
(
new
ParameterizedThreadStart
(
startMonitor
));
//
camerathread[1] = new Thread(new ParameterizedThreadStart(startMonitor));
camerathread
[
1
].
IsBackground
=
true
;
//
camerathread[1].IsBackground = true;
camerathread
[
1
].
Start
(
"box_B"
);
//
camerathread[1].Start("box_B");
}
}
void
startMonitor
(
object
obj
)
void
startMonitor
(
object
obj
)
...
...
source/XLRStoreClient/FrmXLRStore.Designer.cs
查看文件 @
097668d
...
@@ -85,6 +85,7 @@
...
@@ -85,6 +85,7 @@
this
.
toolStripSeparator17
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
toolStripSeparator17
=
new
System
.
Windows
.
Forms
.
ToolStripSeparator
();
this
.
禁用安全光栅
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
禁用安全光栅
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
启用门禁
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
启用门禁
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
查看监控
ToolStripMenuItem
=
new
System
.
Windows
.
Forms
.
ToolStripMenuItem
();
this
.
tabControl1
.
SuspendLayout
();
this
.
tabControl1
.
SuspendLayout
();
this
.
tabPage1
.
SuspendLayout
();
this
.
tabPage1
.
SuspendLayout
();
this
.
tabPage2
.
SuspendLayout
();
this
.
tabPage2
.
SuspendLayout
();
...
@@ -437,7 +438,8 @@
...
@@ -437,7 +438,8 @@
this
.
toolStripSeparator7
,
this
.
toolStripSeparator7
,
this
.
托盘初始化
ToolStripMenuItem
,
this
.
托盘初始化
ToolStripMenuItem
,
this
.
toolStripSeparator16
,
this
.
toolStripSeparator16
,
this
.
toolStripMenuItem3
});
this
.
toolStripMenuItem3
,
this
.
查看监控
ToolStripMenuItem
});
this
.
设置
TToolStripMenuItem
.
Name
=
"设置TToolStripMenuItem"
;
this
.
设置
TToolStripMenuItem
.
Name
=
"设置TToolStripMenuItem"
;
this
.
设置
TToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
112
,
31
);
this
.
设置
TToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
112
,
31
);
this
.
设置
TToolStripMenuItem
.
Text
=
"设备调试 "
;
this
.
设置
TToolStripMenuItem
.
Text
=
"设备调试 "
;
...
@@ -604,6 +606,13 @@
...
@@ -604,6 +606,13 @@
this
.
启用门禁
ToolStripMenuItem
.
Text
=
"启用门禁"
;
this
.
启用门禁
ToolStripMenuItem
.
Text
=
"启用门禁"
;
this
.
启用门禁
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
启用门禁
ToolStripMenuItem_Click
);
this
.
启用门禁
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
启用门禁
ToolStripMenuItem_Click
);
//
//
// 查看监控ToolStripMenuItem
//
this
.
查看监控
ToolStripMenuItem
.
Name
=
"查看监控ToolStripMenuItem"
;
this
.
查看监控
ToolStripMenuItem
.
Size
=
new
System
.
Drawing
.
Size
(
224
,
32
);
this
.
查看监控
ToolStripMenuItem
.
Text
=
"查看监控"
;
this
.
查看监控
ToolStripMenuItem
.
Click
+=
new
System
.
EventHandler
(
this
.
查看监控
ToolStripMenuItem_Click
);
//
// FrmXLRStore
// FrmXLRStore
//
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
...
@@ -694,6 +703,7 @@
...
@@ -694,6 +703,7 @@
private
EquipControl
ShelfBControl
;
private
EquipControl
ShelfBControl
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
禁用安全光栅
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
禁用安全光栅
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
启用门禁
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
启用门禁
ToolStripMenuItem
;
private
System
.
Windows
.
Forms
.
ToolStripMenuItem
查看监控
ToolStripMenuItem
;
}
}
}
}
source/XLRStoreClient/FrmXLRStore.cs
查看文件 @
097668d
...
@@ -784,5 +784,9 @@ namespace OnlineStore.XLRStore
...
@@ -784,5 +784,9 @@ namespace OnlineStore.XLRStore
LogUtil
.
info
(
Name
+
" 点击:"
+
启用门禁
ToolStripMenuItem
.
Text
);
LogUtil
.
info
(
Name
+
" 点击:"
+
启用门禁
ToolStripMenuItem
.
Text
);
}
}
private
void
查看监控
ToolStripMenuItem_Click
(
object
sender
,
EventArgs
e
)
{
IPCameraHelper
.
StartIPCamService
();
}
}
}
}
}
source/XLRStoreClient/boxForm/FrmBoxEquip.Designer.cs
查看文件 @
097668d
此文件的差异被折叠,
点击展开。
source/XLRStoreClient/boxForm/FrmBoxEquip.cs
查看文件 @
097668d
...
@@ -57,14 +57,14 @@ namespace OnlineStore.XLRStore
...
@@ -57,14 +57,14 @@ namespace OnlineStore.XLRStore
private
void
BoxBean_camera_event
(
CameraArgs
cameraArgs
)
private
void
BoxBean_camera_event
(
CameraArgs
cameraArgs
)
{
{
// LogUtil.info($"事件触发{cameraArgs.CamName} 取图");
// LogUtil.info($"事件触发{cameraArgs.CamName} 取图");
if
(
cameraArgs
.
CamName
.
Equals
(
"box_A"
))
//
if(cameraArgs.CamName.Equals("box_A"))
{
//
{
pictureBox1
.
Image
=
cameraArgs
.
Image
;
//
pictureBox1.Image = cameraArgs.Image;
}
//
}
else
if
(
cameraArgs
.
CamName
.
Equals
(
"box_B"
))
//
else if(cameraArgs.CamName.Equals("box_B"))
{
//
{
pictureBox2
.
Image
=
cameraArgs
.
Image
;
//
pictureBox2.Image = cameraArgs.Image;
}
//
}
}
}
protected
Dictionary
<
string
,
IOTextControl
>
DIControlList
=
new
Dictionary
<
string
,
IOTextControl
>();
protected
Dictionary
<
string
,
IOTextControl
>
DIControlList
=
new
Dictionary
<
string
,
IOTextControl
>();
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论