Пример #1
0
 public void Add(ulong value, DateTime time, byte qulity)
 {
     if (mCount >= mLimite)
     {
         int newCount = (int)(mCount * 1.2);
         Resize(newCount);
         mLimite = newCount;
     }
     MemoryHelper.WriteUInt64((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++;
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="offset"></param>
 /// <param name="value"></param>
 public void WriteULongDirect(long offset, ulong value)
 {
     MemoryHelper.WriteUInt64((void *)mHandles, offset, value);
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="offset"></param>
 /// <param name="value"></param>
 public virtual void WriteULong(long offset, ulong value)
 {
     MemoryHelper.WriteUInt64((void *)mHandles, offset, value);
     Position = offset + 8;
 }
Пример #4
0
        /// <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++;
        }