private void OnEntryRegisterChanged() { if (m_regEntryTextBox.Text.Length == 0) { // if nothing in the text box m_registerName.Text = string.Empty; // m_registerName.Text = ("Enter register value in the text box above."); m_regEntryTextBox.BackColor = Color.PaleGreen; return; } if (m_registerSet == RegisterSet.REGISTER_SET_IIDC) { uint registerVal = 0; try { // Get the text in the box registerVal = Convert.ToUInt32(m_regEntryTextBox.Text, 16); } catch (Exception ex) { m_registerName.Text = "Invalid"; m_regEntryTextBox.BackColor = Color.Red; return; } string regValString = ManagedCameraBase.GetRegisterString(registerVal); if (regValString.Equals("Invalid")) { m_regEntryTextBox.BackColor = Color.Red; } else { m_regEntryTextBox.BackColor = Color.PaleGreen; } m_registerName.Text = regValString; } else if (m_registerSet == RegisterSet.REGISTER_SET_GEV) { m_registerName.Text = "Unknown"; m_regEntryTextBox.BackColor = Color.PaleGreen; } }
private void ReadRegisterBlockValueFromCamera() { // Get the text in the box uint regBlockOffset = 0; try { // Get the text in the box regBlockOffset = Convert.ToUInt32(m_regBlockEntryTextBox.Text, 16); } catch (ArgumentException ex) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); ShowErrorMessageDialog("Invalid argument in function ReadRegisterBlockValueFromCamera().", ex); return; } catch (FormatException ex) { Debug.WriteLine(ex.Message); MessageBox.Show( "Please enter a valid register address.", "Invalid Register Address", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } catch (OverflowException ex) { Debug.WriteLine(ex.Message); MessageBox.Show( "The number you entered is too large. Please enter a valid register address.", "Invalid Register Address", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int numQuadlets = Convert.ToInt32(m_numOfQuadletsToReadSpinButton.Value); uint[] values = new uint[numQuadlets]; if (m_registerSet == RegisterSet.REGISTER_SET_IIDC) { try { m_camera.ReadRegisterBlock(0xFFFF, regBlockOffset + 0xF0F00000, values); } catch (FC2Exception ex) { ShowErrorMessageDialog( string.Format( "There was an error reading IIDC register block 0x{0:X8} - 0x{1:X8}.", regBlockOffset, regBlockOffset + (4 * numQuadlets)), ex); return; } } else if (m_registerSet == RegisterSet.REGISTER_SET_GEV) { if (IsGEV() != true) { return; } ManagedGigECamera camera = (ManagedGigECamera)m_camera; try { camera.ReadGVCPRegisterBlock(regBlockOffset, values); } catch (FC2Exception ex) { ShowErrorMessageDialog( string.Format( "There was an error reading GVCP register block 0x{0:X8} - 0x{1:X8}.", regBlockOffset, regBlockOffset + (4 * numQuadlets)), ex); return; } } m_lastRegBlockOffset = regBlockOffset; m_regValueBlock.Rows.Clear(); m_updatingDatagridview = true; for (int i = 0; i < numQuadlets; i++) { uint currentRegVal = (uint)(regBlockOffset + (i * 4)); m_regValueBlock.Rows.Add(new DataGridViewRow()); m_regValueBlock.Rows[i].Cells[0].Value = string.Format("0x{0:X}", currentRegVal); m_regValueBlock.Rows[i].Cells[1].Value = string.Format("0x{0:X8}", values[i]); double ieeeVal = MathUtilities.Convert32bitIEEEToFloat(values[i]); m_regValueBlock.Rows[i].Cells[2].Value = ieeeVal; m_regValueBlock.Rows[i].Cells[3].Value = ManagedCameraBase.GetRegisterString(currentRegVal); } m_updatingDatagridview = false; }