Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cdy816
Mars
提交
2b3d6b81
Mars
项目概览
cdy816
/
Mars
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mars
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2b3d6b81
编写于
10月 13, 2020
作者:
cdy816
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bug 修改
上级
42dd0285
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
527 addition
and
97 deletion
+527
-97
Common/Cdy.Tag.Common/Common/FixedMemoryBlock.cs
Common/Cdy.Tag.Common/Common/FixedMemoryBlock.cs
+2
-2
Common/Cdy.Tag.Common/Common/MarshalFixedMemoryBlock.cs
Common/Cdy.Tag.Common/Common/MarshalFixedMemoryBlock.cs
+2
-2
Common/Cdy.Tag.Common/Common/MarshalMemoryBlock.cs
Common/Cdy.Tag.Common/Common/MarshalMemoryBlock.cs
+8
-2
Common/Cdy.Tag.Common/Common/MemoryBlock.cs
Common/Cdy.Tag.Common/Common/MemoryBlock.cs
+2
-2
Common/Cdy.Tag.Driver/IRealTagProducter.cs
Common/Cdy.Tag.Driver/IRealTagProducter.cs
+7
-1
Common/Cdy.Tag.Driver/ITagHisvalueProducter.cs
Common/Cdy.Tag.Driver/ITagHisvalueProducter.cs
+39
-0
Driver/SimDriver/Driver.cs
Driver/SimDriver/Driver.cs
+48
-2
RunTime/DBInRun/Properties/launchSettings.json
RunTime/DBInRun/Properties/launchSettings.json
+1
-1
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
+2
-2
RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs
...e/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs
+1
-1
RunTime/DBRuntime/His/HisEnginer2.cs
RunTime/DBRuntime/His/HisEnginer2.cs
+279
-40
RunTime/DBRuntime/His/ManualHisDataMemoryBlockPool.cs
RunTime/DBRuntime/His/ManualHisDataMemoryBlockPool.cs
+37
-17
RunTime/DBRuntime/His/MarshalMemoryBlockPool.cs
RunTime/DBRuntime/His/MarshalMemoryBlockPool.cs
+25
-12
RunTime/DBRuntime/His/SeriseEnginer2.cs
RunTime/DBRuntime/His/SeriseEnginer2.cs
+74
-13
未找到文件。
Common/Cdy.Tag.Common/Common/FixedMemoryBlock.cs
浏览文件 @
2b3d6b81
...
@@ -1478,7 +1478,7 @@ namespace Cdy.Tag
...
@@ -1478,7 +1478,7 @@ namespace Cdy.Tag
/// <param name="memory"></param>
/// <param name="memory"></param>
public
static
void
MakeMemoryBusy
(
this
FixedMemoryBlock
memory
)
public
static
void
MakeMemoryBusy
(
this
FixedMemoryBlock
memory
)
{
{
LoggerService
.
Service
.
Info
(
"FixedMemoryBlock"
,
memory
.
Name
+
" is busy....."
);
//
LoggerService.Service.Info("FixedMemoryBlock", memory.Name + " is busy.....");
memory
.
IncRef
();
memory
.
IncRef
();
//memory.StartMemory[0] = 1;
//memory.StartMemory[0] = 1;
}
}
...
@@ -1489,7 +1489,7 @@ namespace Cdy.Tag
...
@@ -1489,7 +1489,7 @@ namespace Cdy.Tag
/// <param name="memory"></param>
/// <param name="memory"></param>
public
static
void
MakeMemoryNoBusy
(
this
FixedMemoryBlock
memory
)
public
static
void
MakeMemoryNoBusy
(
this
FixedMemoryBlock
memory
)
{
{
LoggerService
.
Service
.
Info
(
"FixedMemoryBlock"
,
memory
.
Name
+
" is ready !"
);
//
LoggerService.Service.Info("FixedMemoryBlock", memory.Name+ " is ready !");
memory
.
DecRef
();
memory
.
DecRef
();
//memory.StartMemory[0] = 0;
//memory.StartMemory[0] = 0;
}
}
...
...
Common/Cdy.Tag.Common/Common/MarshalFixedMemoryBlock.cs
浏览文件 @
2b3d6b81
...
@@ -1512,7 +1512,7 @@ namespace Cdy.Tag
...
@@ -1512,7 +1512,7 @@ namespace Cdy.Tag
public
static
void
MakeMemoryBusy
(
this
MarshalFixedMemoryBlock
memory
)
public
static
void
MakeMemoryBusy
(
this
MarshalFixedMemoryBlock
memory
)
{
{
memory
.
IncRef
();
memory
.
IncRef
();
LoggerService
.
Service
.
Info
(
"MemoryBlock"
,
"make "
+
memory
.
Name
+
" is busy....."
);
//
LoggerService.Service.Info("MemoryBlock","make "+ memory.Name + " is busy.....");
//memory.IsBusy = true;
//memory.IsBusy = true;
//memory.StartMemory[0] = 1;
//memory.StartMemory[0] = 1;
...
@@ -1525,7 +1525,7 @@ namespace Cdy.Tag
...
@@ -1525,7 +1525,7 @@ namespace Cdy.Tag
public
static
void
MakeMemoryNoBusy
(
this
MarshalFixedMemoryBlock
memory
)
public
static
void
MakeMemoryNoBusy
(
this
MarshalFixedMemoryBlock
memory
)
{
{
memory
.
DecRef
();
memory
.
DecRef
();
LoggerService
.
Service
.
Info
(
"MemoryBlock"
,
"make "
+
memory
.
Name
+
" is ready !"
);
//
LoggerService.Service.Info("MemoryBlock", "make " + memory.Name+ " is ready !");
//memory.StartMemory[0] = 0;
//memory.StartMemory[0] = 0;
}
}
...
...
Common/Cdy.Tag.Common/Common/MarshalMemoryBlock.cs
浏览文件 @
2b3d6b81
...
@@ -382,6 +382,12 @@ namespace Cdy.Tag
...
@@ -382,6 +382,12 @@ namespace Cdy.Tag
if
(
mIsDisposed
)
break
;
if
(
mIsDisposed
)
break
;
Marshal
.
Copy
(
zoreData
,
0
,
vv
+
i
*
zoreData
.
Length
,
zoreData
.
Length
);
Marshal
.
Copy
(
zoreData
,
0
,
vv
+
i
*
zoreData
.
Length
,
zoreData
.
Length
);
}
}
if
(
BufferItemSize
%
zoreData
.
Length
>
0
)
{
Marshal
.
Copy
(
zoreData
,
0
,
vv
+
(
BufferItemSize
>
zoreData
.
Length
?
BufferItemSize
-
zoreData
.
Length
:
0
),
BufferItemSize
>
zoreData
.
Length
?
zoreData
.
Length
:
BufferItemSize
);
}
}
}
}
}
catch
catch
...
@@ -2490,7 +2496,7 @@ namespace Cdy.Tag
...
@@ -2490,7 +2496,7 @@ namespace Cdy.Tag
public
static
void
MakeMemoryBusy
(
this
MarshalMemoryBlock
memory
)
public
static
void
MakeMemoryBusy
(
this
MarshalMemoryBlock
memory
)
{
{
memory
.
IncRef
();
memory
.
IncRef
();
LoggerService
.
Service
.
Info
(
"MemoryBlock"
,
"make "
+
memory
.
Name
+
" is busy....."
);
//
LoggerService.Service.Info("MemoryBlock","make "+ memory.Name + " is busy.....");
//memory.IsBusy = true;
//memory.IsBusy = true;
//memory.StartMemory[0] = 1;
//memory.StartMemory[0] = 1;
...
@@ -2503,7 +2509,7 @@ namespace Cdy.Tag
...
@@ -2503,7 +2509,7 @@ namespace Cdy.Tag
public
static
void
MakeMemoryNoBusy
(
this
MarshalMemoryBlock
memory
)
public
static
void
MakeMemoryNoBusy
(
this
MarshalMemoryBlock
memory
)
{
{
memory
.
DecRef
();
memory
.
DecRef
();
LoggerService
.
Service
.
Info
(
"MemoryBlock"
,
"make "
+
memory
.
Name
+
" is ready !"
);
//
LoggerService.Service.Info("MemoryBlock", "make " + memory.Name+ " is ready !");
//memory.StartMemory[0] = 0;
//memory.StartMemory[0] = 0;
}
}
...
...
Common/Cdy.Tag.Common/Common/MemoryBlock.cs
浏览文件 @
2b3d6b81
...
@@ -1797,7 +1797,7 @@ namespace Cdy.Tag
...
@@ -1797,7 +1797,7 @@ namespace Cdy.Tag
/// <param name="memory"></param>
/// <param name="memory"></param>
public
static
void
MakeMemoryBusy
(
this
MemoryBlock
memory
)
public
static
void
MakeMemoryBusy
(
this
MemoryBlock
memory
)
{
{
LoggerService
.
Service
.
Info
(
"MemoryBlock"
,
memory
.
Name
+
" is busy....."
);
//
LoggerService.Service.Info("MemoryBlock", memory.Name + " is busy.....");
memory
.
IsBusy
=
true
;
memory
.
IsBusy
=
true
;
//memory.StartMemory[0] = 1;
//memory.StartMemory[0] = 1;
}
}
...
@@ -1808,7 +1808,7 @@ namespace Cdy.Tag
...
@@ -1808,7 +1808,7 @@ namespace Cdy.Tag
/// <param name="memory"></param>
/// <param name="memory"></param>
public
static
void
MakeMemoryNoBusy
(
this
MemoryBlock
memory
)
public
static
void
MakeMemoryNoBusy
(
this
MemoryBlock
memory
)
{
{
LoggerService
.
Service
.
Info
(
"MemoryBlock"
,
memory
.
Name
+
" is ready !"
);
//
LoggerService.Service.Info("MemoryBlock", memory.Name+ " is ready !");
memory
.
IsBusy
=
false
;
memory
.
IsBusy
=
false
;
//memory.StartMemory[0] = 0;
//memory.StartMemory[0] = 0;
}
}
...
...
Common/Cdy.Tag.Driver/IRealTagProducter.cs
浏览文件 @
2b3d6b81
...
@@ -99,7 +99,13 @@ namespace Cdy.Tag.Driver
...
@@ -99,7 +99,13 @@ namespace Cdy.Tag.Driver
/// <returns></returns>
/// <returns></returns>
bool
SetTagValue
(
Tagbase
tag
,
object
value
,
DateTime
time
,
byte
quality
);
bool
SetTagValue
(
Tagbase
tag
,
object
value
,
DateTime
time
,
byte
quality
);
/// <summary>
///
/// </summary>
/// <param name="tag"></param>
/// <param name="value"></param>
/// <param name="quality"></param>
/// <returns></returns>
bool
SetTagValue
(
Tagbase
tag
,
object
value
,
byte
quality
);
bool
SetTagValue
(
Tagbase
tag
,
object
value
,
byte
quality
);
/// <summary>
/// <summary>
...
...
Common/Cdy.Tag.Driver/ITagHisvalueProducter.cs
浏览文件 @
2b3d6b81
...
@@ -36,6 +36,19 @@ namespace Cdy.Tag.Driver
...
@@ -36,6 +36,19 @@ namespace Cdy.Tag.Driver
#
region
...
Methods
...
#
region
...
Methods
...
/// <summary>
/// 获取手工记录的变量的Id
/// </summary>
/// <returns></returns>
List
<
int
>
GetManualRecordTagId
();
/// <summary>
/// 获取变量的记录类型
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
Dictionary
<
int
,
RecordType
>
GetTagRecordType
(
List
<
int
>
id
);
/// <summary>
/// <summary>
/// 设置变量的历史值
/// 设置变量的历史值
/// </summary>
/// </summary>
...
@@ -55,6 +68,26 @@ namespace Cdy.Tag.Driver
...
@@ -55,6 +68,26 @@ namespace Cdy.Tag.Driver
/// <returns></returns>
/// <returns></returns>
bool
SetTagHisValue
(
int
id
,
TagValue
value
,
int
timeUnit
);
bool
SetTagHisValue
(
int
id
,
TagValue
value
,
int
timeUnit
);
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="time"></param>
/// <param name="value"></param>
/// <param name="quality"></param>
/// <param name="timeUnit"></param>
/// <returns></returns>
bool
SetTagHisValue
(
int
id
,
DateTime
time
,
object
value
,
byte
quality
,
int
timeUnit
);
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="value"></param>
/// <param name="timeUnit"></param>
/// <returns></returns>
bool
SetTagHisValue
(
int
id
,
object
value
,
int
timeUnit
);
/// <summary>
/// <summary>
/// 设置变量的历史值
/// 设置变量的历史值
/// </summary>
/// </summary>
...
@@ -64,6 +97,12 @@ namespace Cdy.Tag.Driver
...
@@ -64,6 +97,12 @@ namespace Cdy.Tag.Driver
bool
SetTagHisValues
(
Dictionary
<
int
,
List
<
TagValue
>>
values
,
int
timeUnit
);
bool
SetTagHisValues
(
Dictionary
<
int
,
List
<
TagValue
>>
values
,
int
timeUnit
);
/// <summary>
///
/// </summary>
/// <param name="values"></param>
/// <param name="timeUnit"></param>
/// <returns></returns>
bool
SetTagHisValues
(
Dictionary
<
int
,
TagValue
>
values
,
int
timeUnit
);
bool
SetTagHisValues
(
Dictionary
<
int
,
TagValue
>
values
,
int
timeUnit
);
/// <summary>
/// <summary>
...
...
Driver/SimDriver/Driver.cs
浏览文件 @
2b3d6b81
...
@@ -5,6 +5,7 @@ using System.Collections;
...
@@ -5,6 +5,7 @@ using System.Collections;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Diagnostics
;
using
System.IO
;
using
System.IO
;
using
System.Linq
;
using
System.Threading
;
using
System.Threading
;
namespace
SimDriver
namespace
SimDriver
...
@@ -14,7 +15,9 @@ namespace SimDriver
...
@@ -14,7 +15,9 @@ namespace SimDriver
#
region
...
Variables
...
#
region
...
Variables
...
System
.
Collections
.
Generic
.
Dictionary
<
string
,
List
<
Tagbase
>>
mTagIdCach
=
new
Dictionary
<
string
,
List
<
Tagbase
>>();
Dictionary
<
string
,
List
<
Tagbase
>>
mTagIdCach
=
new
Dictionary
<
string
,
List
<
Tagbase
>>();
Dictionary
<
string
,
List
<
int
>>
mManualRecordTagCach
=
new
Dictionary
<
string
,
List
<
int
>>();
//private System.Timers.Timer mScanTimer;
//private System.Timers.Timer mScanTimer;
...
@@ -102,6 +105,14 @@ namespace SimDriver
...
@@ -102,6 +105,14 @@ namespace SimDriver
private
void
InitTagCach
(
IRealTagProduct
tagQuery
)
private
void
InitTagCach
(
IRealTagProduct
tagQuery
)
{
{
mTagIdCach
=
tagQuery
.
GetTagsByLinkAddress
(
new
List
<
string
>()
{
"Sim:cos"
,
"Sim:sin"
,
"Sim:step"
,
"Sim:steppoint"
,
"Sim:square"
});
mTagIdCach
=
tagQuery
.
GetTagsByLinkAddress
(
new
List
<
string
>()
{
"Sim:cos"
,
"Sim:sin"
,
"Sim:step"
,
"Sim:steppoint"
,
"Sim:square"
});
mTagHisValueService
=
ServiceLocator
.
Locator
.
Resolve
<
ITagHisValueProduct
>();
foreach
(
var
vv
in
mTagIdCach
)
{
mManualRecordTagCach
.
Add
(
vv
.
Key
,
mTagHisValueService
.
GetTagRecordType
(
vv
.
Value
.
Select
(
e
=>
e
.
Id
).
ToList
()).
Where
(
e
=>
e
.
Value
==
RecordType
.
Manual
).
Select
(
e
=>
e
.
Key
).
ToList
());
}
}
}
/// <summary>
/// <summary>
...
@@ -184,6 +195,41 @@ namespace SimDriver
...
@@ -184,6 +195,41 @@ namespace SimDriver
});
});
mTagService
.
SubmiteNotifyChanged
();
mTagService
.
SubmiteNotifyChanged
();
long
llsw
=
sw
.
ElapsedMilliseconds
;
System
.
Threading
.
Tasks
.
Parallel
.
ForEach
(
mManualRecordTagCach
,
(
vv
)
=>
{
if
(
vv
.
Key
==
"Sim:cos"
)
{
TagValue
tv
=
new
TagValue
()
{
Quality
=
0
,
Time
=
DateTime
.
Now
,
Value
=
fval
};
mTagHisValueService
.
SetTagHisValues
(
vv
.
Value
.
ToDictionary
(
e
=>
e
,
e
=>
tv
),
1000
);
}
else
if
(
vv
.
Key
==
"Sim:sin"
)
{
TagValue
tv
=
new
TagValue
()
{
Quality
=
0
,
Time
=
DateTime
.
Now
,
Value
=
sval
};
mTagHisValueService
.
SetTagHisValues
(
vv
.
Value
.
ToDictionary
(
e
=>
e
,
e
=>
tv
),
1000
);
//mTagService.SetTagValue(vv.Value, sval);
}
else
if
(
vv
.
Key
==
"Sim:step"
)
{
TagValue
tv
=
new
TagValue
()
{
Quality
=
0
,
Time
=
DateTime
.
Now
,
Value
=
mNumber
};
mTagHisValueService
.
SetTagHisValues
(
vv
.
Value
.
ToDictionary
(
e
=>
e
,
e
=>
tv
),
1000
);
//mTagService.SetTagValue(vv.Value, mNumber);
}
else
if
(
vv
.
Key
==
"Sim:steppoint"
)
{
TagValue
tv
=
new
TagValue
()
{
Quality
=
0
,
Time
=
DateTime
.
Now
,
Value
=
fval
};
mTagHisValueService
.
SetTagHisValues
(
vv
.
Value
.
ToDictionary
(
e
=>
e
,
e
=>
tv
),
1000
);
// mTagService.SetPointValue(vv.Value, mNumber, mNumber, mNumber);
}
else
if
(
vv
.
Key
==
"Sim:square"
)
{
TagValue
tv
=
new
TagValue
()
{
Quality
=
0
,
Time
=
DateTime
.
Now
,
Value
=
mBoolNumber
};
mTagHisValueService
.
SetTagHisValues
(
vv
.
Value
.
ToDictionary
(
e
=>
e
,
e
=>
tv
),
1000
);
//mTagService.SetTagValue(vv.Value, mBoolNumber);
}
});
int
delay
=
(
int
)(
500
-
(
DateTime
.
Now
-
mLastProcessTime
).
TotalMilliseconds
);
int
delay
=
(
int
)(
500
-
(
DateTime
.
Now
-
mLastProcessTime
).
TotalMilliseconds
);
if
(
delay
<
0
)
if
(
delay
<
0
)
{
{
...
@@ -192,7 +238,7 @@ namespace SimDriver
...
@@ -192,7 +238,7 @@ namespace SimDriver
#if DEBUG
#if DEBUG
sw
.
Stop
();
sw
.
Stop
();
if
(
mNumber
%
10
==
0
)
if
(
mNumber
%
10
==
0
)
LoggerService
.
Service
.
Debug
(
"Sim Driver"
,
"set value elapsed:"
+
sw
.
ElapsedMilliseconds
);
LoggerService
.
Service
.
Debug
(
"Sim Driver"
,
"set value elapsed:"
+
sw
.
ElapsedMilliseconds
+
", set his value elapsed:"
+(
sw
.
ElapsedMilliseconds
-
llsw
)
);
#endif
#endif
Thread
.
Sleep
(
delay
);
Thread
.
Sleep
(
delay
);
}
}
...
...
RunTime/DBInRun/Properties/launchSettings.json
浏览文件 @
2b3d6b81
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"profiles"
:
{
"profiles"
:
{
"DBInRun"
:
{
"DBInRun"
:
{
"commandName"
:
"Executable"
,
"commandName"
:
"Executable"
,
"executablePath"
:
"C:
\\
Users
\\
c
dy81
\\
source
\\
repos
\\
mars
\\
Output
\\
DBInRun.exe"
"executablePath"
:
"C:
\\
Users
\\
c
hongdaoyang
\\
source
\\
repos
\\
mars
\\
Output
\\
DBInRun.exe"
}
}
}
}
}
}
\ No newline at end of file
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
浏览文件 @
2b3d6b81
...
@@ -168,7 +168,7 @@ namespace Cdy.Tag
...
@@ -168,7 +168,7 @@ namespace Cdy.Tag
vpp
=
mMemoryCach
.
Dequeue
();
vpp
=
mMemoryCach
.
Dequeue
();
}
}
Compress
(
vpp
);
Compress
(
vpp
);
Thread
.
Sleep
(
1
);
//
Thread.Sleep(1);
}
}
mIsRunning
=
false
;
mIsRunning
=
false
;
}
}
...
@@ -389,7 +389,7 @@ namespace Cdy.Tag
...
@@ -389,7 +389,7 @@ namespace Cdy.Tag
int
datasize
=
0
;
int
datasize
=
0
;
var
targetPosition
=
28
;
var
targetPosition
=
28
;
block
.
WriteInt
(
0
,
data
.
Id
);
block
.
WriteDatetime
(
4
,
data
.
Time
);
//时间
block
.
WriteDatetime
(
4
,
data
.
Time
);
//时间
block
.
WriteDatetime
(
12
,
data
.
EndTime
);
//结束时间
block
.
WriteDatetime
(
12
,
data
.
EndTime
);
//结束时间
//block.WriteInt(20, 0); //写入数据大小
//block.WriteInt(20, 0); //写入数据大小
...
...
RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs
浏览文件 @
2b3d6b81
...
@@ -68,7 +68,7 @@ namespace Cdy.Tag
...
@@ -68,7 +68,7 @@ namespace Cdy.Tag
{
{
target
.
WriteDatetime
(
targetAddr
,
this
.
StartTime
);
target
.
WriteDatetime
(
targetAddr
,
this
.
StartTime
);
LoggerService
.
Service
.
Debug
(
"LosslessCompressUnit2"
,
"Record time: "
+
this
.
StartTime
.
ToString
(
"yyyy-MM-dd HH:mm:ss.fff"
));
//
LoggerService.Service.Debug("LosslessCompressUnit2", "Record time: "+this.StartTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
target
.
Write
(
TimeTick
);
target
.
Write
(
TimeTick
);
switch
(
TagType
)
switch
(
TagType
)
...
...
RunTime/DBRuntime/His/HisEnginer2.cs
浏览文件 @
2b3d6b81
此差异已折叠。
点击以展开。
RunTime/DBRuntime/His/ManualHisDataMemoryBlockPool.cs
浏览文件 @
2b3d6b81
...
@@ -26,7 +26,7 @@ namespace DBRuntime.His
...
@@ -26,7 +26,7 @@ namespace DBRuntime.His
/// <summary>
/// <summary>
///
///
/// </summary>
/// </summary>
private
Dictionary
<
int
,
Dictionary
<
ManualHisDataMemoryBlock
,
bool
>>
mPools
=
new
Dictionary
<
int
,
Dictionary
<
ManualHisDataMemoryBlock
,
bool
>>();
private
Dictionary
<
int
,
Queue
<
ManualHisDataMemoryBlock
>>
mFreePools
=
new
Dictionary
<
int
,
Queue
<
ManualHisDataMemoryBlock
>>();
#
endregion
...
Variables
...
#
endregion
...
Variables
...
...
@@ -44,6 +44,30 @@ namespace DBRuntime.His
...
@@ -44,6 +44,30 @@ namespace DBRuntime.His
#
region
...
Methods
...
#
region
...
Methods
...
/// <summary>
///
/// </summary>
/// <param name="size"></param>
public
void
PreAlloc
(
int
size
)
{
lock
(
mFreePools
)
{
if
(
mFreePools
.
ContainsKey
(
size
))
{
var
pp
=
mFreePools
[
size
];
var
bnb
=
NewBlock
(
size
);
pp
.
Enqueue
(
bnb
);
}
else
{
var
bnb
=
NewBlock
(
size
);
Queue
<
ManualHisDataMemoryBlock
>
dd
=
new
Queue
<
ManualHisDataMemoryBlock
>();
dd
.
Enqueue
(
bnb
);
mFreePools
.
Add
(
size
,
dd
);
}
}
}
/// <summary>
/// <summary>
///
///
/// </summary>
/// </summary>
...
@@ -51,31 +75,27 @@ namespace DBRuntime.His
...
@@ -51,31 +75,27 @@ namespace DBRuntime.His
/// <returns></returns>
/// <returns></returns>
public
ManualHisDataMemoryBlock
Get
(
int
size
)
public
ManualHisDataMemoryBlock
Get
(
int
size
)
{
{
lock
(
mPools
)
lock
(
m
Free
Pools
)
{
{
if
(
mPools
.
ContainsKey
(
size
))
if
(
m
Free
Pools
.
ContainsKey
(
size
))
{
{
var
pp
=
m
Pools
[
size
].
Where
(
e
=>
!
e
.
Value
)
;
var
pp
=
m
FreePools
[
size
]
;
if
(
pp
.
Count
()
>
0
)
if
(
pp
.
Count
>
0
)
{
{
var
bnb
=
pp
.
First
().
Key
;
var
bnb
=
pp
.
Dequeue
();
mPools
[
size
][
bnb
]
=
true
;
return
bnb
;
return
bnb
;
}
}
else
else
{
{
var
bnb
=
NewBlock
(
size
);
var
bnb
=
NewBlock
(
size
);
mPools
[
size
].
Add
(
bnb
,
true
);
return
bnb
;
return
bnb
;
}
}
}
}
else
else
{
{
var
bnb
=
NewBlock
(
size
);
var
bnb
=
NewBlock
(
size
);
Dictionary
<
ManualHisDataMemoryBlock
,
bool
>
dd
=
new
Dictionary
<
ManualHisDataMemoryBlock
,
bool
>();
Queue
<
ManualHisDataMemoryBlock
>
dd
=
new
Queue
<
ManualHisDataMemoryBlock
>();
dd
.
Add
(
bnb
,
true
);
mFreePools
.
Add
(
size
,
dd
);
mPools
.
Add
(
size
,
dd
);
return
bnb
;
return
bnb
;
}
}
}
}
...
@@ -98,13 +118,13 @@ namespace DBRuntime.His
...
@@ -98,13 +118,13 @@ namespace DBRuntime.His
public
void
Release
(
ManualHisDataMemoryBlock
block
)
public
void
Release
(
ManualHisDataMemoryBlock
block
)
{
{
var
size
=
(
int
)
block
.
AllocSize
;
lock
(
mFreePools
)
if
(
mPools
.
ContainsKey
(
size
))
{
{
var
vv
=
mPools
[
size
]
;
var
size
=
(
int
)
block
.
AllocSize
;
if
(
vv
.
ContainsKey
(
block
))
if
(
mFreePools
.
ContainsKey
(
size
))
{
{
vv
[
block
]
=
false
;
var
vv
=
mFreePools
[
size
];
vv
.
Enqueue
(
block
);
block
.
Clear
();
block
.
Clear
();
}
}
}
}
...
...
RunTime/DBRuntime/His/MarshalMemoryBlockPool.cs
浏览文件 @
2b3d6b81
...
@@ -27,7 +27,7 @@ namespace DBRuntime.His
...
@@ -27,7 +27,7 @@ namespace DBRuntime.His
/// <summary>
/// <summary>
///
///
/// </summary>
/// </summary>
private
Dictionary
<
MarshalMemoryBlock
,
bool
>
mPools
=
new
Dictionary
<
MarshalMemoryBlock
,
bool
>();
private
Dictionary
<
long
,
Queue
<
MarshalMemoryBlock
>>
mFreePools
=
new
Dictionary
<
long
,
Queue
<
MarshalMemoryBlock
>
>();
#
endregion
...
Variables
...
#
endregion
...
Variables
...
...
@@ -52,19 +52,27 @@ namespace DBRuntime.His
...
@@ -52,19 +52,27 @@ namespace DBRuntime.His
/// <returns></returns>
/// <returns></returns>
public
MarshalMemoryBlock
Get
(
long
size
)
public
MarshalMemoryBlock
Get
(
long
size
)
{
{
lock
(
mPools
)
lock
(
m
Free
Pools
)
{
{
var
mms
=
mPools
.
Where
(
e
=>
!
e
.
Value
&&
e
.
Key
.
AllocSize
==
size
);
if
(
mFreePools
.
ContainsKey
(
size
))
if
(
mms
.
Count
()
>
0
)
{
{
var
vv
=
mms
.
First
().
Key
;
var
pp
=
mFreePools
[
size
];
mPools
[
vv
]
=
true
;
if
(
pp
.
Count
>
0
)
return
vv
;
{
var
bnb
=
pp
.
Dequeue
();
return
bnb
;
}
else
{
var
bnb
=
NewBlock
(
size
);
return
bnb
;
}
}
}
else
else
{
{
var
bnb
=
NewBlock
(
size
);
var
bnb
=
NewBlock
(
size
);
mPools
.
Add
(
bnb
,
true
);
Queue
<
MarshalMemoryBlock
>
dd
=
new
Queue
<
MarshalMemoryBlock
>();
mFreePools
.
Add
(
size
,
dd
);
return
bnb
;
return
bnb
;
}
}
}
}
...
@@ -77,7 +85,7 @@ namespace DBRuntime.His
...
@@ -77,7 +85,7 @@ namespace DBRuntime.His
/// <returns></returns>
/// <returns></returns>
private
MarshalMemoryBlock
NewBlock
(
long
size
)
private
MarshalMemoryBlock
NewBlock
(
long
size
)
{
{
return
new
MarshalMemoryBlock
(
size
).
Clear
();
return
new
MarshalMemoryBlock
(
size
,(
int
)
size
).
Clear
();
}
}
/// <summary>
/// <summary>
...
@@ -87,11 +95,16 @@ namespace DBRuntime.His
...
@@ -87,11 +95,16 @@ namespace DBRuntime.His
public
void
Release
(
MarshalMemoryBlock
block
)
public
void
Release
(
MarshalMemoryBlock
block
)
{
{
if
(
mPools
.
ContainsKey
(
block
)
)
lock
(
mFreePools
)
{
{
mPools
[
block
]
=
false
;
var
size
=
(
int
)
block
.
AllocSize
;
if
(
mFreePools
.
ContainsKey
(
size
))
{
var
vv
=
mFreePools
[
size
];
vv
.
Enqueue
(
block
);
block
.
Clear
();
}
}
}
block
.
Clear
();
}
}
#
endregion
...
Methods
...
#
endregion
...
Methods
...
...
...
RunTime/DBRuntime/His/SeriseEnginer2.cs
浏览文件 @
2b3d6b81
...
@@ -17,6 +17,7 @@ using System.Buffers;
...
@@ -17,6 +17,7 @@ using System.Buffers;
using
DotNetty.Common
;
using
DotNetty.Common
;
using
DBRuntime.His
;
using
DBRuntime.His
;
using
System.Collections
;
using
System.Collections
;
using
System.Drawing
;
/*
/*
* ****文件结构****
* ****文件结构****
...
@@ -268,6 +269,12 @@ namespace Cdy.Tag
...
@@ -268,6 +269,12 @@ namespace Cdy.Tag
lock
(
resetEvent
)
lock
(
resetEvent
)
resetEvent
.
Reset
();
resetEvent
.
Reset
();
//#if DEBUG
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
"********开始执行存储********"
,
ConsoleColor
.
Cyan
);
//#endif
if
(
mWaitForProcessMemory
.
Count
>
0
)
if
(
mWaitForProcessMemory
.
Count
>
0
)
{
{
SaveToFile
();
SaveToFile
();
...
@@ -284,6 +291,11 @@ namespace Cdy.Tag
...
@@ -284,6 +291,11 @@ namespace Cdy.Tag
}
}
}
}
//#if DEBUG
sw
.
Stop
();
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
">>>>>>>>>完成执行存储>>>>>>> ElapsedMilliseconds:"
+
sw
.
ElapsedMilliseconds
,
ConsoleColor
.
Cyan
);
//#endif
if
(
mIsClosed
)
if
(
mIsClosed
)
break
;
break
;
}
}
...
@@ -300,11 +312,7 @@ namespace Cdy.Tag
...
@@ -300,11 +312,7 @@ namespace Cdy.Tag
2. 拷贝数据块
2. 拷贝数据块
3. 更新数据块指针
3. 更新数据块指针
*/
*/
//#if DEBUG
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
"********开始执行存储********"
,
ConsoleColor
.
Cyan
);
//#endif
HisDataPath
=
SelectHisDataPath
();
HisDataPath
=
SelectHisDataPath
();
List
<
CompressMemory2
>
mtmp
;
List
<
CompressMemory2
>
mtmp
;
lock
(
mWaitForProcessMemory
)
lock
(
mWaitForProcessMemory
)
...
@@ -320,10 +328,7 @@ namespace Cdy.Tag
...
@@ -320,10 +328,7 @@ namespace Cdy.Tag
vv
.
MakeMemoryNoBusy
();
vv
.
MakeMemoryNoBusy
();
}
}
//#if DEBUG
sw
.
Stop
();
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
">>>>>>>>>完成执行存储>>>>>>> Count:"
+
mtmp
.
Count
+
" ElapsedMilliseconds:"
+
sw
.
ElapsedMilliseconds
,
ConsoleColor
.
Cyan
);
//#endif
}
}
/// <summary>
/// <summary>
...
@@ -351,7 +356,7 @@ namespace Cdy.Tag
...
@@ -351,7 +356,7 @@ namespace Cdy.Tag
foreach
(
var
vv
in
mSeriserFiles
)
foreach
(
var
vv
in
mSeriserFiles
)
{
{
if
(
id
>=
vv
.
Value
.
Id
*
TagCountOneFile
&&
id
<
(
vv
.
Value
.
Id
+
1
)
*
TagCountOneFile
)
if
(
id
>=
vv
.
Value
.
Id
Start
&&
id
<
vv
.
Value
.
IdEnd
)
{
{
vv
.
Value
.
ManualRequestToSeriseFile
(
id
,
data
);
vv
.
Value
.
ManualRequestToSeriseFile
(
id
,
data
);
}
}
...
@@ -370,7 +375,7 @@ namespace Cdy.Tag
...
@@ -370,7 +375,7 @@ namespace Cdy.Tag
HisDataPath
=
SelectHisDataPath
();
HisDataPath
=
SelectHisDataPath
();
lock
(
mCachSeriseMemoryBlock
)
lock
(
mCachSeriseMemoryBlock
)
mCachSeriseMemoryBlock
.
Enqueue
(
data
);
mCachSeriseMemoryBlock
.
Enqueue
(
data
);
if
(
mCachSeriseMemoryBlock
.
Count
>
10
)
RequestToSave
();
}
}
#
endregion
...
Methods
...
#
endregion
...
Methods
...
...
@@ -444,9 +449,10 @@ namespace Cdy.Tag
...
@@ -444,9 +449,10 @@ namespace Cdy.Tag
private
List
<
int
>
mTagIdsCach
;
private
List
<
int
>
mTagIdsCach
;
private
Dictionary
<
DateTime
,
Dictionary
<
int
,
long
>>
mPointerCach
=
new
Dictionary
<
DateTime
,
Dictionary
<
int
,
long
>>();
private
Dictionary
<
DateTime
,
Dictionary
<
int
,
long
>>
mPointerCach
=
new
Dictionary
<
DateTime
,
Dictionary
<
int
,
long
>>();
private
int
mId
=
0
;
#
endregion
...
Variables
...
#
endregion
...
Variables
...
#
region
...
Events
...
#
region
...
Events
...
...
@@ -458,10 +464,21 @@ namespace Cdy.Tag
...
@@ -458,10 +464,21 @@ namespace Cdy.Tag
#
endregion
...
Constructor
...
#
endregion
...
Constructor
...
#
region
...
Properties
...
#
region
...
Properties
...
/// <summary>
/// <summary>
///
///
/// </summary>
/// </summary>
public
int
Id
{
get
;
set
;
}
public
int
IdStart
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
IdEnd
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
Id
{
get
{
return
mId
;
}
set
{
mId
=
value
;
IdStart
=
value
*
TagCountOneFile
;
IdEnd
=
(
value
+
1
)
*
TagCountOneFile
;
}
}
/// <summary>
/// <summary>
///
///
...
@@ -506,6 +523,8 @@ namespace Cdy.Tag
...
@@ -506,6 +523,8 @@ namespace Cdy.Tag
public
bool
IsNeedInit
{
get
;
set
;
}
public
bool
IsNeedInit
{
get
;
set
;
}
private
Dictionary
<
int
,
MarshalMemoryBlock
>
mManualHisDataCach
=
new
Dictionary
<
int
,
MarshalMemoryBlock
>();
#
endregion
...
Properties
...
#
endregion
...
Properties
...
#
region
...
Methods
...
#
region
...
Methods
...
...
@@ -815,6 +834,48 @@ namespace Cdy.Tag
...
@@ -815,6 +834,48 @@ namespace Cdy.Tag
return
preoffset
;
return
preoffset
;
}
}
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="datablock"></param>
public
void
AppendManualSeriseFile
(
int
id
,
MarshalMemoryBlock
datablock
)
{
mManualHisDataCach
.
Add
(
id
,
datablock
);
}
/// <summary>
///
/// </summary>
public
void
FreshManualDataToDisk
()
{
string
oldFile
=
string
.
Empty
;
DataFileSeriserbase
mwriter
;
Dictionary
<
int
,
long
>
mHeadAddress
=
new
Dictionary
<
int
,
long
>();
Dictionary
<
int
,
long
>
mHeadValue
=
new
Dictionary
<
int
,
long
>();
foreach
(
var
vv
in
mManualHisDataCach
)
{
var
id
=
vv
.
Key
;
var
datablock
=
vv
.
Value
;
DateTime
time
=
datablock
.
ReadDateTime
(
4
);
DateTime
endTime
=
datablock
.
ReadDateTime
(
12
);
int
size
=
datablock
.
ReadInt
(
20
);
mTagCount
=
datablock
.
ReadInt
(
24
);
//变量个数
string
sfile
=
GetFileName
(
time
);
if
(
sfile
!=
oldFile
)
{
mHeadAddress
=
new
Dictionary
<
int
,
long
>();
mHeadValue
=
new
Dictionary
<
int
,
long
>();
var
heads
=
GetDataRegionHeadPoint
(
id
,
time
,
out
mwriter
);
mHeadAddress
.
Add
(
id
,
heads
);
}
}
}
/// <summary>
/// <summary>
/// 通过手动更新的方式,提交历史记录
/// 通过手动更新的方式,提交历史记录
/// </summary>
/// </summary>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录