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
33cc7eba
Commit
33cc7eba
authored
Sep 20, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 FObjSys的asyncDelegate 全部都为 AsyncCBHandler
优化 FLY.OBJComponents 匹配 FObjSys的asyncDelegate 的修改 改变
parent
66d3c2b1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
66 additions
and
310 deletions
+66
-310
Reflect_SeviceClient.cs
Project.FLY.FObjSys/FObjBaseReflect/Reflect_SeviceClient.cs
+2
-2
FObjSys.cs
Project.FLY.FObjSys/FObjSys/FObjSys.cs
+23
-23
IFObj.cs
Project.FLY.FObjSys/FObjSys/IFObj.cs
+10
-10
IFObjSys.cs
Project.FLY.FObjSys/FObjSys/IFObjSys.cs
+3
-3
Transaction.cs
Project.FLY.FObjSys/FObjSys/Transaction.cs
+3
-3
BufferServiceClient.cs
...OBJComponents/OBJComponents/Client/BufferServiceClient.cs
+2
-2
PLCProxySystemServiceClient.cs
...nents/OBJComponents/Client/PLCProxySystemServiceClient.cs
+6
-6
RemoteHistorySerivceClient.cs
...onents/OBJComponents/Client/RemoteHistorySerivceClient.cs
+0
-248
SetPLCUpdatePlan.cs
...LY.OBJComponents/OBJComponents/Client/SetPLCUpdatePlan.cs
+4
-2
SyncPropServiceClient.cs
...JComponents/OBJComponents/Client/SyncPropServiceClient.cs
+2
-2
FLY.OBJComponents.csproj
....FLY.OBJComponents/OBJComponents/FLY.OBJComponents.csproj
+0
-1
IPLCProxySystemService.cs
...mponents/OBJComponents/IService/IPLCProxySystemService.cs
+5
-4
PLCProxySystem_OBJProxy.cs
.../OBJComponents/Server.OBJProxy/PLCProxySystem_OBJProxy.cs
+3
-2
PLCProxySystem.cs
....FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
+3
-2
No files found.
Project.FLY.FObjSys/FObjBaseReflect/Reflect_SeviceClient.cs
View file @
33cc7eba
...
...
@@ -407,7 +407,7 @@ namespace FObjBase.Reflect
pushInfoList
.
Clear
();
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
asyncDelegate
,
object
asyncContext
)
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
switch
(
funcid
)
{
...
...
@@ -427,7 +427,7 @@ namespace FObjBase.Reflect
string
json
=
Misc
.
Converter
.
BytesToString
(
retdata
);
var
rData
=
JsonConvert
.
DeserializeObject
<
Reflect_OBJ_INTERFACE
.
ReflectData
>(
json
);
request_CALL_MethodInvoke
(
rData
,
(
AsyncCBHandler
)
asyncDelegate
,
asyncContext
);
request_CALL_MethodInvoke
(
rData
,
asyncDelegate
,
asyncContext
);
}
break
;
}
...
...
Project.FLY.FObjSys/FObjSys/FObjSys.cs
View file @
33cc7eba
...
...
@@ -13,7 +13,7 @@ namespace FObjBase
}
/// <summary>
/// 建议使用方法:
/// 做为客户端,都使用 FObjSys.Current 连接不同的
客户端
/// 做为客户端,都使用 FObjSys.Current 连接不同的
服务器
/// 做为服务器,当要提供2个Obj服务, 应该要使用 Currents[index]
/// 这套逻辑已经潜入到 每个 FObj 中, FObj.CurrObjSys, 就是对应的 Obj服务
/// </summary>
...
...
@@ -323,7 +323,7 @@ namespace FObjBase
{
Transaction
tran
=
ts
.
First
();
Transactions
.
Remove
(
tran
);
PushCallFunction
(
s1
,
srcid
,
destid
,
magic
,
funcid
,
retdata
,
tran
.
AsyncDelegate
,
tran
.
Async
State
);
PushCallFunction
(
s1
,
srcid
,
destid
,
magic
,
funcid
,
retdata
,
tran
.
AsyncDelegate
,
tran
.
Async
Context
);
}
else
{
...
...
@@ -338,7 +338,7 @@ namespace FObjBase
{
PushAny
(
s1
,
destid
,
srcid
,
magic
,
infoid
,
funcid
,
retdata
,
null
,
null
);
}
void
PushAny
(
IFConn
s1
,
UInt32
destid
,
UInt32
srcid
,
UInt32
magic
,
UInt16
infoid
,
UInt16
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
void
PushAny
(
IFConn
s1
,
UInt32
destid
,
UInt32
srcid
,
UInt32
magic
,
UInt16
infoid
,
UInt16
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
if
((
retdata
!=
null
)
&&
(
retdata
.
Length
>
Transaction
.
PackSize
))
//参数太大,需要分包多次发送
{
...
...
@@ -358,15 +358,15 @@ namespace FObjBase
Buf
=
(
byte
[])
retdata
.
Clone
(),
InfoId
=
infoid
,
FuncID
=
funcid
,
AsyncDelegate
=
A
syncDelegate
,
Async
State
=
AsyncState
AsyncDelegate
=
a
syncDelegate
,
Async
Context
=
asyncContext
};
Transactions
.
Add
(
t
);
SendBigSize
(
s1
,
destid
,
srcid
,
magic
);
}
else
{
if
(
A
syncDelegate
!=
null
)
if
(
a
syncDelegate
!=
null
)
{
Transaction
t
=
new
Transaction
()
{
...
...
@@ -375,8 +375,8 @@ namespace FObjBase
Magic
=
magic
,
InfoId
=
infoid
,
FuncID
=
funcid
,
AsyncDelegate
=
A
syncDelegate
,
Async
State
=
AsyncState
AsyncDelegate
=
a
syncDelegate
,
Async
Context
=
asyncContext
};
Transactions
.
Add
(
t
);
}
...
...
@@ -599,9 +599,9 @@ namespace FObjBase
/// <param name="srcid">本地对象ID</param>
/// <param name="funcid">函数ID</param>
/// <param name="param">函数参数</param>
/// <param name="
A
syncDelegate">在其上调用异步调用的委托对象</param>
/// <param name="
AsyncState
">作为 BeginInvoke 方法调用的最后一个参数而提供的对象</param>
public
UInt32
CallFunctionEx
(
IFConn
s1
,
UInt32
destid
,
UInt32
srcid
,
UInt16
funcid
,
byte
[]
param
,
object
AsyncDelegate
,
object
AsyncState
)
/// <param name="
a
syncDelegate">在其上调用异步调用的委托对象</param>
/// <param name="
asyncContext
">作为 BeginInvoke 方法调用的最后一个参数而提供的对象</param>
public
UInt32
CallFunctionEx
(
IFConn
s1
,
UInt32
destid
,
UInt32
srcid
,
UInt16
funcid
,
byte
[]
param
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
if
(
s1
==
null
)
return
0
;
...
...
@@ -609,15 +609,15 @@ namespace FObjBase
UInt32
magic
=
GetFreeMagic
();
if
(
s1
is
FConnLocal
)
{
if
((
AsyncDelegate
!=
null
)
||
(
AsyncState
!=
null
))
//需要返回参数!!!
if
((
asyncDelegate
!=
null
)
||
(
asyncContext
!=
null
))
//需要返回参数!!!
{
Transaction
t
=
new
Transaction
()
{
Conn
=
s1
,
SrcObjID
=
destid
,
Magic
=
magic
,
AsyncDelegate
=
A
syncDelegate
,
Async
State
=
AsyncState
AsyncDelegate
=
a
syncDelegate
,
Async
Context
=
asyncContext
};
Transactions
.
Add
(
t
);
}
...
...
@@ -625,7 +625,7 @@ namespace FObjBase
return
magic
;
}
PushAny
(
s1
,
destid
,
srcid
,
magic
,
Proto
.
INFO_CALL_FUNCTION
,
funcid
,
param
,
AsyncDelegate
,
AsyncState
);
PushAny
(
s1
,
destid
,
srcid
,
magic
,
Proto
.
INFO_CALL_FUNCTION
,
funcid
,
param
,
asyncDelegate
,
asyncContext
);
return
magic
;
}
...
...
@@ -713,7 +713,7 @@ namespace FObjBase
if
(
tran
.
InfoId
==
Proto
.
INFO_PUSH_CALL_FUNCTION
)
{
//如果是callfunction, 引发进度事件
PushCallFunctionBigSizeStatus
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
tran
.
FuncID
,
tran
.
Size
,
tran
.
Position
,
tran
.
Async
State
);
PushCallFunctionBigSizeStatus
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
tran
.
FuncID
,
tran
.
Size
,
tran
.
Position
,
tran
.
Async
Context
);
}
...
...
@@ -730,13 +730,13 @@ namespace FObjBase
if
(
tran
.
InfoId
==
Proto
.
INFO_PUSH_CALL_FUNCTION
)
{
//如果是callfunction, 引发进度事件
PushCallFunctionBigSizeStatus
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
tran
.
FuncID
,
tran
.
Size
,
tran
.
Position
,
tran
.
Async
State
);
PushCallFunctionBigSizeStatus
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
tran
.
FuncID
,
tran
.
Size
,
tran
.
Position
,
tran
.
Async
Context
);
}
switch
(
tran
.
InfoId
)
{
case
Proto
.
INFO_PUSH_CALL_FUNCTION
:
PushCallFunction
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
tran
.
FuncID
,
tran
.
Buf
,
tran
.
AsyncDelegate
,
tran
.
Async
State
);
PushCallFunction
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
tran
.
FuncID
,
tran
.
Buf
,
tran
.
AsyncDelegate
,
tran
.
Async
Context
);
break
;
case
Proto
.
INFO_PUSH_GET_VALUE
:
PushGetValue
(
conn
,
p
.
srcid
,
p
.
destid
,
tran
.
FuncID
,
tran
.
Buf
);
...
...
@@ -1041,21 +1041,21 @@ namespace FObjBase
return
;
destobj
.
PushGetValue
(
from
,
srcid
,
infoid
,
infodata
);
}
void
PushCallFunction
(
IFConn
from
,
UInt32
srcid
,
UInt32
destid
,
UInt32
magic
,
UInt16
infoid
,
byte
[]
infodata
,
object
AsyncDelegate
,
object
AsyncState
)
void
PushCallFunction
(
IFConn
from
,
UInt32
srcid
,
UInt32
destid
,
UInt32
magic
,
UInt16
infoid
,
byte
[]
infodata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
IFObj
destobj
=
Find
(
destid
);
if
(
destobj
==
null
)
return
;
destobj
.
PushCallFunction
(
from
,
srcid
,
magic
,
infoid
,
infodata
,
AsyncDelegate
,
AsyncState
);
destobj
.
PushCallFunction
(
from
,
srcid
,
magic
,
infoid
,
infodata
,
asyncDelegate
,
asyncContext
);
}
void
PushCallFunctionBigSizeStatus
(
IFConn
from
,
UInt32
srcid
,
UInt32
destid
,
UInt32
magic
,
UInt16
infoid
,
int
total_size
,
int
download_size
,
object
AsyncState
)
void
PushCallFunctionBigSizeStatus
(
IFConn
from
,
UInt32
srcid
,
UInt32
destid
,
UInt32
magic
,
UInt16
infoid
,
int
total_size
,
int
download_size
,
object
asyncContext
)
{
IFObj
destobj
=
Find
(
destid
);
if
(
destobj
==
null
)
return
;
destobj
.
PushCallFunctionBigSizeStatus
(
from
,
srcid
,
magic
,
infoid
,
total_size
,
download_size
,
AsyncState
);
destobj
.
PushCallFunctionBigSizeStatus
(
from
,
srcid
,
magic
,
infoid
,
total_size
,
download_size
,
asyncContext
);
}
int
Process
(
IFConn
from
,
UInt32
srcid
,
UInt32
destid
,
UInt32
magic
,
UInt16
info_no
,
byte
[]
infodata
,
out
byte
[]
retdata
)
...
...
@@ -1126,7 +1126,7 @@ namespace FObjBase
{
Transaction
tran
=
ts
.
First
();
Transactions
.
Remove
(
tran
);
//用完,删除
PushCallFunction
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
pack
.
infoid
,
pack
.
infodata
,
tran
.
AsyncDelegate
,
tran
.
Async
State
);
PushCallFunction
(
conn
,
p
.
srcid
,
p
.
destid
,
p
.
magic
,
pack
.
infoid
,
pack
.
infodata
,
tran
.
AsyncDelegate
,
tran
.
Async
Context
);
}
else
{
...
...
Project.FLY.FObjSys/FObjSys/IFObj.cs
View file @
33cc7eba
...
...
@@ -54,9 +54,9 @@ namespace FObjBase
/// <param name="magic">交易号</param>
/// <param name="funcid">功能ID</param>
/// <param name="retdata">回复的数据</param>
/// <param name="
A
syncDelegate">以前客户端调用CallFunction时,放入的函数指针</param>
/// <param name="
AsyncState
">以前客户端调用CallFunction时,放入的object</param>
void
PushCallFunction
(
IFConn
from
,
UInt32
srcid
,
UInt32
magic
,
UInt16
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
);
/// <param name="
a
syncDelegate">以前客户端调用CallFunction时,放入的函数指针</param>
/// <param name="
asyncContext
">以前客户端调用CallFunction时,放入的object</param>
void
PushCallFunction
(
IFConn
from
,
UInt32
srcid
,
UInt32
magic
,
UInt16
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
);
/// <summary>
/// 远端消息推送到本地
...
...
@@ -76,8 +76,8 @@ namespace FObjBase
/// <param name="funcid"></param>
/// <param name="total_size"></param>
/// <param name="download_size"></param>
/// <param name="
AsyncState
"></param>
void
PushCallFunctionBigSizeStatus
(
IFConn
from
,
UInt32
srcid
,
UInt32
magic
,
UInt16
funcid
,
int
total_size
,
int
download_size
,
object
AsyncState
);
/// <param name="
asyncContext
"></param>
void
PushCallFunctionBigSizeStatus
(
IFConn
from
,
UInt32
srcid
,
UInt32
magic
,
UInt16
funcid
,
int
total_size
,
int
download_size
,
object
asyncContext
);
#
endregion
#
region
Client
->
Server
...
...
@@ -177,9 +177,9 @@ namespace FObjBase
/// <param name="magic"></param>
/// <param name="funcid"></param>
/// <param name="retdata"></param>
/// <param name="
A
syncDelegate"></param>
/// <param name="
AsyncState
"></param>
public
virtual
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
UInt32
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
/// <param name="
a
syncDelegate"></param>
/// <param name="
asyncContext
"></param>
public
virtual
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
UInt32
magic
,
ushort
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
}
...
...
@@ -203,8 +203,8 @@ namespace FObjBase
/// <param name="funcid"></param>
/// <param name="total_size"></param>
/// <param name="download_size"></param>
/// <param name="
AsyncState
"></param>
public
virtual
void
PushCallFunctionBigSizeStatus
(
IFConn
from
,
UInt32
srcid
,
UInt32
magic
,
UInt16
funcid
,
int
total_size
,
int
download_size
,
object
AsyncState
)
/// <param name="
asyncContext
"></param>
public
virtual
void
PushCallFunctionBigSizeStatus
(
IFConn
from
,
UInt32
srcid
,
UInt32
magic
,
UInt16
funcid
,
int
total_size
,
int
download_size
,
object
asyncContext
)
{
}
...
...
Project.FLY.FObjSys/FObjSys/IFObjSys.cs
View file @
33cc7eba
...
...
@@ -93,9 +93,9 @@ namespace FObjBase
/// <param name="srcid">本地对象ID</param>
/// <param name="funcid">函数ID</param>
/// <param name="param">函数参数</param>
/// <param name="
A
syncDelegate">在其上调用异步调用的委托对象</param>
/// <param name="
AsyncState
">作为 BeginInvoke 方法调用的最后一个参数而提供的对象</param>
UInt32
CallFunctionEx
(
IFConn
s1
,
UInt32
destid
,
UInt32
srcid
,
UInt16
funcid
,
byte
[]
param
,
object
AsyncDelegate
,
object
AsyncState
);
/// <param name="
a
syncDelegate">在其上调用异步调用的委托对象</param>
/// <param name="
asyncContext
">作为 BeginInvoke 方法调用的最后一个参数而提供的对象</param>
UInt32
CallFunctionEx
(
IFConn
s1
,
UInt32
destid
,
UInt32
srcid
,
UInt16
funcid
,
byte
[]
param
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
);
/// <summary>
/// 向远端CallFunction
...
...
Project.FLY.FObjSys/FObjSys/Transaction.cs
View file @
33cc7eba
...
...
@@ -42,12 +42,12 @@ namespace FObjBase
/// <summary>
/// callfunction 返回时, 异步回调函数
/// </summary>
public
object
AsyncDelegate
;
public
AsyncCBHandler
AsyncDelegate
;
/// <summary>
/// callfunction 返回时, 异步状态
/// </summary>
public
object
Async
State
;
public
object
Async
Context
;
/// <summary>
/// 动作号
...
...
@@ -105,7 +105,7 @@ namespace FObjBase
Buf
=
null
;
Size
=
-
1
;
Position
=
0
;
if
((
AsyncDelegate
==
null
)
&&
(
Async
State
==
null
))
if
((
AsyncDelegate
==
null
)
&&
(
Async
Context
==
null
))
{
return
true
;
}
...
...
Project.FLY.OBJComponents/OBJComponents/Client/BufferServiceClient.cs
View file @
33cc7eba
...
...
@@ -105,7 +105,7 @@ namespace FLY.OBJComponents.Client
}
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
switch
(
funcid
)
{
...
...
@@ -114,7 +114,7 @@ namespace FLY.OBJComponents.Client
{
string
json
=
Misc
.
Converter
.
BytesToString
(
retdata
);
GetRecordReponse
<
T
>
p
=
JsonConvert
.
DeserializeObject
<
GetRecordReponse
<
T
>>(
json
);
((
AsyncCBHandler
)
AsyncDelegate
)(
AsyncState
,
p
);
asyncDelegate
?.
Invoke
(
asyncContext
,
p
);
}
break
;
}
...
...
Project.FLY.OBJComponents/OBJComponents/Client/PLCProxySystemServiceClient.cs
View file @
33cc7eba
...
...
@@ -102,7 +102,7 @@ namespace FLY.OBJComponents.Client
/// <param name="objname">对象名</param>
/// <param name="propertynames">属性名</param>
/// <param name="planID">计划的编号,应该全局唯一,建议使用时间ticks</param>
public
void
SetPlan
(
string
objname
,
IEnumerable
<
string
>
propertynames
,
SetPlanReponseHandler
setPlanReponse
,
object
c
ontext
)
public
void
SetPlan
(
string
objname
,
IEnumerable
<
string
>
propertynames
,
AsyncCBHandler
asyncDelegate
,
object
asyncC
ontext
)
{
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Request
pack
=
new
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Request
()
{
...
...
@@ -113,7 +113,7 @@ namespace FLY.OBJComponents.Client
string
json
=
JsonConvert
.
SerializeObject
(
pack
);
FObjSys
.
Current
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
PLCOS_OBJ_INTERFACE
.
CALL_SET_PLAN2
,
Misc
.
Converter
.
StringToBytes
(
json
),
setPlanReponse
,
c
ontext
);
PLCOS_OBJ_INTERFACE
.
CALL_SET_PLAN2
,
Misc
.
Converter
.
StringToBytes
(
json
),
asyncDelegate
,
asyncC
ontext
);
}
#
endregion
...
...
@@ -129,7 +129,7 @@ namespace FLY.OBJComponents.Client
return
null
;
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
switch
(
funcid
)
{
...
...
@@ -137,10 +137,10 @@ namespace FLY.OBJComponents.Client
{
string
json
=
Misc
.
Converter
.
BytesToString
(
retdata
);
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Reponse
reponse
=
JsonConvert
.
DeserializeObject
<
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Reponse
>(
json
);
SetPlanReponseHandler
setPlanReponseHandler
=
(
SetPlanReponseHandler
)
A
syncDelegate
;
//SetPlanReponseHandler setPlanReponseHandler = (SetPlanReponseHandler)a
syncDelegate;
setPlanReponseHandler
(
reponse
.
planid
,
AsyncState
);
asyncDelegate
(
asyncContext
,
reponse
.
planid
);
//setPlanReponseHandler(reponse.planid, asyncContext
);
}
break
;
}
...
...
Project.FLY.OBJComponents/OBJComponents/Client/RemoteHistorySerivceClient.cs
deleted
100644 → 0
View file @
66d3c2b1
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
Misc
;
using
System.ComponentModel
;
using
FObjBase
;
namespace
FLY.Thick.RemoteHistory
{
public
class
RemoteHistorySerivceClient
:
FObj
,
IRemoteHistory
{
IFConn
mConn
=
null
;
UInt32
mServerID
;
public
bool
IsConnected
;
#
region
IHistory
<
T
>
成员
private
int
currdays
=
0
;
/// <summary>
/// 当前保存的数据天数
/// </summary>
public
int
CurrDays
{
get
{
return
currdays
;
}
protected
set
{
if
(
currdays
!=
value
)
{
currdays
=
value
;
NotifyPropertyChanged
(
"CurrDays"
);
}
}
}
private
int
keeyday
;
/// <summary>
/// 数据能保存的天数
/// </summary>
public
int
KeeyDay
{
get
{
return
keeyday
;
}
set
{
if
(
value
<=
0
)
value
=
1
;
if
(
keeyday
!=
value
)
{
keeyday
=
value
;
NotifyPropertyChanged
(
"KeeyDay"
);
}
}
}
private
int
saverows
;
/// <summary>
/// 多少行保存一次
/// </summary>
public
int
SaveRows
{
get
{
return
saverows
;
}
set
{
if
(
saverows
!=
value
)
{
saverows
=
value
;
NotifyPropertyChanged
(
"SaveRows"
);
}
}
}
private
int
currrows
;
/// <summary>
/// 当前总行数
/// </summary>
public
int
CurrRows
{
get
{
return
currrows
;
}
protected
set
{
if
(
currrows
!=
value
)
{
currrows
=
value
;
NotifyPropertyChanged
(
"CurrRows"
);
}
}
}
private
string
currpath
=
null
;
public
string
CurrPath
{
get
{
return
currpath
;
}
protected
set
{
if
(
currpath
!=
value
)
{
currpath
=
value
;
NotifyPropertyChanged
(
"CurrPath"
);
}
}
}
#
endregion
public
RemoteHistorySerivceClient
(
UInt32
serverid
)
{
mServerID
=
serverid
;
}
public
void
Apply
()
{
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_Params
p
=
new
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_Params
()
{
keeyday
=
KeeyDay
,
saverows
=
SaveRows
};
CurrObjSys
.
SetValueEx
(
mConn
,
mServerID
,
ID
,
REMOTEHISTORY_OBJ_INTERFACE
.
SET_PARAMS
,
p
.
ToBytes
());
}
public
void
Flush
()
{
CurrObjSys
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
REMOTEHISTORY_OBJ_INTERFACE
.
CALL_FLUSH
,
null
);
}
public
void
GetPaths
(
DateTime
dt_begin
,
DateTime
dt_end
,
string
profilename
,
GetPathsReponseHandler
return_func
,
object
state
)
{
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_GetPathsRequest
p
=
new
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_GetPathsRequest
()
{
dt_begin
=
dt_begin
,
dt_end
=
dt_end
,
profilename
=
profilename
};
CurrObjSys
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
REMOTEHISTORY_OBJ_INTERFACE
.
CALL_GETPATHS
,
p
.
ToBytes
(),
return_func
,
state
);
}
/// <summary>
/// 获取根目录
/// </summary>
public
void
GetRootPath
(
GetRootPathReponseHandler
return_func
,
object
state
)
{
CurrObjSys
.
CallFunctionEx
(
mConn
,
mServerID
,
ID
,
REMOTEHISTORY_OBJ_INTERFACE
.
CALL_GETROOTPATH
,
null
,
return_func
,
state
);
}
#
region
INotifyPropertyChanged
成员
public
event
PropertyChangedEventHandler
PropertyChanged
;
protected
void
NotifyPropertyChanged
(
string
propertyname
)
{
if
(
PropertyChanged
!=
null
)
PropertyChanged
.
Invoke
(
this
,
new
PropertyChangedEventArgs
(
propertyname
));
}
#
endregion
public
override
void
Dispose
()
{
//获取所有数据,设置推送
CurrObjSys
.
ObjRemove
(
this
,
mConn
);
}
public
override
void
ConnectNotify
(
IFConn
from
)
{
mConn
=
from
;
IsConnected
=
from
.
IsConnected
;
if
(
from
.
IsConnected
)
{
//获取所有数据,设置推送
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
REMOTEHISTORY_OBJ_INTERFACE
.
GET_PARAMS
);
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
REMOTEHISTORY_OBJ_INTERFACE
.
GET_STATE
);
CurrObjSys
.
SenseConfigEx
(
mConn
,
mServerID
,
ID
,
0xffffffff
,
SENSE_CONFIG
.
ADD
);
}
}
public
override
void
PushGetValue
(
IFConn
from
,
uint
srcid
,
ushort
memid
,
byte
[]
infodata
)
{
switch
(
memid
)
{
case
REMOTEHISTORY_OBJ_INTERFACE
.
GET_PARAMS
:
{
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_Params
p
=
new
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_Params
();
if
(
p
.
TryParse
(
infodata
))
{
KeeyDay
=
p
.
keeyday
;
SaveRows
=
p
.
saverows
;
}
}
break
;
case
REMOTEHISTORY_OBJ_INTERFACE
.
GET_STATE
:
{
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_State
p
=
new
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_State
();
if
(
p
.
TryParse
(
infodata
))
{
CurrRows
=
p
.
currrows
;
CurrPath
=
p
.
currpath
;
CurrDays
=
p
.
currdays
;
}
}
break
;
}
}
public
override
void
PushInfo
(
IFConn
from
,
uint
srcid
,
ushort
infoid
,
byte
[]
infodata
)
{
PushGetValue
(
from
,
srcid
,
infoid
,
infodata
);
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
UInt32
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
{
switch
(
funcid
)
{
case
REMOTEHISTORY_OBJ_INTERFACE
.
CALL_GETPATHS
:
{
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_GetPathsResponse
p
=
new
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_GetPathsResponse
();
if
(!
p
.
TryParse
(
retdata
))
return
;
GetPathsReponseHandler
func
=
(
GetPathsReponseHandler
)
AsyncDelegate
;
func
(
p
.
paths
,
AsyncState
);
}
break
;
case
REMOTEHISTORY_OBJ_INTERFACE
.
CALL_GETROOTPATH
:
{
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_GetRootPathResponse
p
=
new
REMOTEHISTORY_OBJ_INTERFACE
.
Pack_GetRootPathResponse
();
if
(!
p
.
TryParse
(
retdata
))
return
;
GetRootPathReponseHandler
func
=
(
GetRootPathReponseHandler
)
AsyncDelegate
;
func
(
p
.
rootpath
,
AsyncState
);
}
break
;
}
}
}
}
Project.FLY.OBJComponents/OBJComponents/Client/SetPLCUpdatePlan.cs
View file @
33cc7eba
...
...
@@ -39,8 +39,9 @@ namespace FLY.OBJComponents.Client
if
(((
PLCProxySystemServiceClient
)
PLCos
).
IsConnected
)
{
PLCos
.
SetPlan
(
this
.
objname
,
this
.
propertynames
,
(
planid
,
context
)
=>
PLCos
.
SetPlan
(
this
.
objname
,
this
.
propertynames
,
(
asyncContext
,
retData
)
=>
{
long
planid
=
(
long
)
retData
;
this
.
planid
=
planid
;
timer
.
Start
();
},
null
);
...
...
@@ -53,8 +54,9 @@ namespace FLY.OBJComponents.Client
{
if
(((
PLCProxySystemServiceClient
)
PLCos
).
IsConnected
)
{
PLCos
.
SetPlan
(
objname
,
propertynames
,
(
planid
,
context
)
=>
PLCos
.
SetPlan
(
objname
,
propertynames
,
(
asyncContext
,
retData
)
=>
{
long
planid
=
(
long
)
retData
;
this
.
planid
=
planid
;
timer
.
Start
();
},
null
);
...
...
Project.FLY.OBJComponents/OBJComponents/Client/SyncPropServiceClient.cs
View file @
33cc7eba
...
...
@@ -223,7 +223,7 @@ namespace FLY.OBJComponents.Client
pushDataList
.
Clear
();
}
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
object
AsyncDelegate
,
object
AsyncState
)
public
override
void
PushCallFunction
(
IFConn
from
,
uint
srcid
,
uint
magic
,
ushort
funcid
,
byte
[]
retdata
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
)
{
switch
(
funcid
)
{
...
...
@@ -238,7 +238,7 @@ namespace FLY.OBJComponents.Client
{
if
(
ObjNames
.
ContainsKey
(
Dso
.
Key
))
{
INotifyPropertyChanged
obj
=
ObjNames
[
Dso
.
Key
]
as
INotifyPropertyChanged
;
INotifyPropertyChanged
obj
=
ObjNames
[
Dso
.
Key
];
obj
.
PropertyChanged
-=
Data_PropertyChanged
;
foreach
(
var
dv
in
Dso
.
Value
)
{
...
...
Project.FLY.OBJComponents/OBJComponents/FLY.OBJComponents.csproj
View file @
33cc7eba
...
...
@@ -52,7 +52,6 @@
<Compile
Include=
"Client\BufferServiceClient.cs"
/>
<Compile
Include=
"Client\JsonDistServiceClient.cs"
/>
<Compile
Include=
"Client\PLCProxySystemServiceClient.cs"
/>
<Compile
Include=
"Client\RemoteHistorySerivceClient.cs"
/>
<Compile
Include=
"Client\SetPLCUpdatePlan.cs"
/>
<Compile
Include=
"Client\SyncPropServiceClient.cs"
/>
<Compile
Include=
"Client\WarningSystem2ServiceClient.cs"
/>
...
...
Project.FLY.OBJComponents/OBJComponents/IService/IPLCProxySystemService.cs
View file @
33cc7eba
using
System
;
using
FObjBase
;
using
FObjBase.Reflect
;
using
System
;
using
System.Collections.Generic
;
using
System.ComponentModel
;
using
System.Linq
;
...
...
@@ -34,7 +36,8 @@ namespace FLY.OBJComponents.IService
/// <param name="objname">对象名</param>
/// <param name="propertynames">属性名</param>
/// <param name="planID">计划的编号,应该全局唯一,建议使用时间ticks</param>
void
SetPlan
(
string
objname
,
IEnumerable
<
string
>
propertynames
,
SetPlanReponseHandler
setPlanReponse
,
object
context
);
[
Call
(
typeof
(
long
))]
void
SetPlan
(
string
objname
,
IEnumerable
<
string
>
propertynames
,
AsyncCBHandler
asyncDelegate
,
object
asyncContext
);
/// <summary>
/// 更新计划持续,如果不喂狗,120s后停止更新数据
...
...
@@ -48,6 +51,4 @@ namespace FLY.OBJComponents.IService
/// <param name="planID"></param>
void
RemovePlan
(
long
planID
);
}
public
delegate
void
SetPlanReponseHandler
(
long
planid
,
object
context
);
}
Project.FLY.OBJComponents/OBJComponents/Server.OBJProxy/PLCProxySystem_OBJProxy.cs
View file @
33cc7eba
...
...
@@ -47,9 +47,10 @@ namespace FLY.OBJComponents.Server.OBJProxy
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Request
pack
=
JsonConvert
.
DeserializeObject
<
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Request
>(
json
);
plcos
.
SetPlan
(
pack
.
objname
,
pack
.
propertyNames
,
(
planid
,
context
)
=>
plcos
.
SetPlan
(
pack
.
objname
,
pack
.
propertyNames
,
(
asyncContext
,
retData
)
=>
{
ConnContext
conn
=
context
as
ConnContext
;
ConnContext
conn
=
asyncContext
as
ConnContext
;
long
planid
=
(
long
)
retData
;
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Reponse
p
=
new
PLCOS_OBJ_INTERFACE
.
Pack_SetPlan2Reponse
()
{
planid
=
planid
};
string
s
=
JsonConvert
.
SerializeObject
(
p
);
CurrObjSys
.
PushCallFunctionEx
(
conn
.
from
,
srcid
,
ID
,
magic
,
funcid
,
Misc
.
Converter
.
StringToBytes
(
s
));
...
...
Project.FLY.OBJComponents/OBJComponents/Server/PLCProxySystem.cs
View file @
33cc7eba
...
...
@@ -8,6 +8,7 @@ using FLY.Modbus;
using
System.Windows.Threading
;
using
System.IO
;
using
Newtonsoft.Json
;
using
FObjBase
;
namespace
FLY.OBJComponents.Server
{
...
...
@@ -281,11 +282,11 @@ namespace FLY.OBJComponents.Server
/// <param name="objname">对象名称</param>
/// <param name="propertynames"></param>
/// <param name="planID">计划的编号,应该全局唯一,建议使用时间ticks</param>
public
void
SetPlan
(
string
objname
,
IEnumerable
<
string
>
propertynames
,
SetPlanReponseHandler
reponseHandler
,
object
c
ontext
)
public
void
SetPlan
(
string
objname
,
IEnumerable
<
string
>
propertynames
,
AsyncCBHandler
asyncDelegate
,
object
asyncC
ontext
)
{
long
planID
=
GetFreePlanID
();
SetPlan
(
objname
,
propertynames
,
planID
);
reponseHandler
(
planID
,
context
);
asyncDelegate
?.
Invoke
(
asyncContext
,
planID
);
}
/// <summary>
/// 更新计划持续,如果不喂狗,20s后停止更新数据
...
...
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