Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cdy816
Mars
提交
ba87cd21
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 搜索 >>
提交
ba87cd21
编写于
9月 28, 2020
作者:
cdy816
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
日常更新
上级
57c7a1f1
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
384 addition
and
151 deletion
+384
-151
Driver/SimDriver/Driver.cs
Driver/SimDriver/Driver.cs
+1
-1
RunTime/DBHisData/HisQuery/DataFileManager.cs
RunTime/DBHisData/HisQuery/DataFileManager.cs
+19
-49
RunTime/DBHisData/HisQuery/TimeFile/DataFileInfo.cs
RunTime/DBHisData/HisQuery/TimeFile/DataFileInfo.cs
+149
-47
RunTime/DBInRun/Properties/launchSettings.json
RunTime/DBInRun/Properties/launchSettings.json
+1
-1
RunTime/DBRuntime/Driver/DriverManager.cs
RunTime/DBRuntime/Driver/DriverManager.cs
+2
-2
RunTime/DBRuntime/His/Compress/CompressEnginer2.cs
RunTime/DBRuntime/His/Compress/CompressEnginer2.cs
+3
-2
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
+7
-2
RunTime/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs
...e/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs
+30
-4
RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs
...e/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs
+18
-3
RunTime/DBRuntime/His/Compress/Special/SlopeCompressUnit2.cs
RunTime/DBRuntime/His/Compress/Special/SlopeCompressUnit2.cs
+17
-2
RunTime/DBRuntime/His/HisDataMemoryBlockCollection.cs
RunTime/DBRuntime/His/HisDataMemoryBlockCollection.cs
+4
-0
RunTime/DBRuntime/His/HisEnginer2.cs
RunTime/DBRuntime/His/HisEnginer2.cs
+6
-3
RunTime/DBRuntime/His/ManualHisDataMemoryBlock.cs
RunTime/DBRuntime/His/ManualHisDataMemoryBlock.cs
+5
-0
RunTime/DBRuntime/His/SeriseEnginer2.cs
RunTime/DBRuntime/His/SeriseEnginer2.cs
+43
-25
RunTime/DBRuntime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs
...ime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs
+16
-2
RunTime/DBRuntime/His/obsolete/Compress/Special/DoubleCompressBuffer.cs
...ime/His/obsolete/Compress/Special/DoubleCompressBuffer.cs
+13
-0
RunTime/DBRuntime/His/obsolete/Compress/Special/FloatCompressBuffer.cs
...time/His/obsolete/Compress/Special/FloatCompressBuffer.cs
+12
-0
RunTime/DBRuntime/His/obsolete/Compress/Special/LosslessCompressUnit.cs
...ime/His/obsolete/Compress/Special/LosslessCompressUnit.cs
+17
-3
RunTime/DBRuntime/His/obsolete/Compress/Special/SlopeCompressUnit.cs
...untime/His/obsolete/Compress/Special/SlopeCompressUnit.cs
+18
-2
RunTime/DBRuntime/Interface/IDataSerialize2.cs
RunTime/DBRuntime/Interface/IDataSerialize2.cs
+2
-2
Tools/HisDataTools/Properties/launchSettings.json
Tools/HisDataTools/Properties/launchSettings.json
+1
-1
未找到文件。
Driver/SimDriver/Driver.cs
浏览文件 @
ba87cd21
...
...
@@ -192,7 +192,7 @@ namespace SimDriver
#if DEBUG
sw
.
Stop
();
if
(
mNumber
%
10
==
0
)
LoggerService
.
Service
.
Info
(
"Sim Driver"
,
"set value elapsed:"
+
sw
.
ElapsedMilliseconds
);
LoggerService
.
Service
.
Debug
(
"Sim Driver"
,
"set value elapsed:"
+
sw
.
ElapsedMilliseconds
);
#endif
Thread
.
Sleep
(
delay
);
}
...
...
RunTime/DBHisData/HisQuery/DataFileManager.cs
浏览文件 @
ba87cd21
...
...
@@ -36,6 +36,9 @@ namespace Cdy.Tag
/// </summary>
internal
static
Dictionary
<
string
,
DateTime
>
CurrentDateTime
=
new
Dictionary
<
string
,
DateTime
>();
/// <summary>
///
/// </summary>
private
string
mDatabaseName
;
/// <summary>
...
...
@@ -43,12 +46,15 @@ namespace Cdy.Tag
/// </summary>
public
const
string
DataFileExtends
=
".dbd"
;
/// <summary>
///
/// </summary>
public
const
string
LogFileExtends
=
".log"
;
/// <summary>
///
/// </summary>
public
const
int
FileHeadSize
=
72
;
public
const
int
FileHeadSize
=
84
;
private
System
.
IO
.
FileSystemWatcher
hisDataWatcher
;
...
...
@@ -246,12 +252,12 @@ namespace Cdy.Tag
var
vifno
=
new
System
.
IO
.
FileInfo
(
vv
.
Key
);
if
(
vv
.
Value
==
System
.
IO
.
WatcherChangeTypes
.
Created
)
{
LoggerService
.
Service
.
Info
(
"DataFileMananger"
,
"HisDataFile "
+
vv
.
Key
+
" is Created & will be add to dataFileCach
!
"
);
LoggerService
.
Service
.
Info
(
"DataFileMananger"
,
"HisDataFile "
+
vv
.
Key
+
" is Created & will be add to dataFileCach
!
"
);
ParseFileName
(
vifno
);
}
else
{
LoggerService
.
Service
.
Info
(
"DataFileMananger"
,
"HisDataFile "
+
vv
.
Key
+
" is changed & will be processed
!
"
);
LoggerService
.
Service
.
Info
(
"DataFileMananger"
,
"HisDataFile "
+
vv
.
Key
+
" is changed & will be processed
!
"
);
var
vfile
=
CheckAndGetDataFile
(
vv
.
Key
);
if
(
vfile
!=
null
)
...
...
@@ -293,11 +299,14 @@ namespace Cdy.Tag
mFileCach
.
Add
(
e
.
FullPath
,
e
.
ChangeType
);
}
}
//LoggerService.Service.Info("DataFileMananger", "LogFile "+ e.Name + " add to FileCach!");
//ParseLogFile(e.FullPath);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
HisDataWatcher_Changed
(
object
sender
,
System
.
IO
.
FileSystemEventArgs
e
)
{
mResetEvent
.
Set
();
...
...
@@ -312,17 +321,12 @@ namespace Cdy.Tag
if
(
vifno
.
Extension
==
DataFileExtends
)
{
mHisFileCach
.
Add
(
e
.
FullPath
,
e
.
ChangeType
);
//ParseFileName(vifno);
}
}
//LoggerService.Service.Info("DataFileMananger", "HisDataFile " + e.Name + " is Created & will be add to dataFileCach!");
}
}
else
if
(
e
.
ChangeType
==
System
.
IO
.
WatcherChangeTypes
.
Changed
)
{
// LoggerService.Service.Info("DataFileMananger", "HisDataFile " + e.Name + " is changed & will be processed!");
lock
(
mLocker
)
{
if
(!
mHisFileCach
.
ContainsKey
(
e
.
FullPath
))
...
...
@@ -331,26 +335,16 @@ namespace Cdy.Tag
if
(
vifno
.
Extension
==
DataFileExtends
)
{
mHisFileCach
.
Add
(
e
.
FullPath
,
e
.
ChangeType
);
//ParseFileName(vifno);
}
}
//if (vtmp.Extension == DataFileExtends)
//{
// var vfile = CheckAndGetDataFile(e.Name);
// if (vfile != null)
// {
// vfile.UpdateLastDatetime();
// }
// else
// {
// ParseFileName(vtmp);
// }
//}
}
}
}
/// <summary>
///
/// </summary>
/// <param name="path"></param>
public
void
ScanLogFile
(
string
path
)
{
System
.
IO
.
DirectoryInfo
dir
=
new
System
.
IO
.
DirectoryInfo
(
path
);
...
...
@@ -541,7 +535,7 @@ namespace Cdy.Tag
/// <returns></returns>
private
bool
CheckDataInLogFile
(
DateTime
time
,
int
id
)
{
string
sname
=
mDatabaseName
+
id
;
string
sname
=
mDatabaseName
+
(
id
/
TagCountOneFile
)
;
if
(
CurrentDateTime
.
ContainsKey
(
sname
))
return
CurrentDateTime
[
sname
]
<
time
;
else
...
...
@@ -585,30 +579,6 @@ namespace Cdy.Tag
/// <returns></returns>
public
List
<
DataFileInfo
>
GetDataFiles
(
DateTime
starttime
,
DateTime
endtime
,
out
Tuple
<
DateTime
,
DateTime
>
logFileTimes
,
int
Id
)
{
//string sid = mDatabaseName + Id;
//if (CurrentDateTime.ContainsKey(sid))
//{
// if (starttime > CurrentDateTime[sid])
// {
// logFileTimes = new Tuple<DateTime, DateTime>(starttime, endtime);
// return new List<DataFileInfo>();
// }
// else if (endtime <= CurrentDateTime[sid])
// {
// logFileTimes = new Tuple<DateTime, DateTime>(DateTime.MinValue, DateTime.MinValue);
// return GetDataFiles(starttime, endtime - starttime, Id);
// }
// else
// {
// logFileTimes = new Tuple<DateTime, DateTime>(CurrentDateTime[sid], endtime);
// return GetDataFiles(starttime, CurrentDateTime[sid] - starttime, Id);
// }
//}
//else
//{
// logFileTimes = new Tuple<DateTime, DateTime>(starttime, endtime);
// return GetDataFiles(starttime, endtime - starttime, Id);
//}
DateTime
dt
=
DateTime
.
MinValue
;
var
vfiles
=
GetDataFiles
(
starttime
,
endtime
-
starttime
,
Id
);
foreach
(
var
vv
in
vfiles
)
...
...
RunTime/DBHisData/HisQuery/TimeFile/DataFileInfo.cs
浏览文件 @
ba87cd21
...
...
@@ -15,6 +15,23 @@ using System.Text;
namespace
Cdy.Tag
{
/*
* ****文件结构****
* 一个文件头 + 多个数据区组成 , 一个数据区:数据区头+数据块指针区+数据块区
* [] 表示重复的一个或多个内容
*
HisData File Structor
FileHead(84) + [HisDataRegion]
FileHead: dataTime(8)(FileTime)+dataTime(8)(LastUpdateTime)+DataRegionCount(4)+DatabaseName(64)
HisDataRegion Structor: RegionHead + DataBlockPoint Area + DataBlock Area
RegionHead: PreDataRegionPoint(8) + NextDataRegionPoint(8) + Datatime(8)+ tagcount(4)+ tagid sum(8)+file duration(4)+block duration(4)+Time tick duration(4)
DataBlockPoint Area: [ID]+[block Point]
[block point]: [[tag1 point,tag2 point,....][tag1 point,tag2 point,...].....] 以时间单位对变量的数去区指针进行组织
DataBlock Area: [block size + data block]
*/
/// <summary>
///
/// </summary>
...
...
@@ -23,7 +40,7 @@ namespace Cdy.Tag
#
region
...
Variables
...
private
SortedDictionary
<
DateTime
,
Tuple
<
TimeSpan
,
long
,
DateTime
>>
mTimeOffsets
=
new
SortedDictionary
<
DateTime
,
Tuple
<
TimeSpan
,
long
,
DateTime
>>();
private
SortedDictionary
<
DateTime
,
Tuple
<
TimeSpan
,
long
,
DateTime
>>
mTimeOffsets
=
new
SortedDictionary
<
DateTime
,
Tuple
<
TimeSpan
,
long
,
DateTime
>>();
private
bool
mInited
=
false
;
...
...
@@ -31,6 +48,13 @@ namespace Cdy.Tag
private
DateTime
mLastTime
;
private
long
mLastProcessOffset
=
-
1
;
/// <summary>
///
/// </summary>
private
int
mRegionCount
=
0
;
#
endregion
...
Variables
...
#
region
...
Events
...
...
...
@@ -73,15 +97,16 @@ namespace Cdy.Tag
/// <summary>
///
/// </summary>
public
DateTime
EndTime
{
get
public
DateTime
EndTime
{
get
{
return
StartTime
+
Duration
;
}
set
{
Duration
=
value
-
StartTime
;
}
}
}
/// <summary>
...
...
@@ -114,7 +139,7 @@ namespace Cdy.Tag
}
}
}
...
...
@@ -125,33 +150,101 @@ namespace Cdy.Tag
/// <returns></returns>
public
void
Scan
()
{
long
offset
=
DataFileManager
.
FileHeadSize
;
DateTime
time
,
tmp
;
using
(
var
ss
=
DataFileSeriserManager
.
manager
.
GetDefaultFileSersie
())
{
ss
.
OpenForReadOnly
(
FileName
);
long
offset
=
DataFileManager
.
FileHeadSize
;
DateTime
time
;
//读取文件时间
DateTime
fileTime
=
ss
.
ReadDateTime
(
0
);
//读取最后一次更新时间
mLastTime
=
ss
.
ReadDateTime
(
8
);
var
rcount
=
ss
.
ReadInt
(
16
);
if
(
rcount
!=
mRegionCount
)
{
mRegionCount
=
rcount
;
}
else
{
return
;
}
do
{
//读取数据区时间
time
=
ss
.
ReadDateTime
(
offset
+
16
);
long
oset
=
offset
;
//读取下个区域位置
offset
=
ss
.
ReadLong
(
offset
+
8
);
if
(
offset
!=
0
)
{
var
dt2
=
ss
.
ReadDateTime
(
offset
+
16
);
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
dt2
-
time
,
oset
,
dt2
));
mLastTime
=
dt2
;
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
dt2
-
time
,
oset
,
dt2
));
tmp
=
dt2
;
}
else
{
var
tspan
=
StartTime
+
Duration
-
time
;
if
(
tspan
.
TotalMilliseconds
>
0
)
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
tspan
,
oset
,
time
+
tspan
));
mLastTime
=
time
+
tspan
;
if
(
tspan
.
TotalMilliseconds
>
0
)
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
tspan
,
oset
,
time
+
tspan
));
tmp
=
time
+
tspan
;
}
mLastProcessOffset
=
oset
;
}
while
(
offset
!=
0
);
if
(
mLastTime
<=
fileTime
)
{
mLastTime
=
tmp
;
}
//if (mLastProcessOffset == -1)
//{
//}
//else
//{
// offset = mLastProcessOffset;
// //读取数据区时间
// time = ss.ReadDateTime(offset + 16);
// long oset = offset;
// //读取下个区域位置
// offset = ss.ReadLong(offset + 8);
// if (offset != 0)
// {
// var dt2 = ss.ReadDateTime(offset + 16);
// if (mTimeOffsets.ContainsKey(time))
// {
// mTimeOffsets[time] = new Tuple<TimeSpan, long, DateTime>(dt2 - time, oset, dt2);
// }
// else
// {
// mTimeOffsets.Add(time, new Tuple<TimeSpan, long, DateTime>(dt2 - time, oset, dt2));
// }
// tmp = dt2;
// }
// else
// {
// var tspan = StartTime + Duration - time;
// if (tspan.TotalMilliseconds > 0)
// {
// if (mTimeOffsets.ContainsKey(time))
// {
// mTimeOffsets[time] = new Tuple<TimeSpan, long, DateTime>(tspan, oset, time + tspan);
// }
// else
// {
// mTimeOffsets.Add(time, new Tuple<TimeSpan, long, DateTime>(tspan, oset, time + tspan));
// }
// }
// tmp = time + tspan;
// }
//}
mInited
=
true
;
}
}
...
...
@@ -182,7 +275,7 @@ namespace Cdy.Tag
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public
Dictionary
<
DateTime
,
Tuple
<
TimeSpan
,
long
,
DateTime
>>
GetFileOffsets
(
DateTime
startTime
,
DateTime
endTime
)
public
Dictionary
<
DateTime
,
Tuple
<
TimeSpan
,
long
,
DateTime
>>
GetFileOffsets
(
DateTime
startTime
,
DateTime
endTime
)
{
lock
(
mLockObj
)
if
(!
mInited
)
Scan
();
...
...
@@ -206,13 +299,13 @@ namespace Cdy.Tag
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public
List
<
Tuple
<
DateTime
,
DateTime
>>
GetNoValueOffsets
(
DateTime
startTime
,
DateTime
endTime
)
public
List
<
Tuple
<
DateTime
,
DateTime
>>
GetNoValueOffsets
(
DateTime
startTime
,
DateTime
endTime
)
{
List
<
Tuple
<
DateTime
,
DateTime
>>
re
=
new
List
<
Tuple
<
DateTime
,
DateTime
>>();
DateTime
stime
=
startTime
;
List
<
DateTimeSpan
>
dtmp
=
new
List
<
DateTimeSpan
>();
DateTimeSpan
ddt
=
new
DateTimeSpan
()
{
Start
=
startTime
,
End
=
endTime
};
foreach
(
var
vv
in
mTimeOffsets
)
foreach
(
var
vv
in
mTimeOffsets
)
{
DateTimeSpan
dts
=
new
DateTimeSpan
()
{
Start
=
vv
.
Key
,
End
=
vv
.
Value
.
Item3
};
dts
=
dts
.
Cross
(
ddt
);
...
...
@@ -302,7 +395,7 @@ namespace Cdy.Tag
{
DateTime
stime
=
Max
(
target
.
Start
,
this
.
Start
);
DateTime
etime
=
Min
(
target
.
End
,
this
.
End
);
if
(
etime
<
stime
)
if
(
etime
<
stime
)
{
return
Empty
;
}
...
...
@@ -318,7 +411,7 @@ namespace Cdy.Tag
/// <param name="time1"></param>
/// <param name="time2"></param>
/// <returns></returns>
public
DateTime
Min
(
DateTime
time1
,
DateTime
time2
)
public
DateTime
Min
(
DateTime
time1
,
DateTime
time2
)
{
return
time1
<=
time2
?
time1
:
time2
;
}
...
...
@@ -329,7 +422,7 @@ namespace Cdy.Tag
/// <param name="time1"></param>
/// <param name="time2"></param>
/// <returns></returns>
public
DateTime
Max
(
DateTime
time1
,
DateTime
time2
)
public
DateTime
Max
(
DateTime
time1
,
DateTime
time2
)
{
return
time1
>=
time2
?
time1
:
time2
;
}
...
...
@@ -354,7 +447,7 @@ namespace Cdy.Tag
}
#
region
读取所有值
/// <summary>
/// 读取某时间段内的所有bool值
...
...
@@ -386,13 +479,13 @@ namespace Cdy.Tag
//}
}
#
endregion
#
region
读取指定时刻值
/// <summary>
///
...
...
@@ -456,11 +549,11 @@ namespace Cdy.Tag
}
foreach
(
var
vf
in
moffs
)
{
if
(
vf
.
Key
>
-
1
)
vff
.
Read
<
T
>(
vf
.
Key
,
tid
,
vf
.
Value
,
type
,
result
);
if
(
vf
.
Key
>
-
1
)
vff
.
Read
<
T
>(
vf
.
Key
,
tid
,
vf
.
Value
,
type
,
result
);
else
{
foreach
(
var
vv
in
vf
.
Value
)
foreach
(
var
vv
in
vf
.
Value
)
{
result
.
Add
(
default
(
T
),
vv
,
(
byte
)
QualityConst
.
Null
);
}
...
...
@@ -472,8 +565,17 @@ namespace Cdy.Tag
#
region
DataFileSeriser
Read
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="datafile"></param>
/// <param name="offset"></param>
/// <param name="tid"></param>
/// <param name="dataTimes"></param>
/// <param name="type"></param>
/// <param name="res"></param>
public
static
void
Read
<
T
>(
this
DataFileSeriserbase
datafile
,
long
offset
,
int
tid
,
List
<
DateTime
>
dataTimes
,
QueryValueMatchType
type
,
HisQueryResult
<
T
>
res
)
{
int
timetick
=
0
;
...
...
@@ -535,7 +637,7 @@ namespace Cdy.Tag
data
.
Clear
();
}
#
endregion
#
region
DeCompressData
...
...
@@ -583,7 +685,7 @@ namespace Cdy.Tag
}
}
/// <summary>
///
/// </summary>
...
...
@@ -616,7 +718,7 @@ namespace Cdy.Tag
/// <param name="blockDuration"></param>
/// <param name="timetick"></param>
/// <returns></returns>
public
static
Dictionary
<
int
,
int
>
CheckBlockHeadCach
(
this
DataFileSeriserbase
datafile
,
long
offset
,
out
int
tagCount
,
out
int
fileDuration
,
out
int
blockDuration
,
out
int
timetick
,
out
long
blockPointer
,
out
DateTime
time
)
public
static
Dictionary
<
int
,
int
>
CheckBlockHeadCach
(
this
DataFileSeriserbase
datafile
,
long
offset
,
out
int
tagCount
,
out
int
fileDuration
,
out
int
blockDuration
,
out
int
timetick
,
out
long
blockPointer
,
out
DateTime
time
)
{
//文件头部结构:Pre DataRegion(8) + Next DataRegion(8) + Datatime(8)+tagcount(4)+ tagid sum(8) +file duration(4)+ block duration(4)+Time tick duration(4)+ { + tagid1+tagid2+...+tagidn }+ {[tag1 block point1(8) + tag2 block point1+ tag3 block point1+...] + [tag1 block point2(8) + tag2 block point2+ tag3 block point2+...]....}
var
dataoffset
=
offset
+
16
;
...
...
@@ -672,7 +774,7 @@ namespace Cdy.Tag
var
ltmp
=
vcm
.
ToIntList
();
//vcm.Dispose();
if
(
ltmp
.
Count
>
0
)
{
int
preid
=
ltmp
[
0
];
...
...
@@ -684,9 +786,9 @@ namespace Cdy.Tag
preid
=
id
;
}
}
TagHeadOffsetManager
.
manager
.
Add
(
idsum
,
count
,
dtmp
,
blockPointer
);
TagHeadOffsetManager
.
manager
.
Add
(
idsum
,
count
,
dtmp
,
blockPointer
);
}
return
dtmp
;
}
...
...
@@ -709,9 +811,9 @@ namespace Cdy.Tag
/// <param name="blockDuration"></param>
/// <param name="timetick"></param>
/// <returns></returns>
public
static
int
ReadTagIndexInDataPointer
(
this
DataFileSeriserbase
datafile
,
int
tid
,
long
offset
,
out
int
tagCount
,
out
int
fileDuration
,
out
int
blockDuration
,
out
int
timetick
,
out
long
blockpointer
,
out
DateTime
time
)
public
static
int
ReadTagIndexInDataPointer
(
this
DataFileSeriserbase
datafile
,
int
tid
,
long
offset
,
out
int
tagCount
,
out
int
fileDuration
,
out
int
blockDuration
,
out
int
timetick
,
out
long
blockpointer
,
out
DateTime
time
)
{
var
hfile
=
datafile
.
CheckBlockHeadCach
(
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
var
hfile
=
datafile
.
CheckBlockHeadCach
(
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
if
(
hfile
.
ContainsKey
(
tid
))
{
return
hfile
[
tid
];
...
...
@@ -731,7 +833,7 @@ namespace Cdy.Tag
/// <returns></returns>
public
static
List
<
long
>
ReadTargetBlockAddress
(
this
DataFileSeriserbase
datafile
,
List
<
int
>
tid
,
long
offset
,
out
int
tagCount
,
out
int
fileDuration
,
out
int
blockDuration
,
out
int
timetick
,
out
long
blockpointer
,
out
DateTime
time
)
{
var
hfile
=
datafile
.
CheckBlockHeadCach
(
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
var
hfile
=
datafile
.
CheckBlockHeadCach
(
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
List
<
long
>
re
=
new
List
<
long
>();
foreach
(
var
vv
in
tid
)
{
...
...
@@ -766,7 +868,7 @@ namespace Cdy.Tag
DateTime
time
;
long
blockpointer
=
0
;
var
blockIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
var
blockIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
int
blockcount
=
fileDuration
*
60
/
blockDuration
;
var
startTime
=
datafile
.
ReadDateTime
(
16
);
...
...
@@ -804,7 +906,7 @@ namespace Cdy.Tag
int
tagCount
=
0
;
long
blockpointer
=
0
;
DateTime
time
;
var
blockIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
var
blockIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
int
blockcount
=
fileDuration
*
60
/
blockDuration
;
var
startTime
=
datafile
.
ReadDateTime
(
16
);
...
...
@@ -860,8 +962,8 @@ namespace Cdy.Tag
int
tagCount
=
0
;
long
blockpointer
=
0
;
DateTime
time
;
var
tagIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
var
tagIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
Dictionary
<
long
,
MarshalMemoryBlock
>
rtmp
=
new
Dictionary
<
long
,
MarshalMemoryBlock
>();
Dictionary
<
MarshalMemoryBlock
,
List
<
DateTime
>>
re
=
new
Dictionary
<
MarshalMemoryBlock
,
List
<
DateTime
>>();
...
...
@@ -925,9 +1027,9 @@ namespace Cdy.Tag
}
}
}
}
}
return
re
;
}
...
...
@@ -943,13 +1045,13 @@ namespace Cdy.Tag
/// <param name="end"></param>
/// <param name="timetick"></param>
/// <returns></returns>
public
static
Dictionary
<
MarshalMemoryBlock
,
Tuple
<
DateTime
,
DateTime
>>
ReadTagDataBlock2
(
this
DataFileSeriserbase
datafile
,
int
tid
,
long
offset
,
DateTime
start
,
DateTime
end
,
out
int
timetick
)
public
static
Dictionary
<
MarshalMemoryBlock
,
Tuple
<
DateTime
,
DateTime
>>
ReadTagDataBlock2
(
this
DataFileSeriserbase
datafile
,
int
tid
,
long
offset
,
DateTime
start
,
DateTime
end
,
out
int
timetick
)
{
int
fileDuration
,
blockDuration
=
0
;
int
tagCount
=
0
;
long
blockpointer
=
0
;
DateTime
time
;
var
tagIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
var
tagIndex
=
datafile
.
ReadTagIndexInDataPointer
(
tid
,
offset
,
out
tagCount
,
out
fileDuration
,
out
blockDuration
,
out
timetick
,
out
blockpointer
,
out
time
);
int
blockcount
=
fileDuration
*
60
/
blockDuration
;
//读取文件开始时间
...
...
@@ -963,8 +1065,8 @@ namespace Cdy.Tag
while
(
sstart
<
end
)
{
var
ttmp
=
Math
.
Round
((
sstart
-
startTime
).
TotalSeconds
,
3
);
var
vv
=
blockDuration
*
60
-
(
ttmp
%
(
blockDuration
*
60
));
var
ttmp
=
Math
.
Round
((
sstart
-
startTime
).
TotalSeconds
,
3
);
var
vv
=
blockDuration
*
60
-
(
ttmp
%
(
blockDuration
*
60
));
send
=
sstart
.
AddSeconds
(
vv
);
...
...
@@ -984,14 +1086,14 @@ namespace Cdy.Tag
throw
new
Exception
(
"DataPointer index is out of total block number"
);
}
var
dataPointer
=
datafile
.
ReadLong
(
offset
+
blockpointer
+
tagIndex
*
8
+
blockindex
*
tagCount
*
8
);
//读取DataBlock的地址
var
dataPointer
=
datafile
.
ReadLong
(
offset
+
blockpointer
+
tagIndex
*
8
+
blockindex
*
tagCount
*
8
);
//读取DataBlock的地址
if
(
dataPointer
>
0
)
{
var
datasize
=
datafile
.
ReadInt
(
dataPointer
);
//读取DataBlock 的大小
if
(
datasize
>
0
)
{
var
rmm
=
datafile
.
Read
(
dataPointer
+
4
,
(
int
)
datasize
);
var
rmm
=
datafile
.
Read
(
dataPointer
+
4
,
(
int
)
datasize
);
if
(!
re
.
ContainsKey
(
rmm
))
{
re
.
Add
(
rmm
,
new
Tuple
<
DateTime
,
DateTime
>(
sstart
,
send
));
...
...
RunTime/DBInRun/Properties/launchSettings.json
浏览文件 @
ba87cd21
...
...
@@ -2,7 +2,7 @@
"profiles"
:
{
"DBInRun"
:
{
"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/Driver/DriverManager.cs
浏览文件 @
ba87cd21
...
...
@@ -94,7 +94,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Start
()
{
LoggerService
.
Service
.
Info
(
"DriverManager"
,
"
start to Start
"
);
LoggerService
.
Service
.
Info
(
"DriverManager"
,
"
开始启动
"
);
foreach
(
var
vv
in
mDrivers
.
Values
)
{
vv
.
Start
(
mTagDriverService
,
mHisValueDriverService
);
...
...
@@ -106,7 +106,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Stop
()
{
LoggerService
.
Service
.
Info
(
"DriverManager"
,
"
start to stop
"
);
LoggerService
.
Service
.
Info
(
"DriverManager"
,
"
开始停止
"
);
foreach
(
var
vv
in
mDrivers
.
Values
)
{
vv
.
Stop
();
...
...
RunTime/DBRuntime/His/Compress/CompressEnginer2.cs
浏览文件 @
ba87cd21
...
...
@@ -153,7 +153,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Start
()
{
LoggerService
.
Service
.
Info
(
"CompressEnginer"
,
"
start to Start
"
);
LoggerService
.
Service
.
Info
(
"CompressEnginer"
,
"
开始启动
"
);
mIsClosed
=
false
;
//Init();
resetEvent
=
new
ManualResetEvent
(
false
);
...
...
@@ -175,7 +175,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Stop
()
{
LoggerService
.
Service
.
Info
(
"CompressEnginer"
,
"
start to stop
"
);
LoggerService
.
Service
.
Info
(
"CompressEnginer"
,
"
开始停止
"
);
mIsClosed
=
true
;
resetEvent
.
Set
();
...
...
@@ -206,6 +206,7 @@ namespace Cdy.Tag
foreach
(
var
vv
in
mTargetMemorys
)
{
vv
.
Value
.
CurrentTime
=
mCurrentTime
;
vv
.
Value
.
EndTime
=
dataMemory
.
EndDateTime
;
}
resetEvent
.
Set
();
}
...
...
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
浏览文件 @
ba87cd21
...
...
@@ -126,6 +126,11 @@ namespace Cdy.Tag
}
}
/// <summary>
///
/// </summary>
public
DateTime
EndTime
{
get
;
set
;
}
#
endregion
...
Properties
...
...
...
@@ -165,7 +170,7 @@ namespace Cdy.Tag
int
datasize
=
0
;
var
cdata
=
CompressMemory
(
data
,
out
datasize
);
cdata
.
MakeMemoryBusy
();
ServiceLocator
.
Locator
.
Resolve
<
IDataSerialize2
>().
ManualRequestToSeriseFile
(
data
.
Id
,
data
.
Time
,
cdata
,
datasize
);
ServiceLocator
.
Locator
.
Resolve
<
IDataSerialize2
>().
ManualRequestToSeriseFile
(
data
.
Id
,
data
.
Time
,
data
.
EndTime
,
cdata
,
datasize
);
data
.
MakeMemoryNoBusy
();
ManualHisDataMemoryBlockPool
.
Pool
.
Release
(
data
);
}
...
...
@@ -282,7 +287,7 @@ namespace Cdy.Tag
long
ltmp3
=
sw
.
ElapsedMilliseconds
;
ServiceLocator
.
Locator
.
Resolve
<
IDataSerialize2
>().
RequestToSeriseFile
(
this
,
mCurrentTime
);
ServiceLocator
.
Locator
.
Resolve
<
IDataSerialize2
>().
RequestToSeriseFile
(
this
);
sw
.
Stop
();
LoggerService
.
Service
.
Info
(
"CompressEnginer"
,
Id
+
"压缩完成 耗时:"
+
sw
.
ElapsedMilliseconds
+
" ltmp1:"
+
ltmp1
+
" ltmp2:"
+
(
ltmp2
-
ltmp1
)
+
" ltmp3:"
+
(
ltmp3
-
ltmp2
)
+
" CPU Id:"
+
ThreadHelper
.
GetCurrentProcessorNumber
(),
ConsoleColor
.
Blue
);
...
...
RunTime/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs
浏览文件 @
ba87cd21
...
...
@@ -113,6 +113,8 @@ namespace Cdy.Tag
byte
tlen
=
(
timerVals
as
HisDataMemoryBlock
).
TimeLen
;
int
rcount
=
0
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
if
(
i
!=
ig
)
...
...
@@ -130,6 +132,7 @@ namespace Cdy.Tag
{
mVarintMemory2
.
WriteInt32
(
id
-
preids
);
}
rcount
++;
//dtims.Add(i, id);
preids
=
id
;
}
...
...
@@ -139,7 +142,10 @@ namespace Cdy.Tag
// emptyIds.TryDequeue(out ig);
}
}
return
mVarintMemory2
.
DataBuffer
.
AsMemory
(
0
,
(
int
)
mVarintMemory
.
WritePosition
);
LoggerService
.
Service
.
Debug
(
"DeadAreaCompress"
,
"记录时间个数:"
+
rcount
+
" 空时间个数:"
+
(
emptyIds
.
WriteIndex
+
1
));
return
mVarintMemory2
.
DataBuffer
.
AsMemory
(
0
,
(
int
)
mVarintMemory2
.
WritePosition
);
}
/// <summary>
...
...
@@ -425,7 +431,14 @@ namespace Cdy.Tag
break
;
case
TagType
.
Double
:
FindEmpityIds
(
source
,
sourceAddr
,
(
int
)
count
,
emptys
);
if
(
mDCompress
==
null
)
mDCompress
=
new
DoubleCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mDCompress
==
null
)
{
mDCompress
=
new
DoubleCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mDCompress
.
CheckAndResizeTo
(
count
);
}
var
ddres
=
CompressValues
<
double
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
datas
=
CompressTimers2
(
source
,
sourceAddr
,
(
int
)
count
,
emptys2
);
...
...
@@ -434,9 +447,15 @@ namespace Cdy.Tag
target
.
WriteInt
(
targetAddr
,
rcount
);
rsize
+=
4
;
target
.
Write
((
int
)
datas
.
Length
);
target
.
Write
(
datas
);
rsize
+=
4
;
target
.
Write
(
datas
);
rsize
+=
datas
.
Length
;
if
(
rcount
>
0
&&
datas
.
Length
==
0
)
{
LoggerService
.
Service
.
Debug
(
"DeadAreaCompressUnit"
,
"压缩后数据长度为0 :"
+
rcount
);
}
//写入数据
target
.
Write
(
ddres
.
Length
);
target
.
Write
(
ddres
);
...
...
@@ -460,7 +479,14 @@ namespace Cdy.Tag
break
;
case
TagType
.
Float
:
FindEmpityIds
(
source
,
sourceAddr
,
(
int
)
count
,
emptys
);
if
(
mFCompress
==
null
)
mFCompress
=
new
FloatCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mFCompress
==
null
)
{
mFCompress
=
new
FloatCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mFCompress
.
CheckAndResizeTo
(
count
);
}
var
fres
=
CompressValues
<
float
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
datas
=
CompressTimers2
(
source
,
sourceAddr
,
(
int
)
count
,
emptys2
);
...
...
RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs
浏览文件 @
ba87cd21
...
...
@@ -993,8 +993,15 @@ namespace Cdy.Tag
rsize
+=
cqus
.
Length
;
break
;
case
TagType
.
Double
:
if
(
mDCompress
==
null
)
mDCompress
=
new
DoubleCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mDCompress
==
null
)
{
mDCompress
=
new
DoubleCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mDCompress
.
CheckAndResizeTo
(
count
);
}
var
ddres
=
CompressValues
<
double
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
target
.
Write
(
ddres
.
Length
);
...
...
@@ -1010,7 +1017,14 @@ namespace Cdy.Tag
break
;
case
TagType
.
Float
:
if
(
mFCompress
==
null
)
mFCompress
=
new
FloatCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mFCompress
==
null
)
{
mFCompress
=
new
FloatCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mFCompress
.
CheckAndResizeTo
(
count
);
}
var
fres
=
CompressValues
<
float
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
target
.
Write
(
fres
.
Length
);
...
...
@@ -1557,6 +1571,7 @@ namespace Cdy.Tag
Dictionary
<
int
,
DateTime
>
re
=
new
Dictionary
<
int
,
DateTime
>();
var
count
=
source
.
ReadInt
();
var
datasize
=
source
.
ReadInt
();
byte
[]
datas
=
source
.
ReadBytes
(
datasize
);
var
timers
=
DeCompressTimers
(
datas
,
count
);
...
...
RunTime/DBRuntime/His/Compress/Special/SlopeCompressUnit2.cs
浏览文件 @
ba87cd21
...
...
@@ -1971,14 +1971,29 @@ namespace Cdy.Tag
break
;
case
TagType
.
Double
:
if
(
mDCompress
==
null
)
mDCompress
=
new
DoubleCompressBuffer
(
count
*
2
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mDCompress
==
null
)
{
mDCompress
=
new
DoubleCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mDCompress
.
CheckAndResizeTo
(
count
);
}
cval
=
CompressValues
<
double
>(
source
,
count
*
2
+
sourceAddr
,
count
,
tims
,
type
);
timeData
=
CompressTimers
(
tims
,
usedIndex
);
cqus
=
CompressQulitys
(
source
,
count
*
10
+
sourceAddr
,
count
,
usedIndex
);
rsize
=
FillData
(
cval
,
cqus
,
timeData
,
target
,
targetAddr
);
break
;
case
TagType
.
Float
:
if
(
mFCompress
==
null
)
mFCompress
=
new
FloatCompressBuffer
(
count
*
2
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mFCompress
==
null
)
{
mFCompress
=
new
FloatCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mFCompress
.
CheckAndResizeTo
(
count
);
}
cval
=
CompressValues
<
float
>(
source
,
count
*
2
+
sourceAddr
,
count
,
tims
,
type
);
timeData
=
CompressTimers
(
tims
,
usedIndex
);
cqus
=
CompressQulitys
(
source
,
count
*
6
+
sourceAddr
,
count
,
usedIndex
);
...
...
RunTime/DBRuntime/His/HisDataMemoryBlockCollection.cs
浏览文件 @
ba87cd21
...
...
@@ -78,6 +78,10 @@ namespace DBRuntime.His
/// </summary>
public
DateTime
CurrentDatetime
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
DateTime
EndDateTime
{
get
;
set
;
}
#
endregion
...
Properties
...
...
...
RunTime/DBRuntime/His/HisEnginer2.cs
浏览文件 @
ba87cd21
...
...
@@ -823,7 +823,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Start
()
{
LoggerService
.
Service
.
Info
(
"HisEnginer"
,
"
start to Start
"
);
LoggerService
.
Service
.
Info
(
"HisEnginer"
,
"
开始启动
"
);
mIsClosed
=
false
;
mMegerProcessIsClosed
=
false
;
LoggerService
.
Service
.
Info
(
"Record"
,
"历史变量个数: "
+
this
.
mHisTags
.
Count
);
...
...
@@ -924,6 +924,7 @@ namespace Cdy.Tag
RecordAllLastValue
();
//mMergeMemory.Dump();
mCurrentMergeMemory
.
EndDateTime
=
mSnapAllTagTime
;
mCurrentMergeMemory
.
MakeMemoryBusy
();
//提交到数据压缩流程
ServiceLocator
.
Locator
.
Resolve
<
IDataCompress2
>().
RequestToCompress
(
mCurrentMergeMemory
);
...
...
@@ -1053,6 +1054,8 @@ namespace Cdy.Tag
if
(
mcc
!=
null
)
{
mcc
.
MakeMemoryBusy
();
mcc
.
EndDateTime
=
dateTime
;
mWaitForMergeMemory
=
mcc
;
//通知进行内存合并
resetEvent
.
Set
();
...
...
@@ -1227,7 +1230,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Stop
()
{
LoggerService
.
Service
.
Info
(
"HisEnginer"
,
"
start to stop
"
);
LoggerService
.
Service
.
Info
(
"HisEnginer"
,
"
开始停止
"
);
if
(
mRecordTimer
!=
null
)
{
mRecordTimer
.
Stop
();
...
...
@@ -1477,7 +1480,7 @@ namespace Cdy.Tag
break
;
}
hb
.
WriteInt
(
hb
.
QualityAddress
+
hb
.
CurrentCount
,
vv
.
Quality
);
hb
.
EndTime
=
vv
.
Time
;
hb
.
CurrentCount
++;
}
}
...
...
RunTime/DBRuntime/His/ManualHisDataMemoryBlock.cs
浏览文件 @
ba87cd21
...
...
@@ -47,6 +47,11 @@ namespace DBRuntime.His
/// </summary>
public
DateTime
Time
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
DateTime
EndTime
{
get
;
set
;
}
/// <summary>
///
/// </summary>
...
...
RunTime/DBRuntime/His/SeriseEnginer2.cs
浏览文件 @
ba87cd21
...
...
@@ -23,9 +23,9 @@ using DBRuntime.His;
* [] 表示重复的一个或多个内容
*
HisData File Structor
FileHead(
72) + [HisDataRegion]
FileHead(
84) + [HisDataRegion]
FileHead: dataTime(8)+DatabaseName(64)
FileHead: dataTime(8)
(FileTime)+dateTime(8)(LastUpdateTime)+DataRegionCount(4)
+DatabaseName(64)
HisDataRegion Structor: RegionHead + DataBlockPoint Area + DataBlock Area
...
...
@@ -55,12 +55,8 @@ namespace Cdy.Tag
private
bool
mIsClosed
=
false
;
//private MemoryBlock mProcessMemory;
private
DateTime
mCurrentTime
;
//private SeriseFileItem[] mSeriseFile;
private
Dictionary
<
int
,
CompressMemory2
>
mWaitForProcessMemory
=
new
Dictionary
<
int
,
CompressMemory2
>();
/// <summary>
...
...
@@ -194,7 +190,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Start
()
{
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
"
start to Start
"
);
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
"
开始启动
"
);
mIsClosed
=
false
;
resetEvent
=
new
ManualResetEvent
(
false
);
closedEvent
=
new
ManualResetEvent
(
false
);
...
...
@@ -208,7 +204,7 @@ namespace Cdy.Tag
/// </summary>
public
void
Stop
()
{
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
"
start to stop
"
);
LoggerService
.
Service
.
Info
(
"SeriseEnginer"
,
"
开始停止
"
);
mIsClosed
=
true
;
resetEvent
.
Set
();
closedEvent
.
WaitOne
();
...
...
@@ -227,7 +223,7 @@ namespace Cdy.Tag
/// </summary>
/// <param name="dataMemory"></param>
/// <param name="date"></param>
public
void
RequestToSeriseFile
(
CompressMemory2
dataMemory
,
DateTime
date
)
public
void
RequestToSeriseFile
(
CompressMemory2
dataMemory
)
{
lock
(
mWaitForProcessMemory
)
{
...
...
@@ -240,7 +236,7 @@ namespace Cdy.Tag
mWaitForProcessMemory
.
Add
(
dataMemory
.
Id
,
dataMemory
);
}
}
mCurrentTime
=
date
;
mCurrentTime
=
dat
aMemory
.
CurrentTim
e
;
}
/// <summary>
...
...
@@ -294,7 +290,7 @@ namespace Cdy.Tag
foreach
(
var
vv
in
mtmp
)
{
mSeriserFiles
[
vv
.
Id
].
SaveToFile
(
vv
,
vv
.
CurrentTime
);
mSeriserFiles
[
vv
.
Id
].
SaveToFile
(
vv
,
vv
.
CurrentTime
,
vv
.
EndTime
);
vv
.
Clear
();
vv
.
MakeMemoryNoBusy
();
}
...
...
@@ -327,13 +323,13 @@ namespace Cdy.Tag
/// <param name="time"></param>
/// <param name="data"></param>
/// <param name="size"></param>
public
void
ManualRequestToSeriseFile
(
int
id
,
DateTime
time
,
MarshalMemoryBlock
data
,
int
size
)
public
void
ManualRequestToSeriseFile
(
int
id
,
DateTime
time
,
DateTime
endTime
,
MarshalMemoryBlock
data
,
int
size
)
{
foreach
(
var
vv
in
mSeriserFiles
)
{
if
(
id
>=
vv
.
Value
.
Id
*
TagCountOneFile
&&
id
<(
vv
.
Value
.
Id
+
1
)*
TagCountOneFile
)
{
vv
.
Value
.
ManualRequestToSeriseFile
(
id
,
data
,
size
,
time
);
vv
.
Value
.
ManualRequestToSeriseFile
(
id
,
data
,
size
,
time
,
endTime
);
}
}
}
...
...
@@ -382,7 +378,7 @@ namespace Cdy.Tag
/// <summary>
/// 文件头大小
/// </summary>
public
const
int
FileHeadSize
=
72
;
public
const
int
FileHeadSize
=
84
;
private
MemoryBlock
mBlockPointMemory
;
...
...
@@ -498,11 +494,10 @@ namespace Cdy.Tag
{
DateTime
date
=
new
DateTime
(
time
.
Year
,
time
.
Month
,
time
.
Day
,
((
time
.
Hour
/
FileDuration
)
*
FileDuration
),
0
,
0
);
mFileWriter
.
Write
(
date
,
0
);
//byte[] nameBytes = new byte[64];
byte
[]
nameBytes
=
ArrayPool
<
byte
>.
Shared
.
Rent
(
64
);
var
ntmp
=
Encoding
.
UTF8
.
GetBytes
(
databaseName
);
Buffer
.
BlockCopy
(
ntmp
,
0
,
nameBytes
,
0
,
Math
.
Min
(
64
,
ntmp
.
Length
));
mFileWriter
.
Write
(
nameBytes
,
8
);
mFileWriter
.
Write
(
nameBytes
,
20
);
ArrayPool
<
byte
>.
Shared
.
Return
(
nameBytes
);
}
...
...
@@ -524,6 +519,8 @@ namespace Cdy.Tag
mFileWriter
.
Append
(
bval
,
0
,
datalen
);
mFileWriter
.
AppendZore
(
totalLen
-
datalen
);
mFileWriter
.
Write
(
mFileWriter
.
ReadInt
(
16
)
+
1
,
16
);
mPreDataRegion
=
mCurrentDataRegion
;
mBlockPointOffset
=
mCurrentDataRegion
+
mBlockPointOffset
;
...
...
@@ -545,6 +542,8 @@ namespace Cdy.Tag
mFileWriter
.
Append
(
bval
,
0
,
datalen
);
mFileWriter
.
AppendZore
(
totalLen
-
datalen
);
mFileWriter
.
Write
(
mFileWriter
.
ReadInt
(
16
)
+
1
,
16
);
ArrayPool
<
byte
>.
Shared
.
Return
(
bval
);
}
...
...
@@ -633,11 +632,8 @@ namespace Cdy.Tag
offset
=
nextaddr
;
}
}
// mPreDataRegion = offset;
mFileWriter
.
GoToEnd
();
mCurrentDataRegion
=
mFileWriter
.
CurrentPostion
;
return
offset
;
}
...
...
@@ -695,7 +691,7 @@ namespace Cdy.Tag
else
{
if
(
mFileWriter2
.
Length
<
72
)
if
(
mFileWriter2
.
Length
<
FileHeadSize
)
{
//新建文件
AppendFileHeader
(
time
,
this
.
DatabaseName
,
mFileWriter2
);
...
...
@@ -744,12 +740,22 @@ namespace Cdy.Tag
/// <param name="datablock"></param>
/// <param name="size"></param>
/// <param name="time"></param>
public
void
ManualRequestToSeriseFile
(
int
id
,
MarshalMemoryBlock
datablock
,
int
size
,
DateTime
time
)
/// <param name="endTime"></param>
public
void
ManualRequestToSeriseFile
(
int
id
,
MarshalMemoryBlock
datablock
,
int
size
,
DateTime
time
,
DateTime
endTime
)
{
lock
(
mFileLocker
)
{
DataFileSeriserbase
mwriter
;
var
heads
=
GetDataRegionHeadPoint
(
id
,
time
,
out
mwriter
);
//如果更新时间,小于最后更新时间,则更新
var
vtmp
=
mwriter
.
ReadDateTime
(
8
);
if
(
endTime
>
vtmp
)
{
mwriter
.
Write
(
endTime
,
8
);
}
var
vpointer
=
mwriter
.
GoToEnd
().
CurrentPostion
;
datablock
.
WriteToStream
(
mFileWriter
.
GetStream
(),
vpointer
,
size
);
//直接拷贝数据块
datablock
.
WriteLong
(
heads
,
vpointer
);
...
...
@@ -877,7 +883,7 @@ namespace Cdy.Tag
}
else
{
if
(
mFileWriter
.
Length
<
72
)
if
(
mFileWriter
.
Length
<
FileHeadSize
)
{
AppendFileHeader
(
time
,
this
.
DatabaseName
,
mFileWriter
);
//新建文件
...
...
@@ -915,11 +921,16 @@ namespace Cdy.Tag
/// </summary>
/// <param name="mProcessMemory"></param>
/// <param name="time"></param>
public
void
SaveToFile
(
MarshalMemoryBlock
mProcessMemory
,
DateTime
time
)
public
void
SaveToFile
(
MarshalMemoryBlock
mProcessMemory
,
DateTime
time
,
DateTime
endTime
)
{
SaveToFile
(
mProcessMemory
,
0
,
time
);
SaveToFile
(
mProcessMemory
,
0
,
time
,
endTime
);
}
/// <summary>
///
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
private
DateTime
FormateTime
(
DateTime
time
)
{
return
new
DateTime
(
time
.
Year
,
time
.
Month
,
time
.
Day
,
time
.
Hour
,
time
.
Minute
,
0
);
...
...
@@ -928,7 +939,7 @@ namespace Cdy.Tag
/// <summary>
/// 执行存储到磁盘
/// </summary>
public
void
SaveToFile
(
MarshalMemoryBlock
mProcessMemory
,
long
dataOffset
,
DateTime
time
)
public
void
SaveToFile
(
MarshalMemoryBlock
mProcessMemory
,
long
dataOffset
,
DateTime
time
,
DateTime
endTime
)
{
/*
1. 检查变量ID是否变动,如果变动则重新记录变量的ID列表
...
...
@@ -956,6 +967,13 @@ namespace Cdy.Tag
if
(!
CheckFile
(
time
))
return
;
//更新最后写入时间
var
vtmp
=
mFileWriter
.
ReadDateTime
(
8
);
if
(
endTime
>
vtmp
)
{
mFileWriter
.
Write
(
endTime
,
8
);
}
var
ltmp2
=
sw
.
ElapsedMilliseconds
;
long
offset
=
8
+
dataOffset
;
...
...
RunTime/DBRuntime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs
浏览文件 @
ba87cd21
...
...
@@ -407,7 +407,14 @@ namespace Cdy.Tag
break
;
case
TagType
.
Double
:
FindEmpityIds
(
source
,
sourceAddr
,
(
int
)
count
,
emptys
);
if
(
mDCompress
==
null
)
mDCompress
=
new
DoubleCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mDCompress
==
null
)
{
mDCompress
=
new
DoubleCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mDCompress
.
CheckAndResizeTo
(
count
);
}
var
ddres
=
CompressValues
<
double
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
datas
=
CompressTimers2
(
source
,
sourceAddr
,
(
int
)
count
,
emptys2
);
...
...
@@ -434,7 +441,14 @@ namespace Cdy.Tag
break
;
case
TagType
.
Float
:
FindEmpityIds
(
source
,
sourceAddr
,
(
int
)
count
,
emptys
);
if
(
mFCompress
==
null
)
mFCompress
=
new
FloatCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mFCompress
==
null
)
{
mFCompress
=
new
FloatCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mFCompress
.
CheckAndResizeTo
(
count
);
}
var
fres
=
CompressValues
<
float
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
datas
=
CompressTimers2
(
source
,
sourceAddr
,
(
int
)
count
,
emptys2
);
...
...
RunTime/DBRuntime/His/obsolete/Compress/Special/DoubleCompressBuffer.cs
浏览文件 @
ba87cd21
...
...
@@ -78,6 +78,19 @@ namespace DBRuntime.His.Compress
#
region
...
Methods
...
/// <summary>
///
/// </summary>
/// <param name="count"></param>
public
void
CheckAndResizeTo
(
int
count
)
{
if
(
count
>
mBuffer
.
Length
)
{
mBuffer
=
new
double
[
count
];
}
}
/// <summary>
///
/// </summary>
...
...
RunTime/DBRuntime/His/obsolete/Compress/Special/FloatCompressBuffer.cs
浏览文件 @
ba87cd21
...
...
@@ -78,6 +78,18 @@ namespace DBRuntime.His.Compress
#
region
...
Methods
...
/// <summary>
///
/// </summary>
/// <param name="count"></param>
public
void
CheckAndResizeTo
(
int
count
)
{
if
(
count
>
mBuffer
.
Length
)
{
mBuffer
=
new
float
[
count
];
}
}
/// <summary>
///
/// </summary>
...
...
RunTime/DBRuntime/His/obsolete/Compress/Special/LosslessCompressUnit.cs
浏览文件 @
ba87cd21
...
...
@@ -992,8 +992,15 @@ namespace Cdy.Tag
rsize
+=
cqus
.
Length
;
break
;
case
TagType
.
Double
:
if
(
mDCompress
==
null
)
mDCompress
=
new
DoubleCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mDCompress
==
null
)
{
mDCompress
=
new
DoubleCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mDCompress
.
CheckAndResizeTo
(
count
);
}
var
ddres
=
CompressValues
<
double
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
target
.
Write
(
ddres
.
Length
);
...
...
@@ -1009,7 +1016,14 @@ namespace Cdy.Tag
break
;
case
TagType
.
Float
:
if
(
mFCompress
==
null
)
mFCompress
=
new
FloatCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mFCompress
==
null
)
{
mFCompress
=
new
FloatCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mFCompress
.
CheckAndResizeTo
(
count
);
}
var
fres
=
CompressValues
<
float
>(
source
,
count
*
2
+
sourceAddr
,
count
,
emptys
,
TagType
);
target
.
Write
(
fres
.
Length
);
...
...
RunTime/DBRuntime/His/obsolete/Compress/Special/SlopeCompressUnit.cs
浏览文件 @
ba87cd21
...
...
@@ -1940,14 +1940,30 @@ namespace Cdy.Tag
break
;
case
TagType
.
Double
:
if
(
mDCompress
==
null
)
mDCompress
=
new
DoubleCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mDCompress
==
null
)
{
mDCompress
=
new
DoubleCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mDCompress
.
CheckAndResizeTo
(
count
);
}
cval
=
CompressValues
<
double
>(
source
,
count
*
2
+
sourceAddr
,
count
,
tims
,
type
);
timeData
=
CompressTimers
(
tims
,
usedIndex
);
cqus
=
CompressQulitys
(
source
,
count
*
10
+
sourceAddr
,
count
,
usedIndex
);
rsize
=
FillData
(
cval
,
cqus
,
timeData
,
target
,
targetAddr
);
break
;
case
TagType
.
Float
:
if
(
mFCompress
==
null
)
mFCompress
=
new
FloatCompressBuffer
(
310
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
if
(
mFCompress
==
null
)
{
mFCompress
=
new
FloatCompressBuffer
(
count
)
{
MemoryBlock
=
mMarshalMemory
,
VarintMemory
=
mVarintMemory
};
}
else
{
mFCompress
.
CheckAndResizeTo
(
count
);
}
cval
=
CompressValues
<
float
>(
source
,
count
*
2
+
sourceAddr
,
count
,
tims
,
type
);
timeData
=
CompressTimers
(
tims
,
usedIndex
);
cqus
=
CompressQulitys
(
source
,
count
*
6
+
sourceAddr
,
count
,
usedIndex
);
...
...
RunTime/DBRuntime/Interface/IDataSerialize2.cs
浏览文件 @
ba87cd21
...
...
@@ -40,7 +40,7 @@ namespace Cdy.Tag
/// </summary>
/// <param name="dataMemory"></param>
/// <param name="date"></param>
void
RequestToSeriseFile
(
CompressMemory2
dataMemory
,
DateTime
date
);
void
RequestToSeriseFile
(
CompressMemory2
dataMemory
);
/// <summary>
/// 手动更新历史数据
...
...
@@ -49,7 +49,7 @@ namespace Cdy.Tag
/// <param name="time"></param>
/// <param name="data"></param>
/// <param name="size"></param>
void
ManualRequestToSeriseFile
(
int
id
,
DateTime
time
,
MarshalMemoryBlock
data
,
int
size
);
void
ManualRequestToSeriseFile
(
int
id
,
DateTime
time
,
DateTime
enddate
,
MarshalMemoryBlock
data
,
int
size
);
/// <summary>
///
...
...
Tools/HisDataTools/Properties/launchSettings.json
浏览文件 @
ba87cd21
...
...
@@ -2,7 +2,7 @@
"profiles"
:
{
"HisDataTools"
:
{
"commandName"
:
"Executable"
,
"executablePath"
:
"C:
\\
Users
\\
c
dy81
\\
source
\\
repos
\\
mars
\\
Output
\\
HisDataTools.exe"
"executablePath"
:
"C:
\\
Users
\\
c
hongdaoyang
\\
source
\\
repos
\\
mars
\\
Output
\\
HisDataTools.exe"
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录