private void AutoUpdateVave() { m_Waves.Clear(); if (!m_WaveData.Validation(m_VSDSelectIndex + 1)) { MessageBox.Show(ResString.GetResString("Wave_Info_NumberMoreThanMaxOfVSD")); return; } WaveDataEx WaveToSend = new WaveDataEx(m_WaveData); { AmplitudeHeadParameter Amplitude = new AmplitudeHeadParameter(Convert.ToInt32(0)); WaveToSend.AddAmplitude(Amplitude); } { m_WaveData.WaveDatas = m_OriginalWaveSnips; AmplitudeVoltageChange Amplitude = new AmplitudeVoltageChange(m_OriginalWaveSnips, m_WaveData.WaveDatas); WaveToSend.AddAmplitude(Amplitude); } m_Waves.Add(WaveToSend); System.Threading.Thread.Sleep(500); if (IsVoltage) { m_WaveData.NewWaveDatas[0].m_StandardVoltage = Math.Round(currValue, 1); } else { m_WaveData.NewWaveDatas[indexN].m_dVoltage_Cycle = Math.Round(currValue, 1); } currStr = "(V)" + m_WaveData.NewWaveDatas[0].m_StandardVoltage.ToString() + " " + "(W)" + (waveIdx + 1).ToString() + " " + "(1)" + m_WaveData.NewWaveDatas[waveIdx * m_WavePhase_Number].m_dVoltage_Cycle.ToString() + " " + "(2)" + m_WaveData.NewWaveDatas[waveIdx * m_WavePhase_Number + 1].m_dVoltage_Cycle.ToString() + " " + "(3)" + m_WaveData.NewWaveDatas[waveIdx * m_WavePhase_Number + 2].m_dVoltage_Cycle.ToString() + " " + "(4)" + m_WaveData.NewWaveDatas[waveIdx * m_WavePhase_Number + 3].m_dVoltage_Cycle.ToString() + " "; currValue = currValue + step; m_Button_Update_Click(null, null); }
/// <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; }
public void ProceedKernelMessage(IntPtr wParam, IntPtr lParam) { CoreMsgEnum kParam = (CoreMsgEnum)wParam.ToInt32(); switch (kParam) { case CoreMsgEnum.HardPanelDirty: { Ep6Cmd cmd = (Ep6Cmd)lParam.ToInt32(); switch (cmd) { case Ep6Cmd.EP6_CMD_T_WAVE_READ_READY: { FileLog("Ep6Cmd.EP6_CMD_T_WAVE_READ_READY"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_WAVE_READ_READY 波形预读完成"); int TotalLength = EpsonLCD.GetWaveDataTotalLength(); m_WaveData.NewParse2(HBTypeName, EpsonLCD.GetWaveData(TotalLength), m_CycleValue); //保存刚刚获得的波形数据,在幅值方式为电压改变时有用 m_OriginalWaveSnips = new List <WaveDataSnip>(m_WaveData.WaveDatas); ////导入Wave和NM数据 //ImportWaveNMData(); //btnIFSSave.Enabled = true; //m_Button_Import.Enabled = true; } break; case Ep6Cmd.EP6_CMD_T_WAVE_SET_READY: { //波形发送完成,发送幅值 FileLog("Ep6Cmd.EP6_CMD_T_WAVE_SET_READY"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_WAVE_SET_READY 波形发送完成,发送幅值"); if (m_Waves.Count == 0) { break; } WaveDataEx WaveData = m_Waves[0]; m_AmplitudeToSends.Clear(); foreach (IAmplitude Amplitude in WaveData.Amplitudes) { m_AmplitudeToSends.Add(Amplitude); } if (0 == m_AmplitudeToSends.Count) { throw new Exception("0 == m_AmplitudeToSends.Count"); } int Length = EpsonLCD.WriteAmplitudeData(m_AmplitudeToSends[0].GetBytes()); EpsonLCD.SetAmplitudeTotalLength(Length); } break; case Ep6Cmd.EP6_CMD_T_SWING_READY: { FileLog("Ep6Cmd.EP6_CMD_T_SWING_READY"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_SWING_READY 幅值下发完成"); if (m_AmplitudeToSends.Count > 0) { m_AmplitudeToSends.RemoveAt(0); } if (m_AmplitudeToSends.Count > 0) { int Length = EpsonLCD.WriteAmplitudeData(m_AmplitudeToSends[0].GetBytes()); EpsonLCD.SetAmplitudeTotalLength(Length); } else { //幅值发送完成,发送新增加节点信息,暂时为空 byte[] NewNode = new byte[2]; NewNode[0] = 0xFF; int Length = EpsonLCD.WriteNewAddNodeData(NewNode); EpsonLCD.SetNewAddNodeTotalLength(1); } } break; case Ep6Cmd.EP6_CMD_T_WAVE_POINT_FINISH: { //新添加节点数据发送完成命令 FileLog("Ep6Cmd.EP6_CMD_T_WAVE_POINT_FINISH"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_WAVE_POINT_FINISH 新添加节点数据发送完成命令"); int Length = EpsonLCD.WriteWaveMappingData(ConstructWaveMapping()); EpsonLCD.SetWaveMappingTotalLength(Length); } break; case Ep6Cmd.EP6_CMD_T_WAVE_NAME_READY: //预读波形名字就绪,开始读波形名字 { FileLog("Ep6Cmd.EP6_CMD_T_WAVE_NAME_READY"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_WAVE_NAME_READY 预读波形命令下发完成"); //取得波形名字总长度 int TotalSize = EpsonLCD.GetWaveNameTotalLength(); //取得波形名字数据 ParseWaveName(EpsonLCD.GetWaveNameData(TotalSize), TotalSize); //预读映射表命令 EpsonLCD.PrepareReadWaveMapping(); } break; case Ep6Cmd.EP6_CMD_T_WAVE_NAME_FINISH: //波形名字发送完成命令 { FileLog("Ep6Cmd.EP6_CMD_T_WAVE_NAME_FINISH"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_WAVE_NAME_FINISH 波形名字修改发送完成命令"); MessageBox.Show(ResString.GetResString("Wave_Info_WaveNameUpdataFinish"), "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); ControlsEnable(true); } break; case Ep6Cmd.EP6_CMD_T_WAVE_CHANNEL_FINISH: //波形映射表完成命令 { FileLog("Ep6Cmd.EP6_CMD_T_WAVE_CHANNEL_FINISH"); Debug.WriteLine("Ep6Cmd.EP6_CMD_T_WAVE_CHANNEL_FINISH 波形映射表完成命令"); //获得波形映射总长度 int TotalSize = EpsonLCD.GetWaveMappingTotalLength(); if (0 == TotalSize) { MessageBox.Show(ResString.GetResString("Wave_Info_ReadWaveMapping0Length"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //取得波形映射数据 ParseWaveMapping(EpsonLCD.GetWaveMappingData(TotalSize), TotalSize); if (m_ImportMappingFlag == false) { //用户自定义 CustomInitialize(); //界面上所有控件显示 this.Visible = true; //波形映射导入完成 m_ImportMappingFlag = true; } else { MessageBox.Show(ResString.GetResString("Wave_Info_WaveMappingReadFinish"), "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); ControlsEnable(true); m_ComboBox_Channel_SelectedIndexChanged(null, null); m_ComboBox_VSD_SelectedIndexChanged(null, null); } } break; } } break; case CoreMsgEnum.Status_Change: { int status = lParam.ToInt32(); if ((JetStatusEnum)status == JetStatusEnum.Ready && IsAutoWave && IsAutoPrint && !IsAutoStop) { IsAutoPrint = false; AutoUpdateVave(); } else if ((JetStatusEnum)status == JetStatusEnum.Busy && IsAutoWave && !IsAutoPrint && !IsAutoStop) { IsAutoPrint = true; } break; } } }