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
c4205399
Commit
c4205399
authored
Apr 07, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 整理定点图, 可以显示1ms
parent
49008677
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
146 additions
and
177 deletions
+146
-177
FixGraphConfig.xaml.cs
...LY.Thick.Base.UI/UiModule/FixGraph/FixGraphConfig.xaml.cs
+42
-35
FixGraphItemParam.cs
.../FLY.Thick.Base.UI/UiModule/FixGraph/FixGraphItemParam.cs
+1
-1
FixGraphVm.cs
...ck.Base/FLY.Thick.Base.UI/UiModule/FixGraph/FixGraphVm.cs
+22
-29
PgFixAnalyze.xaml
...ase/FLY.Thick.Base.UI/UiModule/FixGraph/PgFixAnalyze.xaml
+18
-38
PgFixAnalyze.xaml.cs
.../FLY.Thick.Base.UI/UiModule/FixGraph/PgFixAnalyze.xaml.cs
+63
-74
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base.UI/UiModule/FixGraph/FixGraphConfig.xaml.cs
View file @
c4205399
...
@@ -54,7 +54,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -54,7 +54,7 @@ namespace FLY.Thick.Base.UI.UiModule
void
graphparam_clone_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
void
graphparam_clone_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
{
if
(
e
.
PropertyName
==
"Interval"
)
if
(
e
.
PropertyName
==
nameof
(
graphparam_clone
.
Interval
)
)
{
{
updateDataLenOpt
();
updateDataLenOpt
();
...
@@ -63,7 +63,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -63,7 +63,7 @@ namespace FLY.Thick.Base.UI.UiModule
graphparam_clone
.
Len
=
10
;
graphparam_clone
.
Len
=
10
;
graphparam_clone
.
Len
=
len
;
graphparam_clone
.
Len
=
len
;
}
}
else
if
(
e
.
PropertyName
==
"IsADMode"
)
else
if
(
e
.
PropertyName
==
nameof
(
graphparam_clone
.
IsADMode
)
)
{
{
graphparam_clone
.
IsAutoTarget
=
true
;
graphparam_clone
.
IsAutoTarget
=
true
;
graphparam_clone
.
IsAutoY
=
false
;
graphparam_clone
.
IsAutoY
=
false
;
...
@@ -77,8 +77,8 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -77,8 +77,8 @@ namespace FLY.Thick.Base.UI.UiModule
void
updateIntervalOpt
()
void
updateIntervalOpt
()
{
{
IntervalOpt
.
Clear
();
IntervalOpt
.
Clear
();
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
1
,
Title
=
"1
.28
ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
1
,
Title
=
"1ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
4
,
Title
=
"5.12
ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
5
,
Title
=
"5
ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
10
,
Title
=
"10ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
10
,
Title
=
"10ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
50
,
Title
=
"50ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
50
,
Title
=
"50ms"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
100
,
Title
=
"0.1s"
});
IntervalOpt
.
Add
(
new
FixInterval
()
{
Interval
=
100
,
Title
=
"0.1s"
});
...
@@ -97,45 +97,55 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -97,45 +97,55 @@ namespace FLY.Thick.Base.UI.UiModule
if
(
graphparam_clone
.
Interval
==
1
)
if
(
graphparam_clone
.
Interval
==
1
)
{
{
DataLenOpt
.
Add
(
500
);
DataLenOpt
.
Add
(
5000
);
//5s
DataLenOpt
.
Add
(
1000
);
DataLenOpt
.
Add
(
10000
);
//10s
DataLenOpt
.
Add
(
2000
);
DataLenOpt
.
Add
(
20000
);
//20s
DataLenOpt
.
Add
(
4000
);
DataLenOpt
.
Add
(
50000
);
//50s
DataLenOpt
.
Add
(
10000
);
DataLenOpt
.
Add
(
100000
);
//100s
DataLenOpt
.
Add
(
20000
);
}
DataLenOpt
.
Add
(
50000
);
else
if
(
graphparam_clone
.
Interval
<=
5
)
DataLenOpt
.
Add
(
100000
);
{
DataLenOpt
.
Add
(
1000
);
//5s
DataLenOpt
.
Add
(
2000
);
//10s
DataLenOpt
.
Add
(
5000
);
//25s
DataLenOpt
.
Add
(
10000
);
//50s
DataLenOpt
.
Add
(
20000
);
//100s
DataLenOpt
.
Add
(
50000
);
//250s
}
}
else
if
(
graphparam_clone
.
Interval
<=
10
)
else
if
(
graphparam_clone
.
Interval
<=
10
)
{
{
DataLenOpt
.
Add
(
500
);
DataLenOpt
.
Add
(
500
);
//5s
DataLenOpt
.
Add
(
1000
);
DataLenOpt
.
Add
(
1000
);
//10s
DataLenOpt
.
Add
(
2000
);
DataLenOpt
.
Add
(
2000
);
//20s
DataLenOpt
.
Add
(
4000
);
DataLenOpt
.
Add
(
5000
);
//50s
DataLenOpt
.
Add
(
10000
);
DataLenOpt
.
Add
(
10000
);
//100s
DataLenOpt
.
Add
(
20000
);
DataLenOpt
.
Add
(
20000
);
//200s
DataLenOpt
.
Add
(
50000
);
//500s
}
}
else
if
(
graphparam_clone
.
Interval
<=
50
)
else
if
(
graphparam_clone
.
Interval
<=
50
)
{
{
DataLenOpt
.
Add
(
500
);
DataLenOpt
.
Add
(
500
);
//25s
DataLenOpt
.
Add
(
1000
);
DataLenOpt
.
Add
(
1000
);
//50s
DataLenOpt
.
Add
(
2000
);
DataLenOpt
.
Add
(
2000
);
//100s
DataLenOpt
.
Add
(
4000
);
DataLenOpt
.
Add
(
5000
);
//250s
DataLenOpt
.
Add
(
10000
);
DataLenOpt
.
Add
(
10000
);
//500s
DataLenOpt
.
Add
(
20000
);
DataLenOpt
.
Add
(
20000
);
//16.6min
}
}
else
if
(
graphparam_clone
.
Interval
<=
100
)
else
if
(
graphparam_clone
.
Interval
<=
100
)
{
{
DataLenOpt
.
Add
(
500
);
DataLenOpt
.
Add
(
500
);
//50s
DataLenOpt
.
Add
(
1000
);
DataLenOpt
.
Add
(
1000
);
//100s
DataLenOpt
.
Add
(
2000
);
DataLenOpt
.
Add
(
2000
);
//200s
DataLenOpt
.
Add
(
4000
);
DataLenOpt
.
Add
(
5000
);
//500s
DataLenOpt
.
Add
(
10000
);
//16.6min
}
}
else
else
{
{
DataLenOpt
.
Add
(
500
);
DataLenOpt
.
Add
(
50
);
//50s
DataLenOpt
.
Add
(
1000
);
DataLenOpt
.
Add
(
100
);
//100s
DataLenOpt
.
Add
(
2000
);
DataLenOpt
.
Add
(
200
);
//200s
DataLenOpt
.
Add
(
500
);
//500s
DataLenOpt
.
Add
(
1000
);
//16.6min
}
}
...
@@ -234,10 +244,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -234,10 +244,7 @@ namespace FLY.Thick.Base.UI.UiModule
double
total_ms
;
double
total_ms
;
if
(
ms
<
10
)
total_ms
=
ms
*
len
;
total_ms
=
(
1.28
*
ms
)
*
len
;
else
total_ms
=
ms
*
len
;
TimeSpan
ts
=
TimeSpan
.
FromTicks
((
long
)(
TimeSpan
.
TicksPerMillisecond
*
total_ms
));
TimeSpan
ts
=
TimeSpan
.
FromTicks
((
long
)(
TimeSpan
.
TicksPerMillisecond
*
total_ms
));
return
ts
.
TotalSeconds
.
ToString
(
"F1"
)
+
"s"
;
return
ts
.
TotalSeconds
.
ToString
(
"F1"
)
+
"s"
;
//DateTime dt = new DateTime((long)(TimeSpan.TicksPerMillisecond * total_ms));
//DateTime dt = new DateTime((long)(TimeSpan.TicksPerMillisecond * total_ms));
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/UiModule/FixGraph/FixGraphItemParam.cs
View file @
c4205399
...
@@ -34,7 +34,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -34,7 +34,7 @@ namespace FLY.Thick.Base.UI.UiModule
private
int
interval
=
1000
;
private
int
interval
=
1000
;
/// <summary>
/// <summary>
/// 间隔,只能选 1, 10, 100, 1000, 这些单位;
/// 间隔,只能选 1, 10, 100, 1000, 这些单位;
///
特别的,1 = 1.28
ms,10=10ms,100=100ms
///
1 = 1
ms,10=10ms,100=100ms
/// </summary>
/// </summary>
public
int
Interval
public
int
Interval
{
{
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/UiModule/FixGraph/FixGraphVm.cs
View file @
c4205399
...
@@ -115,7 +115,6 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -115,7 +115,6 @@ namespace FLY.Thick.Base.UI.UiModule
IFixService
fixService
;
IFixService
fixService
;
FixGraphItemParam
graphparam
;
FixGraphItemParam
graphparam
;
DateTime
updateTime
;
public
FixGraphVm
()
public
FixGraphVm
()
{
{
#
region
与数据无关界面参数
#
region
与数据无关界面参数
...
@@ -123,7 +122,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -123,7 +122,7 @@ namespace FLY.Thick.Base.UI.UiModule
{
{
int
index
=
(
int
)
x
;
int
index
=
(
int
)
x
;
double
s
=
Interval
.
TotalSeconds
*
index
*
values_scale
;
double
s
=
Interval
.
TotalSeconds
*
index
*
values_scale
;
return
$"
{
s
:
F
1
}
s"
;
return
$"
{
s
:
F
0
}
s"
;
};
};
YFormatter
=
(
y
)
=>
y
.
ToString
(
"F1"
);
YFormatter
=
(
y
)
=>
y
.
ToString
(
"F1"
);
...
@@ -147,19 +146,15 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -147,19 +146,15 @@ namespace FLY.Thick.Base.UI.UiModule
{
{
if
(
e
.
PropertyName
==
nameof
(
fixService
.
UpdateTime
))
if
(
e
.
PropertyName
==
nameof
(
fixService
.
UpdateTime
))
{
{
//检测是哪个变化了
//变化了
if
(
fixService
.
UpdateTime
!=
updateTime
)
//向服务获取数据
{
fixService
.
GetFixDatas
(
fixService_GetFixDatas
,
this
);
//变化了
//向服务获取数据
fixService
.
GetFixDatas
(
fixService_GetFixDatas
,
this
);
}
}
}
}
}
private
void
FixGraphViewModel_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
private
void
FixGraphViewModel_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
{
if
(
e
.
PropertyName
==
"AutoTarget"
)
if
(
e
.
PropertyName
==
nameof
(
AutoTarget
)
)
{
{
updateAutoTarget
();
updateAutoTarget
();
}
}
...
@@ -189,26 +184,26 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -189,26 +184,26 @@ namespace FLY.Thick.Base.UI.UiModule
}
}
private
void
Graphparam_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
private
void
Graphparam_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
{
if
(
e
.
PropertyName
==
"Interval"
)
if
(
e
.
PropertyName
==
nameof
(
graphparam
.
Interval
)
)
{
{
UpdateInterval
();
UpdateInterval
();
}
}
else
if
(
e
.
PropertyName
==
"Mix"
)
else
if
(
e
.
PropertyName
==
nameof
(
graphparam
.
Mix
)
)
{
{
UpdateMix
();
UpdateMix
();
}
}
else
if
(
e
.
PropertyName
==
"Len"
)
else
if
(
e
.
PropertyName
==
nameof
(
graphparam
.
Len
)
)
{
{
UpdateX
();
UpdateX
();
}
}
else
if
((
e
.
PropertyName
==
"IsAutoY"
)
||
else
if
((
e
.
PropertyName
==
nameof
(
graphparam
.
IsAutoY
)
)
||
(
e
.
PropertyName
==
"IsAutoTarget"
)
||
(
e
.
PropertyName
==
nameof
(
graphparam
.
IsAutoTarget
)
)
||
(
e
.
PropertyName
==
"YRange"
)
||
(
e
.
PropertyName
==
nameof
(
graphparam
.
YRange
)
)
||
(
e
.
PropertyName
==
"YTarget"
))
(
e
.
PropertyName
==
nameof
(
graphparam
.
YTarget
)
))
{
{
UpdateY
();
UpdateY
();
}
}
else
if
(
e
.
PropertyName
==
"IsADMode"
)
else
if
(
e
.
PropertyName
==
nameof
(
graphparam
.
IsADMode
)
)
{
{
UpdateIsADMode
();
UpdateIsADMode
();
}
}
...
@@ -257,10 +252,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -257,10 +252,7 @@ namespace FLY.Thick.Base.UI.UiModule
void
UpdateInterval
()
void
UpdateInterval
()
{
{
TimeSpan
interval
;
TimeSpan
interval
;
if
(
graphparam
.
Interval
<
10
)
interval
=
TimeSpan
.
FromTicks
((
long
)(
graphparam
.
Interval
*
TimeSpan
.
TicksPerMillisecond
));
interval
=
TimeSpan
.
FromTicks
((
long
)(
graphparam
.
Interval
*
TimeSpan
.
TicksPerMillisecond
*
1.28
));
else
interval
=
TimeSpan
.
FromTicks
((
long
)(
graphparam
.
Interval
*
TimeSpan
.
TicksPerMillisecond
));
Interval
=
interval
;
Interval
=
interval
;
Intervalms
=
((
double
)(
Interval
.
Ticks
))
/
TimeSpan
.
TicksPerMillisecond
;
Intervalms
=
((
double
)(
Interval
.
Ticks
))
/
TimeSpan
.
TicksPerMillisecond
;
}
}
...
@@ -389,9 +381,12 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -389,9 +381,12 @@ namespace FLY.Thick.Base.UI.UiModule
{
{
double
avg
=
data_interval
.
Average
();
double
avg
=
data_interval
.
Average
();
data_interval
.
Clear
();
data_interval
.
Clear
();
data_interval_totaltime
-=
Interval
;
do
{
data_interval_totaltime
-=
Interval
;
data_mix
.
Add
(
avg
);
}
while
(
data_interval_totaltime
>=
Interval
);
//当 reponse.ts = 1.28, Interval=1时,需要添加更多的数据
data_mix
.
Add
(
avg
);
int
len
=
data_mix
.
Count
-
graphparam
.
Mix
;
int
len
=
data_mix
.
Count
-
graphparam
.
Mix
;
if
(
len
>
0
)
if
(
len
>
0
)
data_mix
.
RemoveRange
(
0
,
len
);
data_mix
.
RemoveRange
(
0
,
len
);
...
@@ -489,16 +484,14 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -489,16 +484,14 @@ namespace FLY.Thick.Base.UI.UiModule
{
{
using
(
StreamWriter
sw
=
new
StreamWriter
(
path
,
false
,
Encoding
.
GetEncoding
(
"GB2312"
)))
using
(
StreamWriter
sw
=
new
StreamWriter
(
path
,
false
,
Encoding
.
GetEncoding
(
"GB2312"
)))
{
{
double
ms
=
graphparam
.
Interval
;
int
ms
=
graphparam
.
Interval
;
if
(
ms
<
10
)
ms
*=
1.28
;
if
(
IsADMode
)
if
(
IsADMode
)
{
{
sw
.
WriteLine
(
"时间(ms),AD"
);
sw
.
WriteLine
(
"时间(ms),AD"
);
for
(
int
i
=
0
;
i
<
mDatas
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
mDatas
.
Count
();
i
++)
{
{
double
d
=
mDatas
[
i
];
double
d
=
mDatas
[
i
];
sw
.
WriteLine
(
$"
{(
i
*
ms
)
:
F2
}
,
{
d
:
F0
}
"
);
sw
.
WriteLine
(
$"
{(
i
*
ms
)}
,
{
d
:
F0
}
"
);
}
}
}
}
else
else
...
@@ -507,7 +500,7 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -507,7 +500,7 @@ namespace FLY.Thick.Base.UI.UiModule
for
(
int
i
=
0
;
i
<
mDatas
.
Count
();
i
++)
for
(
int
i
=
0
;
i
<
mDatas
.
Count
();
i
++)
{
{
double
d
=
mDatas
[
i
];
double
d
=
mDatas
[
i
];
sw
.
WriteLine
(
$"
{(
i
*
ms
)
:
F2
}
,
{
d
:
F2
}
"
);
sw
.
WriteLine
(
$"
{(
i
*
ms
)}
,
{
d
:
F2
}
"
);
}
}
}
}
sw
.
Flush
();
sw
.
Flush
();
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/UiModule/FixGraph/PgFixAnalyze.xaml
View file @
c4205399
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:FLY.Thick.Base.UI.UiModule"
xmlns:local="clr-namespace:FLY.Thick.Base.UI.UiModule"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DesignHeight="450" d:DesignWidth="800"
Background="White"
Background="White"
...
@@ -26,12 +26,10 @@
...
@@ -26,12 +26,10 @@
<Grid.RowDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<lvc:CartesianChart Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="10" MouseDown="UIElement_OnMouseDown">
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<lvc:CartesianChart Grid.Column="1" Hoverable="False" DisableAnimations="True" DataTooltip="{x:Null}" Margin="10" MouseDown="UIElement_OnMouseDown">
<lvc:CartesianChart.Series>
<lvc:CartesianChart.Series>
<lvc:LineSeries
<lvc:LineSeries
Values="{Binding Values}"
Values="{Binding Values}"
...
@@ -69,45 +67,27 @@
...
@@ -69,45 +67,27 @@
</lvc:Axis>
</lvc:Axis>
</lvc:CartesianChart.AxisY >
</lvc:CartesianChart.AxisY >
</lvc:CartesianChart>
</lvc:CartesianChart>
<Grid Grid.Column="1" Grid.Row="1" Margin="10,0,10,10">
<Controls:RangeSlider Grid.Row="1"
Margin="5"
Controls:SliderHelper.ChangeValueBy="LargeChange"
Controls:SliderHelper.EnableMouseWheel="MouseHover"
AutoToolTipPlacement="TopLeft"
LargeChange="10"
Maximum="{Binding XRangeSliderMax}"
Minimum="{Binding XRangeSliderMin}"
Orientation="Horizontal"
SmallChange="1"
LowerValue="{Binding LowerValue}"
UpperValue="{Binding UpperValue}" />
<Grid Grid.Row="2" Margin="{StaticResource ControlMargin}">
<Grid.ColumnDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="X轴最小" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding HzMin}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="Hz"/>
<Button Style="{StaticResource ButtonStyle_empty}" Click="ButtonResetXMinClick" VerticalAlignment="Top">
<Button Style="{StaticResource Styles.Button.Square2}" Grid.Column="1" Click="ButtonTestClick" Content="测试"/>
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="复位" Background="{StaticResource Color_theme_activity}" Foreground="White" Padding="3"/>
</Grid>
</Button>
</StackPanel>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="X轴最大" />
<StackPanel Orientation="Horizontal">
<TextBox Style="{StaticResource ResourceKey=TextBoxStyle_FieldContent}" Text="{Binding HzMax}" />
<TextBlock Style="{StaticResource TextBlockStyle_FieldContent_mm}" Text="Hz"/>
<Button Style="{StaticResource ButtonStyle_empty}" Click="ButtonResetXMaxClick" VerticalAlignment="Top">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="复位" Background="{StaticResource Color_theme_activity}" Foreground="White" Padding="3"/>
</Grid>
</Button>
</StackPanel>
</StackPanel>
</StackPanel>
<Button Style="{StaticResource ButtonStyle_empty}" Click="ButtonTestClick" Grid.Column="1">
<Grid Style="{StaticResource GridStyle_ButtonShadow}">
<TextBlock Style="{StaticResource ResourceKey=TextBlockStyle_FieldHeaderEditable}" Text="测试" VerticalAlignment="Bottom" Background="{StaticResource Color_theme_noact}" Foreground="White" Padding="10"/>
</Grid>
</Button>
</Grid>
</Grid>
</Grid>
</Grid>
...
...
Project.FLY.Thick.Base/FLY.Thick.Base.UI/UiModule/FixGraph/PgFixAnalyze.xaml.cs
View file @
c4205399
...
@@ -12,7 +12,7 @@ using System.Windows.Media;
...
@@ -12,7 +12,7 @@ using System.Windows.Media;
using
System.Windows.Media.Imaging
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
using
System.Windows.Shapes
;
using
System.Windows.Threading
;
using
LiveCharts
;
using
LiveCharts
;
using
LiveCharts.Configurations
;
using
LiveCharts.Configurations
;
using
LiveCharts.Helpers
;
using
LiveCharts.Helpers
;
...
@@ -56,14 +56,6 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -56,14 +56,6 @@ namespace FLY.Thick.Base.UI.UiModule
vm
.
XPointer
=
p
.
X
;
vm
.
XPointer
=
p
.
X
;
}
}
private
void
ButtonResetXMinClick
(
object
sender
,
RoutedEventArgs
e
)
{
viewModel
.
HzMin
=
double
.
NaN
;
}
private
void
ButtonResetXMaxClick
(
object
sender
,
RoutedEventArgs
e
)
{
viewModel
.
HzMax
=
double
.
NaN
;
}
private
void
ButtonTestClick
(
object
sender
,
RoutedEventArgs
e
)
private
void
ButtonTestClick
(
object
sender
,
RoutedEventArgs
e
)
{
{
...
@@ -90,74 +82,41 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -90,74 +82,41 @@ namespace FLY.Thick.Base.UI.UiModule
}
}
public
class
PgFixAnalyzeVm
:
INotifyPropertyChanged
public
class
PgFixAnalyzeVm
:
INotifyPropertyChanged
{
{
public
double
XMax
{
get
{
if
(
double
.
IsNaN
(
HzMax
))
return
HzMax
;
else
{
return
HzMax
/
MinFs
;
}
}
}
public
double
XMin
{
get
{
if
(
double
.
IsNaN
(
HzMin
))
return
HzMin
;
else
{
return
HzMin
/
MinFs
;
}
}
}
public
double
YMax
{
get
;
set
;
}
=
double
.
NaN
;
/// <summary>
public
double
YMin
{
get
;
set
;
}
=
double
.
NaN
;
/// X轴拖拉条 最大值
/// </summary>
public
double
XRangeSliderMax
{
get
;
set
;
}
=
10000
;
private
double
hzMax
=
double
.
NaN
;
/// <summary>
public
double
HzMax
/// X轴拖拉条 最小值
{
/// </summary>
get
{
public
double
XRangeSliderMin
{
get
;
set
;
}
=
0
;
return
hzMax
;
}
set
{
if
(
double
.
IsNaN
(
HzMin
)
&&
double
.
IsNaN
(
value
)
&&
(
value
<=
HzMin
))
return
;
if
(
hzMax
!=
value
)
{
hzMax
=
value
;
}
}
}
private
double
hzMin
=
double
.
NaN
;
public
double
HzMin
{
get
{
return
hzMin
;
}
set
{
if
(
double
.
IsNaN
(
HzMax
)
&&
double
.
IsNaN
(
value
)
&&
(
value
<=
HzMax
))
return
;
if
(
hzMin
!=
value
)
/// <summary>
{
/// X轴 最大值
hzMin
=
value
;
/// </summary>
}
public
double
XMax
{
get
;
set
;
}
=
1000
;
}
}
/// <summary>
/// X轴 最小值
/// </summary>
public
double
XMin
{
get
;
set
;
}
public
double
LowerValue
{
get
;
set
;
}
public
double
UpperValue
{
get
;
set
;
}
public
double
YMax
{
get
;
set
;
}
=
double
.
NaN
;
public
double
YMin
{
get
;
set
;
}
=
double
.
NaN
;
public
double
YPointer
{
get
;
set
;
}
=
3
;
public
double
YPointer
{
get
;
set
;
}
=
3
;
public
double
XPointer
{
get
;
set
;
}
=
3
;
public
double
XPointer
{
get
;
set
;
}
=
3
;
public
ChartValues
<
double
>
Values
{
get
;
private
set
;
}
=
new
ChartValues
<
double
>();
public
ChartValues
<
double
>
Values
{
get
;
private
set
;
}
=
new
ChartValues
<
double
>();
public
Func
<
double
,
string
>
XFormatter
{
get
;
private
set
;
}
public
Func
<
double
,
string
>
XFormatter
{
get
;
private
set
;
}
DispatcherTimer
timer
;
public
void
Test
()
public
void
Test
()
{
{
List
<
double
>
datas
=
new
List
<
double
>();
List
<
double
>
datas
=
new
List
<
double
>();
...
@@ -177,7 +136,6 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -177,7 +136,6 @@ namespace FLY.Thick.Base.UI.UiModule
}
}
Init
(
intervalms
,
datas
);
Init
(
intervalms
,
datas
);
//XMax = 1000;
}
}
double
getd
(
double
hz
,
double
ms
,
int
i
)
double
getd
(
double
hz
,
double
ms
,
int
i
)
{
{
...
@@ -187,8 +145,33 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -187,8 +145,33 @@ namespace FLY.Thick.Base.UI.UiModule
public
PgFixAnalyzeVm
()
public
PgFixAnalyzeVm
()
{
{
timer
=
new
DispatcherTimer
();
timer
.
Interval
=
TimeSpan
.
FromSeconds
(
1
);
timer
.
Tick
+=
Timer_Tick
;
this
.
PropertyChanged
+=
PgFixAnalyzeVm_PropertyChanged
;
}
private
void
PgFixAnalyzeVm_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
e
.
PropertyName
==
nameof
(
UpperValue
)
||
e
.
PropertyName
==
nameof
(
LowerValue
))
{
if
(!
timer
.
IsEnabled
)
timer
.
Start
();
}
}
private
void
Timer_Tick
(
object
sender
,
EventArgs
e
)
{
timer
.
Stop
();
if
(
LowerValue
<
UpperValue
)
{
XMax
=
UpperValue
;
XMin
=
LowerValue
;
}
}
}
List
<
double
>
Magnitudes
=
new
List
<
double
>();
public
double
MinFs
{
get
;
private
set
;
}
=
0.1
;
public
double
MinFs
{
get
;
private
set
;
}
=
0.1
;
public
void
Init
(
double
intervalms
,
List
<
double
>
datas
)
public
void
Init
(
double
intervalms
,
List
<
double
>
datas
)
{
{
...
@@ -208,12 +191,18 @@ namespace FLY.Thick.Base.UI.UiModule
...
@@ -208,12 +191,18 @@ namespace FLY.Thick.Base.UI.UiModule
MathNet
.
Numerics
.
IntegralTransforms
.
Fourier
.
Forward
(
complexs
);
MathNet
.
Numerics
.
IntegralTransforms
.
Fourier
.
Forward
(
complexs
);
complexs
[
0
]
=
new
System
.
Numerics
.
Complex
(
0
,
0
);
complexs
[
0
]
=
new
System
.
Numerics
.
Complex
(
0
,
0
);
Magnitudes
.
Clear
();
for
(
int
i
=
0
;
i
<
datas
.
Count
()
/
2
;
i
++)
Magnitudes
.
AddRange
(
complexs
.
Take
(
complexs
.
Count
()
/
2
).
Select
(
c
=>
c
.
Magnitude
));
{
Values
.
Add
(
complexs
[
i
].
Magnitude
);
Values
.
AddRange
(
Magnitudes
);
}
XRangeSliderMax
=
Values
.
Count
();
XRangeSliderMin
=
0
;
UpperValue
=
XRangeSliderMax
;
LowerValue
=
0
;
}
}
public
event
PropertyChangedEventHandler
PropertyChanged
;
public
event
PropertyChangedEventHandler
PropertyChanged
;
protected
void
ToPropertyChanged
(
string
propertyName
)
{
PropertyChanged
?.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
propertyName
));
}
}
}
}
}
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