/// <summary> /// 将UTC时间转换成本地时间 /// </summary> public HisQueryResult <T> ConvertUTCTimeToLocal() { for (int i = 0; i < mCount; i++) { MemoryHelper.WriteDateTime((void *)handle, i * 8 + mTimeAddr, MemoryHelper.ReadDateTime((void *)handle, i * 8 + mTimeAddr).ToLocalTime()); } return(this); }
public override DateTime ReadDateTime(long start) { mStream.Position = start; byte[] re = new byte[8]; mStream.Read(re, 0, re.Length); return(MemoryHelper.ReadDateTime(re)); // return DateTime.FromBinary(BitConverter.ToInt64(re, 0)); }
/// <summary> /// /// </summary> /// <param name="startMemory"></param> /// <param name="offset"></param> /// <returns></returns> public override unsafe bool CheckValueChangeToLastRecordValue(void *startMemory, long offset) { var mTmpValue = MemoryHelper.ReadDateTime(startMemory, offset); if (mTmpValue != mLastValue || mLastValue == DateTime.MinValue) { mLastValue = mTmpValue; return(true); } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <returns></returns> public override DateTime ReadDateTime(long start) { mStream.Position = start; //byte[] re = new byte[8]; var re = ArrayPool <byte> .Shared.Rent(8); try { mStream.Read(re, 0, 8); return(MemoryHelper.ReadDateTime(re)); } finally { ArrayPool <byte> .Shared.Return(re); } // return DateTime.FromBinary(BitConverter.ToInt64(re, 0)); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="time"></param> /// <param name="avgvalue"></param> /// <param name="maxvalue"></param> /// <param name="maxvalueTime"></param> /// <param name="minValue"></param> /// <param name="minValueTime"></param> /// <returns></returns> public bool ReadValue(int id, out DateTime time, out double avgvalue, out double maxvalue, out DateTime maxvalueTime, out double minValue, out DateTime minValueTime) { if (id < mCount) { int pos = id * ValueSize; time = MemoryHelper.ReadDateTime((void *)handle, pos); avgvalue = MemoryHelper.ReadDouble((void *)handle, pos + 8); maxvalueTime = MemoryHelper.ReadDateTime((void *)handle, pos + 16); maxvalue = MemoryHelper.ReadDouble((void *)handle, pos + 24); minValueTime = MemoryHelper.ReadDateTime((void *)handle, pos + 32); minValue = MemoryHelper.ReadDouble((void *)handle, pos + 40); return(true); } else { time = maxvalueTime = minValueTime = DateTime.MinValue; avgvalue = maxvalue = minValue = double.MinValue; return(false); } }
/// <summary> /// /// </summary> /// <returns></returns> public NumberStatisticsQueryResult ConvertUTCTimeToLocal() { for (int i = 0; i < mCount; i++) { int pos = i * ValueSize; var time = MemoryHelper.ReadDateTime((void *)handle, pos); time = time.ToLocalTime(); MemoryHelper.WriteDateTime((void *)handle, pos, time); pos = pos + 16; time = MemoryHelper.ReadDateTime((void *)handle, pos); time = time.ToLocalTime(); MemoryHelper.WriteDateTime((void *)handle, pos, time); pos = pos + 16; time = MemoryHelper.ReadDateTime((void *)handle, pos); time = time.ToLocalTime(); MemoryHelper.WriteDateTime((void *)handle, pos, time); } return(this); }
/// <summary> /// /// </summary> /// <param name="offset"></param> /// <returns></returns> public virtual DateTime ReadDateTime(long offset) { mPosition = offset + sizeof(DateTime); return(MemoryHelper.ReadDateTime((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); }