Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hemei
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
潘栩锋
hemei
Commits
72e637f3
Commit
72e637f3
authored
May 16, 2022
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 下吹记录旋转总脉冲到文件。开机加载。当刚开机,在复位状态时, 直接写入 位置
parent
a852e41a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
4 deletions
+110
-4
PgMain.xaml
...ect.FLY.DownBlowing/FLY.DownBlowing.UI.Server/PgMain.xaml
+6
-0
RotarySystem.cs
...ct.FLY.DownBlowing/FLY.DownBlowing/Server/RotarySystem.cs
+104
-4
No files found.
Project.FLY.DownBlowing/FLY.DownBlowing.UI.Server/PgMain.xaml
View file @
72e637f3
...
...
@@ -157,6 +157,12 @@
<Run FontSize="20" Text="{Binding RPosOfR,StringFormat={}{0:F0}}"/>p
</TextBlock>
</StackPanel>
<StackPanel Margin="4" >
<TextBlock Text="1圈时间" />
<TextBlock>
<Run FontSize="20" Text="{Binding MinuteOfR,StringFormat={}{0:F1}}"/>min
</TextBlock>
</StackPanel>
<Button Content="配置" Padding="20,5" Margin="5" HorizontalAlignment="Left" Click="btnRotaryClick"></Button>
</StackPanel>
</StackPanel>
...
...
Project.FLY.DownBlowing/FLY.DownBlowing/Server/RotarySystem.cs
View file @
72e637f3
...
...
@@ -21,6 +21,13 @@ namespace FLY.DownBlowing.Server
/// 方向相反
/// </summary>
public
bool
IsReversed
{
get
;
set
;
}
=
true
;
/// <summary>
/// 最小一圈脉冲
/// </summary>
const
int
MinRPosOfR
=
8000
;
#
region
状态
/// <summary>
/// 正方向运行 (逆时针旋转 counter-clockwise)
...
...
@@ -57,6 +64,11 @@ namespace FLY.DownBlowing.Server
/// </summary>
public
double
RSpeed
{
get
;
set
;
}
/// <summary>
/// 1圈分钟数 RPosOfR/RSpeed/60.0
/// </summary>
public
double
MinuteOfR
{
get
;
set
;
}
=
double
.
NaN
;
/// <summary>
/// 旋转塔顺时针换向信号发生时, 旋转架脉冲 (小值)
/// </summary>
...
...
@@ -81,8 +93,8 @@ namespace FLY.DownBlowing.Server
///旋转架全局脉冲, 当前旋转架脉冲 = GlobalRPos - OrgRPos;
/// </summary>
public
double
RPosGlobal
{
get
;
set
;
}
=
0
;
public
double
RPosOfR
{
get
;
set
;
}
=
10000
;
public
double
RPosOfR
{
get
;
set
;
}
=
MinRPosOfR
;
public
double
Angle
{
get
;
set
;
}
/// <summary>
...
...
@@ -103,7 +115,7 @@ namespace FLY.DownBlowing.Server
WinderAccessory
winderAccessory
;
DispatcherTimer
dispatcherTimer
;
Stopwatch
stopwatch_rpos
;
double
rposOfRInFile
;
public
RotarySystem
()
{
...
...
@@ -115,6 +127,18 @@ namespace FLY.DownBlowing.Server
if
(!
Load
())
Save
();
rposOfRInFile
=
LoadRPosOfR
();
if
(
double
.
IsNaN
(
rposOfRInFile
))
{
rposOfRInFile
=
14000
;
SaveRPosOfR
(
rposOfRInFile
);
}
if
(!
double
.
IsNaN
(
rposOfRInFile
)
&&
rposOfRInFile
>
MinRPosOfR
)
RPosOfR
=
rposOfRInFile
;
Misc
.
BindingOperations
.
SetBinding
(
winderAccessory
,
nameof
(
winderAccessory
.
T1Velocity
),
()
=>
{
TractionVelocity
=
winderAccessory
.
T1Velocity
;
...
...
@@ -136,6 +160,7 @@ namespace FLY.DownBlowing.Server
Misc
.
BindingOperations
.
SetBinding
(
winderAccessory
,
nameof
(
winderAccessory
.
RotaryFreqSet
),
()
=>
{
RotaryFreqSet
=
winderAccessory
.
RotaryFreqSet
;
updateMinuteOfR
();
});
Misc
.
BindingOperations
.
SetBinding
(
winderAccessory
,
nameof
(
winderAccessory
.
RotaryFreq
),
()
=>
...
...
@@ -182,6 +207,16 @@ namespace FLY.DownBlowing.Server
RSpeed
=
0
;
}
}
void
updateMinuteOfR
()
{
if
(
RotaryFreqSet
>
0
&&
RPosOfR
>=
MinRPosOfR
)
{
MinuteOfR
=
RPosOfR
/
RotaryFreqSet
/
60
;
}
else
{
MinuteOfR
=
double
.
NaN
;
}
}
private
void
DispatcherTimer_Tick
(
object
sender
,
EventArgs
e
)
{
double
totalSeconds
=
stopwatch_rpos
.
Elapsed
.
TotalSeconds
;
...
...
@@ -246,7 +281,22 @@ namespace FLY.DownBlowing.Server
if
(
IsTurnSign1
)
{
RPosAtTurnSign1
=
RPosGlobal
;
RPosOfR
=
RPosAtTurnSign1
-
RPosAtTurnSign0
;
double
rposOfR
=
RPosAtTurnSign1
-
RPosAtTurnSign0
;
if
(!
double
.
IsNaN
(
rposOfRInFile
))
{
if
(
Math
.
Abs
(
rposOfRInFile
-
rposOfR
)
>
rposOfRInFile
/
360
)
{
//变化量大于1°保存
rposOfRInFile
=
rposOfR
;
SaveRPosOfR
(
rposOfRInFile
);
}
}
else
{
rposOfRInFile
=
rposOfR
;
SaveRPosOfR
(
rposOfRInFile
);
}
RPosOfR
=
rposOfR
;
AddSign
(
1
);
}
}
...
...
@@ -278,6 +328,20 @@ namespace FLY.DownBlowing.Server
AddSign
(
20
);
}
}
else
{
if
(
IsOrgSign
)
{
//现在既不是正向,也不是反向
if
(
double
.
IsNaN
(
RPosAtOrgSign
))
{
//刚开机
RPosAtTurnSign0
=
RPosGlobal
-
RPosOfR
/
2
;
RPosAtOrgSign
=
RPosGlobal
;
RPosAtTurnSign1
=
RPosGlobal
+
RPosOfR
/
2
;
}
}
}
}
else
if
(
e
.
PropertyName
==
nameof
(
IsForw
))
{
...
...
@@ -301,6 +365,42 @@ namespace FLY.DownBlowing.Server
{
return
RotarySystemJsonDb
.
Load
(
this
,
filePath
);
}
void
SaveRPosOfR
(
double
rposOfR
)
{
string
file_path
=
"RPosOfR.json"
;
try
{
string
json
=
JsonConvert
.
SerializeObject
(
rposOfR
,
Formatting
.
Indented
);
File
.
WriteAllText
(
file_path
,
json
);
}
catch
{
//异常,没有json 编码失败
}
}
double
LoadRPosOfR
()
{
string
file_path
=
"RPosOfR.json"
;
if
(
File
.
Exists
(
file_path
))
{
try
{
string
json
=
File
.
ReadAllText
(
file_path
);
return
JsonConvert
.
DeserializeObject
<
double
>(
json
);
}
catch
{
//异常,没有json 解码失败
}
}
return
double
.
NaN
;
}
}
public
class
RotarySystemJsonDb
{
...
...
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