コード例 #1
0
        private void LabelInfoAddForm_Load(object sender, EventArgs e)
        {
            sFunSPointXPos = this.Tag.ToString();
            textBox1.Text  = sFunSPointXPos;

            FileStream   fs = new FileStream(CommonClass.listDIC[0].sFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
            BinaryReader br = new BinaryReader(fs);

            int gjtds = CommonClass.listDIC[0].listCC.Count;

            byte[] b = new byte[gjtds * 2];

            int i1 = 0, i2 = 2;


            br.BaseStream.Position = int.Parse(sFunSPointXPos);
            b = br.ReadBytes(gjtds * 2);
            if (CommonClass.listDIC[0].bEncrypt)
            {
                b = WaveformDataProcess.ByteXORByte(b);
            }

            short gongli = BitConverter.ToInt16(b, i1);
            short mi1    = BitConverter.ToInt16(b, i2);

            textBox3.Text = ((gongli * 100000 + (mi1 / (float)CommonClass.listDIC[0].iSmaleRate * 100)) / 1000).ToString();

            br.Close();
            fs.Close();

            textBox1.Text = sFunSPointXPos;
        }
コード例 #2
0
        /// <summary>
        /// 根据通道Id把文件中起始点和结束点之间的绝对值最大的点的原始值
        /// </summary>
        /// <param name="dic">cit文件</param>
        /// <param name="startPos">起始指针</param>
        /// <param name="endPos">结束指针</param>
        /// <param name="channelId">通道号</param>
        /// <returns>起始指针和结束指针之间绝对值最大的点的值</returns>
        private float GetMaxValuesOfChannelById(DataInfoClass dic, long startPos, long endPos, ChannelsClass channelCls)
        {
            try
            {
                FileStream   fs       = new FileStream(dic.sFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                BinaryReader br       = new BinaryReader(fs);
                int          gjtds    = dic.fScale.Length;
                bool         bEncrypt = dic.bEncrypt;
                byte[]       b        = new byte[gjtds * 2];

                long findpos = startPos;
                br.BaseStream.Position = startPos;
                List <float> dataArray = new List <float>();

                while (findpos < endPos)
                {
                    b = br.ReadBytes(gjtds * 2);
                    if (bEncrypt)
                    {
                        b = WaveformDataProcess.ByteXORByte(b);
                    }

                    short km            = BitConverter.ToInt16(b, 0);
                    short count         = BitConverter.ToInt16(b, 2);
                    short channelValueS = BitConverter.ToInt16(b, channelCls.Id * 2);
                    float channelValueF = channelValueS / dic.fScale[channelCls.Id] + dic.fOffset[channelCls.Id];

                    dataArray.Add(channelValueF);

                    findpos += gjtds * 2;
                }

                br.Close();
                fs.Close();

                float fRet = MaxValueOfDataArray(dataArray.ToArray());
                return(fRet);
            }
            catch
            {
                return(0);
            }
        }