REJECT_OBJ_INTERFACE.cs 5.49 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FObjBase;

namespace FLY.Thick.Base.OBJ_INTERFACE
{
    public class REJECT_OBJ_INTERFACE
    {
        #region Pack
        public class Pack_Params : IPack
        {
            public bool enable;
            public double threshold_ratio;
            public bool ispercent;
            public double psigma;
            public int sigma;
            public int range1;
            public int range2;
            

            #region IPack 成员

            public byte[] ToBytes()
            {
                List<byte> buf = new List<byte>();
                buf.AddRange(BitConverter.GetBytes(enable));
                buf.AddRange(BitConverter.GetBytes(threshold_ratio));
                buf.AddRange(BitConverter.GetBytes(ispercent));
                buf.AddRange(BitConverter.GetBytes(psigma));
                buf.AddRange(BitConverter.GetBytes(sigma));
                buf.AddRange(BitConverter.GetBytes(range1));
                buf.AddRange(BitConverter.GetBytes(range2));

                return buf.ToArray();
            }

            public bool TryParse(byte[] value)
            {
                if (value.Length < (1 + 8 + 1 + 8 + 4*3))
                    return false;

                int index = 0;
                enable = BitConverter.ToBoolean(value, index);
                index += 1;
                threshold_ratio = BitConverter.ToDouble(value, index);
                index += 8;
                ispercent = BitConverter.ToBoolean(value, index);
                index += 1;
                psigma = BitConverter.ToDouble(value, index);
                index += 8;
                sigma = BitConverter.ToInt32(value, index);
                index += 4;
                range1 = BitConverter.ToInt32(value, index);
                index += 4;
                range2 = BitConverter.ToInt32(value, index);
                index += 4;
                return true;
            }

            #endregion
        }
        public class Pack_PosInfo : IPack
        {
            public int posofgrid;
            public int poslen;
            public int target;
            #region IPack 成员

            public byte[] ToBytes()
            {
                List<byte> buf = new List<byte>();
                buf.AddRange(BitConverter.GetBytes(posofgrid));
                buf.AddRange(BitConverter.GetBytes(poslen));
                buf.AddRange(BitConverter.GetBytes(target));
                return buf.ToArray();
            }

            public bool TryParse(byte[] value)
            {
                if (value.Length < 12)
                    return false;
                int index = 0;
                posofgrid = BitConverter.ToInt32(value, index);
                index += 4;
                poslen = BitConverter.ToInt32(value, index);
                index += 4;
                target = BitConverter.ToInt32(value, index);
                index += 4;
                return true;
            }

            #endregion

        }
        public class Pack_Data : IPack
        {
            public int[] data;

            public byte[] ToBytes()
            {
                List<byte> buf = new List<byte>();
                buf.AddRange(BitConverter.GetBytes(data.Length));
                for (int i = 0; i < data.Length; i++)
                {
                    buf.AddRange(BitConverter.GetBytes(data[i]));
                }
                return buf.ToArray();
            }

            public bool TryParse(byte[] value)
            {
                if (value.Length < 4)
                    return false;
                int index = 0;
                int len = BitConverter.ToInt32(value, index);
                index += 4;
                if (value.Length < (len * 4 + 4))
                    return false;

                data = new int[len];
                for (int i = 0; i < len; i++)
                {
                    data[i] = BitConverter.ToInt32(value, index);
                    index += 4;
                }

                return true;
            }
        }
        #endregion
        #region GetValue
        /// <summary>
        /// Pack_Params
        /// </summary>
        public const UInt16 GET_PARAMS = 1;
        /// <summary>
        /// Pack_PosInfo
        /// </summary>
        public const UInt16 GET_POSINFO = 2;
        /// <summary>
        /// Pack_Data
        /// </summary>
        public const UInt16 GET_FILTERDATAS = 3;
        /// <summary>
        /// Pack_Data
        /// </summary>
        public const UInt16 GET_REJECTDATAS = 4;
        /// <summary>
        /// Pack_Data
        /// </summary>
        public const UInt16 GET_SIGMADATAS = 5;

        #endregion

        #region SetValue
        /// <summary>
        /// Pack_Params
        /// </summary>
        public const UInt16 SET_PARAMS = 1;
        #endregion

        #region CallFunction

        #endregion
        #region PushInfo
        /// <summary>
        /// Pack_Params
        /// </summary>
        public const UInt16 PUSH_PARAMS = 1;
        /// <summary>
        /// Pack_PosInfo
        /// </summary>
        public const UInt16 PUSH_POSINFO = 2;
        /// <summary>
        /// Pack_Data
        /// </summary>
        public const UInt16 PUSH_FILTERDATAS = 3;
        /// <summary>
        /// Pack_Data
        /// </summary>
        public const UInt16 PUSH_REJECTDATAS = 4;
        /// <summary>
        /// Pack_Data
        /// </summary>
        public const UInt16 PUSH_SIGMADATAS = 5;
        #endregion

    }
}