Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
cdy816
Mars
提交
f6475de3
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 搜索 >>
提交
f6475de3
编写于
7月 03, 2020
作者:
cdy816
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修复值改变记录Bug 2020/7/3 三沙永兴岛
上级
e095321e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
55 addition
and
103 deletion
+55
-103
Develop/DbManager.Desktop/View/TagGroupDetailView.xaml
Develop/DbManager.Desktop/View/TagGroupDetailView.xaml
+2
-2
RunTime/DBRuntime/His/Compress/CompressMemory.cs
RunTime/DBRuntime/His/Compress/CompressMemory.cs
+1
-1
RunTime/DBRuntime/His/HisEnginer.cs
RunTime/DBRuntime/His/HisEnginer.cs
+10
-9
RunTime/DBRuntime/His/HisEnginerSingleMergerBuffer.cs
RunTime/DBRuntime/His/HisEnginerSingleMergerBuffer.cs
+10
-10
RunTime/DBRuntime/His/ValueChangedMemoryCacheProcesser.cs
RunTime/DBRuntime/His/ValueChangedMemoryCacheProcesser.cs
+32
-81
未找到文件。
Develop/DbManager.Desktop/View/TagGroupDetailView.xaml
浏览文件 @
f6475de3
...
...
@@ -270,7 +270,7 @@
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{local:ResMarker RecordType,:}" VerticalAlignment="Center" />
<ComboBox Margin="4,0" Grid.Column="1" Width="1
0
0" VerticalAlignment="Center" Text="{Binding RecordTypeString,Mode=OneWay}" SelectedIndex="{Binding RecordType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding RecordTypeList}"/>
<ComboBox Margin="4,0" Grid.Column="1" Width="1
6
0" VerticalAlignment="Center" Text="{Binding RecordTypeString,Mode=OneWay}" SelectedIndex="{Binding RecordType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding RecordTypeList}"/>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Grid Margin="4,0" Visibility="{Binding IsTimerRecord,Converter={StaticResource btv}}">
<Grid.ColumnDefinitions>
...
...
@@ -281,7 +281,7 @@
<TextBox Margin="8,0" Grid.Column="1" Width="60" Text="{Binding CompressCircle,Mode=TwoWay}" VerticalAlignment="Center" />
</Grid>
<TextBlock Text="{local:ResMarker CompressType,:}" VerticalAlignment="Center"/>
<ComboBox Margin="8,0" Width="1
0
0" VerticalAlignment="Center" ItemsSource="{Binding CompressTypeList}" SelectedIndex="{Binding CompressType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<ComboBox Margin="8,0" Width="1
6
0" VerticalAlignment="Center" ItemsSource="{Binding CompressTypeList}" SelectedIndex="{Binding CompressType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<ContentControl VerticalAlignment="Center" Content="{Binding CompressParameterModel}" HorizontalAlignment="Stretch" />
</StackPanel>
...
...
RunTime/DBRuntime/His/Compress/CompressMemory.cs
浏览文件 @
f6475de3
...
...
@@ -227,7 +227,7 @@ namespace Cdy.Tag
}
catch
(
Exception
ex
)
{
LoggerService
.
Service
.
Erro
(
"CompressEnginer"
,
ex
.
Message
);
LoggerService
.
Service
.
Erro
(
"CompressEnginer"
,
ex
.
StackTrace
+
" "
+
ex
.
Message
);
}
mIsRunning
=
false
;
}
...
...
RunTime/DBRuntime/His/HisEnginer.cs
浏览文件 @
f6475de3
...
...
@@ -339,11 +339,12 @@ namespace Cdy.Tag
// int count = MemoryCachTime * 1000 / MemoryTimeTick;
int
count
=
MergeMemoryTime
;
//对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
if
(
recordType
==
RecordType
.
ValueChanged
)
{
count
=
MergeMemoryTime
*
1000
/
MemoryTimeTick
;
}
////对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
//if(recordType == RecordType.ValueChanged)
//{
// count = MergeMemoryTime * 1000 / MemoryTimeTick;
//}
//用于解码时在头尾分别记录前一个区域的值和后一个区域的值
count
+=
2
;
...
...
@@ -404,10 +405,10 @@ namespace Cdy.Tag
int
count
=
CachMemoryTime
;
//对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
if
(
recordType
==
RecordType
.
ValueChanged
)
{
count
=
CachMemoryTime
*
1000
/
MemoryTimeTick
;
}
//
if (recordType == RecordType.ValueChanged)
//
{
//
count = CachMemoryTime * 1000 / MemoryTimeTick;
//
}
//数据区偏移,时间戳占2个字节,质量戳占1个字节
dataOffset
=
headSize
+
count
*
2
;
...
...
RunTime/DBRuntime/His/HisEnginerSingleMergerBuffer.cs
浏览文件 @
f6475de3
...
...
@@ -325,11 +325,11 @@ namespace Cdy.Tag
// int count = MemoryCachTime * 1000 / MemoryTimeTick;
int
count
=
MergeMemoryTime
;
//对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
if
(
recordType
==
RecordType
.
ValueChanged
)
{
count
=
MergeMemoryTime
*
1000
/
MemoryTimeTick
;
}
//
//
对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
//
if(recordType == RecordType.ValueChanged)
//
{
//
count = MergeMemoryTime * 1000 / MemoryTimeTick;
//
}
//用于解码时在头尾分别记录前一个区域的值和后一个区域的值
count
+=
2
;
...
...
@@ -389,11 +389,11 @@ namespace Cdy.Tag
qulityOffset
=
headSize
;
int
count
=
CachMemoryTime
;
//对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
if
(
recordType
==
RecordType
.
ValueChanged
)
{
count
=
CachMemoryTime
*
1000
/
MemoryTimeTick
;
}
//
//
对于值改变的记录方式,提高内存分配量,以提高值改变记录的数据个数
//
if (recordType == RecordType.ValueChanged)
//
{
//
count = CachMemoryTime * 1000 / MemoryTimeTick;
//
}
//数据区偏移,时间戳占2个字节,质量戳占1个字节
dataOffset
=
headSize
+
count
*
2
;
...
...
RunTime/DBRuntime/His/ValueChangedMemoryCacheProcesser.cs
浏览文件 @
f6475de3
...
...
@@ -11,11 +11,14 @@ using System.Collections.Generic;
using
System.Text
;
using
System.Threading
;
using
System.Linq
;
using
System.Collections.Concurrent
;
namespace
Cdy.Tag
{
/// <summary>
///
/// 值改变记录,记录周期同定时记录的周期的一样1s
/// 每隔1s毫秒检查一次变量是否改变,如果改变则记录。
/// 变化周期超过1s的情况,则会被忽略
/// </summary>
public
class
ValueChangedMemoryCacheProcesser
:
IDisposable
{
...
...
@@ -31,7 +34,7 @@ namespace Cdy.Tag
/// <summary>
///
/// </summary>
private
Dictionary
<
int
,
bool
>
mChangedTags
=
new
Dictionary
<
int
,
bool
>();
private
ConcurrentDictionary
<
int
,
bool
>
mChangedTags
=
new
Concurrent
Dictionary
<
int
,
bool
>();
public
const
int
MaxTagCount
=
100000
;
...
...
@@ -87,6 +90,8 @@ namespace Cdy.Tag
/// </summary>
private
DateTime
mLastUpdateTime
;
private
int
mLastUpdateSecond
=
-
1
;
#
endregion
...
Properties
...
#
region
...
Methods
...
...
...
@@ -98,7 +103,11 @@ namespace Cdy.Tag
public
void
Notify
(
DateTime
time
)
{
mLastUpdateTime
=
time
;
resetEvent
.
Set
();
if
(
mLastUpdateTime
.
Second
!=
mLastUpdateSecond
)
{
mLastUpdateSecond
=
mLastUpdateTime
.
Second
;
resetEvent
.
Set
();
}
}
/// <summary>
...
...
@@ -110,13 +119,16 @@ namespace Cdy.Tag
ServiceLocator
.
Locator
.
Resolve
<
IRealDataNotify
>().
SubscribeValueChangedForConsumer
(
this
.
Name
,
new
ValueChangedNotifyProcesser
.
ValueChangedDelegate
((
ids
)
=>
{
foreach
(
var
vv
in
ids
)
{
if
(
mChangedTags
.
ContainsKey
(
vv
))
{
mChangedTags
[
vv
]
=
true
;
}
mChangedTags
[
vv
]
=
true
;
}
}),
null
,
null
,
new
Func
<
List
<
int
>>(()
=>
{
return
mTags
.
Keys
.
ToList
();
}));
foreach
(
var
vv
in
mTags
.
Keys
)
{
mChangedTags
.
TryAdd
(
vv
,
false
);
}
mRecordThread
=
new
Thread
(
ThreadProcess
);
mRecordThread
.
IsBackground
=
true
;
mRecordThread
.
Start
();
...
...
@@ -130,6 +142,9 @@ namespace Cdy.Tag
mIsClosed
=
true
;
resetEvent
.
Set
();
closedEvent
.
WaitOne
();
Clear
();
ServiceLocator
.
Locator
.
Resolve
<
IRealDataNotify
>().
UnSubscribeValueChangedForConsumer
(
this
.
Name
);
}
/// <summary>
...
...
@@ -157,75 +172,11 @@ namespace Cdy.Tag
public
void
Clear
()
{
mTags
.
Clear
();
mChangedTags
.
Clear
();
mCurrentCount
=
0
;
}
///// <summary>
/////
///// </summary>
//public void WriteHeader()
//{
// foreach (var vv in mTags.Values)
// {
// vv.UpdateHeader();
// }
//}
///// <summary>
/////
///// </summary>
///// <param name="time"></param>
//public void RecordFirstValue(DateTime time)
//{
// mLastUpdateTime = time;
// int tim = (int)((mLastUpdateTime - HisRunTag.StartTime).TotalMilliseconds / HisEnginer.MemoryTimeTick);
// foreach (var vv in mTags)
// {
// vv.Value.UpdateFirstValue(tim);
// }
//}
///// <summary>
/////
///// </summary>
///// <param name="time"></param>
//public void RecordLastValue(DateTime time)
//{
// mLastUpdateTime = time;
// int tim = (int)((mLastUpdateTime - HisRunTag.StartTime).TotalMilliseconds / HisEnginer.MemoryTimeTick);
// foreach (var vv in mTags)
// {
// vv.Value.UpdateLastValue(tim);
// }
//}
///// <summary>
///// 记录所有值
///// </summary>
//public void RecordAllValue(DateTime time)
//{
// try
// {
// mLastUpdateTime = time;
// int tim = (int)((mLastUpdateTime - HisRunTag.StartTime).TotalMilliseconds / HisEnginer.MemoryTimeTick);
// foreach (var vv in mTags)
// {
// if (mChangedTags.ContainsKey(vv.Key) && mChangedTags[vv.Key])
// {
// mTags[vv.Key].UpdateValue(tim);
// }
// else
// {
// vv.Value.AppendValue(tim);
// }
// }
// }
// catch
// {
// }
//}
/// <summary>
///
...
...
@@ -238,6 +189,8 @@ namespace Cdy.Tag
resetEvent
.
WaitOne
();
resetEvent
.
Reset
();
if
(
mIsClosed
)
break
;
//LoggerService.Service.Info("ValueChangedMemoryCacheProcesser", Name + " 执行!");
try
{
int
tim
=
(
int
)((
mLastUpdateTime
-
HisRunTag
.
StartTime
).
TotalMilliseconds
/
HisEnginer
.
MemoryTimeTick
);
...
...
@@ -245,18 +198,14 @@ namespace Cdy.Tag
{
if
(
vv
.
Value
)
{
mTags
[
vv
.
Key
].
UpdateValue
(
tim
/
10
,
tim
);
mChangedTags
[
vv
.
Key
]
=
false
;
mTags
[
vv
.
Key
].
UpdateValue
(
tim
);
}
else
{
mTags
[
vv
.
Key
].
UpdateNone
();
}
mChangedTags
[
vv
.
Key
]
=
false
;
}
}
catch
catch
(
Exception
ex
)
{
LoggerService
.
Service
.
Erro
(
"ValueChangedMemoryCacheProcesser"
,
ex
.
Message
);
}
resetEvent
.
Reset
();
}
...
...
@@ -271,6 +220,8 @@ namespace Cdy.Tag
{
resetEvent
.
Close
();
closedEvent
.
Close
();
mChangedTags
.
Clear
();
mTags
.
Clear
();
}
#
endregion
...
Methods
...
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录