/// <summary> /// /// </summary> /// <param name="start"></param> /// <returns></returns> public override float ReadFloat(long start) { mStream.Position = start; byte[] re = new byte[4]; mStream.Read(re, 0, re.Length); return(MemoryHelper.ReadFloat(re)); }
/// <summary> /// /// </summary> /// <param name="startMemory"></param> /// <param name="offset"></param> /// <returns></returns> public override unsafe bool CheckValueChangeToLastRecordValue(void *startMemory, long offset) { var mTmpValue = MemoryHelper.ReadFloat(startMemory, offset); if (mTmpValue != mLastValue || mLastValue == float.MinValue) { mLastValue = mTmpValue; return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <returns></returns> public override float ReadFloat(long start) { mStream.Position = start; // byte[] re = new byte[4]; var re = ArrayPool <byte> .Shared.Rent(4); try { mStream.Read(re, 0, 4); return(MemoryHelper.ReadFloat(re)); } finally { ArrayPool <byte> .Shared.Return(re); } }
/// <summary> /// /// </summary> /// <param name="offset"></param> /// <returns></returns> public virtual float ReadFloat(long offset) { mPosition = offset + 4; return(MemoryHelper.ReadFloat((void *)mHandles, offset)); }
/// <summary> /// /// </summary> /// <param name="index"></param> /// <returns></returns> public T GetValue(int index, out DateTime time, out byte qulity) { object re = null; switch (mDataType) { case 0: re = Convert.ToBoolean(MemoryHelper.ReadByte((void *)handle, index)); break; case 1: re = MemoryHelper.ReadByte((void *)handle, index); break; case 2: re = MemoryHelper.ReadShort((void *)handle, index * 2); break; case 3: re = MemoryHelper.ReadUShort((void *)handle, index * 2); break; case 4: re = MemoryHelper.ReadInt32((void *)handle, index * 4); break; case 5: re = MemoryHelper.ReadUInt32((void *)handle, index * 4); break; case 6: re = MemoryHelper.ReadInt64((void *)handle, index * 8); break; case 7: re = MemoryHelper.ReadUInt64((void *)handle, index * 8); break; case 8: re = MemoryHelper.ReadFloat((void *)handle, index * 4); break; case 9: re = MemoryHelper.ReadDouble((void *)handle, index * 8); break; case 10: re = MemoryHelper.ReadDateTime((void *)handle, index * 8); break; case 11: if (mStringCach != null) { re = mStringCach[index]; } else { mStringCach = new List <string>(mCount); int cc = 0; int pos = 0; int len = 0; while (cc < this.mCount) { len = MemoryHelper.ReadByte((void *)handle, pos); mStringCach.Add(new string((sbyte *)handle, pos + 1, len, Encoding.Unicode)); pos += len + 1; cc++; } re = mStringCach[index]; } break; case 12: var x = MemoryHelper.ReadInt32((void *)handle, index * 8); var y = MemoryHelper.ReadInt32((void *)handle, index * 8 + 4); re = new IntPointData(x, y); break; case 13: re = new UIntPointData(MemoryHelper.ReadUInt32((void *)handle, index * 8), MemoryHelper.ReadUInt32((void *)handle, index * 8 + 4)); break; case 14: re = new IntPoint3Data(MemoryHelper.ReadInt32((void *)handle, index * 12), MemoryHelper.ReadInt32((void *)handle, index * 12 + 4), MemoryHelper.ReadInt32((void *)handle, index * 12 + 8)); break; case 15: re = new UIntPoint3Data(MemoryHelper.ReadUInt32((void *)handle, index * 12), MemoryHelper.ReadUInt32((void *)handle, index * 12 + 4), MemoryHelper.ReadUInt32((void *)handle, index * 12 + 8)); break; case 16: re = new LongPointData(MemoryHelper.ReadInt64((void *)handle, index * 16), MemoryHelper.ReadInt64((void *)handle, index * 16 + 8)); break; case 17: re = new ULongPointData(MemoryHelper.ReadUInt64((void *)handle, index * 16), MemoryHelper.ReadUInt64((void *)handle, index * 16 + 8)); break; case 18: re = new LongPoint3Data(MemoryHelper.ReadInt64((void *)handle, index * 24), MemoryHelper.ReadInt64((void *)handle, index * 24 + 8), MemoryHelper.ReadInt64((void *)handle, index * 24 + 16)); break; case 19: re = new ULongPoint3Data(MemoryHelper.ReadUInt64((void *)handle, index * 24), MemoryHelper.ReadUInt64((void *)handle, index * 24 + 8), MemoryHelper.ReadUInt64((void *)handle, index * 24 + 16)); break; } time = MemoryHelper.ReadDateTime((void *)handle, index * 8 + mTimeAddr); qulity = MemoryHelper.ReadByte((void *)handle, mQulityAddr + index); return((T)re); }
/// <summary> /// /// </summary> /// <param name="index"></param> /// <returns></returns> public T GetValue(int index, out DateTime time, out byte qulity) { object re = null; switch (mDataType) { case 0: re = Convert.ToBoolean(MemoryHelper.ReadByte((void *)handle, index)); break; case 1: re = MemoryHelper.ReadByte((void *)handle, index); break; case 2: re = MemoryHelper.ReadShort((void *)handle, index * 2); break; case 3: re = MemoryHelper.ReadShort((void *)handle, index * 2); break; case 4: re = MemoryHelper.ReadInt32((void *)handle, index * 4); break; case 5: re = MemoryHelper.ReadInt32((void *)handle, index * 4); break; case 6: re = MemoryHelper.ReadInt32((void *)handle, index * 8); break; case 7: re = MemoryHelper.ReadInt32((void *)handle, index * 8); break; case 8: re = MemoryHelper.ReadFloat((void *)handle, index * 4); break; case 9: re = MemoryHelper.ReadDouble((void *)handle, index * 8); break; case 10: re = MemoryHelper.ReadDateTime((void *)handle, index * 8); break; case 11: int cc = 0; int pos = 0; while (true) { if (cc >= index) { break; } //pos += (mDataBuffer[pos]+1); pos += MemoryHelper.ReadByte((void *)handle, pos) + 1; cc++; } re = new string((char *)handle, pos + 1, MemoryHelper.ReadByte((void *)handle, pos)); break; } time = MemoryHelper.ReadDateTime((void *)handle, index * 8 + mTimeAddr); qulity = MemoryHelper.ReadByte((void *)handle, mQulityAddr + index); return((T)re); }