提交 d49a5c68 编写于 作者: cdy816's avatar cdy816

修复死区压缩算法的Bug

上级 7674c9b8
......@@ -121,6 +121,12 @@ namespace Cdy.Tag
return mColections[index];
}
public void Restet()
{
WriteIndex = 0;
ReadIndex = 0;
}
#endregion ...Methods...
#region ... Interfaces ...
......
......@@ -1231,7 +1231,7 @@ namespace Cdy.Tag
public virtual void Dispose()
{
Marshal.FreeHGlobal(mHandles);
LoggerService.Service.Erro("MarshalFixedMemoryBlock", Name +" Disposed " );
LoggerService.Service.Info("MarshalFixedMemoryBlock", Name +" Disposed ",ConsoleColor.Red );
//GC.Collect();
}
......
......@@ -53,7 +53,14 @@ namespace DBDevelopService
/// </summary>
public void Start(int port)
{
StartAsync("0.0.0.0", port);
try
{
StartAsync("0.0.0.0", port);
}
catch(Exception ex)
{
LoggerService.Service.Erro("GrpcDBService",ex.Message);
}
}
/// <summary>
......
......@@ -30,6 +30,9 @@ namespace DBStudio
WindowConsolHelper.DisbleQuickEditMode();
Console.CancelKeyPress += Console_CancelKeyPress;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
LogoHelper.Print();
DBDevelopService.Service.Instanse.Start(port, webPort);
//OutByLine("", "输入exit退出服务");
......@@ -77,6 +80,11 @@ namespace DBStudio
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
LoggerService.Service.Erro("GrpcDBService", e.ExceptionObject.ToString());
}
/// <summary>
///
......@@ -840,7 +848,7 @@ namespace DBStudio
{
for (int j = 0; j < repeat; j++)
{
var vtag = new Cdy.Tag.DoubleTag() { Name = tag+j, LinkAddress = link };
var vtag = new Cdy.Tag.DoubleTag() { Name = tag+j, LinkAddress = link,Group="" };
database.RealDatabase.Append(vtag);
database.HisDatabase.AddHisTags(new Cdy.Tag.HisTag() { Id = vtag.Id, TagType = TagType.Double, Type = RecordType.Timer, Circle = 1000, CompressType = 0 });
}
......
......@@ -2,7 +2,7 @@
"profiles": {
"DBInStudioServer": {
"commandName": "Executable",
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInStudioServer.exe"
"executablePath": "C:\\Users\\Lenovo\\source\\repos\\mars\\Output\\DBInStudioServer.exe"
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"profiles": {
"DBInStudio.Desktop": {
"commandName": "Executable",
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInStudio.exe"
"executablePath": "C:\\Users\\Lenovo\\source\\repos\\mars\\Output\\DBInStudio.exe"
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
"profiles": {
"DBInRun": {
"commandName": "Executable",
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInRun.exe"
"executablePath": "C:\\Users\\Lenovo\\source\\repos\\mars\\Output\\DBInRun.exe"
}
}
}
\ No newline at end of file
......@@ -28,7 +28,10 @@ namespace Cdy.Tag
protected FloatCompressBuffer mFCompress;
private CustomQueue<int> emptys = new CustomQueue<int>(604);
/// <summary>
///
/// </summary>
protected CustomQueue<int> emptys = new CustomQueue<int>(604);
/// <summary>
///
......@@ -117,8 +120,9 @@ namespace Cdy.Tag
{
int preids = 0;
mVarintMemory.Reset();
emptys.WriteIndex = 0;
emptyIds.ReadIndex = 0;
emptys.Restet();
//emptys.WriteIndex = 0;
//emptyIds.ReadIndex = 0;
bool isFirst = true;
for (int i = 0; i < timerVals.Count; i++)
{
......@@ -144,12 +148,19 @@ namespace Cdy.Tag
return mVarintMemory.DataBuffer.AsMemory(0, (int)mVarintMemory.WritePosition);
}
protected Memory<byte> CompressTimers(MarshalMemoryBlock timerVals,long startaddr,int count, CustomQueue<int> emptyIds)
/// <summary>
///
/// </summary>
/// <param name="timerVals"></param>
/// <param name="startaddr"></param>
/// <param name="count"></param>
/// <param name="emptyIds"></param>
/// <returns></returns>
protected virtual Memory<byte> CompressTimers(MarshalMemoryBlock timerVals,long startaddr,int count, CustomQueue<int> emptyIds)
{
int preids = 0;
mVarintMemory.Reset();
emptyIds.WriteIndex = 0;
emptyIds.ReadIndex = 0;
emptys.Restet();
bool isFirst = true;
int id = 0;
......@@ -699,7 +710,7 @@ namespace Cdy.Tag
//using (ProtoMemory memory = new ProtoMemory(qulitys.Length * 2))
mVarintMemory.Reset();
int ig = -1;
ig = emptys.ReadIndex<emptyIds.WriteIndex ? emptys.IncRead() : -1;
ig = emptyIds.ReadIndex<emptyIds.WriteIndex ? emptyIds.IncRead() : -1;
//emptyIds.TryDequeue(out ig);
mVarintMemory.WriteInt32(qus);
for (int i = 1; i < totalcount; i++)
......@@ -721,7 +732,7 @@ namespace Cdy.Tag
}
else
{
ig = emptys.ReadIndex<emptyIds.WriteIndex ? emptys.IncRead() : -1;
ig = emptyIds.ReadIndex<emptyIds.WriteIndex ? emptyIds.IncRead() : -1;
// emptyIds.TryDequeue(out ig);
}
}
......@@ -743,7 +754,7 @@ namespace Cdy.Tag
//using (ProtoMemory memory = new ProtoMemory(qulitys.Length * 2))
mVarintMemory.Reset();
int ig = -1;
ig = emptys.ReadIndex<emptyIds.WriteIndex ? emptys.IncRead() : -1;
ig = emptyIds.ReadIndex<emptyIds.WriteIndex ? emptyIds.IncRead() : -1;
mVarintMemory.WriteInt32(qus);
for (int i = 1; i < qulitys.Length; i++)
{
......@@ -763,7 +774,7 @@ namespace Cdy.Tag
}
else
{
ig = emptys.ReadIndex<emptyIds.WriteIndex ? emptys.IncRead() : -1;
ig = emptyIds.ReadIndex<emptyIds.WriteIndex ? emptyIds.IncRead() : -1;
}
}
mVarintMemory.WriteInt32(count);
......@@ -781,7 +792,7 @@ namespace Cdy.Tag
byte bval = source.ReadByte(offset);
short scount = 1;
int ig = -1;
ig = emptys.ReadIndex<emptyIds.WriteIndex ? emptys.IncRead() : -1;
ig = emptyIds.ReadIndex<emptyIds.WriteIndex ? emptyIds.IncRead() : -1;
//emptyIds.TryDequeue(out ig);
short sval = (short)(bval << 15);
......@@ -805,7 +816,7 @@ namespace Cdy.Tag
}
else
{
ig = emptys.ReadIndex<emptyIds.WriteIndex ? emptys.IncRead() : -1;
ig = emptyIds.ReadIndex<emptyIds.WriteIndex ? emptyIds.IncRead() : -1;
// emptyIds.TryDequeue(out ig);
}
}
......@@ -861,7 +872,7 @@ namespace Cdy.Tag
rsize += 4;
rsize += datas.Length;
switch (TagType)
switch (type)
{
case TagType.Bool:
var cval = CompressBoolValues(source, count * 2 + sourceAddr, count, emptys);
......
......@@ -2,7 +2,7 @@
"profiles": {
"HisDataTools": {
"commandName": "Executable",
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\HisDataTools.exe"
"executablePath": "C:\\Users\\Lenovo\\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.
先完成此消息的编辑!
想要评论请 注册