void ProcSetYp7() { byte boardAddr = (byte)(int.Parse(((FormMain)(this.Parent.Parent)).txtBoardAddr.Text)); byte ch = (byte)(int.Parse(txtChNo.Text)); float freq; float lowFreq; Int16 val = 0; try { Funs485.Rst(boardAddr); Thread.Sleep(1500); Board brd = new Board(boardAddr, 8); for (int i = 0; i < 7; i++) { brd.AddCh(new ParamCh((byte)45)); } byte[] paramAyy = brd.ToByteAry(); Funs485.SendParam(paramAyy); Thread.Sleep(20); Funs485.StartBoard(boardAddr); while (true) { Thread.Sleep(1000); if (Funs485.ReadAnalogCh(boardAddr, ch, out val, out freq, out lowFreq) == false) { MessageBox.Show("�ɼ�ʧ��"); return; } txtUpVal.Text = val.ToString(); ShowText(lblUpVal, val.ToString()); ShowText(lblUpFreq, freq.ToString()); ShowText(lblLowFreq, freq.ToString()); } } catch (System.Exception ex) { } finally { } }
void ProcCalcDcI66() { byte boardAddr = (byte)(int.Parse(((FormMain)(this.Parent.Parent)).txtBoardAddr.Text)); byte ch = (byte)(int.Parse(txtChNo.Text)); UInt16 oldOffset; UInt16 oldCoff; Int16 val = 0; try { Board brd = new Board(boardAddr, 11); for (int i = 0; i < 6; i++) { brd.AddCh(new ParamCh((byte)66)); } byte[] paramAyy = brd.ToByteAry(); MessageBox.Show("��ȷ��δ���ź�"); if (Funs485.ReadAnalogCh(boardAddr, ch, out val) == false) { Funs485.Rst(boardAddr); Thread.Sleep(1500); Funs485.SendParam(paramAyy); Thread.Sleep(20); Funs485.StartBoard(boardAddr); Thread.Sleep(1000); if (Funs485.ReadAnalogCh(boardAddr, ch, out val) == false) { MessageBox.Show("�ɼ�ʧ��"); return; } ShowText(txtUpVal, val.ToString()); } Funs485.Rst(boardAddr); Thread.Sleep(1500); if (Funs485.ReadDebugReg((byte)boardAddr, (UInt16)(0x10 + ch), out oldCoff) != true) { MessageBox.Show("��ԭϵ��ʧ��"); } if (Funs485.ReadDebugReg((byte)boardAddr, (UInt16)(ch), out oldOffset) != true) { MessageBox.Show("��ԭƫ��ʧ��"); } //����ƫ= val/ ϵ��+����ƫ Int16 newOff = (Int16)((float)val * ((float)oldCoff / 4096) + oldCoff); if (newOff < 0) { MessageBox.Show("����ƫ��Ϊ��"); return; } if (Funs485.WriteDebugReg(boardAddr, (UInt16)0xffff, (UInt16)0x55aa) == false) { MessageBox.Show("����1ʧ��"); return; } Thread.Sleep(20); if (Funs485.WriteDebugReg(boardAddr, (UInt16)0xffff, (UInt16)0xaa55) == false) { MessageBox.Show("����2ʧ��"); return; } Thread.Sleep(20); Funs485.WriteDebugReg(boardAddr, ch, (UInt16)newOff); Thread.Sleep(20); Funs485.WriteDebugReg(boardAddr, 0x210, 0x55); Thread.Sleep(20); Funs485.SendParam(paramAyy); Thread.Sleep(20); Funs485.StartBoard(boardAddr); while (true) { if (Funs485.ReadAnalogCh(boardAddr, ch, out val) == false) { MessageBox.Show("�ɼ�ʧ��"); } } } catch (System.Exception ex) { } finally { } }
void ProcSetGy() { byte boardAddr = (byte)(int.Parse(((FormMain)(this.Parent.Parent)).txtBoardAddr.Text)); byte ch = (byte)(int.Parse(txtChNo.Text)); Int16 val = 0; try { Funs485.Rst(boardAddr); Thread.Sleep(1500); Board brd = new Board(boardAddr, 9); brd.AddCh(new ParamCh((byte)88)); for (int i = 1; i < 3; i++) { brd.AddCh(new ParamCh((byte)66)); } brd.AddCh(new ParamCh((byte)88)); for (int i = 1; i < 3; i++) { brd.AddCh(new ParamCh((byte)66)); } byte[] paramAyy = brd.ToByteAry(); Funs485.SendParam(paramAyy); Thread.Sleep(20); Funs485.StartBoard(boardAddr); while (true) { Thread.Sleep(1000); if (Funs485.ReadAnalogCh(boardAddr, ch, out val) == false) { MessageBox.Show("�ɼ�ʧ��"); } ShowText(txtUpVal, val.ToString()); } } catch (System.Exception ex) { } finally { } }