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
b29fe1ad
Commit
b29fe1ad
authored
Oct 29, 2023
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加 FlyAd2021.B2 按序号获取 脉冲
parent
5dd2a75d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
179 additions
and
0 deletions
+179
-0
TimeGridAdvHelper.cs
Project.FLY.FlyADBase/FlyAd2021.B2/TimeGridAdvHelper.cs
+179
-0
No files found.
Project.FLY.FlyADBase/FlyAd2021.B2/TimeGridAdvHelper.cs
View file @
b29fe1ad
...
...
@@ -502,6 +502,14 @@ namespace FlyADBase
else
return
pos2
;
}
public
int
GetPosByIndex
(
int
index
)
{
if
(
index
==
0
)
return
pos
;
else
return
pos2
;
}
public
override
string
ToString
()
{
return
$"ad=
{
ad
}
| ad2=
{
ad2
}
| p=
{
pos
}
| p2=
{
pos2
}
| i=
{
istatus
:
X4
}
"
;
...
...
@@ -653,6 +661,78 @@ namespace FlyADBase
return
(
endPoint
.
GetPos
(
posNo
)
-
beginPoint
.
GetPos
(
posNo
))
/
((
end_idx
-
begin_idx
)
/
60000.0
);
}
/// <summary>
/// 获取平均速度, 单位 脉冲/min
/// </summary>
/// <param name="posPool">脉冲缓存区</param>
/// <param name="begin">开始时间点</param>
/// <param name="end">结束时间点</param>
/// <returns></returns>
public
static
double
GetSpeedByIndex
(
List
<
DateTimeUnit5
>
dataPool
,
DateTime
newestTime
,
DateTime
begin
,
DateTime
end
,
int
posIndex
)
{
if
(
posIndex
!=
0
&&
posIndex
!=
1
)
throw
new
Exception
(
$"写错程序 GetSpeedByIndex posIndex=
{
posIndex
}
只能是0 或 1"
);
int
begin_idx
=
dataPool
.
Count
()
-
(
int
)(
newestTime
-
begin
).
TotalMilliseconds
;
int
end_idx
=
dataPool
.
Count
()
-
(
int
)(
newestTime
-
end
).
TotalMilliseconds
;
if
(
begin_idx
<
0
)
begin_idx
=
0
;
if
(
end_idx
>
dataPool
.
Count
()
-
1
)
end_idx
=
dataPool
.
Count
()
-
1
;
var
beginPoint
=
dataPool
[
begin_idx
];
var
endPoint
=
dataPool
[
end_idx
];
return
(
endPoint
.
GetPosByIndex
(
posIndex
)
-
beginPoint
.
GetPosByIndex
(
posIndex
))
/
((
end_idx
-
begin_idx
)
/
60000.0
);
}
/// <summary>
/// 获取平均速度, 单位 脉冲/min
/// </summary>
/// <param name="posPool">脉冲缓存区</param>
/// <param name="begin">开始时间点</param>
/// <param name="end">结束时间点</param>
/// <returns></returns>
public
static
double
GetSpeed
(
List
<
DateTimeUnit5
>
dataPool
,
int
dataLen
,
int
posNo
)
{
if
(
posNo
!=
1
&&
posNo
!=
2
)
throw
new
Exception
(
$"写错程序 GetSpeed posNo=
{
posNo
}
只能是1 或 2"
);
int
begin_idx
=
dataPool
.
Count
()
-
dataLen
;
int
end_idx
=
dataPool
.
Count
()
-
1
;
if
(
begin_idx
<
0
)
begin_idx
=
0
;
if
(
end_idx
>
dataPool
.
Count
()
-
1
)
end_idx
=
dataPool
.
Count
()
-
1
;
var
beginPoint
=
dataPool
[
begin_idx
];
var
endPoint
=
dataPool
[
end_idx
];
return
(
endPoint
.
GetPos
(
posNo
)
-
beginPoint
.
GetPos
(
posNo
))
/
((
end_idx
-
begin_idx
)
/
60000.0
);
}
/// <summary>
/// 获取平均速度, 单位 脉冲/min
/// </summary>
/// <param name="posPool">脉冲缓存区</param>
/// <param name="begin">开始时间点</param>
/// <param name="end">结束时间点</param>
/// <returns></returns>
public
static
double
GetSpeedByIndex
(
List
<
DateTimeUnit5
>
dataPool
,
int
dataLen
,
int
posIndex
)
{
if
(
posIndex
!=
0
&&
posIndex
!=
1
)
throw
new
Exception
(
$"写错程序 GetSpeed posIndex=
{
posIndex
}
只能是0 或 1"
);
int
begin_idx
=
dataPool
.
Count
()
-
dataLen
;
int
end_idx
=
dataPool
.
Count
()
-
1
;
if
(
begin_idx
<
0
)
begin_idx
=
0
;
if
(
end_idx
>
dataPool
.
Count
()
-
1
)
end_idx
=
dataPool
.
Count
()
-
1
;
var
beginPoint
=
dataPool
[
begin_idx
];
var
endPoint
=
dataPool
[
end_idx
];
return
(
endPoint
.
GetPosByIndex
(
posIndex
)
-
beginPoint
.
GetPosByIndex
(
posIndex
))
/
((
end_idx
-
begin_idx
)
/
60000.0
);
}
/// <summary>
/// 获取时间对应的 位置点
/// </summary>
...
...
@@ -674,7 +754,27 @@ namespace FlyADBase
var
point
=
dataPool
[
idx
];
return
point
.
GetPos
(
posNo
);
}
/// <summary>
/// 获取时间对应的 位置点
/// </summary>
/// <param name="dt"></param>
/// <param name="posPool">脉冲缓存池</param>
/// <param name="searchIdx">查询开始序号</param>
/// <returns></returns>
public
static
int
GetPosByIndex
(
List
<
DateTimeUnit5
>
dataPool
,
DateTime
newestTime
,
DateTime
dt
,
int
posIndex
)
{
if
(
posIndex
!=
0
&&
posIndex
!=
1
)
throw
new
Exception
(
$"写错程序 GetSpeed posIndex=
{
posIndex
}
只能是0 或 1"
);
int
idx
=
dataPool
.
Count
()
-
(
int
)((
newestTime
-
dt
).
TotalMilliseconds
);
if
(
idx
<
0
)
idx
=
0
;
if
(
idx
>
dataPool
.
Count
()
-
1
)
idx
=
dataPool
.
Count
()
-
1
;
var
point
=
dataPool
[
idx
];
return
point
.
GetPosByIndex
(
posIndex
);
}
/// <summary>
/// 输出 grid图。 dataPool[x+ad0Lag].ad 对应 dataPool[x].position
...
...
@@ -894,6 +994,85 @@ namespace FlyADBase
}
}
}
/// <summary>
/// <para>data0s 的 输入口=false 序号范围</para>
/// <para>data1s 的 输入口=true 序号范围</para>
/// </summary>
/// <param name="dataPool">数据池</param>
/// <param name="newestTime">数据池最后一个数据时间</param>
/// <param name="istatusIndex">输入口序号</param>
/// <param name="beginTime">开始时间</param>
/// <param name="endTime">结束时间</param>
/// <param name="data0s">输入口=false 序号范围<</param>
/// <param name="data1s">输入口=true 序号范围</param>
public
static
void
GetIStatusRange
(
List
<
DateTimeUnit5
>
dataPool
,
int
istatusIndex
,
int
dataLen
,
out
List
<
Range
>
data0s
,
out
List
<
Range
>
data1s
)
{
data0s
=
new
List
<
Range
>();
data1s
=
new
List
<
Range
>();
Range
range
=
new
Range
();
bool
is1
=
false
;
int
begin_idx
=
dataPool
.
Count
()
-
dataLen
;
if
(
begin_idx
<
0
)
begin_idx
=
0
;
if
(
begin_idx
>
dataPool
.
Count
()
-
1
)
begin_idx
=
dataPool
.
Count
()
-
1
;
int
end_idx
=
dataPool
.
Count
()
-
1
;
for
(
int
i
=
begin_idx
;
i
<=
end_idx
;
i
++)
{
var
data
=
dataPool
[
i
];
bool
istatus_bit
=
Misc
.
MyBase
.
CHECKBIT
(
data
.
istatus
,
istatusIndex
);
if
(!
range
.
IsValid
)
{
//第1次
range
.
Begin
=
i
;
range
.
End
=
i
;
is1
=
istatus_bit
;
if
(
is1
)
{
data1s
.
Add
(
range
);
}
else
{
data0s
.
Add
(
range
);
}
}
else
{
if
(
istatus_bit
==
is1
)
{
//信号一样
range
.
End
=
i
;
}
else
{
//信号改变了
range
=
new
Range
();
range
.
Begin
=
i
;
range
.
End
=
i
;
is1
=
istatus_bit
;
if
(
is1
)
{
data1s
.
Add
(
range
);
}
else
{
data0s
.
Add
(
range
);
}
}
}
}
}
}
public
class
Range_DateTime
{
...
...
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