Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
李娜
/
SO908-XLRStore
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 437aefa4
由
张东亮
编写于
2022-03-19 09:48:53 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
添加互斥锁,以确保配置文件保存的完整性
1 个父辈
05a1d4dc
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
57 行增加
和
34 行删除
source/Common/util/ConfigAppSettings.cs
source/DeviceLibrary/deviceLibrary/halcon/CodeManager.cs
source/DeviceLibrary/storeBean/boxBean/BoxEquip_Camera.cs
source/Common/util/ConfigAppSettings.cs
查看文件 @
437aefa
...
...
@@ -15,7 +15,7 @@ namespace OnlineStore.Common
//public static readonly ILog LOGGER = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private
static
int
seq
=
1
;
static
object
lockobj
=
new
object
();
public
static
int
nextSeq
()
{
if
(
seq
.
Equals
(
Int32
.
MaxValue
))
...
...
@@ -126,28 +126,36 @@ namespace OnlineStore.Common
}
public
static
void
SaveValue
(
string
key
,
string
value
)
{
try
if
(
Monitor
.
TryEnter
(
lockobj
,
300
))
{
if
(
key
.
Equals
(
""
))
//if (key.Equals("") || value.Equals(""))
try
{
return
;
if
(
key
.
Equals
(
""
))
//if (key.Equals("") || value.Equals(""))
{
return
;
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
{
SetValue
(
key
,
value
);
}
else
{
UpdateConfig
(
key
,
value
);
}
}
//增加的内容写在appSettings段下 <add key="RegCode" value="0"/>
System
.
Configuration
.
Configuration
config
=
ConfigurationManager
.
OpenExeConfiguration
(
ConfigurationUserLevel
.
None
);
if
(
config
.
AppSettings
.
Settings
[
key
]
==
null
)
catch
(
Exception
ex
)
{
SetValue
(
key
,
value
);
LogUtil
.
error
(
"SaveValue保存配置出错:AppKey="
+
key
+
",AppValue="
+
value
+
","
,
ex
);
}
else
{
UpdateConfig
(
key
,
value
);
finally
{
Monitor
.
Exit
(
lockobj
);
}
}
catch
(
Exception
ex
)
{
LogUtil
.
error
(
"SaveValue保存配置出错:AppKey="
+
key
+
",AppValue="
+
value
+
","
,
ex
);
}
}
public
static
string
GetValue
(
object
debugDeviceId
)
...
...
source/DeviceLibrary/deviceLibrary/halcon/CodeManager.cs
查看文件 @
437aefa
...
...
@@ -351,10 +351,11 @@ namespace OnlineStore.DeviceLibrary
}
return
false
;
}
static
string
codeParampath
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
CodeParamPath
);
public
static
string
GetCodeParamFilePath
(
string
codePath
)
{
string
appPath
=
Application
.
StartupPath
;
string
path
=
appPath
+
ConfigAppSettings
.
GetValue
(
Setting_Init
.
CodeParamPath
)
;
string
path
=
appPath
+
codeParampath
;
string
filePath
=
path
+
codePath
+
".dcm"
;
if
(
File
.
Exists
(
filePath
))
{
...
...
source/DeviceLibrary/storeBean/boxBean/BoxEquip_Camera.cs
查看文件 @
437aefa
...
...
@@ -202,11 +202,11 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 开始记录
/// </summary>
public
void
StartRecord
(
bool
isTest
=
false
)
public
void
StartRecord
(
bool
isTest
=
false
)
{
if
(
isTest
)
if
(
isTest
)
{
inOutPosInfo
=
new
InOutPosInfo
(
"code"
+
DateTime
.
Now
.
ToString
(
"mmssfff"
),
DateTime
.
Now
.
ToString
(
"yyyyMMddhh"
));
inOutPosInfo
=
new
InOutPosInfo
(
"code"
+
DateTime
.
Now
.
ToString
(
"mmssfff"
),
DateTime
.
Now
.
ToString
(
"yyyyMMddhh"
));
}
else
{
...
...
@@ -217,7 +217,7 @@ namespace OnlineStore.DeviceLibrary
string
inputfolderB
=
Application
.
StartupPath
+
imgPath
+
"box_B\\"
+
DateTime
.
Now
.
ToString
(
"yyyyMMdd"
)
+
"\\"
+
inOutPosInfo
.
PosId
;
string
outputfolderA
=
Application
.
StartupPath
+
"\\Videos\\box_A\\"
+
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"
);
IsRecord
=
true
;
}
...
...
@@ -227,8 +227,29 @@ namespace OnlineStore.DeviceLibrary
public
void
StopRecord
()
{
IsRecord
=
false
;
ffmpegA
.
ConvertImgsToMp4
();
ffmpegB
.
ConvertImgsToMp4
();
Task
task1
=
ffmpegA
.
ConvertImgsToMp4
();
Task
task2
=
ffmpegB
.
ConvertImgsToMp4
();
Task
.
WaitAll
(
new
Task
[]
{
task1
,
task2
},
TimeSpan
.
FromMinutes
(
1
));
Task
.
Factory
.
StartNew
(
delegate
{
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
}
...
...
@@ -250,7 +271,7 @@ namespace OnlineStore.DeviceLibrary
}
public
class
FFMPEG
{
public
static
string
appFolderPath
=
Application
.
StartupPath
;
public
static
string
appFolderPath
=
Application
.
StartupPath
;
static
string
imgPath
=
ConfigAppSettings
.
GetValue
(
Setting_Init
.
ImagePath
);
/// <summary>
/// 帧频
...
...
@@ -272,7 +293,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary>
/// 输出文件夹
/// </summary>
public
string
OutputFolder
{
get
;
set
;
}
=
appFolderPath
+
"Videos\\"
;
public
string
OutputFolder
{
get
;
set
;
}
=
appFolderPath
+
"Videos\\"
;
/// <summary>
/// 输出文件名带后缀
/// </summary>
...
...
@@ -294,7 +315,7 @@ namespace OnlineStore.DeviceLibrary
sb
.
Append
(
OutputFolder
+
"\\"
+
OutputFileName
);
return
sb
.
ToString
();
}
public
void
ConvertImgsToMp4
()
public
Task
ConvertImgsToMp4
()
{
Task
task
=
Task
.
Factory
.
StartNew
(
delegate
{
...
...
@@ -319,17 +340,10 @@ namespace OnlineStore.DeviceLibrary
p
.
StandardInput
.
Close
();
p
.
StandardError
.
ReadToEnd
();
p
.
WaitForExit
();
try
{
System
.
IO
.
Directory
.
Delete
(
InputFolder
,
true
);
}
catch
{
}
}
});
task
.
Wait
(
120000
);
return
task
;
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论