首页新闻找找看学习计划

一个逻辑问题 路过的大侠帮忙看下吧 !

0
悬赏园豆:10 [已解决问题] 解决于 2014-07-24 08:35

代码:

                        while (stream8_12.Position < stream8_12.Length)//126
                        {
                            var yyyy_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var MM_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var dd_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var hh_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var mm_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var ss_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);

                            var sd = Convert.ToString(stream8_12.ReadByte(), 16);
                            var zt =Convert.ToString(stream8_12.ReadByte(), 2).PadLeft(8, '0');
                            DataRow tempSix = resultDtListSix_12.NewRow();
                            tempSix[0] = "20" + statr_yyyy_08H + "-" + statr_MM_08H + "-" + statr_dd_08H + ":" + statr_hh_08H + ":" + statr_mm_08H + ":" + statr_ss_08H;
                            tempSix[1] = sd;
                            for (int ss = 0; ss < zt.Length; ss++)
                            {
                                tempSix[ss + 2] = zt[ss].ToString() == "0" ? "" : "";
                            }
                        }

stream8_12 是流 

规则

即这样的规则:

1 2 3 4 5 6 ~~~~~~~~~~~~~~~~~~126
127 128 129 130 131 132 ~~~~~~~252

253 254 255 256 257 258 259~~~~~~ 504

循环的时候 前面6个只循环一次 

s_p的主页 s_p | 菜鸟二级 | 园豆:269
提问于:2014-07-22 14:35
< >
分享
最佳答案
0

你想问啥问题?

收获园豆:10
Launcher | 高人七级 |园豆:45030 | 2014-07-22 14:38

确实问题没描述清楚! 就这么说吧   

1 2 3 4 5 6 ~~~~~~~~~~~~~~~~~~126
127 128 129 130 131 132 ~~~~~~~252

253 254 255 256 257 258 259~~~~~~ 504

 你对着代码看这个  1 2 3 4  5 6  代表时间 位 这个只循环一次 在126这个循环里 

同样 在252 里面127 128 129 130 131 132 循环一次

s_p | 园豆:269 (菜鸟二级) | 2014-07-22 14:42

@s_p: 然后呢?

Launcher | 园豆:45030 (高人七级) | 2014-07-22 14:46

@Launcher: 我写了下 按自己的想法 我也描述不清楚问题 文字描述有点困难

这个是我修改的

                    if (dataList_8H.Rows.Count > 0)
                    {
                        var tempByte = (byte[])dataList_8H.Rows[0]["DP_RecvParamValue"];             
                        stream8_12 = new MemoryStream();
                        byte[] tempByteList = new byte[tempByte.Length];
                        stream8_12.Write(tempByteList, 0, tempByte.Length);
                        stream8_12.Position = 0;
                        var statr_yyyy_08H = Convert.ToString(stream8_12.ReadByte(), 16);
                        var statr_MM_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var statr_dd_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var statr_hh_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var statr_mm_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var statr_ss_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var end_yyyy_08H = Convert.ToString(stream8_12.ReadByte(), 16);
                        var end_MM_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var end_dd_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var end_hh_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var end_mm_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var end_ss_08H = Convert.ToString(stream8_12.ReadByte(), 16).PadLeft(2, '0');
                        var count_8HTemp = readStream(stream8_12, 4);
                        var count_8H = byteToHexStr(count_8HTemp);
                        stream8_12.Position = 15;
                        if (int.Parse(count_8H) * 126 != stream8_12.Length - 17)
                        {
                            dtAssignment(null);
                            return; 
                        }
                        long tempIndex = 1;
                        while (stream8_12.Position < stream8_12.Length)//126
                        {
                            var yyyy_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var MM_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var dd_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var hh_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var mm_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);
                            var ss_08HTemp = Convert.ToString(stream8_12.ReadByte(), 16);

                            for (long k = stream8_12.Position; k < tempIndex * 126; k++)
                            {
                                var sd = Convert.ToString(stream8_12.ReadByte(), 16);
                                var zt = Convert.ToString(stream8_12.ReadByte(), 2).PadLeft(8, '0');
                                DataRow tempSix = resultDtListSix_12.NewRow();
                                tempSix[0] = "20" + statr_yyyy_08H + "-" + statr_MM_08H + "-" + statr_dd_08H + ":" + statr_hh_08H + ":" + statr_mm_08H + ":" + statr_ss_08H;
                                tempSix[1] = sd;
                                for (int ss = 0; ss < zt.Length; ss++)
                                {
                                    tempSix[ss + 2] = zt[ss].ToString() == "0" ? "" : "";
                                }
                            }
                            tempIndex++;
                            if (tempIndex >long.Parse( count_8H))
                            {
                                break;
                            }
                        }
                        dtAssignment(resultDtListEight_12);
                        stream8_12.Close();
                    }
s_p | 园豆:269 (菜鸟二级) | 2014-07-22 14:49

@s_p: 来学习下如何描述文件结构:http://blog.csdn.net/chun_hua/article/details/6053035

Launcher | 园豆:45030 (高人七级) | 2014-07-22 14:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册