Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
ea85577c
Commit
ea85577c
authored
Dec 07, 2019
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 timeGridAdvHelper 的bug
parent
e3af7e40
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
63 deletions
+94
-63
PUSH_DATA.cs
...FLY.FlyADBase/FLY.Simulation.Flyad7/OBJProxy/PUSH_DATA.cs
+3
-2
TimeGridAdvHelper.cs
Project.FLY.FlyADBase/FlyADBase/TimeGridAdvHelper.cs
+61
-61
MainWindow.xaml
Project.FLY.FlyADBase/Flyad7_WPF/MainWindow.xaml
+1
-0
MainWindow.xaml.cs
Project.FLY.FlyADBase/Flyad7_WPF/MainWindow.xaml.cs
+29
-0
No files found.
Project.FLY.FlyADBase/FLY.Simulation.Flyad7/OBJProxy/PUSH_DATA.cs
View file @
ea85577c
...
...
@@ -52,11 +52,12 @@ namespace FLY.Simulation.Flyad7.OBJProxy
void
mPosGrid_PushEvent
(
bool
isMini
,
Misc
.
DIRECTION
dir
,
int
grid_start
,
int
[]
data
)
{
FLYAD7_OBJ_INTERFACE
.
PUSH_DATA_INTERFACE
.
Pack_PushGrid
p
=
new
FLYAD7_OBJ_INTERFACE
.
PUSH_DATA_INTERFACE
.
Pack_PushGrid
();
FLYAD7_OBJ_INTERFACE
.
PUSH_DATA_INTERFACE
.
Pack_PushGrid
_2
p
=
new
FLYAD7_OBJ_INTERFACE
.
PUSH_DATA_INTERFACE
.
Pack_PushGrid_2
();
p
.
grid_start
=
grid_start
;
p
.
direction
=
dir
;
p
.
data
=
data
;
p
.
systick
=
Data
.
GetSysTick
(
Data
.
Now
);
p
.
marker
=
Data
.
Marker
;
if
(
isMini
)
CurrObjSys
.
PushObjInfoEx
(
this
,
FLYAD7_OBJ_INTERFACE
.
PUSH_DATA_INTERFACE
.
PUSH_MINIGRID
,
p
.
ToBytes
());
...
...
Project.FLY.FlyADBase/FlyADBase/TimeGridAdvHelper.cs
View file @
ea85577c
...
...
@@ -288,8 +288,9 @@ namespace FlyADBase
ForwToCheck
}
/// <summary>
/// 找到 时间 dt 落在 [idx,idx+1] 之间的 idx
,
/// 找到 时间 dt 落在 [idx,idx+1] 之间的 idx
;
/// 返回 -1,证明dt 在列表在前面, 或列表数据量为=0,
/// 当dt 大于 列表最后一个数, 返回最后一个数据的id
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list">列表</param>
...
...
@@ -302,78 +303,77 @@ namespace FlyADBase
return
-
1
;
int
max_index
=
list
.
Count
()
-
1
;
if
(
dt
>=
list
[
max_index
].
dt
)
return
max_index
;
if
(
dt
<
list
[
0
].
dt
)
return
-
1
;
int
index
=
searchStartIdx
;
SearchState
state
=
SearchState
.
ContinueLastTime
;
if
((
index
<
0
)
||
(
index
>=
max_index
))
//重新开始
{
index
=
max_index
;
state
=
SearchState
.
Back
;
}
//从上次位置开始查找
while
(
true
)
else
if
(
state
==
SearchState
.
ContinueLastTime
)
{
DateTime
time
=
list
[
index
].
dt
;
switch
(
state
)
if
(
list
[
index
].
dt
<=
dt
)
{
case
SearchState
.
ContinueLastTime
:
{
if
(
time
<=
dt
)
{
//可能找到了
//再向前看看
state
=
SearchState
.
ForwToCheck
;
index
++;
}
else
{
state
=
SearchState
.
Back
;
index
--;
}
}
break
;
case
SearchState
.
ForwToCheck
:
{
if
(
index
>
max_index
)
{
index
--;
//最后一个就是了
goto
_finish
;
}
if
(
time
>
dt
)
{
//就是之前那个
index
--;
goto
_finish
;
}
else
{
//找过头了
index
++;
}
}
break
;
case
SearchState
.
Back
:
{
if
(
time
<=
dt
)
{
//就是它
goto
_finish
;
}
index
--;
}
break
;
default
:
{
throw
new
Exception
(
"程序出错, 不可以有第4种情况"
);
}
break
;
//可能找到了
//再向正方向看看
state
=
SearchState
.
ForwToCheck
;
}
else
{
state
=
SearchState
.
Back
;
}
}
_finish
:
return
index
;
if
(
state
==
SearchState
.
ForwToCheck
)
{
while
(
true
)
{
DateTime
time
=
list
[
index
].
dt
;
if
(
time
>
dt
)
{
//就是之前那个
index
--;
return
index
;
}
else
{
index
++;
}
if
(
index
>
max_index
)
{
//最后一个就是了
throw
new
Exception
(
"之前没有判断出 时间点在列表后,异常!!"
);
//return max_index;
}
}
}
else
//SearchState.Back
{
while
(
true
)
{
DateTime
time
=
list
[
index
].
dt
;
if
(
time
<=
dt
)
{
//就是它
return
index
;
}
index
--;
if
(
index
<
0
)
{
//不可能发生
throw
new
Exception
(
"之前没有判断出 时间点在列表前,异常!!"
);
}
}
}
}
...
...
Project.FLY.FlyADBase/Flyad7_WPF/MainWindow.xaml
View file @
ea85577c
...
...
@@ -353,6 +353,7 @@
<Button Content="反向获取" Height="23" Name="button2" Width="75" Click="button2_Click" Margin="3" />
<Button Content="正向获取" Height="23" Name="button1" Width="75" Click="button1_Click" Margin="3" />
<Button Content="清除" Height="23" Width="75" Click="button_cleargrid_Click" Margin="3" />
<Button Content="保存" Height="23" Width="75" Click="button_gridSave_Click" Margin="3" />
<CheckBox Content="接收Grid" IsChecked="{Binding DataContext.HasGrid,ElementName=grid_param}" VerticalAlignment="Center" Margin="3" />
<TextBlock Margin="3">
<Run Text="Grid Marker:"/>
...
...
Project.FLY.FlyADBase/Flyad7_WPF/MainWindow.xaml.cs
View file @
ea85577c
...
...
@@ -579,6 +579,35 @@ namespace Flyad7_WPF
{
flyad
.
RuntoMax
();
}
private
void
button_gridSave_Click
(
object
sender
,
RoutedEventArgs
e
)
{
System
.
Windows
.
Forms
.
DataVisualization
.
Charting
.
Series
series_forw
=
chart1
.
Series
[
"Series 1"
];
System
.
Windows
.
Forms
.
DataVisualization
.
Charting
.
Series
series_backw
=
chart1
.
Series
[
"Series 2"
];
string
strDesktopPath
=
Environment
.
GetFolderPath
(
Environment
.
SpecialFolder
.
DesktopDirectory
);
string
path
=
System
.
IO
.
Path
.
Combine
(
strDesktopPath
,
$"grid_
{
DateTime
.
Now
.
ToString
(
"yyyyMMdd_HHmmss"
)}
.csv"
);
StreamWriter
sw
=
new
StreamWriter
(
path
);
//int count = Math.Max(series_forw.Points.Count(), series_backw.Points.Count());
sw
.
WriteLine
(
$"Index,Forw,Backw"
);
int
gridLen
=
flyad
.
PosLen
/
flyad
.
PosOfGrid
;
for
(
int
i
=
0
;
i
<
gridLen
;
i
++)
{
int
f_v
=
Misc
.
MyBase
.
NULL_VALUE
;
int
b_v
=
Misc
.
MyBase
.
NULL_VALUE
;
if
(
i
<
series_forw
.
Points
.
Count
)
f_v
=
(
int
)(
series_forw
.
Points
[
i
].
YValues
[
0
]);
if
(
i
<
series_backw
.
Points
.
Count
)
b_v
=
(
int
)(
series_backw
.
Points
[
i
].
YValues
[
0
]);
sw
.
WriteLine
(
$"
{
i
}
,
{
f_v
}
,
{
b_v
}
"
);
}
sw
.
Flush
();
sw
.
Close
();
MessageBox
.
Show
(
$"成功保存到
{
path
}
"
);
}
}
}
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