Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
IoTSharp
IoTSharp
提交
622fcf32
IoTSharp
项目概览
IoTSharp
/
IoTSharp
10 个月 前同步成功
通知
15
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
IoTSharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
622fcf32
编写于
6月 29, 2022
作者:
麦壳饼
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/IoTSharp/IoTSharp
上级
a40163a3
81ef9935
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
0 deletion
+75
-0
IoTSharp.TaskAction/RangerCheckExcutor.cs
IoTSharp.TaskAction/RangerCheckExcutor.cs
+75
-0
未找到文件。
IoTSharp.TaskAction/RangerCheckExcutor.cs
0 → 100644
浏览文件 @
622fcf32
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
namespace
IoTSharp.TaskAction
{
[
DisplayName
(
"用于增加范围属性的执行器"
)]
public
class
RangerCheckExcutor
:
ITaskAction
{
public
override
Task
<
TaskActionOutput
>
ExecuteAsync
(
TaskActionInput
_input
)
{
JObject
o
=
JsonConvert
.
DeserializeObject
(
_input
.
Input
)
as
JObject
;
var
config
=
JsonConvert
.
DeserializeObject
<
ModelExecutorConfig
>(
_input
.
ExecutorConfig
);
if
(
o
.
SelectToken
(
config
.
PointX
)
!=
null
&&
o
.
SelectToken
(
config
.
PointY
)
!=
null
)
{
var
point
=
new
Point
();
point
.
X
=
o
.
SelectToken
(
config
.
PointX
).
Value
<
double
>();
point
.
Y
=
o
.
SelectToken
(
config
.
PointY
).
Value
<
double
>();
if
(
PointInFeaces
(
point
,
config
.
Ranger
))
{
o
.
Add
(
"iswithinrange"
,
true
);
return
Task
.
FromResult
(
new
TaskActionOutput
()
{
ExecutionInfo
=
o
.
ToString
(),
ExecutionStatus
=
true
,
DynamicOutput
=
o
});
;
}
else
{
o
.
Add
(
"iswithinrange"
,
false
);
return
Task
.
FromResult
(
new
TaskActionOutput
()
{
ExecutionInfo
=
o
.
ToString
(),
ExecutionStatus
=
true
,
DynamicOutput
=
o
});
;
}
}
else
{
o
.
Add
(
"iswithinrange"
,
true
);
return
Task
.
FromResult
(
new
TaskActionOutput
()
{
ExecutionInfo
=
o
.
ToString
(),
ExecutionStatus
=
true
,
DynamicOutput
=
o
});
;
}
}
public
static
bool
PointInFeaces
(
Point
pnt
,
Point
[]
pntlist
)
{
if
(
pntlist
==
null
)
{
return
false
;
}
int
j
=
0
,
cnt
=
0
;
for
(
int
i
=
0
;
i
<
pntlist
.
Length
;
i
++)
{
j
=
(
i
==
pntlist
.
Length
-
1
)
?
0
:
j
+
1
;
if
((
pntlist
[
i
].
Y
!=
pntlist
[
j
].
Y
)
&&
(((
pnt
.
Y
>=
pntlist
[
i
].
Y
)
&&
(
pnt
.
Y
<
pntlist
[
j
].
Y
))
||
((
pnt
.
Y
>=
pntlist
[
j
].
Y
)
&&
(
pnt
.
Y
<
pntlist
[
i
].
Y
)))
&&
(
pnt
.
X
<
(
pntlist
[
j
].
X
-
pntlist
[
i
].
X
)
*
(
pnt
.
Y
-
pntlist
[
i
].
Y
)
/
(
pntlist
[
j
].
Y
-
pntlist
[
i
].
Y
)
+
pntlist
[
i
].
X
))
cnt
++;
}
return
(
cnt
%
2
>
0
)
?
true
:
false
;
}
private
class
ModelExecutorConfig
{
public
string
PointX
{
get
;
set
;
}
public
string
PointY
{
get
;
set
;
}
public
Point
[]
Ranger
{
get
;
set
;
}
}
public
class
Point
{
public
double
X
{
get
;
set
;
}
public
double
Y
{
get
;
set
;
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录