/// <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); }
/// <summary> /// /// </summary> /// <param name="Hourtime"></param> /// <param name="avgValue"></param> /// <param name="maxvalue"></param> /// <param name="maxvalueTime"></param> /// <param name="minvalue"></param> /// <param name="minValueTime"></param> public void AddValue(DateTime time, double avgValue, double maxvalue, DateTime maxvalueTime, double minvalue, DateTime minValueTime) { MemoryHelper.WriteDateTime((void *)handle, mPosition, time); MemoryHelper.WriteDouble((void *)(handle), mPosition + 8, avgValue); MemoryHelper.WriteDateTime((void *)(handle), mPosition + 16, maxvalueTime); MemoryHelper.WriteDouble((void *)(handle), mPosition + 24, maxvalue); MemoryHelper.WriteDateTime((void *)(handle), mPosition + 32, minValueTime); MemoryHelper.WriteDouble((void *)(handle), mPosition + 40, minvalue); mPosition += ValueSize; mCount++; }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <param name="time"></param> /// <param name="qulity"></param> public void Add(DateTime value, DateTime time, byte qulity) { if (mCount >= mLimite) { int newCount = (int)(mCount * 1.2); Resize(newCount); mLimite = newCount; } MemoryHelper.WriteDateTime((void *)handle, mPosition, value); mPosition += 8; MemoryHelper.WriteDateTime((void *)handle, mCount * 8 + mTimeAddr, time); // mDataBuffer[mCount + mQulityAddr] = qulity; Marshal.WriteByte(handle + mCount + mQulityAddr, qulity); mCount++; }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <param name="time"></param> /// <param name="qulity"></param> public void Add(bool value, DateTime time, byte qulity) { if (mCount >= mLimite) { int newCount = (int)(mCount * 1.2); Resize(newCount); mLimite = newCount; } Marshal.WriteByte(handle + mPosition, (byte)(value ? 1 : 0)); // mDataBuffer[mPosition] = (byte)(value ? 1 : 0); mPosition++; MemoryHelper.WriteDateTime((void *)(handle), mCount * 8 + mTimeAddr, time); Marshal.WriteByte(handle + mCount + mQulityAddr, qulity); // mDataBuffer[mCount + mQulityAddr] = qulity; mCount++; }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <param name="time"></param> /// <param name="qulity"></param> public void AddPoint(uint x, uint y, uint z, DateTime time, byte qulity) { if (mCount >= mLimite) { int newCount = (int)(mCount * 1.2); Resize(newCount); mLimite = newCount; } MemoryHelper.WriteUInt32((void *)handle, mPosition, x); mPosition += 4; MemoryHelper.WriteUInt32((void *)handle, mPosition, y); mPosition += 4; MemoryHelper.WriteUInt32((void *)handle, mPosition, z); mPosition += 4; MemoryHelper.WriteDateTime((void *)handle, mCount * 8 + mTimeAddr, time); // mDataBuffer[mCount + mQulityAddr] = qulity; Marshal.WriteByte(handle + mCount + mQulityAddr, qulity); mCount++; }
/// <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="value"></param> /// <param name="time"></param> /// <param name="qulity"></param> public void Add(string value, DateTime time, byte qulity) { if (mCount >= mLimite) { int newCount = (int)(mCount * 1.2); Resize(newCount); mLimite = newCount; } var sdata = Encoding.Unicode.GetBytes((string)value); MemoryHelper.WriteByte((void *)handle, mPosition, (byte)sdata.Length); mPosition++; Marshal.Copy(sdata, 0, handle + mPosition, sdata.Length); //System.Buffer.BlockCopy(sdata, 0, mDataBuffer, mPosition, sdata.Length); mPosition += sdata.Length; MemoryHelper.WriteDateTime((void *)handle, mCount * 8 + mTimeAddr, time); //mDataBuffer[mCount + mQulityAddr] = qulity; Marshal.WriteByte(handle + mCount + mQulityAddr, qulity); mCount++; }
/// <summary> /// /// </summary> /// <param name="offset"></param> /// <param name="value"></param> public virtual void WriteDatetime(long offset, DateTime value) { MemoryHelper.WriteDateTime((void *)mHandles, offset, value); Position = offset + 8; }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <param name="time"></param> /// <param name="qulity"></param> public void Add(object value, DateTime time, byte qulity) { if (mCount >= mLimite) { int newCount = (int)(mCount * 1.2); Resize(newCount); mLimite = newCount; } switch (mDataType) { case 0: Marshal.WriteByte(handle + mPosition, (byte)(((bool)value)?1:0)); mPosition++; break; case 1: Marshal.WriteByte(handle + mPosition, (byte)value); //mDataBuffer[mPosition] = (byte)value; mPosition++; break; case 2: MemoryHelper.WriteShort((void *)handle, mPosition, Convert.ToInt16(value)); mPosition += 2; break; case 3: MemoryHelper.WriteUShort((void *)handle, mPosition, Convert.ToUInt16(value)); mPosition += 2; break; case 4: MemoryHelper.WriteInt32((void *)handle, mPosition, Convert.ToInt32(value)); mPosition += 4; break; case 5: MemoryHelper.WriteUInt32((void *)handle, mPosition, Convert.ToUInt32(value)); mPosition += 4; break; case 6: MemoryHelper.WriteInt64((void *)handle, mPosition, Convert.ToInt64(value)); mPosition += 8; break; case 7: MemoryHelper.WriteUInt64((void *)handle, mPosition, Convert.ToUInt64(value)); mPosition += 8; break; case 8: MemoryHelper.WriteFloat((void *)handle, mPosition, Convert.ToSingle(value)); mPosition += 4; break; case 9: MemoryHelper.WriteDouble((void *)handle, mPosition, Convert.ToDouble(value)); mPosition += 8; break; case 10: try { MemoryHelper.WriteDateTime((void *)handle, mPosition, (DateTime)value); } catch { } mPosition += 8; break; case 11: var sdata = Encoding.Unicode.GetBytes((string)value); MemoryHelper.WriteByte((void *)handle, mPosition, (byte)sdata.Length); mPosition++; Marshal.Copy(sdata, 0, handle + mPosition, sdata.Length); mPosition += sdata.Length; break; case 12: Add((IntPointData)value, time, qulity); return; case 13: Add((UIntPointData)value, time, qulity); return; case 14: Add((IntPoint3Data)value, time, qulity); return; case 15: Add((UIntPoint3Data)value, time, qulity); return; case 16: Add((LongPointData)value, time, qulity); return; case 17: Add((ULongPointData)value, time, qulity); return; case 18: Add((LongPoint3Data)value, time, qulity); return; case 19: Add((ULongPoint3Data)value, time, qulity); return; } MemoryHelper.WriteDateTime((void *)handle, mCount * 8 + mTimeAddr, time); Marshal.WriteByte(handle + mCount + mQulityAddr, (byte)qulity); // mDataBuffer[mCount + mQulityAddr] = qulity; mCount++; }