Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cdy816
Mars
提交
547920cb
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 搜索 >>
提交
547920cb
编写于
10月 16, 2020
作者:
cdy816
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
BUG 修改
上级
50cabe22
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
262 addition
and
416 deletion
+262
-416
Common/Cdy.Tag/His/CompressUnitManager2.cs
Common/Cdy.Tag/His/CompressUnitManager2.cs
+10
-0
RunTime/DBHisData/HisQuery/TimeFile/DataFileInfo.cs
RunTime/DBHisData/HisQuery/TimeFile/DataFileInfo.cs
+33
-71
RunTime/DBRuntime/His/Compress/CompressEnginer2.cs
RunTime/DBRuntime/His/Compress/CompressEnginer2.cs
+1
-0
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
+20
-7
RunTime/DBRuntime/His/HisEnginer2.cs
RunTime/DBRuntime/His/HisEnginer2.cs
+25
-184
RunTime/DBRuntime/His/SeriseEnginer2.cs
RunTime/DBRuntime/His/SeriseEnginer2.cs
+173
-154
未找到文件。
Common/Cdy.Tag/His/CompressUnitManager2.cs
浏览文件 @
547920cb
...
...
@@ -49,6 +49,16 @@ namespace Cdy.Tag
#
endregion
...
Constructor
...
#
region
...
Properties
...
/// <summary>
///
/// </summary>
public
Dictionary
<
int
,
CompressUnitbase2
>
CompressUnit
{
get
{
return
mCompressUnit
;
}
}
#
endregion
...
Properties
...
...
...
RunTime/DBHisData/HisQuery/TimeFile/DataFileInfo.cs
浏览文件 @
547920cb
...
...
@@ -170,87 +170,49 @@ namespace Cdy.Tag
{
return
;
}
do
try
{
//读取数据区时间
time
=
ss
.
ReadDateTime
(
offset
+
16
);
if
(
time
==
DateTime
.
MinValue
)
do
{
tmp
=
time
;
continue
;
}
//读取数据区时间
time
=
ss
.
ReadDateTime
(
offset
+
16
);
long
oset
=
offset
;
//读取下个区域位置
offset
=
ss
.
ReadLong
(
offset
+
8
);
if
(
time
==
DateTime
.
MinValue
)
{
tmp
=
time
;
continue
;
}
if
(
offset
>
0
)
{
var
dt2
=
ss
.
ReadDateTime
(
offset
+
16
);
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
dt2
-
time
,
oset
,
dt2
));
tmp
=
dt2
;
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
));
tmp
=
dt2
;
}
else
{
var
tspan
=
StartTime
+
Duration
-
time
;
if
(
tspan
.
TotalMilliseconds
>
0
)
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
tspan
,
oset
,
time
+
tspan
));
tmp
=
time
+
tspan
;
}
mLastProcessOffset
=
oset
;
}
else
while
(
offset
>
0
);
if
(
mLastTime
<=
fileTime
)
{
var
tspan
=
StartTime
+
Duration
-
time
;
if
(
tspan
.
TotalMilliseconds
>
0
)
mTimeOffsets
.
Add
(
time
,
new
Tuple
<
TimeSpan
,
long
,
DateTime
>(
tspan
,
oset
,
time
+
tspan
));
tmp
=
time
+
tspan
;
mLastTime
=
tmp
;
}
mLastProcessOffset
=
oset
;
}
while
(
offset
>
0
);
if
(
mLastTime
<=
fileTime
)
catch
{
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
;
}
...
...
RunTime/DBRuntime/His/Compress/CompressEnginer2.cs
浏览文件 @
547920cb
...
...
@@ -304,6 +304,7 @@ namespace Cdy.Tag
sm
.
Clear
();
sm
.
MakeMemoryNoBusy
();
System
.
Threading
.
Tasks
.
Parallel
.
ForEach
(
mTargetMemorys
.
Where
(
e
=>
e
.
Value
.
HasManualCompressItems
),
(
mm
)
=>
{
ThreadHelper
.
AssignToCPU
(
CPUAssignHelper
.
Helper
.
CPUArray2
);
...
...
RunTime/DBRuntime/His/Compress/CompressMemory2.cs
浏览文件 @
547920cb
...
...
@@ -207,17 +207,30 @@ namespace Cdy.Tag
{
mTagIds
.
Clear
();
long
lsize
=
0
;
//var tagserver = ServiceLocator.Locator.Resolve<IHisEngine2>();
//var tags = tagserver.ListAllTags().Where(e => e.Id >= Id * TagCountPerMemory && e.Id < (Id + 1) * TagCountPerMemory).OrderBy(e => e.Id);
foreach
(
var
vv
in
CompressUnitManager2
.
Manager
.
CompressUnit
)
{
mCompressCach
.
Add
(
vv
.
Key
,
vv
.
Value
.
Clone
());
}
//foreach(var vv in tags)
//{
// var cpt = vv.CompressType;
// if (!mCompressCach.ContainsKey(cpt))
// {
// mCompressCach.Add(cpt, CompressUnitManager2.Manager.GetCompressQuick(cpt).Clone());
// }
//}
foreach
(
var
vv
in
sourceM
.
TagAddress
.
Where
(
e
=>
e
.
Key
>=
Id
*
TagCountPerMemory
&&
e
.
Key
<
(
Id
+
1
)
*
TagCountPerMemory
))
{
mTagIds
.
Add
(
vv
.
Key
);
dtmp
.
Add
(
vv
.
Key
,
0
);
var
cpt
=
mHisTagService
.
GetHisTag
(
vv
.
Key
).
CompressType
;
if
(!
mCompressCach
.
ContainsKey
(
cpt
))
{
mCompressCach
.
Add
(
cpt
,
CompressUnitManager2
.
Manager
.
GetCompressQuick
(
cpt
).
Clone
());
}
if
(
vv
.
Value
!=
null
)
lsize
+=
vv
.
Value
.
Length
;
lsize
+=
vv
.
Value
.
Length
;
}
this
.
ReAlloc
(
HeadSize
+
(
long
)(
lsize
*
1.2
));
...
...
RunTime/DBRuntime/His/HisEnginer2.cs
浏览文件 @
547920cb
...
...
@@ -848,14 +848,14 @@ namespace Cdy.Tag
cachHeadSize
+=
css
;
}
else
{
mMergeMemory1
.
AddTagAddress
(
vv
.
Value
.
Id
,
null
);
mMergeMemory2
.
AddTagAddress
(
vv
.
Value
.
Id
,
null
);
mCachMemory1
.
AddTagAddress
(
vv
.
Value
.
Id
,
null
);
mCachMemory2
.
AddTagAddress
(
vv
.
Value
.
Id
,
null
);
}
//
else
//
{
//
mMergeMemory1.AddTagAddress(vv.Value.Id, null);
//
mMergeMemory2.AddTagAddress(vv.Value.Id, null);
//
mCachMemory1.AddTagAddress(vv.Value.Id, null);
//
mCachMemory2.AddTagAddress(vv.Value.Id, null);
//
}
}
...
...
@@ -1054,14 +1054,18 @@ namespace Cdy.Tag
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
foreach
(
var
tag
in
mHisTags
)
//foreach (var tag in mHisTags)
foreach
(
var
vv
in
mcc
.
TagAddress
)
{
var
taddrs
=
mCurrentMergeMemory
.
TagAddress
[
tag
.
Value
.
Id
];
var
tag
=
mHisTags
[
vv
.
Key
];
var
taddrs
=
mCurrentMergeMemory
.
TagAddress
[
tag
.
Id
];
var
saddrs
=
mcc
.
TagAddress
[
tag
.
Value
.
Id
];
//var saddrs = mcc.TagAddress[tag.Value.Id];
var
saddrs
=
vv
.
Value
;
//
if
(
taddrs
==
null
||
saddrs
==
null
)
continue
;
//
if (taddrs == null || saddrs == null) continue;
//拷贝时间
var
dlen
=
saddrs
.
ValueAddress
;
...
...
@@ -1071,12 +1075,12 @@ namespace Cdy.Tag
//拷贝数值
dlen
=
saddrs
.
QualityAddress
-
saddrs
.
ValueAddress
;
vtimeaddr
=
taddrs
.
ValueAddress
+
dlen
*
count
+
tag
.
Value
.
SizeOfValue
;
vtimeaddr
=
taddrs
.
ValueAddress
+
dlen
*
count
+
tag
.
SizeOfValue
;
saddrs
.
CopyTo
(
taddrs
,
saddrs
.
ValueAddress
,
vtimeaddr
,
dlen
);
//拷贝质量戳
dlen
=
tag
.
Value
.
DataSize
-
saddrs
.
QualityAddress
;
dlen
=
tag
.
DataSize
-
saddrs
.
QualityAddress
;
vtimeaddr
=
taddrs
.
QualityAddress
+
dlen
*
count
+
1
;
saddrs
.
CopyTo
(
taddrs
,
saddrs
.
QualityAddress
,
vtimeaddr
,
dlen
);
...
...
@@ -1166,6 +1170,7 @@ namespace Cdy.Tag
sw
.
Start
();
foreach
(
var
vv
in
mHisTags
)
{
if
(
vv
.
Value
.
Type
!=
RecordType
.
Driver
)
vv
.
Value
.
Snape
();
}
sw
.
Stop
();
...
...
@@ -1314,9 +1319,12 @@ namespace Cdy.Tag
mNeedSnapAllTag
=
true
;
mForceSubmiteToCompress
=
true
;
mIsClosed
=
true
;
SaveManualCachData
();
SubmiteMemory
(
DateTime
.
Now
);
while
(!
mMegerProcessIsClosed
)
Thread
.
Sleep
(
1
);
SaveManualCachData
();
}
/// <summary>
...
...
@@ -1619,8 +1627,8 @@ namespace Cdy.Tag
isNeedSubmite
=
true
;
}
}
if
(
isNeedSubmite
)
ServiceLocator
.
Locator
.
Resolve
<
IDataCompress2
>().
SubmitManualToCompress
();
if
(
isNeedSubmite
)
ServiceLocator
.
Locator
.
Resolve
<
IDataCompress2
>().
SubmitManualToCompress
();
}
return
true
;
...
...
@@ -1641,173 +1649,6 @@ namespace Cdy.Tag
private
bool
ManualRecordHisValues
(
long
id
,
Cdy
.
Tag
.
TagValue
value
,
int
timeUnit
=
100
)
{
return
ManualRecordHisValues
(
id
,
value
.
Time
,
value
.
Value
,
value
.
Quality
,
timeUnit
);
//if (mIsClosed) return false;
//int valueOffset, qulityOffset = 0;
//DateTime mLastTime = DateTime.MinValue;
//SortedDictionary<DateTime, ManualHisDataMemoryBlock> datacach;
//if (mHisTags.ContainsKey(id) && mHisTags[id].Type == RecordType.Manual)
//{
// if (mManualHisDataCach.ContainsKey(id))
// {
// datacach = mManualHisDataCach[id];
// }
// else
// {
// datacach = new SortedDictionary<DateTime, ManualHisDataMemoryBlock>();
// mManualHisDataCach.Add(id, datacach);
// }
// var tag = mHisTags[id];
// ManualHisDataMemoryBlock hb = null;
// var vdata = value.Time.Date;
// var mms = (int)(value.Time.Subtract(vdata).TotalSeconds / MergeMemoryTime);
// var time = vdata.AddSeconds(mms * MergeMemoryTime);
// if (datacach.ContainsKey(time))
// {
// hb = datacach[time];
// }
// else
// {
// var css = CalCachDatablockSize(tag.TagType, 0, MergeMemoryTime * 1000 / timeUnit, out valueOffset, out qulityOffset);
// hb = ManualHisDataMemoryBlockPool.Pool.Get(css);
// hb.Time = time;
// hb.MaxCount = MergeMemoryTime * 1000 / timeUnit;
// hb.TimeUnit = timeUnit;
// hb.TimeLen = 4;
// hb.TimerAddress = 0;
// hb.ValueAddress = valueOffset;
// hb.QualityAddress = qulityOffset;
// hb.Id = (int)id;
// hb.CurrentCount = 0;
// datacach.Add(time, hb);
// }
// mLastTime = time;
// if (hb.CurrentCount < hb.MaxCount && value.Time > hb.EndTime)
// {
// hb.Lock();
// var vtime = (int)((value.Time - hb.Time).TotalMilliseconds / timeUnit);
// //写入时间戳
// hb.WriteInt(hb.TimerAddress + hb.CurrentCount * 4, vtime);
// switch (tag.TagType)
// {
// case TagType.Bool:
// hb.WriteByteDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToByte(Convert.ToBoolean(value.Value)));
// break;
// case TagType.Byte:
// hb.WriteByteDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToByte(value.Value));
// break;
// case TagType.Short:
// hb.WriteShortDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToInt16(value.Value));
// break;
// case TagType.UShort:
// hb.WriteUShortDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToUInt16(value.Value));
// break;
// case TagType.Int:
// hb.WriteIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToInt32(value.Value));
// break;
// case TagType.UInt:
// hb.WriteUIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToUInt32(value.Value));
// break;
// case TagType.Long:
// hb.WriteLongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToInt64(value.Value));
// break;
// case TagType.ULong:
// hb.WriteULongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToUInt64(value.Value));
// break;
// case TagType.Float:
// hb.WriteFloatDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToSingle(value.Value));
// break;
// case TagType.Double:
// hb.WriteDoubleDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToDouble(value.Value));
// break;
// case TagType.String:
// hb.WriteStringDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToString(value.Value), Encoding.Unicode);
// break;
// case TagType.DateTime:
// hb.WriteDatetime(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, Convert.ToDateTime(value.Value));
// break;
// case TagType.UIntPoint:
// UIntPointData data = (UIntPointData)value.Value;
// hb.WriteUIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, data.X);
// hb.WriteUIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 4, data.Y);
// break;
// case TagType.IntPoint:
// IntPointData idata = (IntPointData)value.Value;
// hb.WriteIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, idata.X);
// hb.WriteIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 4, idata.Y);
// break;
// case TagType.UIntPoint3:
// UIntPoint3Data udata3 = (UIntPoint3Data)value.Value;
// hb.WriteUIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, udata3.X);
// hb.WriteUIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 4, udata3.Y);
// hb.WriteUIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 8, udata3.Z);
// break;
// case TagType.IntPoint3:
// IntPoint3Data idata3 = (IntPoint3Data)value.Value;
// hb.WriteIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, idata3.X);
// hb.WriteIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 4, idata3.Y);
// hb.WriteIntDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 8, idata3.Z);
// break;
// case TagType.ULongPoint:
// ULongPointData udata = (ULongPointData)value.Value;
// hb.WriteULongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, udata.X);
// hb.WriteULongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 8, udata.Y);
// break;
// case TagType.LongPoint:
// LongPointData lidata = (LongPointData)value.Value;
// hb.WriteLongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, lidata.X);
// hb.WriteLongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 8, lidata.Y);
// break;
// case TagType.ULongPoint3:
// ULongPoint3Data ludata3 = (ULongPoint3Data)value.Value;
// hb.WriteULongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, ludata3.X);
// hb.WriteULongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 16, ludata3.Y);
// hb.WriteULongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 24, ludata3.Z);
// break;
// case TagType.LongPoint3:
// LongPoint3Data lidata3 = (LongPoint3Data)value.Value;
// hb.WriteLongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue, lidata3.X);
// hb.WriteLongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 16, lidata3.Y);
// hb.WriteLongDirect(hb.ValueAddress + hb.CurrentCount * tag.SizeOfValue + 24, lidata3.Z);
// break;
// }
// hb.WriteInt(hb.QualityAddress + hb.CurrentCount, value.Quality);
// hb.EndTime = value.Time;
// hb.CurrentCount++;
// hb.Relase();
// HisDataMemoryQueryService.Service.RegistorManual(id, hb.Time, hb.EndTime, hb);
// }
// bool isNeedSubmite = false;
// foreach (var vv in datacach.ToArray())
// {
// if (vv.Key < mLastTime || vv.Value.CurrentCount >= vv.Value.MaxCount)
// {
// ServiceLocator.Locator.Resolve<IDataCompress2>().RequestManualToCompress(vv.Value);
// datacach.Remove(vv.Key);
// isNeedSubmite = true;
// }
// }
// if (isNeedSubmite)
// ServiceLocator.Locator.Resolve<IDataCompress2>().SubmitManualToCompress();
// return true;
//}
//else
//{
// return false;
//}
}
/// <summary>
...
...
RunTime/DBRuntime/His/SeriseEnginer2.cs
浏览文件 @
547920cb
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录