Example #1
0
        public void MargeList()
        {
            Swaper <MockRestrycion, int> swap = new Swaper <MockRestrycion, int>((X) => X, (X, K) => X.restrycion.Contains(K), 10, 10);
            MockRestrycion m0 = new MockRestrycion()
            {
                1
            }; m0.AddRestryction(0);
            MockRestrycion m1 = new MockRestrycion()
            {
                3
            }; m1.AddRestryction(1);
            MockRestrycion m2 = new MockRestrycion()
            {
                2
            }; m2.AddRestryction(2);
            MockRestrycion m3 = new MockRestrycion()
            {
                0
            }; m3.AddRestryction(3);
            List <MockRestrycion> ml = new List <MockRestrycion>()
            {
                m0, m1, m2, m3
            };

            swap.Run(ml);
            Assert.AreEqual(0, m0.First());
            Assert.AreEqual(1, m1.First());
            Assert.AreEqual(2, m2.First());
            Assert.AreEqual(3, m3.First());
        }
        /// <summary>
        /// swapBase를 기준으로 Swap을 하지만 unswapBase를 최소유닛으로 Swap하여 버퍼에 복사한다.
        /// 예를 들어 swapBase가 8이고 unswapBase가 2이면, 2바이트를 최소유닛으로 생각하여 8바이트를
        /// Swap한다. 각각 바이트로 01,02,03,04,05,06,07,08 이 들어있는 버퍼라면 결과는
        /// 07,08,05,06,03,04,01,02 가 나오게 된다.
        /// </summary>
        /// <param name="srcBuffer">복사할 데이터가 들어있는 버퍼</param>
        /// <param name="offset">복사될 버퍼의 offset</param>
        /// <param name="size">복사할 크기</param>
        /// <param name="swapBase">swap할 단위. -1이면 initBuffer의 타입사이즈가 된다.</param>
        /// <param name="unSwapBase">swap할 때 swap되지 않을 최소단위. 기본값은 1로서 모두 swap된다.</param>
        /// <param name="srcOffset">소스의 offset. 기본값은 0이다.</param>
        public void copyBufferUnSwapBasedSwapFromArray(Array srcBuffer, int offset, int size, int swapBase = -1, int unSwapBase = 1, int srcOffset = 0)
        {
            if (swapBase < 0)
            {
                swapBase = Marshal.SizeOf(typeof(T));
            }

            Swaper.swapWithUnswapBase(srcBuffer, srcOffset, _initBuffer, offset, size, unSwapBase);
        }
Example #3
0
        public override Byte[] getByteBufferSwapCopied(int offset)
        {
            byte[] dst = new byte[this.bufferByteSize];

            foreach (Enum item in _itemIndexInBuffer)
            {
                Swaper.swapWithSize(_initBuffer, dst, _sizeOfItemInBuffer[item], _sizeOfItemInBuffer[item], _startOffsetInBuffer[item] + offset, _startOffsetInBuffer[item]);
            }
            return(dst);
        }
Example #4
0
        protected override void OnElementChanged(ElementChangedEventArgs <StackLayout> e)
        {
            base.OnElementChanged(e);

            horizontalSwaper = e.NewElement as Swaper;

            Touch += ButtonContextMenuRenderer_Touch;
            timer  = new Timer {
                Interval = 500, AutoReset = false
            };
            timer.Elapsed += (o, a) => { CScrollViewRenderer.IsDisabled = false; };
        }
 public String getUnitsToString(int startIndex, int size, Boolean isSwappedBefore)
 {
     byte[] charbuff = new byte[size * Marshal.SizeOf(typeof(T))];
     if (isSwappedBefore)
     {
         Swaper.swapWithSize(buffer, charbuff, Marshal.SizeOf(typeof(T)), size * Marshal.SizeOf(typeof(T)), startIndex, 0);
     }
     else
     {
         Buffer.BlockCopy(buffer, startIndex, charbuff, 0, size * Marshal.SizeOf(typeof(T)));
     }
     return(Encoding.UTF8.GetString(charbuff));
 }
Example #6
0
        public void swapBuffer(Enum startUnit, int numOfUnits)
        {
            int startIndex = 0;
            int size       = 0;


            foreach (Enum key in _itemIndexInBuffer)
            {
                startIndex = _startOffsetInBuffer[key];
                size       = _sizeOfItemInBuffer[key];
                Swaper.swapWithSize(_initBuffer, _initBuffer, size, size, startIndex, startIndex);
            }
        }
Example #7
0
        public void copyBufferSwapFromArray(Array srcBuffer, int srcOffset = 0, int size = -1, int dstOffset = 0)
        {
            if (size < 0)
            {
                if (Buffer.ByteLength(srcBuffer) > Buffer.ByteLength(this.buffer))
                {
                    size = Buffer.ByteLength(this.buffer);
                }
                else
                {
                    size = Buffer.ByteLength(srcBuffer);
                }
            }

            foreach (Enum item in _itemIndexInBuffer)
            {
                Swaper.swapWithSize(srcBuffer, _initBuffer, _sizeOfItemInBuffer[item], _sizeOfItemInBuffer[item], _startOffsetInBuffer[item] + srcOffset, _startOffsetInBuffer[item] + dstOffset);
            }
        }
Example #8
0
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List <Box <string> > list = new List <Box <string> >(n);

        for (int i = 0; i < n; i++)
        {
            string       data = Console.ReadLine();
            Box <string> box  = new Box <string>(data);
            list.Add(box);
        }

        int[] indexes = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        int   left    = indexes[0];
        int   right   = indexes[1];

        Swaper <Box <string> > .Swap(list, left, right);

        foreach (Box <string> box in list)
        {
            Console.WriteLine(box);
        }
    }
Example #9
0
    static void Main(string[] args)
    {
        List <Box <string> > collectionOfBoxes = new List <Box <string> >();

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            string       input = Console.ReadLine();
            Box <string> box   = new Box <string>(input);

            collectionOfBoxes.Add(box);
        }

        int[] indexesToSwap = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        collectionOfBoxes = Swaper <Box <string> > .Swap(indexesToSwap[0], indexesToSwap[1], collectionOfBoxes);

        foreach (var box in collectionOfBoxes)
        {
            Console.WriteLine(box);
        }
    }
Example #10
0
 /// <summary>
 /// 버퍼에 있는 값을 initValue와 비교하여 그 차이를 리턴한다.
 /// +값이면 buff의 값이 큰 것을 나타내고, -값이면 buff의 값이 작은 것을 나타낸다.
 /// </summary>
 /// <param name="buff"></param>
 /// <param name="startIndex"></param>
 /// <param name="values">받은 값.swap이면 swap된 값이 string으로 들어간다.</param>
 /// <returns>차이값의 배열. initValue의 버퍼크기와 동일하다.</returns>
 public double[] GetMarginFromInitValue(Array buff, int startIndex, object [] values = null)
 {
     double[] margins = new double[_size];
     if (_initValueArray == null)
     {
         return(null);
     }
     else if (buff == null)
     {
         throw new Exception("입력 buff가 null임");
     }
     else if (Buffer.ByteLength(buff) - startIndex < Buffer.ByteLength(_initValueArray))
     {
         throw new Exception("입력버퍼의 크기가 item의 buff크기보다 작음");
     }
     else
     {
         if (RealType == typeof(byte))
         {
             //Buffer.BlockCopy(buffer, startOffsetInByte, dst, 0, item.TotalSize);
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     byte value = value = TypeArrayConverter.CopyBufferToVariable <byte>(buff, startIndex + i, -1, true, false);
                     // (byte)(((byte[])buff)[startIndex+i]);
                     margins[i] = value - (byte)(((byte[])_initValueArray)[i]);
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(sbyte))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     sbyte value = TypeArrayConverter.CopyBufferToVariable <sbyte>(buff, startIndex + i, -1, true, false);
                     // (byte)(((byte[])buff)[startIndex + i]);
                     margins[i] = value - (byte)(((byte[])_initValueArray)[i]);
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(short))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     short value;
                     if (IsSwap)
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <short>(buff, startIndex + i, -1, false, true);
                         // =  Swaper.swap<short>((short)(((short[])buff)[startIndex + i]));
                         margins[i] = value - ((short[])_initValueArray)[i];
                     }
                     else
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <short>(buff, startIndex + i, -1, false, false);
                         //(short)(((short[])buff)[startIndex + i]);
                         margins[i] = value - (((short[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(ushort))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     ushort value;
                     if (IsSwap)
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <ushort>(buff, startIndex + i, -1, true, true);
                         //Swaper.swap<ushort>((ushort)(((ushort[])buff)[startIndex + i]));
                         margins[i] = value - ((ushort[])_initValueArray)[i];
                     }
                     else
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <ushort>(buff, startIndex + i, -1, true, false);
                         //(ushort)(((ushort[])buff)[startIndex + i]);
                         margins[i] = value - (((ushort[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(int))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     int value;
                     if (IsSwap)
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <short>(buff, startIndex + i, -1, false, true);
                         //Swaper.swap<int>((int)(((int[])buff)[startIndex + i]));
                         margins[i] = value - ((int[])_initValueArray)[i];
                     }
                     else
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <short>(buff, startIndex + i, -1, false, false);
                         //(int)(((int[])buff)[startIndex + i]);
                         margins[i] = value - (((int[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(uint))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     uint value;
                     if (IsSwap)
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <uint>(buff, startIndex + i, -1, true, true);
                         //value = Swaper.swap<uint>((uint)(((uint[])buff)[startIndex + i]));
                         margins[i] = value - ((uint[])_initValueArray)[i];
                     }
                     else
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <uint>(buff, startIndex + i, -1, true, false);
                         //value = (uint)(((uint[])buff)[startIndex + i]);
                         margins[i] = value - (((uint[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(long))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     long value;
                     if (IsSwap)
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <short>(buff, startIndex + i, -1, false, true);
                         //Swaper.swap<long>((long)(((long[])buff)[startIndex + i]));
                         margins[i] = value - ((long[])_initValueArray)[i];
                     }
                     else
                     {
                         value = TypeArrayConverter.CopyBufferToVariable <short>(buff, startIndex + i, -1, false, false);
                         //(long)(((long[])buff)[startIndex + i]);
                         margins[i] = value - (((long[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(ulong))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     ulong value;
                     if (IsSwap)
                     {
                         value      = Swaper.swap <ulong>((ulong)(((ulong[])buff)[startIndex + i]));
                         margins[i] = value - ((ulong[])_initValueArray)[i];
                     }
                     else
                     {
                         value      = (ulong)(((ulong[])buff)[startIndex + i]);
                         margins[i] = value - (((ulong[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(float))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     float value;
                     if (IsSwap)
                     {
                         value      = Swaper.swap <float>((float)(((float[])buff)[startIndex + i]));
                         margins[i] = value - ((float[])_initValueArray)[i];
                     }
                     else
                     {
                         value      = (float)(((float[])buff)[startIndex + i]);
                         margins[i] = value - (((float[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else if (RealType == typeof(double))
         {
             for (int i = 0; i < InitValues.Length; i++)
             {
                 try
                 {
                     double value;
                     if (IsSwap)
                     {
                         value      = Swaper.swap <double>((double)(((double[])buff)[startIndex + i]));
                         margins[i] = value - ((double[])_initValueArray)[i];
                     }
                     else
                     {
                         value      = (double)(((double[])buff)[startIndex + i]);
                         margins[i] = value - (((double[])_initValueArray)[i]);
                     }
                     if (values != null && values.Length >= _size)
                     {
                         values[i] = value;
                     }
                     else
                     {
                         throw new Exception("value size exception..");
                     }
                 }
                 catch (Exception ex)
                 {
                     margins[i] = 0;
                 }
             }
         }
         else
         {
             throw new Exception("No RealType..." + RealType);
         }
     }
     return(margins);
 }
        public static bool ItemsToPacket(List <CPacketItem> items, bool swap, Byte[] sendBuff, out int totalSendSize)
        {
            totalSendSize = 0;
            Boolean unsigned = false;

            for (int i = 0; i < items.Count; i++)
            {
                int    typeSize = 4;
                String type     = items[i].TypeString;
                Array  packets  = TypeHandling.GetArrayByTypeName(type, items[i].Length, out typeSize, out unsigned);

                if (packets == null || packets.Length < 1 || typeSize < 0)
                {
                    String error = "타입명세실패";
                    throw new Exception(error);
                }


                if (type.Equals("char") || type.Equals("string"))
                {
                    if (items[i].InitString == null || items[i].InitString.Length == 0)
                    {
                        continue;
                    }
                    packets = Encoding.UTF8.GetBytes(items[i].InitString);
                    Buffer.BlockCopy(packets, 0, sendBuff, totalSendSize, packets.Length);
                    totalSendSize += packets.Length;
                }
                else
                {
                    String[] units = items[i].InitValues;
                    for (int k = 0; k < units.Length; k++)
                    {
                        TypeHandling.TypeName typeName = TypeHandling.getTypeKind(units[k]);

                        if (typeName == TypeHandling.TypeName.Integer)
                        {
                            if (unsigned == false)
                            {
                                if (typeSize == 1)
                                {
                                    packets.SetValue(SByte.Parse(units[k]), k);
                                }
                                else if (typeSize == 2)
                                {
                                    packets.SetValue(Int16.Parse(units[k]), k);
                                }
                                else if (typeSize == 4)
                                {
                                    packets.SetValue(Int32.Parse(units[k]), k);
                                }
                                else
                                {
                                    packets.SetValue(Int64.Parse(units[k]), k);
                                }
                            }
                            else
                            {
                                if (typeSize == 1)
                                {
                                    packets.SetValue(Byte.Parse(units[k]), k);
                                }
                                else if (typeSize == 2)
                                {
                                    packets.SetValue(UInt16.Parse(units[k]), k);
                                }
                                else if (typeSize == 4)
                                {
                                    packets.SetValue(UInt32.Parse(units[k]), k);
                                }
                                else
                                {
                                    packets.SetValue(UInt64.Parse(units[k]), k);
                                }
                            }
                        }
                        else if (typeName == TypeHandling.TypeName.HexString)
                        {
                            if (unsigned)
                            {
                                if (typeSize == 1)
                                {
                                    packets.SetValue((byte)TypeHandling.getHexNumber <byte>(units[k]), k);
                                }
                                else if (typeSize == 2)
                                {
                                    packets.SetValue((ushort)TypeHandling.getHexNumber <ushort>(units[k]), k);
                                }
                                else if (typeSize == 4)
                                {
                                    packets.SetValue((uint)TypeHandling.getHexNumber <uint>(units[k]), k);
                                }
                                else
                                {
                                    packets.SetValue((UInt64)TypeHandling.getHexNumber <ulong>(units[k]), k);
                                }
                            }
                            else
                            {
                                if (typeSize == 1)
                                {
                                    packets.SetValue((sbyte)TypeHandling.getHexNumber <sbyte>(units[k]), k);
                                }
                                else if (typeSize == 2)
                                {
                                    packets.SetValue((short)TypeHandling.getHexNumber <short>(units[k]), k);
                                }
                                else if (typeSize == 4)
                                {
                                    packets.SetValue((int)TypeHandling.getHexNumber <int>(units[k]), k);
                                }
                                else
                                {
                                    packets.SetValue((Int64)TypeHandling.getHexNumber <long>(units[k]), k);
                                }
                            }
                        }
                        else if (typeName == TypeHandling.TypeName.Float)
                        {
                            if (typeSize == 4)
                            {
                                packets.SetValue(float.Parse(units[k]), k);
                            }
                            else
                            {
                                packets.SetValue(Double.Parse(units[k]), k);
                            }
                        }
                        else if (typeName == TypeHandling.TypeName.Bin)
                        {
                            if (typeSize == 1)
                            {
                                packets.SetValue((byte)TypeHandling.getBinNumber(units[k]), k);
                            }
                            else if (typeSize == 2)
                            {
                                packets.SetValue((short)TypeHandling.getBinNumber(units[k]), k);
                            }
                            else if (typeSize == 4)
                            {
                                packets.SetValue((int)TypeHandling.getBinNumber(units[k]), k);
                            }
                            else
                            {
                                packets.SetValue((Int64)TypeHandling.getBinNumber(units[k]), k);
                            }
                        }
                    }
                    //buff = new Byte[Marshal.SizeOf(packets.GetValue(0)) * packets.Length];
                    if (swap) //전체 swap
                    {
                        if (items[i].IsSwap == false)
                        {
                            Swaper.swapWithSize(packets, sendBuff, typeSize, Buffer.ByteLength(packets), 0, totalSendSize);
                        }
                        else
                        {
                            Buffer.BlockCopy(packets, 0, sendBuff, totalSendSize, Buffer.ByteLength(packets));
                        }
                    }
                    else //일부만 swap
                    {
                        if (items[i].IsSwap)
                        {
                            Swaper.swapWithSize(packets, sendBuff, typeSize, Buffer.ByteLength(packets), 0, totalSendSize);
                        }
                        else
                        {
                            Buffer.BlockCopy(packets, 0, sendBuff, totalSendSize, Buffer.ByteLength(packets));
                        }
                    }
                    totalSendSize += Buffer.ByteLength(packets);
                }
            }

            /*
             * if(_sendBuff.Equals(PacketBuffer)){ //만일 _sendBuff가 Packet버퍼와 같을 때, 사이즈를 조정한다.(초기사이즈->실제사이즈)
             *  Byte[] buff = new Byte[totalSendSize];
             *  Buffer.BlockCopy(_sendBuff, 0, buff, 0, totalSendSize);
             *  PacketBuffer = buff;
             * }
             */
            return(true);
        }
        /// <summary>
        /// Items의 내용을 바꾸어 packet으로 변경한다.
        /// Send할 패킷을 만드는 데 사용된다.
        /// </summary>
        /// <param name="items"></param>
        /// <param name="funcList">사용될 function의 리스트. function은 String들을 argument로 받고, String[]을 리턴하는 function들이다.</param>
        /// <param name="varList">사용될 variables의 리스트. 같은 CPacketItem의 다른 item들을 찾아보고, 찾을 수 없다면 이 리스트에서 찾는다.</param>
        /// <param name="swap">전체적으로 swap을 할 것인지를 묻는다. 이 arguemnt가 true인데 단일 item이 IsSwap에 true가 되어있다면 다른 것과는 반대로 동작한다. 즉, swap되지 않는다</param>
        /// <param name="dataBuff">패킷데이터가 저장될 버퍼</param>
        /// <param name="dataSize">전체 크기</param>
        /// <returns></returns>
        public void ItemsToPacket(List <CPacketItem> items, Dictionary <String, InitVarFunc> funcList, Dictionary <String, VariableInfo> varList, bool swap, Byte[] dataBuff, out int dataSize)
        {
            dataSize = 0;
            Boolean unsigned = false;
            Dictionary <String, VariableInfo> vars = new Dictionary <string, VariableInfo>(); // = new Dictionary<string, string[]>(varList);

            for (int i = 0; i < items.Count; i++)                                             //static 하게 정의된 item의 요소는 변수로 사용가능하다.
            {
                if (items[i].InitValues.Length > 0)
                {
                    vars.Add(items[i].Name, new VariableInfo(items[i].Name, items[i].InitValues));
                }
            }
            for (int i = 0; i < varList.Count; i++)
            {
                if (vars.Keys.Contains(varList.Keys.ElementAt(i)))
                {
                    continue;                                               //같은 변수명이면 같은 패킷에 속한 것이 적용된다.
                }
                else
                {
                    vars.Add(varList.Keys.ElementAt(i), varList.Values.ElementAt(i));
                }
            }


            for (int i = 0; i < items.Count; i++)
            {
                int typeSize = 4;

                String type    = items[i].TypeString;
                Array  packets = TypeHandling.GetArrayByTypeName(type, items[i].Length, out typeSize, out unsigned);

                //Byte[] buff;
                if (items[i].Function.Exists)
                {
                    items[i].InitValues = runFunction(funcList, vars, items[i].Function);
                }
                else if (items[i].Var.Exists)
                {
                    String refName = items[i].Var.Name;
                    if (vars.Keys.Contains(refName))
                    {
                        if (vars[refName].Values != null && vars[refName].Values.Length > 0)
                        {
                            items[i].InitValues = vars[items[i].Var.Name].Values;
                        }
                        else
                        {
                            throw new Exception("변수" + refName + "가 존재하지 않거나 값이 설정되지 않았습니다.");
                        }
                    }
                }

                if (type.Equals("char") || type.Equals("string"))
                {
                    if (items[i].InitString == null || items[i].InitString.Length == 0)
                    {
                        continue;
                    }
                    packets = Encoding.UTF8.GetBytes(items[i].InitString);
                    Buffer.BlockCopy(packets, 0, dataBuff, dataSize, packets.Length);
                    dataSize += packets.Length;
                }
                else
                {
                    for (int k = 0; k < items[i].InitValues.Length; k++)
                    {
                        TypeHandling.TypeName typeName = TypeHandling.getTypeKind(items[i].InitValues[k]);
                        if (typeName == TypeHandling.TypeName.Integer)
                        {
                            if (unsigned == false)
                            {
                                if (typeSize == 1)
                                {
                                    packets.SetValue(SByte.Parse(items[i].InitValues[k]), k);
                                }
                                else if (typeSize == 2)
                                {
                                    packets.SetValue(Int16.Parse(items[i].InitValues[k]), k);
                                }
                                else if (typeSize == 4)
                                {
                                    packets.SetValue(Int32.Parse(items[i].InitValues[k]), k);
                                }
                                else
                                {
                                    packets.SetValue(Int64.Parse(items[i].InitValues[k]), k);
                                }
                            }
                            else
                            {
                                if (typeSize == 1)
                                {
                                    packets.SetValue(Byte.Parse(items[i].InitValues[k]), k);
                                }
                                else if (typeSize == 2)
                                {
                                    packets.SetValue(UInt16.Parse(items[i].InitValues[k]), k);
                                }
                                else if (typeSize == 4)
                                {
                                    packets.SetValue(UInt32.Parse(items[i].InitValues[k]), k);
                                }
                                else
                                {
                                    packets.SetValue(UInt64.Parse(items[i].InitValues[k]), k);
                                }
                            }
                        }
                        else if (typeName == TypeHandling.TypeName.HexString)
                        {
                            if (typeSize == 1)
                            {
                                packets.SetValue(TypeHandling.getHexNumber <byte>(items[i].InitValues[k]), k);
                            }
                            else if (typeSize == 2)
                            {
                                packets.SetValue(TypeHandling.getHexNumber <ushort>(items[i].InitValues[k]), k);
                            }
                            else if (typeSize == 4)
                            {
                                packets.SetValue(TypeHandling.getHexNumber <uint>(items[i].InitValues[k]), k);
                            }
                            else
                            {
                                packets.SetValue(TypeHandling.getHexNumber <ulong>(items[i].InitValues[k]), k);
                            }
                        }
                        else if (typeName == TypeHandling.TypeName.Float)
                        {
                            if (typeSize == 4)
                            {
                                packets.SetValue(float.Parse(items[i].InitValues[k]), k);
                            }
                            else
                            {
                                packets.SetValue(Double.Parse(items[i].InitValues[k]), k);
                            }
                        }
                        else if (typeName == TypeHandling.TypeName.Bin)
                        {
                            if (typeSize == 1)
                            {
                                packets.SetValue((byte)TypeHandling.getBinNumber(items[i].InitValues[k]), k);
                            }
                            else if (typeSize == 2)
                            {
                                packets.SetValue((short)TypeHandling.getBinNumber(items[i].InitValues[k]), k);
                            }
                            else if (typeSize == 4)
                            {
                                packets.SetValue((int)TypeHandling.getBinNumber(items[i].InitValues[k]), k);
                            }
                            else
                            {
                                packets.SetValue((Int64)TypeHandling.getBinNumber(items[i].InitValues[k]), k);
                            }
                        }
                    }
                    //buff = new Byte[Marshal.SizeOf(packets.GetValue(0)) * packets.Length];
                    if (swap)//전체 swap
                    {
                        if (items[i].IsSwap == false)
                        {
                            Swaper.swapWithSize(packets, dataBuff, typeSize, Buffer.ByteLength(packets), 0, dataSize);
                        }
                        else
                        {
                            Buffer.BlockCopy(packets, 0, dataBuff, dataSize, Buffer.ByteLength(packets));
                        }
                    }
                    else //각각 swap
                    {
                        if (items[i].IsSwap)
                        {
                            Swaper.swapWithSize(packets, dataBuff, typeSize, Buffer.ByteLength(packets), 0, dataSize);
                        }
                        else
                        {
                            Buffer.BlockCopy(packets, 0, dataBuff, dataSize, Buffer.ByteLength(packets));
                        }
                    }
                    dataSize += Buffer.ByteLength(packets);
                }
            }

            /*
             * if(_sendBuff.Equals(PacketBuffer)){ //만일 _sendBuff가 Packet버퍼와 같을 때, 사이즈를 조정한다.(초기사이즈->실제사이즈)
             *  Byte[] buff = new Byte[totalSendSize];
             *  Buffer.BlockCopy(_sendBuff, 0, buff, 0, totalSendSize);
             *  PacketBuffer = buff;
             * }
             */
        }