Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit f8a1ac6c
由
张东亮
编写于
2023-03-20 09:23:08 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
添加监控相机保存视频功能
1 个父辈
b8c27a60
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
180 行增加
和
13 行删除
Common/Common.csproj
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/DeviceLibrary/IPCameraHelper.cs
DeviceLibrary/theMachine/BoxTransport.cs
DeviceLibrary/theMachine/MainMachine.cs
TheMachine/SettingControl.Designer.cs
TheMachine/SettingControl.cs
Common/Common.csproj
查看文件 @
f8a1ac6
...
...
@@ -34,7 +34,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="ConfigHelper">
<HintPath>..\
..\ConfigHelper\ConfigHelper\bin\Debug
\ConfigHelper.dll</HintPath>
<HintPath>..\
DLL
\ConfigHelper.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\DLL\log4net.dll</HintPath>
...
...
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
f8a1ac6
...
...
@@ -55,8 +55,10 @@
<HintPath>..\DLL\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
...
...
@@ -75,6 +77,7 @@
<Compile Include="DeviceLibrary\CameraTest.cs" />
<Compile Include="DeviceLibrary\CylinderManger.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\IPCameraHelper.cs" />
<Compile Include="DeviceLibrary\I_SafetyDevice.cs" />
<Compile Include="DeviceLibrary\LiftMonitor.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
...
...
DeviceLibrary/DeviceLibrary/IPCameraHelper.cs
0 → 100644
查看文件 @
f8a1ac6
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
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
fileName
=
""
)
{
string
url
=
$
"{baseDir}/cam/startRecord?camName=cam1&filename={fileName}"
;
string
res
=
HttpHelper
.
Get
(
url
);
LogUtil
.
info
(
$
"开始记录视频:{fileName},{res}"
);
}
public
static
void
StopRecord
()
{
string
url
=
$
"{baseDir}/cam/stopRecord?camName=cam1"
;
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
();
}
}
}
}
}
DeviceLibrary/theMachine/BoxTransport.cs
查看文件 @
f8a1ac6
...
...
@@ -87,7 +87,7 @@ namespace DeviceLibrary
Fix
=
BoxStorePosition
.
GetFixPos
(
Config
,
To
.
Reel
);
}
MoveInfo
.
MoveParam
.
WareCode
=
WareCode
;
IPCameraHelper
.
StartRecord
(
$
"{WareCode}-{From?.posid}-{To?.posid}"
);
ErrMsgTxt
=
""
;
return
true
;
//thread = new Thread(new ThreadStart(Run));
...
...
@@ -315,6 +315,7 @@ namespace DeviceLibrary
ErrMsgTxt
=
""
;
InOutEndProcess
(
StoreMoveType
.
InStore
,
To
.
posid
);
storeMoveType
=
StoreMoveType
.
None
;
IPCameraHelper
.
StopRecord
();
break
;
default
:
MoveInfo
.
log
(
$
"{storeMoveType}:未找到对应步骤:{MoveInfo.MoveStep}"
);
...
...
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
f8a1ac6
...
...
@@ -186,6 +186,7 @@ namespace DeviceLibrary
ConfigHelper
.
Config
.
Get
(
"CamTestReel_Ability"
,
false
);
ConfigHelper
.
Config
.
Set
(
"CamTestReel_debug"
,
false
);
ConfigHelper
.
Config
.
Get
(
"Device_1315_ReelHeight_Compensation"
,
0
);
IPCameraHelper
.
InstallService
();
}
private
void
Crc_LanguageChangeEvent
(
object
sender
,
EventArgs
e
)
...
...
@@ -318,6 +319,7 @@ namespace DeviceLibrary
ServerCM
.
storeStatus
=
currnetstoreStatus
;
}
}
IPCameraHelper
.
StopRecord
();
LogUtil
.
info
(
"主线程已退出."
);
}
public
void
Start
()
{
...
...
TheMachine/SettingControl.Designer.cs
查看文件 @
f8a1ac6
...
...
@@ -40,6 +40,8 @@ namespace TheMachine
this
.
cb_usefixpos
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
uC_SetUserPassword1
=
new
TheMachine
.
UC_SetUserPassword
();
this
.
button2
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button3
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
tp
.
SuspendLayout
();
this
.
SuspendLayout
();
//
...
...
@@ -47,10 +49,10 @@ namespace TheMachine
//
this
.
chbAutoRun
.
AutoSize
=
true
;
this
.
tp
.
SetColumnSpan
(
this
.
chbAutoRun
,
2
);
this
.
chbAutoRun
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
1
66
);
this
.
chbAutoRun
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
1
75
);
this
.
chbAutoRun
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
10
);
this
.
chbAutoRun
.
Name
=
"chbAutoRun"
;
this
.
chbAutoRun
.
Size
=
new
System
.
Drawing
.
Size
(
84
,
16
);
this
.
chbAutoRun
.
Size
=
new
System
.
Drawing
.
Size
(
104
,
19
);
this
.
chbAutoRun
.
TabIndex
=
1
;
this
.
chbAutoRun
.
Text
=
"开机自启动"
;
this
.
chbAutoRun
.
UseVisualStyleBackColor
=
true
;
...
...
@@ -59,10 +61,10 @@ namespace TheMachine
//
this
.
cb_tempsensorport
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cb_tempsensorport
.
FormattingEnabled
=
true
;
this
.
cb_tempsensorport
.
Location
=
new
System
.
Drawing
.
Point
(
1
39
,
6
);
this
.
cb_tempsensorport
.
Location
=
new
System
.
Drawing
.
Point
(
1
61
,
6
);
this
.
cb_tempsensorport
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
6
);
this
.
cb_tempsensorport
.
Name
=
"cb_tempsensorport"
;
this
.
cb_tempsensorport
.
Size
=
new
System
.
Drawing
.
Size
(
121
,
2
0
);
this
.
cb_tempsensorport
.
Size
=
new
System
.
Drawing
.
Size
(
121
,
2
3
);
this
.
cb_tempsensorport
.
TabIndex
=
2
;
this
.
cb_tempsensorport
.
Tag
=
"not"
;
//
...
...
@@ -73,7 +75,7 @@ namespace TheMachine
this
.
label_tempsensor
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
10
);
this
.
label_tempsensor
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
10
);
this
.
label_tempsensor
.
Name
=
"label_tempsensor"
;
this
.
label_tempsensor
.
Size
=
new
System
.
Drawing
.
Size
(
1
07
,
12
);
this
.
label_tempsensor
.
Size
=
new
System
.
Drawing
.
Size
(
1
35
,
15
);
this
.
label_tempsensor
.
TabIndex
=
3
;
this
.
label_tempsensor
.
Text
=
"温湿度控制器端口:"
;
this
.
label_tempsensor
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
TopRight
;
...
...
@@ -81,7 +83,7 @@ namespace TheMachine
// button_positiontool
//
this
.
tp
.
SetColumnSpan
(
this
.
button_positiontool
,
2
);
this
.
button_positiontool
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
74
);
this
.
button_positiontool
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
80
);
this
.
button_positiontool
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
10
);
this
.
button_positiontool
.
Name
=
"button_positiontool"
;
this
.
button_positiontool
.
Size
=
new
System
.
Drawing
.
Size
(
181
,
36
);
...
...
@@ -94,10 +96,10 @@ namespace TheMachine
//
this
.
lbl_hmdstate
.
AutoSize
=
true
;
this
.
tp
.
SetColumnSpan
(
this
.
lbl_hmdstate
,
2
);
this
.
lbl_hmdstate
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
4
2
);
this
.
lbl_hmdstate
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
4
5
);
this
.
lbl_hmdstate
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
10
);
this
.
lbl_hmdstate
.
Name
=
"lbl_hmdstate"
;
this
.
lbl_hmdstate
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
12
);
this
.
lbl_hmdstate
.
Size
=
new
System
.
Drawing
.
Size
(
67
,
15
);
this
.
lbl_hmdstate
.
TabIndex
=
5
;
this
.
lbl_hmdstate
.
Tag
=
"not"
;
this
.
lbl_hmdstate
.
Text
=
"当前状态"
;
...
...
@@ -132,17 +134,17 @@ namespace TheMachine
this
.
tp
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
());
this
.
tp
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
());
this
.
tp
.
RowStyles
.
Add
(
new
System
.
Windows
.
Forms
.
RowStyle
());
this
.
tp
.
Size
=
new
System
.
Drawing
.
Size
(
266
,
192
);
this
.
tp
.
Size
=
new
System
.
Drawing
.
Size
(
310
,
204
);
this
.
tp
.
TabIndex
=
6
;
//
// cb_usefixpos
//
this
.
cb_usefixpos
.
AutoSize
=
true
;
this
.
tp
.
SetColumnSpan
(
this
.
cb_usefixpos
,
2
);
this
.
cb_usefixpos
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
13
0
);
this
.
cb_usefixpos
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
13
6
);
this
.
cb_usefixpos
.
Margin
=
new
System
.
Windows
.
Forms
.
Padding
(
10
);
this
.
cb_usefixpos
.
Name
=
"cb_usefixpos"
;
this
.
cb_usefixpos
.
Size
=
new
System
.
Drawing
.
Size
(
96
,
16
);
this
.
cb_usefixpos
.
Size
=
new
System
.
Drawing
.
Size
(
119
,
19
);
this
.
cb_usefixpos
.
TabIndex
=
6
;
this
.
cb_usefixpos
.
Text
=
"启用校准库位"
;
this
.
cb_usefixpos
.
UseVisualStyleBackColor
=
true
;
...
...
@@ -167,9 +169,31 @@ namespace TheMachine
this
.
uC_SetUserPassword1
.
Size
=
new
System
.
Drawing
.
Size
(
405
,
272
);
this
.
uC_SetUserPassword1
.
TabIndex
=
8
;
//
// button2
//
this
.
button2
.
Location
=
new
System
.
Drawing
.
Point
(
50
,
325
);
this
.
button2
.
Name
=
"button2"
;
this
.
button2
.
Size
=
new
System
.
Drawing
.
Size
(
144
,
41
);
this
.
button2
.
TabIndex
=
9
;
this
.
button2
.
Text
=
"Start Recording"
;
this
.
button2
.
UseVisualStyleBackColor
=
true
;
this
.
button2
.
Click
+=
new
System
.
EventHandler
(
this
.
button2_Click
);
//
// button3
//
this
.
button3
.
Location
=
new
System
.
Drawing
.
Point
(
50
,
403
);
this
.
button3
.
Name
=
"button3"
;
this
.
button3
.
Size
=
new
System
.
Drawing
.
Size
(
144
,
41
);
this
.
button3
.
TabIndex
=
10
;
this
.
button3
.
Text
=
"Stop Recording"
;
this
.
button3
.
UseVisualStyleBackColor
=
true
;
this
.
button3
.
Click
+=
new
System
.
EventHandler
(
this
.
button3_Click
);
//
// SettingControl
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
Controls
.
Add
(
this
.
button3
);
this
.
Controls
.
Add
(
this
.
button2
);
this
.
Controls
.
Add
(
this
.
uC_SetUserPassword1
);
this
.
Controls
.
Add
(
this
.
button1
);
this
.
Controls
.
Add
(
this
.
tp
);
...
...
@@ -194,5 +218,7 @@ namespace TheMachine
private
System
.
Windows
.
Forms
.
CheckBox
cb_usefixpos
;
private
System
.
Windows
.
Forms
.
Button
button1
;
private
UC_SetUserPassword
uC_SetUserPassword1
;
private
System
.
Windows
.
Forms
.
Button
button2
;
private
System
.
Windows
.
Forms
.
Button
button3
;
}
}
TheMachine/SettingControl.cs
查看文件 @
f8a1ac6
...
...
@@ -132,5 +132,15 @@ namespace TheMachine
{
Task
.
Run
(()=>
CodeManager
.
TestHasReel
(
CodeManager
.
hikNameList
[
0
]));
}
private
void
button2_Click
(
object
sender
,
EventArgs
e
)
{
DeviceLibrary
.
IPCameraHelper
.
StartRecord
(
"manual"
);
}
private
void
button3_Click
(
object
sender
,
EventArgs
e
)
{
DeviceLibrary
.
IPCameraHelper
.
StopRecord
();
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论