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
d6b402b3
Commit
d6b402b3
authored
Nov 16, 2019
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
还在构思中
parent
738777ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
653 additions
and
55 deletions
+653
-55
BufferPage.cs
Project.FLY.OBJComponents/OBJComponents/Client/BufferPage.cs
+493
-0
BufferServiceClient.cs
...OBJComponents/OBJComponents/Client/BufferServiceClient.cs
+25
-32
NotifyBufferChangedEventArgs.cs
...ents/OBJComponents/Common/NotifyBufferChangedEventArgs.cs
+21
-0
OBJComponents.csproj
Project.FLY.OBJComponents/OBJComponents/OBJComponents.csproj
+1
-0
BUFFER_OBJ_INTERFACE.cs
...nents/OBJComponents/OBJ_INTERFACE/BUFFER_OBJ_INTERFACE.cs
+18
-1
Buffer_OBJProxy.cs
...mponents/OBJComponents/Server.OBJProxy/Buffer_OBJProxy.cs
+40
-21
BufferSQLite.cs
...ct.FLY.OBJComponents/OBJComponents/Server/BufferSQLite.cs
+55
-1
No files found.
Project.FLY.OBJComponents/OBJComponents/Client/BufferPage.cs
0 → 100644
View file @
d6b402b3
This diff is collapsed.
Click to expand it.
Project.FLY.OBJComponents/OBJComponents/Client/BufferServiceClient.cs
View file @
d6b402b3
...
@@ -30,29 +30,10 @@ namespace FLY.OBJComponents.Client
...
@@ -30,29 +30,10 @@ namespace FLY.OBJComponents.Client
IFConn
mConn
;
IFConn
mConn
;
UInt32
mServerID
;
UInt32
mServerID
;
/// <summary>
/// 数据是从服务器推送过来的,忽略属性变化事件
/// </summary>
bool
isIgnore
=
false
;
public
BufferServiceClient
(
UInt32
serverid
)
public
BufferServiceClient
(
UInt32
serverid
)
{
{
mServerID
=
serverid
;
mServerID
=
serverid
;
this
.
PropertyChanged
+=
BufferServiceClient_PropertyChanged
;
}
private
void
BufferServiceClient_PropertyChanged
(
object
sender
,
PropertyChangedEventArgs
e
)
{
if
(
isIgnore
)
return
;
Dictionary
<
string
,
object
>
datas
=
new
Dictionary
<
string
,
object
>
{
{
e
.
PropertyName
,
Misc
.
PropertiesManager
.
GetValue
(
sender
,
e
.
PropertyName
)
}
};
string
json
=
JsonConvert
.
SerializeObject
(
datas
);
CurrObjSys
.
SetValueEx
(
mConn
,
mServerID
,
ID
,
BUFFER_OBJ_INTERFACE
.
SET_PARAMS
,
Misc
.
Converter
.
StringToBytes
(
json
));
}
}
public
override
void
Dispose
()
public
override
void
Dispose
()
...
@@ -69,6 +50,9 @@ namespace FLY.OBJComponents.Client
...
@@ -69,6 +50,9 @@ namespace FLY.OBJComponents.Client
CurrObjSys
.
GetValueEx
(
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
mConn
,
mServerID
,
ID
,
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
);
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
);
CurrObjSys
.
GetValueEx
(
mConn
,
mServerID
,
ID
,
BUFFER_OBJ_INTERFACE
.
GET_STATUS
);
CurrObjSys
.
SenseConfigEx
(
CurrObjSys
.
SenseConfigEx
(
mConn
,
mServerID
,
ID
,
mConn
,
mServerID
,
ID
,
...
@@ -90,19 +74,16 @@ namespace FLY.OBJComponents.Client
...
@@ -90,19 +74,16 @@ namespace FLY.OBJComponents.Client
case
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
:
case
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
:
{
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BUFFER_OBJ_INTERFACE
.
Pack_Params
>(
json
);
Dictionary
<
string
,
object
>
datas
=
JsonConvert
.
DeserializeObject
<
Dictionary
<
string
,
object
>>(
json
);
Capacity
=
p
.
capcity
;
}
//设置属性
break
;
//屏蔽属性改变后,设置到服务器
case
BUFFER_OBJ_INTERFACE
.
GET_STATUS
:
isIgnore
=
true
;
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
foreach
(
KeyValuePair
<
string
,
object
>
kv
in
datas
)
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BUFFER_OBJ_INTERFACE
.
Pack_Status
>(
json
);
{
Count
=
p
.
count
;
PropertiesManager_JSON
.
SetValue
(
this
,
kv
.
Key
,
kv
.
Value
);
NewestID
=
p
.
newestId
;
}
isIgnore
=
false
;
}
}
break
;
break
;
...
@@ -112,6 +93,7 @@ namespace FLY.OBJComponents.Client
...
@@ -112,6 +93,7 @@ namespace FLY.OBJComponents.Client
{
{
switch
(
infoid
)
switch
(
infoid
)
{
{
case
BUFFER_OBJ_INTERFACE
.
PUSH_STATUS
:
case
BUFFER_OBJ_INTERFACE
.
PUSH_PARAMS
:
case
BUFFER_OBJ_INTERFACE
.
PUSH_PARAMS
:
{
{
PushGetValue
(
from
,
srcid
,
infoid
,
infodata
);
PushGetValue
(
from
,
srcid
,
infoid
,
infodata
);
...
@@ -175,5 +157,16 @@ namespace FLY.OBJComponents.Client
...
@@ -175,5 +157,16 @@ namespace FLY.OBJComponents.Client
asyncCB
,
asyncContext
asyncCB
,
asyncContext
);
);
}
}
public
void
Apply
()
{
var
p
=
new
BUFFER_OBJ_INTERFACE
.
Pack_Params
()
{
capcity
=
Capacity
};
string
json
=
Newtonsoft
.
Json
.
JsonConvert
.
SerializeObject
(
p
);
CurrObjSys
.
SetValueEx
(
mConn
,
mServerID
,
ID
,
BUFFER_OBJ_INTERFACE
.
SET_PARAMS
,
Misc
.
Converter
.
StringToBytes
(
json
));
}
}
}
}
}
Project.FLY.OBJComponents/OBJComponents/Common/NotifyBufferChangedEventArgs.cs
View file @
d6b402b3
...
@@ -18,9 +18,30 @@ namespace FLY.OBJComponents.Common
...
@@ -18,9 +18,30 @@ namespace FLY.OBJComponents.Common
public
class
NotifyBufferChangedEventArgs
<
T
>
:
EventArgs
public
class
NotifyBufferChangedEventArgs
<
T
>
:
EventArgs
{
{
/// <summary>
/// 动作
/// </summary>
public
NotifyBufferChangedAction
Action
{
get
;
set
;
}
public
NotifyBufferChangedAction
Action
{
get
;
set
;
}
/// <summary>
/// 被修改的数据,可能为空,需要再向Buffer 获取
/// </summary>
public
IEnumerable
<
T
>
Items
{
get
;
set
;
}
public
IEnumerable
<
T
>
Items
{
get
;
set
;
}
/// <summary>
/// 最后一条记录ID
/// </summary>
public
int
EndingID
{
get
;
set
;
}
public
int
EndingID
{
get
;
set
;
}
/// <summary>
/// 当前修改数据量
/// </summary>
public
int
Count
{
get
;
set
;
}
/// <summary>
/// 列表最后一条记录
/// </summary>
public
int
BufferNewestID
{
get
;
set
;
}
/// <summary>
/// 列表总数据量
/// </summary>
public
int
BufferCount
{
get
;
set
;
}
}
}
public
enum
NotifyBufferChangedAction
public
enum
NotifyBufferChangedAction
...
...
Project.FLY.OBJComponents/OBJComponents/OBJComponents.csproj
View file @
d6b402b3
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
<Reference
Include=
"WindowsBase"
/>
<Reference
Include=
"WindowsBase"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"Client\BufferPage.cs"
/>
<Compile
Include=
"Client\BufferWindow.cs"
/>
<Compile
Include=
"Client\BufferWindow.cs"
/>
<Compile
Include=
"Client\BufferServiceClient.cs"
/>
<Compile
Include=
"Client\BufferServiceClient.cs"
/>
<Compile
Include=
"Client\PLCProxySystemServiceClient.cs"
/>
<Compile
Include=
"Client\PLCProxySystemServiceClient.cs"
/>
...
...
Project.FLY.OBJComponents/OBJComponents/OBJ_INTERFACE/BUFFER_OBJ_INTERFACE.cs
View file @
d6b402b3
...
@@ -19,6 +19,15 @@ namespace FLY.OBJComponents.OBJ_INTERFACE
...
@@ -19,6 +19,15 @@ namespace FLY.OBJComponents.OBJ_INTERFACE
{
{
public
int
count
;
public
int
count
;
}
}
public
class
Pack_Status
{
public
int
newestId
;
public
int
count
;
}
public
class
Pack_Params
{
public
int
capcity
;
}
#
endregion
#
endregion
#
region
SetValue
#
region
SetValue
...
@@ -33,6 +42,10 @@ namespace FLY.OBJComponents.OBJ_INTERFACE
...
@@ -33,6 +42,10 @@ namespace FLY.OBJComponents.OBJ_INTERFACE
/// Dictionary<string, object>
/// Dictionary<string, object>
/// </summary>
/// </summary>
public
const
UInt16
GET_PARAMS
=
0
;
public
const
UInt16
GET_PARAMS
=
0
;
/// <summary>
/// Pack_Status
/// </summary>
public
const
UInt16
GET_STATUS
=
1
;
#
endregion
#
endregion
#
region
PushMsg
#
region
PushMsg
...
@@ -41,9 +54,13 @@ namespace FLY.OBJComponents.OBJ_INTERFACE
...
@@ -41,9 +54,13 @@ namespace FLY.OBJComponents.OBJ_INTERFACE
/// </summary>
/// </summary>
public
const
UInt16
PUSH_PARAMS
=
0
;
public
const
UInt16
PUSH_PARAMS
=
0
;
/// <summary>
/// <summary>
/// Pack_Status
/// </summary>
public
const
UInt16
PUSH_STATUS
=
1
;
/// <summary>
/// NotifyBufferChangedEventArgs
/// NotifyBufferChangedEventArgs
/// </summary>
/// </summary>
public
const
UInt16
PUSH_BUFFERCHANGED
=
1
;
public
const
UInt16
PUSH_BUFFERCHANGED
=
1
0
;
#
endregion
#
endregion
#
region
Call
#
region
Call
/// <summary>
/// <summary>
...
...
Project.FLY.OBJComponents/OBJComponents/Server.OBJProxy/Buffer_OBJProxy.cs
View file @
d6b402b3
...
@@ -14,6 +14,8 @@ namespace FLY.OBJComponents.Server.OBJProxy
...
@@ -14,6 +14,8 @@ namespace FLY.OBJComponents.Server.OBJProxy
{
{
public
class
Buffer_OBJProxy
<
T
>
:
FObj
public
class
Buffer_OBJProxy
<
T
>
:
FObj
{
{
const
int
MARKNO_PUSH_STATUS
=
1
;
const
int
MARKNO_PUSH_PARAMS
=
2
;
IBuffer
<
T
>
buffer
;
IBuffer
<
T
>
buffer
;
public
Buffer_OBJProxy
(
int
objsys_idx
,
UInt32
id
,
IBuffer
<
T
>
buffer
)
public
Buffer_OBJProxy
(
int
objsys_idx
,
UInt32
id
,
IBuffer
<
T
>
buffer
)
...
@@ -36,16 +38,29 @@ namespace FLY.OBJComponents.Server.OBJProxy
...
@@ -36,16 +38,29 @@ namespace FLY.OBJComponents.Server.OBJProxy
private
void
Buffer_PropertyChanged
(
object
sender
,
System
.
ComponentModel
.
PropertyChangedEventArgs
e
)
private
void
Buffer_PropertyChanged
(
object
sender
,
System
.
ComponentModel
.
PropertyChangedEventArgs
e
)
{
{
Dictionary
<
string
,
object
>
p
=
new
Dictionary
<
string
,
object
>
if
((
e
.
PropertyName
==
"NewestID"
)
||
(
e
.
PropertyName
==
"Count"
))
{
{
{
e
.
PropertyName
,
Misc
.
PropertiesManager
.
GetValue
(
sender
,
e
.
PropertyName
)
}
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(()
=>
};
{
byte
[]
buf
;
string
json
=
JsonConvert
.
SerializeObject
(
p
);
GetValue
(
null
,
0
,
BUFFER_OBJ_INTERFACE
.
GET_STATUS
,
out
buf
);
CurrObjSys
.
PushObjInfoEx
(
CurrObjSys
.
PushObjInfoEx
(
this
,
BUFFER_OBJ_INTERFACE
.
PUSH_PARAMS
,
this
,
BUFFER_OBJ_INTERFACE
.
GET_STATUS
,
Misc
.
Converter
.
StringToBytes
(
json
)
buf
);
);
},
this
,
MARKNO_PUSH_STATUS
);
}
if
(
e
.
PropertyName
==
"Capacity"
)
{
FObjBase
.
PollModule
.
Current
.
Poll_JustOnce
(()
=>
{
byte
[]
buf
;
GetValue
(
null
,
0
,
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
,
out
buf
);
CurrObjSys
.
PushObjInfoEx
(
this
,
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
,
buf
);
},
this
,
MARKNO_PUSH_PARAMS
);
}
}
}
public
override
void
SetValue
(
IFConn
from
,
uint
srcid
,
ushort
memid
,
byte
[]
infodata
)
public
override
void
SetValue
(
IFConn
from
,
uint
srcid
,
ushort
memid
,
byte
[]
infodata
)
...
@@ -55,13 +70,8 @@ namespace FLY.OBJComponents.Server.OBJProxy
...
@@ -55,13 +70,8 @@ namespace FLY.OBJComponents.Server.OBJProxy
case
BUFFER_OBJ_INTERFACE
.
SET_PARAMS
:
case
BUFFER_OBJ_INTERFACE
.
SET_PARAMS
:
{
{
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
string
json
=
Misc
.
Converter
.
BytesToString
(
infodata
);
var
p
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
BUFFER_OBJ_INTERFACE
.
Pack_Params
>(
json
);
Dictionary
<
string
,
object
>
p
=
JsonConvert
.
DeserializeObject
<
Dictionary
<
string
,
object
>>(
json
);
buffer
.
Capacity
=
p
.
capcity
;
foreach
(
var
kv
in
p
)
{
PropertiesManager_JSON
.
SetValue
(
buffer
,
kv
.
Key
,
kv
.
Value
);
}
}
}
break
;
break
;
}
}
...
@@ -73,12 +83,21 @@ namespace FLY.OBJComponents.Server.OBJProxy
...
@@ -73,12 +83,21 @@ namespace FLY.OBJComponents.Server.OBJProxy
{
{
case
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
:
case
BUFFER_OBJ_INTERFACE
.
GET_PARAMS
:
{
{
Dictionary
<
string
,
object
>
p
=
new
Dictionary
<
string
,
object
>();
var
p
=
new
BUFFER_OBJ_INTERFACE
.
Pack_Params
()
IEnumerable
<
string
>
propertynames
=
Misc
.
PropertiesManager
.
GetAllPropertyNames
(
buffer
);
{
foreach
(
string
pn
in
propertynames
)
capcity
=
buffer
.
Capacity
};
string
json
=
JsonConvert
.
SerializeObject
(
p
);
infodata
=
Misc
.
Converter
.
StringToBytes
(
json
);
}
break
;
case
BUFFER_OBJ_INTERFACE
.
GET_STATUS
:
{
var
p
=
new
BUFFER_OBJ_INTERFACE
.
Pack_Status
()
{
{
p
.
Add
(
pn
,
Misc
.
PropertiesManager
.
GetValue
(
buffer
,
pn
));
newestId
=
buffer
.
NewestID
,
}
count
=
buffer
.
Count
};
string
json
=
JsonConvert
.
SerializeObject
(
p
);
string
json
=
JsonConvert
.
SerializeObject
(
p
);
infodata
=
Misc
.
Converter
.
StringToBytes
(
json
);
infodata
=
Misc
.
Converter
.
StringToBytes
(
json
);
}
}
...
...
Project.FLY.OBJComponents/OBJComponents/Server/BufferSQLite.cs
View file @
d6b402b3
...
@@ -66,9 +66,20 @@ namespace FLY.OBJComponents.Server
...
@@ -66,9 +66,20 @@ namespace FLY.OBJComponents.Server
sqliteHelper
.
QueryTranAsync
(
sqls
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
Count
++;
Count
++;
BufferChanged
?.
Invoke
(
this
,
new
NotifyBufferChangedEventArgs
<
TLc
>()
{
Action
=
NotifyBufferChangedAction
.
Add
,
EndingID
=
NewestID
,
Count
=
1
,
Items
=
new
TLc
[]
{
lc
},
BufferCount
=
Count
,
BufferNewestID
=
NewestID
});
}
}
public
void
AddRange
(
IEnumerable
<
TLc
>
lcs
)
public
void
AddRange
(
IEnumerable
<
TLc
>
lcs
)
{
{
if
(
lcs
.
Count
()
==
0
)
return
;
List
<
string
>
sqls
=
new
List
<
string
>();
List
<
string
>
sqls
=
new
List
<
string
>();
foreach
(
var
lc
in
lcs
)
foreach
(
var
lc
in
lcs
)
{
{
...
@@ -80,6 +91,15 @@ namespace FLY.OBJComponents.Server
...
@@ -80,6 +91,15 @@ namespace FLY.OBJComponents.Server
sqliteHelper
.
QueryTranAsync
(
sqls
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
Count
+=
lcs
.
Count
();
Count
+=
lcs
.
Count
();
BufferChanged
?.
Invoke
(
this
,
new
NotifyBufferChangedEventArgs
<
TLc
>()
{
Action
=
NotifyBufferChangedAction
.
Add
,
EndingID
=
NewestID
,
Count
=
lcs
.
Count
(),
Items
=
lcs
,
BufferCount
=
Count
,
BufferNewestID
=
NewestID
});
}
}
/// <summary>
/// <summary>
/// 清空全部数据
/// 清空全部数据
...
@@ -91,6 +111,14 @@ namespace FLY.OBJComponents.Server
...
@@ -91,6 +111,14 @@ namespace FLY.OBJComponents.Server
sqls
.
Add
(
$"DELETE FROM
{
dbTable
.
TableName
}
"
);
sqls
.
Add
(
$"DELETE FROM
{
dbTable
.
TableName
}
"
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
Count
=
0
;
Count
=
0
;
BufferChanged
?.
Invoke
(
this
,
new
NotifyBufferChangedEventArgs
<
TLc
>()
{
Action
=
NotifyBufferChangedAction
.
Reset
,
EndingID
=
-
1
,
Count
=
0
,
BufferCount
=
Count
,
BufferNewestID
=
NewestID
});
}
}
/// <summary>
/// <summary>
...
@@ -188,9 +216,19 @@ namespace FLY.OBJComponents.Server
...
@@ -188,9 +216,19 @@ namespace FLY.OBJComponents.Server
sqliteHelper
.
QueryTranAsync
(
sqls
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
Count
++;
Count
++;
BufferChanged
?.
Invoke
(
this
,
new
NotifyBufferChangedEventArgs
<
TDb
>()
{
Action
=
NotifyBufferChangedAction
.
Add
,
EndingID
=
NewestID
,
Count
=
1
,
BufferCount
=
Count
,
BufferNewestID
=
NewestID
});
}
}
public
void
AddRange
(
IEnumerable
<
TDb
>
dbs
)
public
void
AddRange
(
IEnumerable
<
TDb
>
dbs
)
{
{
if
(
dbs
.
Count
()
==
0
)
return
;
List
<
string
>
sqls
=
new
List
<
string
>();
List
<
string
>
sqls
=
new
List
<
string
>();
foreach
(
var
db
in
dbs
)
foreach
(
var
db
in
dbs
)
{
{
...
@@ -203,6 +241,14 @@ namespace FLY.OBJComponents.Server
...
@@ -203,6 +241,14 @@ namespace FLY.OBJComponents.Server
sqliteHelper
.
QueryTranAsync
(
sqls
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
Count
+=
dbs
.
Count
();
Count
+=
dbs
.
Count
();
BufferChanged
?.
Invoke
(
this
,
new
NotifyBufferChangedEventArgs
<
TDb
>()
{
Action
=
NotifyBufferChangedAction
.
Add
,
EndingID
=
NewestID
,
Count
=
dbs
.
Count
(),
BufferCount
=
Count
,
BufferNewestID
=
NewestID
});
}
}
/// <summary>
/// <summary>
/// 清空全部数据
/// 清空全部数据
...
@@ -214,6 +260,14 @@ namespace FLY.OBJComponents.Server
...
@@ -214,6 +260,14 @@ namespace FLY.OBJComponents.Server
sqls
.
Add
(
$"DELETE FROM
{
dbTable
.
TableName
}
"
);
sqls
.
Add
(
$"DELETE FROM
{
dbTable
.
TableName
}
"
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
sqliteHelper
.
QueryTranAsync
(
sqls
);
Count
=
0
;
Count
=
0
;
BufferChanged
?.
Invoke
(
this
,
new
NotifyBufferChangedEventArgs
<
TDb
>()
{
Action
=
NotifyBufferChangedAction
.
Reset
,
EndingID
=
-
1
,
Count
=
0
,
BufferCount
=
Count
,
BufferNewestID
=
NewestID
});
}
}
/// <summary>
/// <summary>
...
...
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