示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public HisDataBuffer AppendValue(DateTime time, LongPoint3Data value, byte quality)
 {
     ValueCount++;
     CheckAndResize(Position + 33);
     this.WriteLong(Position, time.ToBinary());
     this.WriteLong(Position, value.X);
     this.WriteLong(Position, value.Y);
     this.WriteLong(Position, value.Z);
     this.WriteByte(Position, quality);
     return(this);
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="clientid"></param>
        /// <param name="block"></param>
        private void ProcessSetRealData(string clientid, ByteBuffer block)
        {
            var service = ServiceLocator.Locator.Resolve <IRealTagConsumer>();
            int count   = block.ReadInt();

            for (int i = 0; i < count; i++)
            {
                var    id    = block.ReadInt();
                byte   typ   = block.ReadByte();
                object value = null;
                switch (typ)
                {
                case (byte)TagType.Bool:
                    value = block.ReadByte();
                    break;

                case (byte)TagType.Byte:
                    value = block.ReadByte();
                    break;

                case (byte)TagType.Short:
                    value = block.ReadShort();
                    break;

                case (byte)TagType.UShort:
                    value = (ushort)block.ReadShort();
                    break;

                case (byte)TagType.Int:
                    value = block.ReadInt();
                    break;

                case (byte)TagType.UInt:
                    value = (uint)block.ReadInt();
                    break;

                case (byte)TagType.Long:
                    value = block.ReadLong();
                    break;

                case (byte)TagType.ULong:
                    value = (ulong)block.ReadLong();
                    break;

                case (byte)TagType.Float:
                    value = block.ReadFloat();
                    break;

                case (byte)TagType.Double:
                    value = block.ReadDouble();
                    break;

                case (byte)TagType.String:
                    value = block.ReadString();
                    break;

                case (byte)TagType.DateTime:
                    var tick = block.ReadLong();
                    value = new DateTime(tick);
                    break;

                case (byte)TagType.IntPoint:
                    value = new IntPointData(block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.UIntPoint:
                    value = new UIntPointData(block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.IntPoint3:
                    value = new IntPoint3Data(block.ReadInt(), block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.UIntPoint3:
                    value = new UIntPoint3Data(block.ReadInt(), block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.LongPoint:
                    value = new LongPointData(block.ReadLong(), block.ReadLong());
                    break;

                case (byte)TagType.ULongPoint:
                    value = new ULongPointData(block.ReadLong(), block.ReadLong());
                    break;

                case (byte)TagType.LongPoint3:
                    value = new LongPoint3Data(block.ReadLong(), block.ReadLong(), block.ReadLong());
                    break;

                case (byte)TagType.ULongPoint3:
                    value = new ULongPoint3Data(block.ReadLong(), block.ReadLong(), block.ReadLong());
                    break;
                }
                service.SetTagValueForConsumer(id, value);
            }
            Parent.AsyncCallback(clientid, ToByteBuffer(ApiFunConst.RealDataSetFun, (byte)1));
        }
示例#3
0
        private void ProcessSingleBufferData(ByteBuffer block)
        {
            if (block == null)
            {
                return;
            }
            var count = block.ReadInt();

            for (int i = 0; i < count; i++)
            {
                var vid = block.ReadInt();
                if (vid < 0)
                {
                    Debug.Print("Invaild value!");
                }
                var    typ   = block.ReadByte();
                object value = null;
                switch (typ)
                {
                case (byte)TagType.Bool:
                    value = block.ReadByte();
                    break;

                case (byte)TagType.Byte:
                    value = block.ReadByte();
                    break;

                case (byte)TagType.Short:
                    value = block.ReadShort();
                    break;

                case (byte)TagType.UShort:
                    value = (ushort)block.ReadShort();
                    break;

                case (byte)TagType.Int:
                    value = block.ReadInt();
                    break;

                case (byte)TagType.UInt:
                    value = Convert.ToUInt32(block.ReadInt());
                    break;

                case (byte)TagType.Long:
                    value = block.ReadLong();
                    break;

                case (byte)TagType.ULong:
                    value = (ulong)block.ReadLong();
                    break;

                case (byte)TagType.Float:
                    value = block.ReadFloat();
                    break;

                case (byte)TagType.Double:
                    value = block.ReadDouble();
                    break;

                case (byte)TagType.String:
                    value = ReadString(block);
                    break;

                case (byte)TagType.DateTime:
                    var tick = block.ReadLong();
                    value = new DateTime(tick);
                    break;

                case (byte)TagType.IntPoint:
                    value = new IntPointData(block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.UIntPoint:
                    value = new UIntPointData(block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.IntPoint3:
                    value = new IntPoint3Data(block.ReadInt(), block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.UIntPoint3:
                    value = new UIntPoint3Data(block.ReadInt(), block.ReadInt(), block.ReadInt());
                    break;

                case (byte)TagType.LongPoint:
                    value = new LongPointData(block.ReadLong(), block.ReadLong());
                    break;

                case (byte)TagType.ULongPoint:
                    value = new ULongPointData(block.ReadLong(), block.ReadLong());
                    break;

                case (byte)TagType.LongPoint3:
                    value = new LongPoint3Data(block.ReadLong(), block.ReadLong(), block.ReadLong());
                    break;

                case (byte)TagType.ULongPoint3:
                    value = new ULongPoint3Data(block.ReadLong(), block.ReadLong(), block.ReadLong());
                    break;
                }
                var time = new DateTime(block.ReadLong());
                var qua  = block.ReadByte();
                mServier.SetTagValue(vid, ref value, time, qua);
            }
            block.UnlockAndReturn();
        }