diff --git a/Common/Cdy.Tag.Common/Common/CustomQueue.cs b/Common/Cdy.Tag.Common/Common/CustomQueue.cs index 2302371051ca9b458a5e3fe0261ecf56d06492b1..6aa298b07738495465a64326c3f1968f8ce88913 100644 --- a/Common/Cdy.Tag.Common/Common/CustomQueue.cs +++ b/Common/Cdy.Tag.Common/Common/CustomQueue.cs @@ -20,6 +20,7 @@ namespace Cdy.Tag #region ... Variables ... private T[] mColections; private int mCount = 0; + private object mReadLockObj = new object(); #endregion ...Variables... #region ... Events ... @@ -43,13 +44,15 @@ namespace Cdy.Tag #region ... Properties ... - - public int WriteIndex { get; set; } = 0; + /// + /// + /// + public int WriteIndex { get; set; } = -1; /// /// /// - public int ReadIndex { get; set; } + public int ReadIndex { get; set; } = 0; /// /// @@ -66,7 +69,18 @@ namespace Cdy.Tag /// public void Insert(T value) { - mColections[WriteIndex++] = value; + lock(mColections) + mColections[++WriteIndex] = value; + } + + /// + /// + /// + /// + /// + public void InsertAt(T value,int index) + { + mColections[index] = value; } @@ -85,16 +99,19 @@ namespace Cdy.Tag /// public T IncRead() { - if (ReadIndex <= WriteIndex) + lock (mReadLockObj) { - return mColections[ReadIndex++]; + if (ReadIndex <= WriteIndex) + { + return mColections[ReadIndex++]; + } + else + { + ReadIndex++; + return default(T); + } } - else - { - ReadIndex++; - return default(T); - } - + } /// @@ -103,25 +120,45 @@ namespace Cdy.Tag /// public T DescRead() { - - if (ReadIndex >=0) - { - return mColections[ReadIndex--]; - } - else + lock (mReadLockObj) { - ReadIndex--; - return default(T); + if (ReadIndex >= 0) + { + return mColections[ReadIndex--]; + } + else + { + ReadIndex--; + return default(T); + } } } + /// + /// + /// + /// + public T Read() + { + return mColections[ReadIndex]; + } + + /// + /// + /// + /// + /// + public T Read(int index) + { + return mColections[index]; + } + /// /// /// /// public T Remove() { - WriteIndex--; if (WriteIndex < 0) { WriteIndex = -1; @@ -129,8 +166,11 @@ namespace Cdy.Tag } else { - return mColections[WriteIndex]; + var re = mColections[WriteIndex]; + --WriteIndex; + return re; } + } public T Get(int index) @@ -143,7 +183,7 @@ namespace Cdy.Tag /// public void Reset() { - WriteIndex = 0; + WriteIndex = -1; ReadIndex = 0; } diff --git a/Common/Cdy.Tag.Common/Common/ProtoMemory.cs b/Common/Cdy.Tag.Common/Common/ProtoMemory.cs index 3ab4148f89fb8e5532adbb2e8b9ee50222e917fa..a652342856fca539ea723f91bfe5541492c578a0 100644 --- a/Common/Cdy.Tag.Common/Common/ProtoMemory.cs +++ b/Common/Cdy.Tag.Common/Common/ProtoMemory.cs @@ -138,6 +138,20 @@ namespace Cdy.Tag return inputStream.ReadInt32(); } + /// + /// + /// + /// + public List ReadInt32s() + { + List re = new List(); + while(!inputStream.IsAtEnd) + { + re.Add(inputStream.ReadInt32()); + } + return re; + } + /// /// /// @@ -202,6 +216,20 @@ namespace Cdy.Tag return inputStream.ReadInt64(); } + /// + /// + /// + /// + public List ReadInt64s() + { + List re = new List(); + while (!inputStream.IsAtEnd) + { + re.Add(inputStream.ReadInt64()); + } + return re; + } + /// /// /// diff --git a/Develop/DbManager.Desktop/Properties/launchSettings.json b/Develop/DbManager.Desktop/Properties/launchSettings.json index 4cfb86df453b8beb606f8686db74eca036820204..e480c59bbe941fe4b786f9ca0a645caa5e7db11d 100644 --- a/Develop/DbManager.Desktop/Properties/launchSettings.json +++ b/Develop/DbManager.Desktop/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "DBInStudio.Desktop": { "commandName": "Executable", - "executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInStudio.exe" + "executablePath": "C:\\Users\\chongdaoyang\\source\\repos\\mars\\Output\\DBInStudio.exe" } } } \ No newline at end of file diff --git a/RunTime/DBInRun/Properties/launchSettings.json b/RunTime/DBInRun/Properties/launchSettings.json index 21cb4218ac8cdf7641c4cf095a7db6c95139cbf5..d74015f88dab164d7be203163f5a025e72959e8e 100644 --- a/RunTime/DBInRun/Properties/launchSettings.json +++ b/RunTime/DBInRun/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "DBInRun": { "commandName": "Executable", - "executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBInRun.exe" + "executablePath": "C:\\Users\\chongdaoyang\\source\\repos\\mars\\Output\\DBInRun.exe" } } } \ No newline at end of file diff --git a/RunTime/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs b/RunTime/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs index 35558db70fde39154404767cce4c2ad8712cdf72..422f97d2c4a16de23de9220ab5bf3d0fc1c93ba9 100644 --- a/RunTime/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs +++ b/RunTime/DBRuntime/His/Compress/Special/DeadAreaCompressUnit2.cs @@ -109,7 +109,7 @@ namespace Cdy.Tag int id = 0; int ig = -1; - ig = emptyIds.ReadIndex < emptyIds.WriteIndex ? emptyIds.IncRead() : -1; + ig = emptyIds.ReadIndex <= emptyIds.WriteIndex ? emptyIds.IncRead() : -1; byte tlen = (timerVals as HisDataMemoryBlock).TimeLen; @@ -135,7 +135,7 @@ namespace Cdy.Tag } else { - ig = emptyIds.ReadIndex < emptyIds.WriteIndex ? emptyIds.IncRead() : -1; + ig = emptyIds.ReadIndex <= emptyIds.WriteIndex ? emptyIds.IncRead() : -1; // emptyIds.TryDequeue(out ig); } } @@ -192,7 +192,7 @@ namespace Cdy.Tag var cval = CompressBoolValues(source, count * 2 + sourceAddr, count, emptys); - int rcount = count - emptys.WriteIndex; + int rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -221,7 +221,7 @@ namespace Cdy.Tag cval = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -249,7 +249,7 @@ namespace Cdy.Tag var ures = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -275,7 +275,7 @@ namespace Cdy.Tag var res = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -301,7 +301,7 @@ namespace Cdy.Tag var uires = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -326,7 +326,7 @@ namespace Cdy.Tag FindEmpityIds(source, sourceAddr, (int)count, emptys); var ires = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -351,7 +351,7 @@ namespace Cdy.Tag FindEmpityIds(source, sourceAddr, (int)count, emptys); var ulres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -376,7 +376,7 @@ namespace Cdy.Tag FindEmpityIds(source, sourceAddr, (int)count, emptys); var lres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -402,7 +402,7 @@ namespace Cdy.Tag var dres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -429,7 +429,7 @@ namespace Cdy.Tag var ddres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -464,7 +464,7 @@ namespace Cdy.Tag var fres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -488,7 +488,7 @@ namespace Cdy.Tag case TagType.String: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -515,7 +515,7 @@ namespace Cdy.Tag break; case TagType.IntPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -539,7 +539,7 @@ namespace Cdy.Tag break; case TagType.UIntPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -563,7 +563,7 @@ namespace Cdy.Tag break; case TagType.LongPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -587,7 +587,7 @@ namespace Cdy.Tag break; case TagType.ULongPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -611,7 +611,7 @@ namespace Cdy.Tag break; case TagType.IntPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -635,7 +635,7 @@ namespace Cdy.Tag break; case TagType.UIntPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -659,7 +659,7 @@ namespace Cdy.Tag break; case TagType.LongPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -683,7 +683,7 @@ namespace Cdy.Tag break; case TagType.ULongPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 target.WriteUShort(targetAddr, (ushort)rcount); rsize += 2; @@ -731,7 +731,7 @@ namespace Cdy.Tag bool isFirst = true; int ig = -1; - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; @@ -766,7 +766,7 @@ namespace Cdy.Tag else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -800,7 +800,7 @@ namespace Cdy.Tag else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -834,7 +834,7 @@ namespace Cdy.Tag else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -867,7 +867,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -900,7 +900,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -933,7 +933,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -966,7 +966,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -1006,7 +1006,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -1042,7 +1042,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } diff --git a/RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs b/RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs index 5463cb49c865b56641e4bfdd966a653f0f4e654d..33da3e414df1fb7aff31c55cc1bcab1970698d6d 100644 --- a/RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs +++ b/RunTime/DBRuntime/His/Compress/Special/LosslessCompressUnit2.cs @@ -207,7 +207,7 @@ namespace Cdy.Tag mMarshalMemory.Position = 0; mVarintMemory.Reset(); int ig = -1; - ig = emptyIds.ReadIndex(0, (int)mMarshalMemory.Position); @@ -713,7 +713,7 @@ namespace Cdy.Tag //using (ProtoMemory memory = new ProtoMemory(qulitys.Length * 2)) mVarintMemory.Reset(); int ig = -1; - ig = emptyIds.ReadIndex CompressTimers(List timerVals, CustomQueue usedIndex) { usedIndex.ReadIndex = 0; - // int preids = timerVals[0]; int preids = 0; - int ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + int ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; bool isFirst = true; mVarintMemory2.Reset(); - //mVarintMemory.WriteInt32(preids); for (int i = 0; i < timerVals.Count; i++) { if (i == ig) @@ -103,10 +101,10 @@ namespace Cdy.Tag mVarintMemory2.WriteInt32(id - preids); } preids = id; - ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; } } - return mVarintMemory2.DataBuffer.AsSpan(0, (int)mVarintMemory2.WritePosition).ToArray(); + return mVarintMemory2.DataBuffer.AsMemory(0, (int)mVarintMemory2.WritePosition); } /// @@ -141,7 +139,7 @@ namespace Cdy.Tag int count = 0; byte qus = 0; mVarintMemory.Reset(); - int ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + int ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; bool isFirst = true; for (int i = 0; i < totalcount; i++) @@ -170,7 +168,7 @@ namespace Cdy.Tag count = 1; } } - ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; } } mVarintMemory.WriteInt32(count); @@ -1635,7 +1633,7 @@ namespace Cdy.Tag int ig = -1; emptys.ReadIndex = 0; - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; int ac = 0; mAvaiableDatabuffer.Position = 0; mAvaiableDatabuffer.Write((int)0); @@ -1656,7 +1654,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1675,7 +1673,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1694,7 +1692,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1713,7 +1711,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1732,7 +1730,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1750,7 +1748,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1768,7 +1766,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1787,7 +1785,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1805,7 +1803,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); diff --git a/RunTime/DBRuntime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs b/RunTime/DBRuntime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs index 0e4fbe8392f8aa222cd95157e09f60f1d227c8fd..83f1e79b03548f646390326b84e7c100c0e64d31 100644 --- a/RunTime/DBRuntime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs +++ b/RunTime/DBRuntime/His/obsolete/Compress/Special/DeadAreaCompressUnit.cs @@ -104,7 +104,7 @@ namespace Cdy.Tag int id = 0; int ig = -1; - ig = emptyIds.ReadIndex < emptyIds.WriteIndex ? emptyIds.IncRead() : -1; + ig = emptyIds.ReadIndex <= emptyIds.WriteIndex ? emptyIds.IncRead() : -1; for (int i = 0; i < count; i++) { @@ -124,7 +124,7 @@ namespace Cdy.Tag } else { - ig = emptyIds.ReadIndex < emptyIds.WriteIndex ? emptyIds.IncRead() : -1; + ig = emptyIds.ReadIndex <= emptyIds.WriteIndex ? emptyIds.IncRead() : -1; // emptyIds.TryDequeue(out ig); } } @@ -174,10 +174,10 @@ namespace Cdy.Tag var cval = CompressBoolValues(source, count * 2 + sourceAddr, count, emptys); - int rcount = count - emptys.WriteIndex; + int rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -203,10 +203,10 @@ namespace Cdy.Tag cval = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex-1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -231,10 +231,10 @@ namespace Cdy.Tag var ures = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -257,10 +257,10 @@ namespace Cdy.Tag var res = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -283,10 +283,10 @@ namespace Cdy.Tag var uires = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -308,10 +308,10 @@ namespace Cdy.Tag FindEmpityIds(source, sourceAddr, (int)count, emptys); var ires = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -333,10 +333,10 @@ namespace Cdy.Tag FindEmpityIds(source, sourceAddr, (int)count, emptys); var ulres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -358,10 +358,10 @@ namespace Cdy.Tag FindEmpityIds(source, sourceAddr, (int)count, emptys); var lres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -384,10 +384,10 @@ namespace Cdy.Tag var dres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -411,10 +411,10 @@ namespace Cdy.Tag var ddres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -438,10 +438,10 @@ namespace Cdy.Tag var fres = CompressValues(source, count * 2 + sourceAddr, count, emptys, TagType); datas = CompressTimers2(source, sourceAddr, (int)count, emptys2); - rcount = count - emptys2.WriteIndex; + rcount = count - emptys2.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -462,10 +462,10 @@ namespace Cdy.Tag case TagType.String: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -489,10 +489,10 @@ namespace Cdy.Tag break; case TagType.IntPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -513,10 +513,10 @@ namespace Cdy.Tag break; case TagType.UIntPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -537,10 +537,10 @@ namespace Cdy.Tag break; case TagType.LongPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -561,10 +561,10 @@ namespace Cdy.Tag break; case TagType.ULongPoint: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -585,10 +585,10 @@ namespace Cdy.Tag break; case TagType.IntPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -609,10 +609,10 @@ namespace Cdy.Tag break; case TagType.UIntPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -633,10 +633,10 @@ namespace Cdy.Tag break; case TagType.LongPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -657,10 +657,10 @@ namespace Cdy.Tag break; case TagType.ULongPoint3: datas = CompressTimers(source, sourceAddr, (int)count, emptys); - rcount = count - emptys.WriteIndex; + rcount = count - emptys.WriteIndex - 1; //写入时间 - target.WriteUShort(targetAddr, (ushort)rcount); - rsize += 2; + target.WriteInt(targetAddr, rcount); + rsize += 4; target.Write((int)datas.Length); target.Write(datas); rsize += 4; @@ -705,7 +705,7 @@ namespace Cdy.Tag bool isFirst = true; int ig = -1; - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; switch (type) { @@ -738,7 +738,7 @@ namespace Cdy.Tag else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -772,7 +772,7 @@ namespace Cdy.Tag else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -806,7 +806,7 @@ namespace Cdy.Tag else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -839,7 +839,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -872,7 +872,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -905,7 +905,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -938,7 +938,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -974,7 +974,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } @@ -1010,7 +1010,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; emptys2.Insert(i); } } diff --git a/RunTime/DBRuntime/His/obsolete/Compress/Special/LosslessCompressUnit.cs b/RunTime/DBRuntime/His/obsolete/Compress/Special/LosslessCompressUnit.cs index ba96b3676548d2d50203228d6b62402b4383bdc7..edc78e8e76089748514dc73f11b9855053765f47 100644 --- a/RunTime/DBRuntime/His/obsolete/Compress/Special/LosslessCompressUnit.cs +++ b/RunTime/DBRuntime/His/obsolete/Compress/Special/LosslessCompressUnit.cs @@ -204,7 +204,7 @@ namespace Cdy.Tag mMarshalMemory.Position = 0; mVarintMemory.Reset(); int ig = -1; - ig = emptyIds.ReadIndex(0, (int)mMarshalMemory.Position); @@ -710,7 +710,7 @@ namespace Cdy.Tag //using (ProtoMemory memory = new ProtoMemory(qulitys.Length * 2)) mVarintMemory.Reset(); int ig = -1; - ig = emptyIds.ReadIndex re = new Dictionary(); - ushort count = source.ReadUShort(); + + int count = source.ReadInt(); var datasize = source.ReadInt(); byte[] datas = source.ReadBytes(datasize); var timers = DeCompressTimers(datas, count); @@ -1577,7 +1578,7 @@ namespace Cdy.Tag { DateTime sTime = source.ReadDateTime(sourceAddr); Dictionary re = new Dictionary(); - ushort count = source.ReadUShort(); + var count = source.ReadInt(); var datasize = source.ReadInt(); byte[] datas = source.ReadBytes(datasize); var timers = DeCompressTimers(datas, count); diff --git a/RunTime/DBRuntime/His/obsolete/Compress/Special/SlopeCompressUnit.cs b/RunTime/DBRuntime/His/obsolete/Compress/Special/SlopeCompressUnit.cs index f266acc235e95bbbcdcf7a0f658f389dba7be1e8..374638302595ecba6aa7de34349c8aa8caafa809 100644 --- a/RunTime/DBRuntime/His/obsolete/Compress/Special/SlopeCompressUnit.cs +++ b/RunTime/DBRuntime/His/obsolete/Compress/Special/SlopeCompressUnit.cs @@ -82,7 +82,7 @@ namespace Cdy.Tag usedIndex.ReadIndex = 0; // int preids = timerVals[0]; int preids = 0; - int ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + int ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; bool isFirst = true; mVarintMemory2.Reset(); @@ -103,7 +103,7 @@ namespace Cdy.Tag mVarintMemory2.WriteInt32(id - preids); preids = id; } - ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; } } return mVarintMemory2.DataBuffer.AsSpan(0, (int)mVarintMemory2.WritePosition).ToArray(); @@ -143,7 +143,7 @@ namespace Cdy.Tag int count = 0; byte qus = 0; mVarintMemory.Reset(); - int ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + int ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; bool isFirst = true; for (int i = 0; i < totalcount; i++) @@ -172,7 +172,7 @@ namespace Cdy.Tag count = 1; } } - ig = usedIndex.ReadIndex < usedIndex.WriteIndex ? usedIndex.IncRead() : -1; + ig = usedIndex.ReadIndex <= usedIndex.WriteIndex ? usedIndex.IncRead() : -1; } } mVarintMemory.WriteInt32(count); @@ -1631,7 +1631,7 @@ namespace Cdy.Tag int ig = -1; emptys.ReadIndex = 0; - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; int ac = 0; mAvaiableDatabuffer.Position = 0; mAvaiableDatabuffer.Write((int)0); @@ -1652,7 +1652,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1671,7 +1671,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1690,7 +1690,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1709,7 +1709,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1728,7 +1728,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1746,7 +1746,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1764,7 +1764,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1783,7 +1783,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1801,7 +1801,7 @@ namespace Cdy.Tag } else { - ig = emptys.ReadIndex < emptys.WriteIndex ? emptys.IncRead() : -1; + ig = emptys.ReadIndex <= emptys.WriteIndex ? emptys.IncRead() : -1; } } mAvaiableDatabuffer.WriteInt(0, ac); @@ -1826,9 +1826,9 @@ namespace Cdy.Tag { int rsize = 0; - target.WriteUShort(targetAddr, (ushort)usedIndex.WriteIndex); + target.WriteInt(targetAddr,(usedIndex.WriteIndex+1)); - rsize += 2; + rsize += 4; target.Write((int)timedata.Length); target.Write(timedata); rsize += 4; diff --git a/Tools/HisDataTools/Properties/launchSettings.json b/Tools/HisDataTools/Properties/launchSettings.json index baa806c6ab6e0795d9a4c2065136d55a7b37a9d1..47e9ff54c0eb75961f0ffdca4e11591a40dce948 100644 --- a/Tools/HisDataTools/Properties/launchSettings.json +++ b/Tools/HisDataTools/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "HisDataTools": { "commandName": "Executable", - "executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\HisDataTools.exe" + "executablePath": "C:\\Users\\chongdaoyang\\source\\repos\\mars\\Output\\HisDataTools.exe" } } } \ No newline at end of file