Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.ElectricRabbit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.ElectricRabbit
Commits
d266bc7a
Commit
d266bc7a
authored
Feb 06, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加启动算法
parent
e455f67a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
117 additions
and
3 deletions
+117
-3
VIZ.ElectricRabbit.Module/MainView/ViewModel/MainViewModel.cs
+1
-1
VIZ.ElectricRabbit.Module/Setup/Provider/AppSetup_InitAlgorithm.cs
+103
-0
VIZ.ElectricRabbit.Module/VIZ.ElectricRabbit.Module.csproj
+1
-0
VIZ.ElectricRabbit.Storage/Ini/ClientConfig.cs
+6
-0
VIZ.ElectricRabbit/App.xaml.cs
+2
-0
VIZ.ElectricRabbit/config/config.ini
+4
-2
No files found.
VIZ.ElectricRabbit.Module/MainView/ViewModel/MainViewModel.cs
View file @
d266bc7a
...
@@ -347,7 +347,7 @@ namespace VIZ.ElectricRabbit.Module
...
@@ -347,7 +347,7 @@ namespace VIZ.ElectricRabbit.Module
// 更新差值
// 更新差值
double
center
=
left
+
(
right
-
left
)
/
2d
;
double
center
=
left
+
(
right
-
left
)
/
2d
;
this
.
DifferenceValue
=
center
-
this
.
SettingViewModel
.
SafeAxis
;
this
.
DifferenceValue
=
center
-
this
.
SettingViewModel
.
SafeAxis
;
this
.
AlgorithmCenterX
=
msg
.
center_x
;
this
.
AlgorithmCenterX
=
msg
.
center_x
-
this
.
SettingViewModel
.
SafeAxis
;
this
.
AlgorithmDifferenceValue
=
this
.
SettingViewModel
.
SafeAxis
-
msg
.
center_x
;
this
.
AlgorithmDifferenceValue
=
this
.
SettingViewModel
.
SafeAxis
-
msg
.
center_x
;
// 更新FPS
// 更新FPS
...
...
VIZ.ElectricRabbit.Module/Setup/Provider/AppSetup_InitAlgorithm.cs
0 → 100644
View file @
d266bc7a
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Windows.Media
;
using
VIZ.ElectricRabbit.Domain
;
using
VIZ.ElectricRabbit.Storage
;
using
VIZ.Framework.Common
;
using
VIZ.Framework.Core
;
using
VIZ.Framework.Domain
;
using
VIZ.Framework.Module
;
namespace
VIZ.ElectricRabbit.Module
{
/// <summary>
/// 应用程序启动 -- 初始化算法
/// </summary>
public
class
AppSetup_InitAlgorithm
:
AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
AppSetup_InitAlgorithm
));
/// <summary>
/// 算法路径
/// </summary>
private
readonly
static
string
CLIENT_ALGORITHM_PATH
=
ApplicationDomainEx
.
IniStorage
.
GetValue
<
ClientConfig
,
string
>(
p
=>
p
.
CLIENT_ALGORITHM_PATH
);
/// <summary>
/// 描述
/// </summary>
public
override
string
Detail
{
get
;
}
=
"应用程序启动 -- 初始化算法"
;
/// <summary>
/// 算法进程
/// </summary>
private
Process
AlgorithmProcess
;
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public
override
bool
Setup
(
AppSetupContext
context
)
{
// 如果未配置,那么不处理
if
(
string
.
IsNullOrWhiteSpace
(
CLIENT_ALGORITHM_PATH
))
return
true
;
this
.
AlgorithmProcess
=
this
.
CreateSetupProcess
(
CLIENT_ALGORITHM_PATH
);
this
.
AlgorithmProcess
?.
Start
();
return
true
;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public
override
void
Shutdown
(
AppSetupContext
context
)
{
this
.
AlgorithmProcess
?.
Kill
();
}
/// <summary>
/// 创建启动进程
/// </summary>
/// <param name="path">进程路径</param>
/// <returns>进程对象</returns>
private
Process
CreateSetupProcess
(
string
path
)
{
StringBuilder
sb
=
new
StringBuilder
();
string
fileName
=
null
;
string
arguments
=
null
;
if
(
System
.
IO
.
Path
.
GetExtension
(
path
).
ToLower
()
==
".py"
)
{
// 如果是 .py 文件那么 采用 CMD 启动python程序
fileName
=
"python"
;
arguments
=
$"\"
{
path
}
\""
;
}
else
{
// 否则采用直接启动的方式启动
fileName
=
path
;
arguments
=
$"
{
sb
}
"
;
}
Process
proc
=
new
Process
();
proc
.
StartInfo
.
UseShellExecute
=
true
;
proc
.
StartInfo
.
FileName
=
fileName
;
proc
.
StartInfo
.
Arguments
=
arguments
;
proc
.
StartInfo
.
WindowStyle
=
ProcessWindowStyle
.
Normal
;
return
proc
;
}
}
}
\ No newline at end of file
VIZ.ElectricRabbit.Module/VIZ.ElectricRabbit.Module.csproj
View file @
d266bc7a
...
@@ -129,6 +129,7 @@
...
@@ -129,6 +129,7 @@
<Compile Include="SettingView\View\SettingView.xaml.cs">
<Compile Include="SettingView\View\SettingView.xaml.cs">
<DependentUpon>SettingView.xaml</DependentUpon>
<DependentUpon>SettingView.xaml</DependentUpon>
</Compile>
</Compile>
<Compile Include="Setup\Provider\AppSetup_InitAlgorithm.cs" />
<Compile Include="Setup\Provider\AppSetup_SerialPort.cs" />
<Compile Include="Setup\Provider\AppSetup_SerialPort.cs" />
<Compile Include="Setup\Provider\AppSetup_InitUDP.cs" />
<Compile Include="Setup\Provider\AppSetup_InitUDP.cs" />
<Compile Include="Setup\Provider\AppSetup_InitOpenCV.cs" />
<Compile Include="Setup\Provider\AppSetup_InitOpenCV.cs" />
...
...
VIZ.ElectricRabbit.Storage/Ini/ClientConfig.cs
View file @
d266bc7a
...
@@ -78,5 +78,11 @@ namespace VIZ.ElectricRabbit.Storage
...
@@ -78,5 +78,11 @@ namespace VIZ.ElectricRabbit.Storage
/// </summary>
/// </summary>
[
Ini
(
Section
=
"Client"
,
DefaultValue
=
"COM1"
,
Type
=
typeof
(
string
))]
[
Ini
(
Section
=
"Client"
,
DefaultValue
=
"COM1"
,
Type
=
typeof
(
string
))]
public
string
CLIENT_OUTPUT_SERIAL_PORT
{
get
;
set
;
}
public
string
CLIENT_OUTPUT_SERIAL_PORT
{
get
;
set
;
}
/// <summary>
/// 算法路径
/// </summary>
[
Ini
(
Section
=
"Client"
,
DefaultValue
=
""
,
Type
=
typeof
(
string
))]
public
string
CLIENT_ALGORITHM_PATH
{
get
;
set
;
}
}
}
}
}
VIZ.ElectricRabbit/App.xaml.cs
View file @
d266bc7a
...
@@ -25,6 +25,8 @@ namespace VIZ.ElectricRabbit
...
@@ -25,6 +25,8 @@ namespace VIZ.ElectricRabbit
AppSetup
.
AppendSetup
(
new
AppSetup_InitUDP
());
AppSetup
.
AppendSetup
(
new
AppSetup_InitUDP
());
// 初始化串口
// 初始化串口
AppSetup
.
AppendSetup
(
new
AppSetup_SerialPort
());
AppSetup
.
AppendSetup
(
new
AppSetup_SerialPort
());
// 初始化算法
AppSetup
.
AppendSetup
(
new
AppSetup_InitAlgorithm
());
// 执行启动流程
// 执行启动流程
AppSetupContext
context
=
AppSetup
.
Setup
();
AppSetupContext
context
=
AppSetup
.
Setup
();
...
...
VIZ.ElectricRabbit/config/config.ini
View file @
d266bc7a
...
@@ -35,4 +35,6 @@ CLIENT_RIGHT_COLOR=#00000000
...
@@ -35,4 +35,6 @@ CLIENT_RIGHT_COLOR=#00000000
; 箭头安全颜色(格式:#AARRGGBB)
; 箭头安全颜色(格式:#AARRGGBB)
CLIENT_SAFE_COLOR
=
#00000000
CLIENT_SAFE_COLOR
=
#00000000
; 输出串口号
; 输出串口号
CLIENT_OUTPUT_SERIAL_PORT=COM3
CLIENT_OUTPUT_SERIAL_PORT=COM3
\ No newline at end of file
; 算法路径
CLIENT_ALGORITHM_PATH
=
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment