ResultMessage GetData(byte[] data)
        {
            foreach (var reg in registerList)
            {
                var startIdx = reg.Value[0] * 2;
                var count    = reg.Value[1] * 2;
                switch (reg.Key)
                {
                case RegCls.Rint:
                    intRegs = hexhelper.Byte2Int(data, startIdx, count);
                    break;

                case RegCls.Rfloat:
                    floatRegs = hexhelper.Byte2Float(data, startIdx, count);
                    break;

                case RegCls.Rpos:
                    curPos = GetPosData(data, startIdx, count)[0];
                    break;

                case RegCls.Rpr:
                    prRegs = GetPosData(data, startIdx, count);
                    break;

                case RegCls.Rstring:
                    strRegs = GetString(data, startIdx, count);
                    break;

                default:
                    return(CreatResult(true, "data error : in get data"));
                }
            }
            return(CreatResult());
        }
        byte[] Pos2Bytes(PR pr)
        {
            var rets  = new byte[52];
            var dataB = hexhelper.Float2Byte(pr.pc);

            Array.Copy(dataB, 0, rets, 0, dataB.Length);
            return(rets);
        }
        public ResultMessage WritePR(PR data, int startIdx)
        {
            startIdx -= prRegion[0];
            startIdx *= 50;
            startIdx += registerList[RegCls.Rpr][0];
            var dataB = Pos2Bytes(data);

            return(WriteData1(dataB, startIdx, dataB.Length / 2, "0708"));
        }
        PR[] GetPosData(byte[] data, int startIdx = 0, int count = 0)
        {
            var dataF  = hexhelper.Byte2Float(data, startIdx, count);
            var countP = dataF.Length / 25;
            var prs    = new PR[countP];

            for (int i = 0; i < countP; i++)
            {
                PR pr = new PR();
                Array.Copy(dataF, i * 25 + 0, pr.pc, 0, 6);
                Array.Copy(dataF, i * 25 + 13, pr.pj, 0, 6);
                prs[i] = pr;
            }
            return(prs);
        }