Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
1069_MIMO_PlUS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2b3863d0
由
张东亮
编写于
2024-03-12 09:22:57 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
添加监控上传功能,默认不开启
1 个父辈
bde4b79a
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
158 行增加
和
2 行删除
Common/Setting_Init.cs
Common/util/SMF.cs
DeviceLibrary/DeviceLibrary.csproj
DeviceLibrary/DeviceLibrary/IPCamera.cs
DeviceLibrary/theMachine/MainMachine.cs
TheMachine/Form1.cs
Common/Setting_Init.cs
查看文件 @
2b3863d
...
@@ -178,6 +178,8 @@ namespace OnlineStore.Common
...
@@ -178,6 +178,8 @@ namespace OnlineStore.Common
[
MyConfigComment
(
"启用隐藏smf单盘入库按钮"
)]
[
MyConfigComment
(
"启用隐藏smf单盘入库按钮"
)]
public
static
MyConfig
<
bool
>
Enable_HideSingleReelIn
=
false
;
public
static
MyConfig
<
bool
>
Enable_HideSingleReelIn
=
false
;
[
MyConfigComment
(
"启用上传监控图像给SMF"
)]
public
static
MyConfig
<
bool
>
Enable_UploadVideo
=
false
;
[
MyConfigComment
(
"压紧轴回原失败重试最大次数"
)]
[
MyConfigComment
(
"压紧轴回原失败重试最大次数"
)]
public
static
MyConfig
<
int
>
Comp_Axis_HomeResetTimes
=
999
;
public
static
MyConfig
<
int
>
Comp_Axis_HomeResetTimes
=
999
;
...
@@ -210,5 +212,18 @@ namespace OnlineStore.Common
...
@@ -210,5 +212,18 @@ namespace OnlineStore.Common
public
static
MyConfig
<
int
>
SingleInOut_ReelWidth
=
7
;
public
static
MyConfig
<
int
>
SingleInOut_ReelWidth
=
7
;
[
MyConfigComment
(
"单盘出入库的指定尺寸-高度"
)]
[
MyConfigComment
(
"单盘出入库的指定尺寸-高度"
)]
public
static
MyConfig
<
int
>
SingleInOut_ReelHeight
=
20
;
public
static
MyConfig
<
int
>
SingleInOut_ReelHeight
=
20
;
[
MyConfigComment
(
"监控上传功能_相机名"
)]
public
static
MyConfig
<
string
[
]>
UploadVideo_IPCameraNames
=
new
string
[]
{
"cam1"
,
"cam2"
};
[
MyConfigComment
(
"监控上传功能_监控服务的IP"
)]
public
static
MyConfig
<
string
>
UploadVideo_ServiceIp
=
"localhost"
;
[
MyConfigComment
(
"监控上传功能_监控服务的端口"
)]
public
static
MyConfig
<
int
>
UploadVideo_ServicePort
=
8088
;
[
MyConfigComment
(
"监控上传功能_图像宽度"
)]
public
static
MyConfig
<
int
>
UploadVideo_ImgWidth
=
1920
;
[
MyConfigComment
(
"监控上传功能_图像高度"
)]
public
static
MyConfig
<
int
>
UploadVideo_ImgHeight
=
1080
;
[
MyConfigComment
(
"监控上传功能_图像质量"
)]
public
static
MyConfig
<
int
>
UploadVideo_ImgQuality
=
100
;
}
}
}
}
Common/util/SMF.cs
查看文件 @
2b3863d
...
@@ -5,6 +5,7 @@ using System.Collections.Specialized;
...
@@ -5,6 +5,7 @@ using System.Collections.Specialized;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
static
System
.
Net
.
WebRequestMethods
;
namespace
OnlineStore.Common
namespace
OnlineStore.Common
{
{
...
@@ -72,6 +73,42 @@ namespace OnlineStore.Common
...
@@ -72,6 +73,42 @@ namespace OnlineStore.Common
return
new
List
<
SmfLangData
>();
return
new
List
<
SmfLangData
>();
}
}
/// <summary>
/// 上传监控
/// </summary>
static
string
Addr_uploadVideo
=
"/service/video/upload"
;
public
static
bool
UploadVideo
(
string
cid
,
string
img
)
{
try
{
Dictionary
<
string
,
string
>
paramMap
=
new
Dictionary
<
string
,
string
>
{
{
"cid"
,
cid
},
{
"img"
,
ParseBase64Str
(
img
)
}
};
var
resultStr
=
HttpHelper
.
Post
(
server
+
Addr_uploadVideo
,
JsonHelper
.
SerializeObject
(
paramMap
),
300
);
SmfResult
smfResult
=
JsonHelper
.
DeserializeJsonToObject
<
SmfResult
>(
resultStr
);
if
(
smfResult
!=
null
)
{
return
smfResult
.
code
==
0
;
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"{cid} UploadVideo error "
,
ex
);
}
return
false
;
}
static
string
ParseBase64Str
(
string
base64
)
{
if
(
base64
==
null
)
return
""
;
string
dump
=
base64
.
Trim
(
'"'
,
'"'
).
Replace
(
"%"
,
""
).
Replace
(
","
,
""
).
Replace
(
" "
,
"+"
).
Replace
(
"\\"
,
""
);
if
(
dump
.
Length
%
4
>
0
)
{
dump
=
dump
.
PadRight
(
dump
.
Length
+
4
-
dump
.
Length
%
4
,
'='
);
}
return
dump
;
}
}
}
//{"code":0,"data":"ok","msg":"ok","msgKey":"smfcore.ok","okResult":true}
//{"code":0,"data":"ok","msg":"ok","msgKey":"smfcore.ok","okResult":true}
...
@@ -89,6 +126,4 @@ namespace OnlineStore.Common
...
@@ -89,6 +126,4 @@ namespace OnlineStore.Common
public
string
lanCode
;
public
string
lanCode
;
public
Dictionary
<
string
,
string
>
resourceMap
;
public
Dictionary
<
string
,
string
>
resourceMap
;
}
}
}
}
DeviceLibrary/DeviceLibrary.csproj
查看文件 @
2b3863d
...
@@ -79,6 +79,7 @@
...
@@ -79,6 +79,7 @@
<Compile Include="DeviceLibrary\CameraTest.cs" />
<Compile Include="DeviceLibrary\CameraTest.cs" />
<Compile Include="DeviceLibrary\CylinderManger.cs" />
<Compile Include="DeviceLibrary\CylinderManger.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\IPCamera.cs" />
<Compile Include="DeviceLibrary\I_SafetyDevice.cs" />
<Compile Include="DeviceLibrary\I_SafetyDevice.cs" />
<Compile Include="DeviceLibrary\LiftMonitor.cs" />
<Compile Include="DeviceLibrary\LiftMonitor.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
...
...
DeviceLibrary/DeviceLibrary/IPCamera.cs
0 → 100644
查看文件 @
2b3863d
using
OnlineStore.Common
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
namespace
DeviceLibrary
{
public
class
IPCamera
{
public
IPCamera
()
{
string
ip
=
Setting_Init
.
UploadVideo_ServiceIp
;
int
port
=
Setting_Init
.
UploadVideo_ServicePort
;
server
=(
$
"http://{ip}:{port}"
);
}
string
server
;
string
Addr_getImgBase64
=
"/cam/grabOneImgByBase64"
;
public
string
GetImgBase64
(
string
cameName
)
{
string
base64
=
""
;
try
{
Dictionary
<
string
,
string
>
dic
=
new
Dictionary
<
string
,
string
>()
{
{
"camName"
,
cameName
},
{
"width"
,
Setting_Init
.
UploadVideo_ImgWidth
.
ToString
()
},
{
"height"
,
Setting_Init
.
UploadVideo_ImgHeight
.
ToString
()},
{
"quality"
,
Setting_Init
.
UploadVideo_ImgQuality
.
ToString
()},
};
base64
=
HttpHelper
.
Get
(
GetAddr
(
Addr_getImgBase64
,
dic
));
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
$
"{cameName} 采集异常"
,
ex
);
}
return
base64
;
}
string
GetAddr
(
string
addr
,
Dictionary
<
string
,
string
>
paramsMap
)
{
if
(
server
.
EndsWith
(
"/"
))
{
server
=
server
.
Substring
(
0
,
server
.
Length
-
1
);
}
string
path
=
server
+
addr
.
Trim
()
+
"?"
;
foreach
(
string
paramName
in
paramsMap
.
Keys
)
{
string
par
=
System
.
Web
.
HttpUtility
.
UrlEncode
(
paramsMap
[
paramName
],
System
.
Text
.
Encoding
.
UTF8
);
path
+=
paramName
+
"="
+
par
+
"&"
;
}
path
=
path
.
Substring
(
0
,
path
.
Length
-
1
);
return
path
;
}
}
}
\ No newline at end of file
\ No newline at end of file
DeviceLibrary/theMachine/MainMachine.cs
查看文件 @
2b3863d
using
CodeLibrary
;
using
OnlineStore
;
using
OnlineStore
;
using
OnlineStore.Common
;
using
OnlineStore.Common
;
using
OnlineStore.LoadCSVLibrary
;
using
OnlineStore.LoadCSVLibrary
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Linq
;
using
System.Security.Cryptography
;
using
System.Text
;
using
System.Text
;
using
System.Threading
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
...
@@ -891,5 +893,51 @@ namespace DeviceLibrary
...
@@ -891,5 +893,51 @@ namespace DeviceLibrary
boxTransport
.
IgnoreX09
=
true
;
boxTransport
.
IgnoreX09
=
true
;
LogUtil
.
info
(
"按下X09忽略"
);
LogUtil
.
info
(
"按下X09忽略"
);
}
}
#
region
监控上报
System
.
Threading
.
Timer
uploadVideotimer
;
void
uploadVideo
(
object
o
)
{
if
(
Monitor
.
TryEnter
(
uploadVideotimer
))
{
string
[]
camnames
=
Setting_Init
.
UploadVideo_IPCameraNames
;
try
{
if
(
camnames
!=
null
&&
camnames
.
Length
>
0
)
{
for
(
int
i
=
0
;
i
<
camnames
.
Length
;
i
++)
{
string
base64
=
ipCam
.
GetImgBase64
(
camnames
[
i
]);
if
(!
string
.
IsNullOrEmpty
(
base64
))
{
SMF
.
UploadVideo
(
$
"{Setting_Init.App_CID}_{i + 1}"
,
base64
);
}
Thread
.
Sleep
(
200
);
}
}
}
catch
(
Exception
e
)
{
LogUtil
.
error
(
$
"{Name} 上传监控图片异常"
,
e
);
}
finally
{
Monitor
.
Exit
(
uploadVideotimer
);
}
}
}
public
IPCamera
ipCam
;
public
void
UploadVideoProcessInit
()
{
if
(!
Setting_Init
.
Enable_UploadVideo
)
return
;
ipCam
=
new
IPCamera
();
uploadVideotimer
=
new
System
.
Threading
.
Timer
(
new
TimerCallback
(
uploadVideo
),
null
,
0
,
500
);
GC
.
KeepAlive
(
uploadVideotimer
);
LogUtil
.
info
(
$
"{Name} 初始化上传监控模块"
);
}
#
endregion
}
}
}
}
\ No newline at end of file
\ No newline at end of file
TheMachine/Form1.cs
查看文件 @
2b3863d
...
@@ -377,6 +377,7 @@ namespace TheMachine
...
@@ -377,6 +377,7 @@ namespace TheMachine
}
}
SetMsg
(
lm
);
SetMsg
(
lm
);
WindowManager
.
Show
();
WindowManager
.
Show
();
RobotManage
.
mainMachine
.
UploadVideoProcessInit
();
}
}
object
showMsgLoc
=
new
object
();
object
showMsgLoc
=
new
object
();
void
SetMsg
(
List
<
Msg
>
msgs
)
void
SetMsg
(
List
<
Msg
>
msgs
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论