Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.GimbalAI.Controller
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.GimbalAI.Controller
Commits
bf264c4b
Commit
bf264c4b
authored
Aug 15, 2022
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
协议改变
parent
733f36f4
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
209 additions
and
10 deletions
+209
-10
Doc/云台连接线.txt
+9
-0
VIZ.GimbalAI.Controller.Connection/SerialPort/Gimbal/GimbalPackageDownProvider.cs
+0
-0
VIZ.GimbalAI.Controller.Connection/SerialPort/Gimbal/Signal/GimbalPackageBase.cs
+58
-1
VIZ.GimbalAI.Controller.Connection/SerialPort/Gimbal/Signal/Up/GimbalPackage_up.cs
+71
-5
VIZ.GimbalAI.Controller.Module/MainView/View/MainView.xaml
+36
-3
VIZ.GimbalAI.Controller.Module/MainView/View/MainView.xaml.cs
+27
-0
VIZ.GimbalAI.Controller.UnitTest/BufferTest.cs
+2
-0
VIZ.GimbalAI.Controller.sln
+5
-0
VIZ.GimbalAI.Controller/MainWindow.xaml
+1
-1
No files found.
Doc/云台连接线.txt
0 → 100644
View file @
bf264c4b
=================================================
=================================================
4 3 1 2
1 2 3 4
=================================================
1 2 3 4
̨ 2 1 3 4
=================================================
\ No newline at end of file
VIZ.GimbalAI.Controller.Connection/SerialPort/Gimbal/GimbalPackageDownProvider.cs
View file @
bf264c4b
VIZ.GimbalAI.Controller.Connection/SerialPort/Gimbal/Signal/GimbalPackageBase.cs
View file @
bf264c4b
...
...
@@ -69,7 +69,6 @@ namespace VIZ.GimbalAI.Controller.Connection
return
(
UInt16
)(
buffer
[
index
]
+
(
buffer
[
index
+
1
]
<<
8
));
}
/// <summary>
/// 获取两个字节数据的值,没有正负值
/// </summary>
...
...
@@ -82,6 +81,28 @@ namespace VIZ.GimbalAI.Controller.Connection
}
/// <summary>
/// 获取四个字节数据的值,没有正负值
/// </summary>
/// <param name="buffer">Buffer</param>
/// <param name="index">当前位序</param>
/// <returns>值</returns>
protected
UInt32
GetValue_4_NoPN
(
byte
[]
buffer
,
int
index
)
{
return
(
UInt32
)(
buffer
[
index
]
+
(
buffer
[
index
+
1
]
<<
8
)
+
(
buffer
[
index
+
2
]
<<
16
)
+
(
buffer
[
index
+
3
]
<<
24
));
}
/// <summary>
/// 获取四个字节数据的值,没有正负值
/// </summary>
/// <param name="buffer">Buffer</param>
/// <param name="index">当前位序</param>
/// <returns>值</returns>
protected
Int32
GetValue_4_NoPN2
(
byte
[]
buffer
,
int
index
)
{
return
(
Int32
)(
buffer
[
index
]
+
(
buffer
[
index
+
1
]
<<
8
)
+
(
buffer
[
index
+
2
]
<<
16
)
+
(
buffer
[
index
+
3
]
<<
24
));
}
/// <summary>
/// 获取1个字节数据
/// </summary>
/// <param name="pn">符号位</param>
...
...
@@ -155,6 +176,42 @@ namespace VIZ.GimbalAI.Controller.Connection
}
/// <summary>
/// 获取4个字节数据
/// </summary>
/// <param name="value">值</param>
/// <returns>字节数据</returns>
protected
byte
[]
GetBuffer_4
(
UInt32
value
)
{
// 00000000
// 11111111
byte
[]
result
=
new
byte
[
4
];
result
[
0
]
=
(
byte
)(
value
&
0
b00000000000000000000000011111111
);
result
[
1
]
=
(
byte
)((
value
&
0
b00000000000000001111111100000000
)
>>
8
);
result
[
2
]
=
(
byte
)((
value
&
0
b00000000111111110000000000000000
)
>>
16
);
result
[
3
]
=
(
byte
)((
value
&
0
b11111111000000000000000000000000
)
>>
24
);
return
result
;
}
/// <summary>
/// 获取4个字节数据
/// </summary>
/// <param name="value">值</param>
/// <returns>字节数据</returns>
protected
byte
[]
GetBuffer_4
(
Int32
value
)
{
// 00000000
// 11111111
byte
[]
result
=
new
byte
[
4
];
result
[
0
]
=
(
byte
)(
value
&
0
b00000000000000000000000011111111
);
result
[
1
]
=
(
byte
)((
value
&
0
b00000000000000001111111100000000
)
>>
8
);
result
[
2
]
=
(
byte
)((
value
&
0
b00000000111111110000000000000000
)
>>
16
);
result
[
3
]
=
(
byte
)((
value
&
0
b11111111000000000000000000000000
)
>>
24
);
return
result
;
}
/// <summary>
/// 获取带PN的值
/// </summary>
/// <param name="pn">符号位</param>
...
...
VIZ.GimbalAI.Controller.Connection/SerialPort/Gimbal/Signal/Up/GimbalPackage_up.cs
View file @
bf264c4b
...
...
@@ -35,13 +35,13 @@ namespace VIZ.GimbalAI.Controller.Connection
/// <summary>
/// 俯仰角度值
/// </summary>
[
ConnBitLength
(
1
5
)]
[
ConnBitLength
(
1
6
)]
public
Int16
Vertical
{
get
;
set
;
}
/// <summary>
/// 方位角度值
/// </summary>
[
ConnBitLength
(
1
5
)]
[
ConnBitLength
(
1
6
)]
public
Int16
Horizontal
{
get
;
set
;
}
/// <summary>
...
...
@@ -99,6 +99,36 @@ namespace VIZ.GimbalAI.Controller.Connection
public
UInt16
Real_Focus
{
get
;
set
;
}
/// <summary>
/// 方位位置值
/// </summary>
[
ConnBitLength
(
32
)]
public
UInt32
Real_Horizontal
{
get
;
set
;
}
/// <summary>
/// 俯仰位置值
/// </summary>
[
ConnBitLength
(
32
)]
public
UInt32
Real_Vertical
{
get
;
set
;
}
/// <summary>
/// 同步帧尾 固定值 0xAA
/// </summary>
[
ConnBitLength
(
8
)]
public
byte
SyncEnd_1
{
get
;
set
;
}
/// <summary>
/// 同步帧尾 固定值 0xBB
/// </summary>
[
ConnBitLength
(
8
)]
public
byte
SyncEnd_2
{
get
;
set
;
}
/// <summary>
/// 同步帧尾 固定值 0xCC
/// </summary>
[
ConnBitLength
(
8
)]
public
byte
SyncEnd_3
{
get
;
set
;
}
/// <summary>
/// 校验和
/// (序号1+……+序号52)&0xFF
/// </summary>
...
...
@@ -152,8 +182,29 @@ namespace VIZ.GimbalAI.Controller.Connection
// 焦点位置
buffer
[
index
++]
=
this
.
GetBuffer_2_low
(
this
.
Real_Focus
);
buffer
[
index
++]
=
this
.
GetBuffer_2_heigh
(
this
.
Real_Focus
);
// 方位位置值
byte
[]
buffer_real_horizontal
=
this
.
GetBuffer_4
(
this
.
Real_Horizontal
);
buffer
[
index
++]
=
buffer_real_horizontal
[
0
];
buffer
[
index
++]
=
buffer_real_horizontal
[
1
];
buffer
[
index
++]
=
buffer_real_horizontal
[
2
];
buffer
[
index
++]
=
buffer_real_horizontal
[
3
];
// 俯仰位置值
byte
[]
buffer_real_vertical
=
this
.
GetBuffer_4
(
this
.
Real_Vertical
);
buffer
[
index
++]
=
buffer_real_vertical
[
0
];
buffer
[
index
++]
=
buffer_real_vertical
[
1
];
buffer
[
index
++]
=
buffer_real_vertical
[
2
];
buffer
[
index
++]
=
buffer_real_vertical
[
3
];
// 备用
index
+=
28
;
index
+=
17
;
// 同步帧尾 1
buffer
[
index
++]
=
this
.
SyncEnd_1
;
// 同步帧尾 2
buffer
[
index
++]
=
this
.
SyncEnd_2
;
// 同步帧尾 3
buffer
[
index
++]
=
this
.
SyncEnd_3
;
// 校验值
buffer
[
index
++]
=
this
.
Check
;
...
...
@@ -205,8 +256,23 @@ namespace VIZ.GimbalAI.Controller.Connection
// 焦点位置
this
.
Real_Focus
=
this
.
GetValue_2_NoPN
(
buffer
,
index
);
index
+=
2
;
// 备用 1
index
+=
28
;
// 方位位置值
this
.
Real_Horizontal
=
this
.
GetValue_4_NoPN
(
buffer
,
index
);
index
+=
4
;
// 俯仰位置值
this
.
Real_Vertical
=
this
.
GetValue_4_NoPN
(
buffer
,
index
);
index
+=
4
;
// 备用
index
+=
17
;
// 同步帧尾 1
this
.
SyncEnd_1
=
this
.
GetValue_1
(
buffer
,
index
++);
// 同步帧尾 2
this
.
SyncEnd_2
=
this
.
GetValue_1
(
buffer
,
index
++);
// 同步帧尾 3
this
.
SyncEnd_3
=
this
.
GetValue_1
(
buffer
,
index
++);
// 校验值
this
.
Check
=
buffer
[
index
++];
}
...
...
VIZ.GimbalAI.Controller.Module/MainView/View/MainView.xaml
View file @
bf264c4b
...
...
@@ -8,7 +8,7 @@
xmlns:resource="clr-namespace:Viz.GimbalAI.Controller.Module.Resource;assembly=Viz.GimbalAI.Controller.Module.Resource"
mc:Ignorable="d" Background="White"
d:DataContext="{d:DesignInstance Type=local:MainViewModel}"
d:DesignHeight="
85
0" d:DesignWidth="1200">
d:DesignHeight="
100
0" d:DesignWidth="1200">
<UserControl.Resources>
<resource:GimbalPackage_down_CheckValueConverter x:Key="GimbalPackage_down_CheckValueConverter"></resource:GimbalPackage_down_CheckValueConverter>
<resource:GimbalPackage_up_CheckValueConverter x:Key="GimbalPackage_up_CheckValueConverter"></resource:GimbalPackage_up_CheckValueConverter>
...
...
@@ -33,6 +33,7 @@
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<common:LabelValue2 Label="命令状态:" Text1="{Binding Path=CurrentCommandStatus}" Margin="5,0,5,0"></common:LabelValue2>
<Button Content="发送测试" Width="120" Height="30" Click="Button_Click" Grid.Column="1" HorizontalAlignment="Right"></Button>
</Grid>
</GroupBox>
...
...
@@ -185,6 +186,10 @@
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
...
...
@@ -273,12 +278,40 @@
Text2="{Binding Path=UpData.Real_Focus}"
Margin="5,0,5,0"></common:LabelValue2>
<!-- 方位位置值 -->
<common:LabelValue2 Grid.Row="13" Grid.Column="0" Label="方位位置值:"
Text1="{Binding Path=UpData.Real_Horizontal,StringFormat=X6}"
Text2="{Binding Path=UpData.Real_Horizontal}"
Margin="5,0,5,0"></common:LabelValue2>
<!-- 俯仰位置值 -->
<common:LabelValue2 Grid.Row="14" Grid.Column="0" Label="俯仰位置值:"
Text1="{Binding Path=UpData.Real_Vertical,StringFormat=X6}"
Text2="{Binding Path=UpData.Real_Vertical}"
Margin="5,0,5,0"></common:LabelValue2>
<!-- 同步帧尾 -->
<common:LabelValue2 Grid.Row="15" Grid.Column="0" Label="同步帧尾1:"
Text1="{Binding Path=UpData.SyncEnd_1,StringFormat=X6}"
Text2="{Binding Path=UpData.SyncEnd_1}"
Margin="5,0,5,0"></common:LabelValue2>
<common:LabelValue2 Grid.Row="15" Grid.Column="1" Label="同步帧尾2:"
Text1="{Binding Path=UpData.SyncEnd_2,StringFormat=X6}"
Text2="{Binding Path=UpData.SyncEnd_2}"
Margin="5,0,5,0"></common:LabelValue2>
<common:LabelValue2 Grid.Row="16" Grid.Column="0" Label="同步帧尾3:"
Text1="{Binding Path=UpData.SyncEnd_3,StringFormat=X6}"
Text2="{Binding Path=UpData.SyncEnd_3}"
Margin="5,0,5,0"></common:LabelValue2>
<!-- 校验和 -->
<common:LabelValue2 Grid.Row="1
3
" Grid.Column="0" Label="校验和:"
<common:LabelValue2 Grid.Row="1
7
" Grid.Column="0" Label="校验和:"
Text1="{Binding Path=UpData.Check,StringFormat=X6}"
Text2="{Binding Path=UpData.Check}"
Margin="5,0,5,0"></common:LabelValue2>
<common:LabelValue2 Grid.Row="1
3
" Grid.Column="1" Label="计算校验和:"
<common:LabelValue2 Grid.Row="1
7
" Grid.Column="1" Label="计算校验和:"
Text1="{Binding Path=UpData,Converter={StaticResource GimbalPackage_up_CheckValueConverter},StringFormat=X6}"
Text2="{Binding Path=UpData,Converter={StaticResource GimbalPackage_up_CheckValueConverter}}"
Margin="5,0,5,0"></common:LabelValue2>
...
...
VIZ.GimbalAI.Controller.Module/MainView/View/MainView.xaml.cs
View file @
bf264c4b
using
System
;
using
System.Collections.Generic
;
using
System.IO.Ports
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -12,7 +13,10 @@ using System.Windows.Media;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
using
VIZ.Framework.Connection
;
using
VIZ.Framework.Core
;
using
VIZ.GimbalAI.Controller.Connection
;
using
VIZ.GimbalAI.Controller.Domain
;
namespace
VIZ.GimbalAI.Controller.Module
{
...
...
@@ -27,5 +31,28 @@ namespace VIZ.GimbalAI.Controller.Module
WPFHelper
.
BindingViewModel
(
this
,
new
MainViewModel
());
}
private
void
Button_Click
(
object
sender
,
RoutedEventArgs
e
)
{
SerialPortEndpointManager
down_endpoint_manager
=
ConnectionManager
.
SerialPortConnection
.
GetEndpointManager
(
SerialPortKeys
.
DOWN
);
GimbalPackage_up
up
=
new
GimbalPackage_up
();
up
.
SyncHead_1
=
0x58
;
up
.
SyncHead_2
=
0xA0
;
up
.
Command
=
(
byte
)
GimbalPackage_Commands
.
Normal
;
up
.
Vertical
=
100
;
up
.
Horizontal
=
100
;
up
.
Zoom
=
100
;
up
.
Aperture
=
100
;
up
.
Focus
=
100
;
up
.
Roll
=
100
;
up
.
Real_Horizontal_Angle
=
-
60
;
up
.
Real_Vertical_Angle
=
60
;
up
.
Check
=
up
.
GetCheckValue
();
byte
[]
buffer
=
up
.
ToBuffer
();
down_endpoint_manager
.
Send
(
buffer
);
}
}
}
VIZ.GimbalAI.Controller.UnitTest/BufferTest.cs
View file @
bf264c4b
...
...
@@ -63,6 +63,8 @@ namespace VIZ.GimbalAI.Controller.UnitTest
up
.
Roll
=
1000
;
up
.
Real_Horizontal_Angle
=
-
60
;
up
.
Real_Vertical_Angle
=
60
;
up
.
Real_Horizontal
=
1000
;
up
.
Real_Vertical
=
500
;
up
.
Check
=
up
.
GetCheckValue
();
byte
[]
buffer
=
up
.
ToBuffer
();
...
...
VIZ.GimbalAI.Controller.sln
View file @
bf264c4b
...
...
@@ -57,6 +57,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VIZ.GimbalAI.Controller.Con
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Viz.GimbalAI.Controller.Module.Resource", "Viz.GimbalAI.Controller.Module.Resource\Viz.GimbalAI.Controller.Module.Resource.csproj", "{0A9657ED-FDF9-48B7-8B78-A94814EC211F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "05-Doc", "05-Doc", "{BD74E48A-3E90-4280-8422-9CA78FD2E149}"
ProjectSection(SolutionItems) = preProject
Doc\云台连接线.txt = Doc\云台连接线.txt
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
...
...
VIZ.GimbalAI.Controller/MainWindow.xaml
View file @
bf264c4b
...
...
@@ -6,7 +6,7 @@
xmlns:local="clr-namespace:VIZ.GimbalAI.Controller"
xmlns:module="clr-namespace:VIZ.GimbalAI.Controller.Module;assembly=VIZ.GimbalAI.Controller.Module"
mc:Ignorable="d" WindowStartupLocation="CenterScreen"
Title="智能云台控制器" Height="
90
0" Width="1200">
Title="智能云台控制器" Height="
105
0" Width="1200">
<Grid>
<module:MainView Margin="20"></module:MainView>
</Grid>
...
...
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