Ejemplo n.º 1
0
        /// <summary>
        /// 波形下发
        /// </summary>
        private void m_Button_Update_Click(object sender, EventArgs e)
        {
            FileLog("Write wave to board");
            ControlsEnable(false);                              //按钮无效化
            WaveDataEx WaveData = m_Waves[0];

            //遍历确定各波所含的段数
            ushort[] usCountArray = new ushort[] { 0, 0, 0, 0, 0, 0, 0, 0 };
            for (int nIndex = 0; nIndex < m_WaveData.NewWaveDatas.Count; nIndex++)
            {
                {
                    m_WaveData.NewWaveDatas[nIndex].m_VoltageStart = m_WaveData.G4_Voltage2DigitalValue((float)(m_WaveData.NewWaveDatas[0].m_StandardVoltage * m_WaveData.NewWaveDatas[nIndex].m_VoltageStart_Percentage / 100));
                    m_WaveData.NewWaveDatas[nIndex].m_VoltageEnd   = m_WaveData.G4_Voltage2DigitalValue((float)(m_WaveData.NewWaveDatas[0].m_StandardVoltage * m_WaveData.NewWaveDatas[nIndex].m_VoltageEnd_Percentage / 100));
                }
                if (m_WaveData.NewWaveDatas[nIndex].m_dVoltage_Cycle != 0)
                {
                    usCountArray[nIndex / 8] += 1;
                    m_WaveData.NewWaveDatas[nIndex].m_Voltage_Cycle = (ushort)(m_WaveData.NewWaveDatas[nIndex].m_dVoltage_Cycle * m_CycleValue + 0.5);
                }
                else
                {
                    m_WaveData.NewWaveDatas[nIndex].m_Voltage_Cycle = 0;
                }
            }

            //设定总段数,总周期数,开始周期不变
            //总段数
            ushort usTotalPhase = 0;

            for (int nIndex = 0; nIndex < usCountArray.Length; nIndex++)
            {
                usTotalPhase += usCountArray[nIndex];
            }
            byte[] byTotalPhase = BitConverter.GetBytes(usTotalPhase);
            if (m_WaveData.WaveSummary.ContainsKey("Summary1"))
            {
                m_WaveData.WaveSummary["Summary1"] = byTotalPhase[0];
            }
            else
            {
                m_WaveData.WaveSummary.Add("Summary1", byTotalPhase[0]);
            }

            ConvertWaveCycle2NMCycle();

            //总周期数
            ushort usTotalCycle = (ushort)(m_WaveData.NewWaveNMDatas[m_WaveData.NewWaveNMDatas.Count - 1].m_Cycle | 0x8000);

            byte[] byTotalCycle = BitConverter.GetBytes(usTotalCycle);
            if (m_WaveData.WaveSummary.ContainsKey("Summary3"))
            {
                m_WaveData.WaveSummary["Summary3"] = byTotalCycle[0];
            }
            else
            {
                m_WaveData.WaveSummary.Add("Summary3", byTotalCycle[0]);
            }

            if (m_WaveData.WaveSummary.ContainsKey("Summary4"))
            {
                m_WaveData.WaveSummary["Summary4"] = byTotalCycle[1];
            }
            else
            {
                m_WaveData.WaveSummary.Add("Summary4", byTotalCycle[1]);
            }

            //int Length = EpsonLCD.WriteWaveData(WaveData.Wave.NewGetBytes(m_ImportPreFlag,m_WriteWaveFlag, m_VSDSelectIndex + 1, m_WaveSelectIndex + 1, usCountArray, usTotalPhase));
            int Length = EpsonLCD.WriteWaveData(m_WaveData.NewGetBytes(m_ImportPreFlag, m_WriteWaveFlag, m_VSDSelectIndex + 1, m_WaveSelectIndex + 1, usCountArray, usTotalPhase));

            EpsonLCD.SetWaveDataTotalLength(Length);
            //m_CheckBox_WriteWave.Checked = false;	//覆盖波形去除勾选
            //btnIFSSave.Enabled = true;
        }