Exemplo n.º 1
0
        public bool AddPointData(int nPos, string strDataString)
        {
            if (strDataString.IndexOf("Data") == 0)
            {
                int nDataCount = strDataString.Split(',').Length;
                if (nDataCount == m_pETETCStage.m_nChannelCount - 1)
                {
                    string strLineString1 = strDataString.Substring(strDataString.Length - 5, 5);

                    for (int ii = 0; ii < m_pETETCStage.m_nChannelCount; ii++)
                    {
                        int nTempdata = 0;

                        //AfxExtractSubString(strTemp, strLineString1, ii, ',');
                        string strTemp = strLineString1.Split(',')[ii];

                        //判断是否乱码
                        if (strTemp.IndexOf("-----") >= 0)
                        {
                            nTempdata = 0;
                        }
                        else
                        {
                            nTempdata = strTemp.ToInt();
                        }

                        CETChannel pETChannel = m_pETETCStage.m_ETChannels.ElementAtOrDefault(ii);;
                        if (pETChannel != null)
                        {
                            double dTemperatureValue = nTempdata / 10.0;
                            //	double		dTimeValue = nPos;// / m_pETETCStage.m_nSampleRate;

                            //	m_fSampleUnit = 1.0/g_nSampleRate[m_nSampleRate];

                            if (dTemperatureValue >= 300 && pETChannel.m_dTemperatureValues.Count > 0)
                            {
                                dTemperatureValue = pETChannel.m_dTemperatureValues[pETChannel.m_dTemperatureValues.Count - 1];
                            }
                            if (pETChannel.m_dTemperatureValues.Count > 0)
                            {
                                if (Math.Abs(dTemperatureValue - pETChannel.m_dTemperatureValues[pETChannel.m_dTemperatureValues.Count - 1]) > 30)
                                {
                                    dTemperatureValue = pETChannel.m_dTemperatureValues[pETChannel.m_dTemperatureValues.Count - 1];
                                }
                            }


                            pETChannel.m_dTemperatureValues.Add(dTemperatureValue);
                        }
                    }
                }
                // 判断数据是否合法
            }
            else
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public double CaclPeakDifference()
        {
            double dMaxPeak = 0;
            double dMinPeak = 400;

            for (int row = 0; row < CETCManagerApp.Instance.m_pETETCStage.m_nChannelCount; row++)
            {
                CETChannel pETChannel  = CETCManagerApp.Instance.m_pETETCStage.m_ETChannels.ElementAtOrDefault(row);;
                double     m_dPeakTemp = 0;
                double     m_dMinTemp  = 400;
                if (pETChannel != null)
                {
                    for (int ii = 0; ii < pETChannel.m_dTemperatureValues.Count; ii++)
                    {
                        // 最小值
                        //		 m_dMinTemp = m_dPeakTemp > pETChannel.m_dTemperatureValues[ii] ? pETChannel.m_dTemperatureValues[ii] :m_dPeakTemp;
                        // 最大值
                        m_dPeakTemp = m_dPeakTemp > pETChannel.m_dTemperatureValues[ii] ? m_dPeakTemp : pETChannel.
                                      m_dTemperatureValues[ii];
                    }
                }
                //////////////////////////////////////////////////////////////////////////
                dMaxPeak = dMaxPeak > m_dPeakTemp ? dMaxPeak : m_dPeakTemp;
                dMinPeak = dMinPeak > m_dPeakTemp ? m_dPeakTemp : dMinPeak;
            }
            m_dChannelTempDifferenceMax = dMaxPeak;
            m_dChannelTempDifferenceMin = dMinPeak;
            return(dMaxPeak);
        }
Exemplo n.º 3
0
 public void RemoveChannelData()
 {
     for (int ii = 0; ii < m_pETETCStage.m_ETChannels.Count; ii++)
     {
         CETChannel pETChannel = m_pETETCStage.m_ETChannels.ElementAtOrDefault(ii);
         if (pETChannel != null)
         {
             pETChannel.m_dTemperatureValues.Clear();
         }
     }
 }
Exemplo n.º 4
0
        public bool UpdateETCData()
        {
            //m_DataList.Clear();
            GV_PageData.Columns.Clear();

            /*InsertColumn(0, "序号", HorzAlignment.Center, HorzAlignment.Center, 80, UnboundColumnType.String);
             * InsertColumn(1, "时间(mm:ss.tt)", HorzAlignment.Center, HorzAlignment.Center, 120, UnboundColumnType.String);
             * InsertColumn(2, "距离[cm]", HorzAlignment.Center, HorzAlignment.Center, 80, UnboundColumnType.String);*/

            /*InsertColumn(0, "序号", DataGridViewContentAlignment.MiddleCenter, DataGridViewContentAlignment.MiddleCenter, 80, typeof(string));
             * InsertColumn(1, "时间(mm:ss.tt)", DataGridViewContentAlignment.MiddleCenter, DataGridViewContentAlignment.MiddleCenter, 120, typeof(string));
             * InsertColumn(2, "距离[cm]", DataGridViewContentAlignment.MiddleCenter, DataGridViewContentAlignment.MiddleCenter, 80, typeof(string));*/
            InsertColumn("序号", 80, HorzAlignment.Center, UnboundColumnType.String, typeof(string));
            InsertColumn("时间(mm:ss.tt)", 120, HorzAlignment.Center, UnboundColumnType.String, typeof(string));
            InsertColumn("距离[cm]", 80, HorzAlignment.Center, UnboundColumnType.String, typeof(string));
            for (int ii = 0; ii < CETCManagerApp.Instance.m_pETETCStage.m_nChannelCount; ii++)
            {
                CETChannel pETChannel = CETCManagerApp.Instance.m_pETETCStage.m_ETChannels.ElementAtOrDefault(ii);
                if (pETChannel != null)
                {
                    //InsertColumn(3 + ii, CETCManagerApp.Instance.m_pETETCStage.m_ETProduct.m_SamplesPoints[ii].m_strPointTitle, DataGridViewContentAlignment.MiddleCenter, DataGridViewContentAlignment.MiddleRight, 60, typeof(double));
                    InsertColumn(CETCManagerApp.Instance.m_pETETCStage.m_ETProduct.m_SamplesPoints[ii].m_strPointTitle, 60,
                                 HorzAlignment.Far, UnboundColumnType.Decimal, typeof(double));
                }
            }

            //用不到

            /*int nCount = 0;
             *
             * // 通道
             * for (int ii = 0; ii < CETCManagerApp.Instance.m_pETETCStage.m_nChannelCount; ii++)
             * {
             *  CETChannel pETChannel = CETCManagerApp.Instance.m_pETETCStage.m_ETChannels[ii];
             *  if (pETChannel != null)
             *  {
             *      nCount = pETChannel.m_dTemperatureValues.Count;
             *  }
             * }
             *
             * SetItemCount(nCount);*/

            return(true);
        }
Exemplo n.º 5
0
        public bool RefreshHVData()
        {
            GV_PageHV.Columns.Clear();

            InsertColumn("XY数值", 100, HorzAlignment.Center, UnboundColumnType.String, typeof(string), true);
            InsertColumn("坐标数值", 100, HorzAlignment.Far, UnboundColumnType.Decimal, typeof(decimal), false);

            //	m_Grid.DeleteAllItems();
            //沒用到

            /*CRect rect;
             * GetClientRect(rect);*/

            // fill it up with stuff
            //m_Grid.SetEditable(TRUE);
            //m_Grid.EnableDragAndDrop(TRUE);


            // 获得行标题
            GetXYAxisRow();

            // 获得行数据

            var theApp = CETCManagerApp.Instance;

            for (int ii = 0; ii < theApp.m_pETETCStage.m_nHAxisNum; ii++)
            {
                for (int jj = 0; jj < theApp.m_pETETCStage.m_nChannelCount; jj++)
                {
                    CETChannel pETChannel = theApp.m_pETETCStage.m_ETChannels.ElementAtOrDefault(jj);
                    if (pETChannel != null)
                    {
                        int nXPos = (int)theApp.m_pETETCStage.m_fHAxis[ii];
                        if (nXPos < pETChannel.m_dTemperatureValues.Count)
                        {
                            theApp.m_pETETCStage.m_fHAxisValue[jj, ii] = pETChannel.m_dTemperatureValues[nXPos];
                        }
                        else
                        {
                            theApp.m_pETETCStage.m_fHAxisValue[jj, ii] = 999999;
                        }
                    }
                }
            }

            // 计算
            for (int ii = 0; ii < theApp.m_pETETCStage.m_nHAxisNum - 1; ii++)
            {
                for (int jj = 0; jj < theApp.m_pETETCStage.m_nChannelCount; jj++)
                {
                    if (theApp.m_pETETCStage.m_fHAxisValue[jj, ii] != 999999 && theApp.m_pETETCStage.m_fHAxisValue[jj, ii + 1] != 999999)
                    {
                        theApp.m_pETETCStage.m_fHAxisBetween[jj, ii] = theApp.m_pETETCStage.m_fHAxisValue[jj, ii + 1] - theApp.m_pETETCStage.m_fHAxisValue[jj, ii];
                    }
                    else
                    {
                        theApp.m_pETETCStage.m_fHAxisBetween[jj, ii] = 888888;
                    }
                }
            }


            ///

            for (int ii = 0; ii < theApp.m_pETETCStage.m_nVAxisNum; ii++)
            {
                for (int jj = 0; jj < theApp.m_pETETCStage.m_nChannelCount; jj++)
                {
                    double     nXPos = theApp.m_pETETCStage.m_fVAxis[ii];
                    int        s;
                    CETChannel pETChannel = theApp.m_pETETCStage.m_ETChannels.ElementAtOrDefault(jj);
                    if (pETChannel != null)
                    {
                        for (s = 0; s < pETChannel.m_dTemperatureValues.Count; s++)
                        {
                            if ((int)pETChannel.m_dTemperatureValues[s] == (int)nXPos)
                            {
                                theApp.m_pETETCStage.m_fVAxisValue[jj, ii] = (double)s / theApp.m_ETETC.m_nSampleRate;
                                break;
                            }
                        }
                    }
                }
            }


            for (int ii = 0; ii < theApp.m_pETETCStage.m_nVAxisNum - 1; ii++)
            {
                for (int jj = 0; jj < theApp.m_pETETCStage.m_nChannelCount; jj++)
                {
                    if (theApp.m_pETETCStage.m_fVAxisValue[jj, ii] != 999999 && theApp.m_pETETCStage.m_fVAxisValue[jj, ii + 1] != 999999)
                    {
                        theApp.m_pETETCStage.m_fVAxisBetween[jj, ii] = theApp.m_pETETCStage.m_fVAxisValue[jj, ii + 1] - theApp.m_pETETCStage.m_fVAxisValue[jj, ii];
                    }
                    else
                    {
                        theApp.m_pETETCStage.m_fVAxisBetween[jj, ii] = 888888;
                    }
                }
            }

            int nRowCount = 2 * theApp.m_pETETCStage.m_nHAxisNum - 1 + 2 * theApp.m_pETETCStage.m_nVAxisNum - 1;

            //用不到
            //int mRowCount = nRowCount + 2;
            int mRowCount   = nRowCount + 1;
            int ColumnCount = 3 + theApp.m_pETETCStage.m_nChannelCount;

            for (int i = 0; i < theApp.m_pETETCStage.m_nChannelCount; i++)
            {
                InsertColumn(string.Format("[{0}] {1}", i + 1, theApp.m_pETETCStage.m_ETProduct.m_SamplesPoints[i].m_strPointTitle), 80, HorzAlignment.Far, UnboundColumnType.Decimal, typeof(decimal), true);
            }

            /*try
             * {
             *  m_Grid.SetRowCount(nRowCount + 2);
             *  m_Grid.SetColumnCount(3 + theApp.m_pETETCStage.m_nChannelCount);
             *  m_Grid.SetFixedRowCount(1);
             *  m_Grid.SetFixedColumnCount(1);
             * }
             * catch (CMemoryException* e)
             * {
             *  e.ReportError();
             *  e.Delete();
             *  return FALSE;
             * }*/


            // fill rows/cols with text
            for (int row = 0; row < mRowCount; row++)
            {
                GV_PageHV.Rows.Add();

                for (int col = 0; col < ColumnCount - 1; col++)
                {
                    //var Item = new CusCells();
                    var Item = GV_PageHV.Rows[row].Cells[col];

                    /*GV_ITEM Item;
                     * Item.mask = GVIF_TEXT | GVIF_FORMAT;
                     * Item.row = row;
                     * Item.col = col;*/
                    /*if (row < 1)
                     * {
                     *  //Item.nFormat = DT_CENTER | DT_WORDBREAK;
                     *  if (col < 2)
                     *  {
                     *      Item.Value = string.Format(, m_strColumn[col]);
                     *  }
                     *  else
                     *  {
                     *      Item.strText.Format(_T("[%d]  %s "), col - 1, theApp.m_pETETCStage.m_ETProduct.m_SamplesPoints[col - 2].m_strPointTitle);
                     *
                     *  }
                     * }
                     * else if (col < 1)
                     * {
                     *  Item.nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
                     *  if (row < nRowCount + 2)
                     *  {
                     *      Item.strText.Format(_T("%s"), m_strRow[row - 1]);
                     *  }
                     * }
                     * else
                     * {*/
                    if (col == 0)
                    {
                        //Item.nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
                        //if (row < nRowCount + 2)
                        {
                            Item.Value           = m_strRow[row];
                            Item.ReadOnly        = true;
                            Item.Style.BackColor = Color.LightGray;
                        }
                    }
                    else
                    // 数据
                    if (col == 1)
                    {
                        if (row < 2 * theApp.m_pETETCStage.m_nHAxisNum - 1 && row >= 0)
                        {
                            if ((row) % 2 == 0)
                            {
                                Item.Value           = string.Format("{0:n1}", theApp.m_pETETCStage.m_fHAxis[(row) / 2]);
                                Item.ReadOnly        = false;
                                Item.Style.BackColor = Color.LightGreen;
                                Item.Tag             = new SuperTag()
                                {
                                    CETPageHV_RowCaption = "X" + (row) / 2
                                };
                            }
                            else
                            {
                                Item.Value    = string.Format("{0:n1}", theApp.m_pETETCStage.m_fHAxis[(row) / 2 + 1] - theApp.m_pETETCStage.m_fHAxis[(row) / 2]);
                                Item.ReadOnly = true;
                            }
                        }
                        else if (row > 2 * theApp.m_pETETCStage.m_nHAxisNum - 1)
                        {
                            int nTempRow = row - (2 * theApp.m_pETETCStage.m_nHAxisNum - 1) - 1;
                            if ((nTempRow) % 2 == 0)
                            {
                                Item.Value           = string.Format("{0:n1}", theApp.m_pETETCStage.m_fVAxis[(nTempRow) / 2]);
                                Item.ReadOnly        = false;
                                Item.Style.BackColor = Color.LightGreen;
                                Item.Tag             = new SuperTag()
                                {
                                    CETPageHV_RowCaption = "Y" + (nTempRow) / 2
                                };
                            }
                            else
                            {
                                Item.Value    = string.Format("{0:n1}", theApp.m_pETETCStage.m_fVAxis[(nTempRow) / 2 + 1] - theApp.m_pETETCStage.m_fVAxis[(nTempRow) / 2]);
                                Item.ReadOnly = true;
                            }
                        }
                    }

                    if (col <= 1)
                    {
                        //GV_PageHV.SetRowCellValue(row, GV_PageHV.Columns[col].FieldName, Item.Value);
                        //cells.Add($"{row};{col}", Item);
                    }
                }
            }

            int nItemHRowCount = 2 * theApp.m_pETETCStage.m_nHAxisNum - 1;

            //int nItemHRowCount = mRowCount;
            // fill rows/cols with text
            for (int row = 0; row < nItemHRowCount; row++)
            {
                for (int col = 0; col < theApp.m_pETETCStage.m_nChannelCount; col++)
                {
                    //var Item = new CusCells();
                    var Item = GV_PageHV.Rows[row].Cells[col + 2];

                    /*GV_ITEM Item;
                     * Item.mask = GVIF_TEXT | GVIF_FORMAT;
                     * Item.row = row + 1;
                     * Item.col = col + 2;
                     *
                     * Item.nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
                     */
                    // 数据
                    CETChannel pETChannel = theApp.m_pETETCStage.m_ETChannels.ElementAtOrDefault(col);;
                    if (pETChannel != null)
                    {
                        if (row % 2 == 0)
                        {
                            if (theApp.m_pETETCStage.m_fHAxisValue[col, row / 2] != 999999)
                            {
                                Item.Value = string.Format("{0:n1}", theApp.m_pETETCStage.m_fHAxisValue[col, row / 2]);
                            }
                        }
                        else
                        {
                            if (theApp.m_pETETCStage.m_fHAxisBetween[col, row / 2] != 888888)
                            {
                                Item.Value = string.Format("{0:n1}", theApp.m_pETETCStage.m_fHAxisBetween[col, row / 2]);
                            }
                        }
                        Item.ReadOnly = true;

                        /*GV_PageHV.SetRowCellValue(row / 2, GV_PageHV.Columns[col].FieldName, Item.Value);
                         * if (cells.ContainsKey($"{row / 2};{col}"))
                         * {
                         *  cells[$"{row / 2};{col}"].Value = Item;
                         * }*/
                    }
                }
            }

            // fill rows/cols with text
            int nItemVRowCount = 2 * theApp.m_pETETCStage.m_nVAxisNum - 1;

            if (nItemHRowCount >= 0)
            {
                for (int i = 0; i < GV_PageHV.Columns.Count; i++)
                {
                    GV_PageHV.Rows[nItemHRowCount].Cells[i].Style.BackColor = Color.LightGray;
                }
            }

            for (int row = 0; row < nItemVRowCount; row++)
            {
                for (int col = 0; col < theApp.m_pETETCStage.m_nChannelCount; col++)
                {
                    //var Item = new CusCells();
                    var Item = GV_PageHV.Rows[row + (nItemHRowCount + 1)].Cells[col + 2];

                    /*
                     * GV_ITEM Item;
                     * Item.mask = GVIF_TEXT | GVIF_FORMAT;
                     * Item.row = row + 2 + nItemVRowCount;
                     * Item.col = col + 2;
                     *
                     * Item.nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOPREFIX;
                     */
                    // 数据
                    CETChannel pETChannel = theApp.m_pETETCStage.m_ETChannels.ElementAtOrDefault(col);;

                    if (pETChannel != null)
                    {
                        if (row % 2 == 0)
                        {
                            if (theApp.m_pETETCStage.m_fVAxisValue[col, row / 2] != 999999)
                            {
                                Item.Value = string.Format("{0:n1}", theApp.m_pETETCStage.m_fVAxisValue[col, row / 2]);
                            }
                            else
                            {
                                Item.Value = "";
                            }
                        }
                        else
                        {
                            if (theApp.m_pETETCStage.m_fVAxisBetween[col, row / 2] != 888888)
                            {
                                Item.Value = string.Format("{0:n1}", theApp.m_pETETCStage.m_fVAxisBetween[col, row / 2]);
                            }
                            else
                            {
                                Item.Value = "";
                            }
                        }
                        Item.ReadOnly = true;

                        /*GV_PageHV.SetRowCellValue(row / 2, GV_PageHV.Columns[col].FieldName, Item.Value);
                         * if (cells.ContainsKey($"{row / 2};{col}"))
                         * {
                         *  cells[$"{row / 2};{col}"].Value = Item;
                         * }*/
                    }
                    //	m_Grid.SetItemState(row, col, GVIS_);
                    //m_Grid.SetItem(&Item);
                }
            }
            //m_Grid.AutoSize();

            /*for (int i = 0; i < GV_PageHV.RowCount; i++)
             * {
             *  for (int j = 0; j < GV_PageHV.ColumnCount; j++)
             *  {
             *      if (j==1)
             *      {
             *          if(GV_PageHV.Rows[i].Cells[j].Value != null)
             *              GV_PageHV.Rows[i].Cells[j].ReadOnly = false;
             *          else
             *              GV_PageHV.Rows[i].Cells[j].ReadOnly = true;
             *      }
             *      else
             *      {
             *          GV_PageHV.Rows[i].Cells[j].ReadOnly = true;
             *      }
             *  }
             *
             * }*/
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 解析文件
        /// </summary>
        /// <param name="fName"></param>
        public void UnSerialize(string fName)
        {
            try
            {
                FileStream fs = new FileStream(fName, FileMode.Open, FileAccess.Read);
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter format = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                using (BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding("gb2312")))
                {
                    uint headID  = br.ReadUInt32();
                    uint version = br.ReadUInt32();
                    var  headID1 = 'N' | ('E' << 8) | ('O' << 16) | ('N' << 24);

                    m_ETProjectInfo.m_strProjectName    = br.ReadString();
                    m_ETProjectInfo.m_strOperator       = br.ReadString();
                    m_ETProjectInfo.m_strMeasureTime    = br.ReadString();
                    m_ETProjectInfo.m_strPrintTime      = br.ReadString();
                    m_ETProjectInfo.m_nDataTotalTime    = br.ReadInt32();  //总时长
                    m_ETProjectInfo.m_nSampleRate       = br.ReadInt32();  //采样周期
                    m_ETProjectInfo.m_nMeasureCount     = br.ReadInt32();  //采样通道数
                    m_ETProjectInfo.m_strCustomer       = br.ReadString(); //焊锡信号
                    m_ETProjectInfo.m_strProduct        = br.ReadString(); //产品名称
                    m_ETProjectInfo.m_strReflower       = br.ReadString(); //回流焊型号
                    m_ETProjectInfo.m_strTinCream       = br.ReadString(); //焊锡信号
                    m_ETProjectInfo.m_strProductionline = br.ReadString();
                    m_ETProjectInfo.m_strHaiqiLongdu    = br.ReadString();
                    m_ViewShowInfo.m_IsShowAxisX        = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowAxisY        = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowGrid         = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowHV           = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowAllChannel   = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowTinCream     = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowNotes        = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowSlope        = br.ReadInt32() == 1 ? true : false;
                    m_ViewShowInfo.m_IsShowReflowerZone = br.ReadInt32() == 1 ? true : false;

                    // 采样板信息
                    m_ETETC.m_nChannelCount  = br.ReadInt32();
                    m_ETETC.m_nBandRate      = br.ReadUInt32();
                    m_ETETC.m_nComID         = br.ReadInt32();
                    m_ETETC.m_strETCName     = br.ReadString();
                    m_ETETC.m_IsHaveWireLess = br.ReadInt32() == 1 ? true : false;

                    // 回流炉信息
                    m_ETReflower.m_strTitle               = br.ReadString();
                    m_ETReflower.m_strTemplUnit           = br.ReadString();
                    m_ETReflower.m_strLengthUnit          = br.ReadString();
                    m_ETReflower.m_strSpeedUnit           = br.ReadString();
                    m_ETReflower.m_fSpeed                 = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETReflower.m_nSampleHeaterAreaCount = br.ReadInt32();
                    m_ETReflower.m_strProduct             = br.ReadString();
                    m_ETReflower.m_strModel               = br.ReadString();
                    m_ETReflower.m_IsTempSmall            = br.ReadInt32() == 1 ? true : false;
                    m_ETReflower.m_IsWidthSmall           = br.ReadInt32() == 1 ? true : false;
                    m_ETReflower.m_IsSpeedSmall           = br.ReadInt32() == 1 ? true : false;
                    m_ETReflower.m_strNotes               = br.ReadString();
                    m_ETReflower.m_fInitTempl             = BitConverter.ToSingle(br.ReadBytes(4), 0);


                    var pReflowerAreaData_Hot = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_CAreaData["Hot"];
                    for (int ii = 0; ii < 12; ii++)
                    {
                        pReflowerAreaData_Hot[ii].m_fAreaLength         = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaTemplTop       = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaTemplButtom    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaFanSpeedTop    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaFanSpeedButtom = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaFanSpeedButtom = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaFanSpeedTop    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaForecastButtom = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Hot[ii].m_fAreaForecastTop    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    }

                    var pReflowerAreaData_Cool = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_CAreaData["Cool"];
                    for (int ii = 0; ii < 12; ii++)
                    {
                        pReflowerAreaData_Cool[ii].m_fAreaLength         = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaTemplTop       = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaTemplButtom    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaFanSpeedTop    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaFanSpeedButtom = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaFanSpeedButtom = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaFanSpeedTop    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaForecastButtom = BitConverter.ToSingle(br.ReadBytes(4), 0);
                        pReflowerAreaData_Cool[ii].m_fAreaForecastTop    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    }

                    for (int ii = 0; ii < 16 * 9; ii++)
                    {
                        br.ReadBytes(4);
                    }


                    // 锡膏信息
                    m_ETTinCream.m_strName          = br.ReadString();
                    m_ETTinCream.m_strManufacturers = br.ReadString();
                    m_ETTinCream.m_strType          = br.ReadString();
                    // 预热
                    m_ETTinCream.m_fStartTempl1       = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMinSlopeValue1    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMaxSlopeValue1    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTargetSlopeValue1 = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    // 浸泡
                    m_ETTinCream.m_fStartTempl2       = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fEndTempl2         = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMinSlopeValue2    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMaxSlopeValue2    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTargetSlopeValue2 = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTimeRangeMin2     = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTimeRangeMax2     = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTimeRangeTarget2  = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    // 回流
                    m_ETTinCream.m_fStartTempl3       = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMinSlopeValue3    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMaxSlopeValue3    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTargetSlopeValue3 = BitConverter.ToSingle(br.ReadBytes(4), 0);

                    m_ETTinCream.m_fTimeRangeMin3    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTimeRangeMax3    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTimeRangeTarget3 = BitConverter.ToSingle(br.ReadBytes(4), 0);

                    m_ETTinCream.m_fMinTemplValue3    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMaxTemplValue3    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTargetTemplValue3 = BitConverter.ToSingle(br.ReadBytes(4), 0);

                    // 冷却
                    m_ETTinCream.m_fMinSlopeValue4    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fMaxSlopeValue4    = BitConverter.ToSingle(br.ReadBytes(4), 0);
                    m_ETTinCream.m_fTargetSlopeValue4 = BitConverter.ToSingle(br.ReadBytes(4), 0);

                    // 水平垂直线

                    m_nHAxisNum = br.ReadInt32();
                    for (int i = 0; i < 4; i++)
                    {
                        m_fHAxis[i] = br.ReadDouble();
                    }

                    m_nVAxisNum = br.ReadInt32();
                    for (int i = 0; i < 4; i++)
                    {
                        m_fVAxis[i] = br.ReadDouble();
                    }

                    // 产品数据

                    m_ETProduct.m_strName          = br.ReadString();
                    m_ETProduct.m_strProductCode   = br.ReadString();
                    m_ETProduct.m_strDescription   = br.ReadString();
                    m_ETProduct.m_strManufacturers = br.ReadString();
                    m_ETProduct.m_strCustomor      = br.ReadString();

                    m_ETProduct.m_strProductImage[0] = br.ReadString();
                    m_ETProduct.m_strProductImage[1] = br.ReadString();
                    m_ETProduct.m_dWidth             = br.ReadDouble();
                    m_ETProduct.m_dHeight            = br.ReadDouble();
                    m_ETProduct.m_dThickness         = br.ReadDouble();

                    for (int ii = 0; ii < 24; ii++)
                    {
                        m_ETProduct.m_SamplesPoints[ii].m_dPostionY     = br.ReadDouble();
                        m_ETProduct.m_SamplesPoints[ii].m_dPostionX     = br.ReadDouble();
                        m_ETProduct.m_SamplesPoints[ii].m_clrColor      = ShareFunc.ConvertFromWin32Color(br.ReadInt32());
                        m_ETProduct.m_SamplesPoints[ii].m_strPointTitle = br.ReadString(); //Encoding.GetEncoding("gb2312").GetString(br.ReadBytes(8));
                        m_ETProduct.m_SamplesPoints[ii].m_nPointPostion = br.ReadInt32();
                    }

                    double dTemperatureValue;
                    int    nPointCount;
                    // 数据通道
                    for (int ii = 0; ii < m_ETProjectInfo.m_nMeasureCount; ii++)
                    {
                        CETChannel pETChannel = new CETChannel();
                        m_ETProduct.m_SamplesPoints[ii].m_strPointTitle = br.ReadString();
                        pETChannel.m_strName = m_ETProduct.m_SamplesPoints[ii].m_strPointTitle;
                        m_ETProduct.m_SamplesPoints[ii].m_clrColor = ShareFunc.ConvertFromWin32Color(br.ReadInt32());
                        nPointCount = br.ReadInt32();
                        for (int s = 0; s < nPointCount; s++)
                        {
                            dTemperatureValue = br.ReadDouble();
                            pETChannel.m_dTemperatureValues.Add(dTemperatureValue);
                        }
                        m_ETChannels.Add(pETChannel);
                    }
                }
            }
            catch
            {
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 序列化
        /// </summary>
        /// <param name="fName"></param>
        public void Serialize(string fName)
        {
            try
            {
                if (!File.Exists(fName))
                {
                    File.Create(fName).Close();
                }
                FileStream fs = new FileStream(fName, FileMode.Open, FileAccess.ReadWrite);
                System.Runtime.Serialization.Formatters.Binary.BinaryFormatter format = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                using (BinaryWriter br = new BinaryWriter(fs, Encoding.UTF8))
                {
                    var headID1 = 'N' | ('E' << 8) | ('O' << 16) | ('N' << 24);
                    br.Write(headID1);
                    br.Write(m_Header.version);


                    br.Write(m_ETProjectInfo.m_strProjectName);
                    br.Write(m_ETProjectInfo.m_strOperator);
                    br.Write(m_ETProjectInfo.m_strMeasureTime);
                    br.Write(m_ETProjectInfo.m_strPrintTime);
                    br.Write(m_ETProjectInfo.m_nDataTotalTime); //总时长
                    br.Write(m_ETProjectInfo.m_nSampleRate);    //采样周期
                    br.Write(m_ETProjectInfo.m_nMeasureCount);  //采样通道数
                    br.Write(m_ETProjectInfo.m_strCustomer);    //焊锡信号
                    br.Write(m_ETProjectInfo.m_strProduct);     //产品名称
                    br.Write(m_ETProjectInfo.m_strReflower);    //回流焊型号
                    br.Write(m_ETProjectInfo.m_strTinCream);    //焊锡信号
                    br.Write(m_ETProjectInfo.m_strProductionline);
                    br.Write(m_ETProjectInfo.m_strHaiqiLongdu);
                    br.Write(m_ViewShowInfo.m_IsShowAxisX ? 1: 0);
                    br.Write(m_ViewShowInfo.m_IsShowAxisY ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowGrid ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowHV ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowAllChannel ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowTinCream ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowNotes ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowSlope ? 1 : 0);
                    br.Write(m_ViewShowInfo.m_IsShowReflowerZone ? 1 : 0);

                    // 采样板信息
                    br.Write(m_ETETC.m_nChannelCount);
                    br.Write(m_ETETC.m_nBandRate);
                    br.Write(m_ETETC.m_nComID);
                    br.Write(m_ETETC.m_strETCName);
                    br.Write(m_ETETC.m_IsHaveWireLess ? 1 : 0);

                    // 回流炉信息
                    br.Write(m_ETReflower.m_strTitle);
                    br.Write(m_ETReflower.m_strTemplUnit);
                    br.Write(m_ETReflower.m_strLengthUnit);
                    br.Write(m_ETReflower.m_strSpeedUnit);
                    br.Write(m_ETReflower.m_fSpeed);
                    br.Write(m_ETReflower.m_nSampleHeaterAreaCount);
                    br.Write(m_ETReflower.m_strProduct);
                    br.Write(m_ETReflower.m_strModel);
                    br.Write(m_ETReflower.m_IsTempSmall ? 1 : 0);
                    br.Write(m_ETReflower.m_IsWidthSmall ? 1 : 0);
                    br.Write(m_ETReflower.m_IsSpeedSmall ? 1 : 0);
                    br.Write(m_ETReflower.m_strNotes);
                    br.Write(m_ETReflower.m_fInitTempl);


                    var pReflowerAreaData_Hot = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_CAreaData["Hot"];
                    for (int ii = 0; ii < 12; ii++)
                    {
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaLength);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaTemplTop);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaTemplButtom);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaFanSpeedTop);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaFanSpeedButtom);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaFanSpeedButtom);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaFanSpeedTop);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaForecastButtom);
                        br.Write(pReflowerAreaData_Hot[ii].m_fAreaForecastTop);
                    }

                    var pReflowerAreaData_Cool = CETCManagerApp.Instance.m_pETETCStage.m_ETReflower.m_CAreaData["Cool"];
                    for (int ii = 0; ii < 12; ii++)
                    {
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaLength);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaTemplTop);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaTemplButtom);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaFanSpeedTop);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaFanSpeedButtom);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaFanSpeedButtom);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaFanSpeedTop);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaForecastButtom);
                        br.Write(pReflowerAreaData_Cool[ii].m_fAreaForecastTop);
                    }

                    for (int ii = 0; ii < 16 * 9; ii++)
                    {
                        br.Write(4);
                        //br.ReadBytes(4);
                    }


                    // 锡膏信息
                    br.Write(m_ETTinCream.m_strName);
                    br.Write(m_ETTinCream.m_strManufacturers);
                    br.Write(m_ETTinCream.m_strType);
                    // 预热
                    br.Write(m_ETTinCream.m_fStartTempl1);
                    br.Write(m_ETTinCream.m_fMinSlopeValue1);
                    br.Write(m_ETTinCream.m_fMaxSlopeValue1);
                    br.Write(m_ETTinCream.m_fTargetSlopeValue1);
                    // 浸泡
                    br.Write(m_ETTinCream.m_fStartTempl2);
                    br.Write(m_ETTinCream.m_fEndTempl2);
                    br.Write(m_ETTinCream.m_fMinSlopeValue2);
                    br.Write(m_ETTinCream.m_fMaxSlopeValue2);
                    br.Write(m_ETTinCream.m_fTargetSlopeValue2);
                    br.Write(m_ETTinCream.m_fTimeRangeMin2);
                    br.Write(m_ETTinCream.m_fTimeRangeMax2);
                    br.Write(m_ETTinCream.m_fTimeRangeTarget2);
                    // 回流
                    br.Write(m_ETTinCream.m_fStartTempl3);
                    br.Write(m_ETTinCream.m_fMinSlopeValue3);
                    br.Write(m_ETTinCream.m_fMaxSlopeValue3);
                    br.Write(m_ETTinCream.m_fTargetSlopeValue3);

                    br.Write(m_ETTinCream.m_fTimeRangeMin3);
                    br.Write(m_ETTinCream.m_fTimeRangeMax3);
                    br.Write(m_ETTinCream.m_fTimeRangeTarget3);

                    br.Write(m_ETTinCream.m_fMinTemplValue3);
                    br.Write(m_ETTinCream.m_fMaxTemplValue3);
                    br.Write(m_ETTinCream.m_fTargetTemplValue3);

                    // 冷却
                    br.Write(m_ETTinCream.m_fMinSlopeValue4);
                    br.Write(m_ETTinCream.m_fMaxSlopeValue4);
                    br.Write(m_ETTinCream.m_fTargetSlopeValue4);

                    // 水平垂直线

                    br.Write(m_nHAxisNum);
                    for (int i = 0; i < 4; i++)
                    {
                        br.Write(m_fHAxis[i]);
                    }

                    br.Write(m_nVAxisNum);
                    for (int i = 0; i < 4; i++)
                    {
                        br.Write(m_fVAxis[i]);
                    }

                    // 产品数据

                    br.Write(m_ETProduct.m_strName);
                    br.Write(m_ETProduct.m_strProductCode);
                    br.Write(m_ETProduct.m_strDescription);
                    br.Write(m_ETProduct.m_strManufacturers);
                    br.Write(m_ETProduct.m_strCustomor);

                    br.Write(m_ETProduct.m_strProductImage[0]);
                    br.Write(m_ETProduct.m_strProductImage[1]);
                    br.Write(m_ETProduct.m_dWidth);
                    br.Write(m_ETProduct.m_dHeight);
                    br.Write(m_ETProduct.m_dThickness);

                    for (int ii = 0; ii < 24; ii++)
                    {
                        br.Write(m_ETProduct.m_SamplesPoints[ii].m_dPostionY);
                        br.Write(m_ETProduct.m_SamplesPoints[ii].m_dPostionX);
                        br.Write(m_ETProduct.m_SamplesPoints[ii].m_clrColor.ToArgb());
                        br.Write(m_ETProduct.m_SamplesPoints[ii].m_strPointTitle); //Encoding.GetEncoding("gb2312").GetString(br.ReadBytes(8));
                        br.Write(m_ETProduct.m_SamplesPoints[ii].m_nPointPostion);
                    }

                    // 数据通道
                    var theApp = CETCManagerApp.Instance;
                    for (int ii = 0; ii < m_ETProjectInfo.m_nMeasureCount; ii++)
                    {
                        CETChannel pETChannel = m_ETChannels.ElementAtOrDefault(ii);
                        if (pETChannel != null)
                        {
                            br.Write(theApp.m_pETETCStage.m_ETProduct.m_SamplesPoints[ii].m_strPointTitle);
                            br.Write(m_ETProduct.m_SamplesPoints[ii].m_clrColor.ToArgb());
                            br.Write(pETChannel.m_dTemperatureValues.Count);
                            for (int s = 0; s < pETChannel.m_dTemperatureValues.Count; s++)
                            {
                                double dTemperatureValue = pETChannel.m_dTemperatureValues[s];
                                br.Write(dTemperatureValue);
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }