Now you can download a copy of these docs so you can use them offline! Download now
EnumCameraParameter.cpp
00001 /*----------------------------------------------------------------------------*/ 00002 /* Copyright (c) FIRST 2008. All Rights Reserved. */ 00003 /* Open Source Software - may be modified and shared by FRC teams. The code */ 00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ 00005 /*----------------------------------------------------------------------------*/ 00006 00007 #include "EnumCameraParameter.h" 00008 #include <stdio.h> 00009 #include <string.h> 00010 00020 EnumCameraParameter::EnumCameraParameter(const char *setString, const char *getString, bool requiresRestart, 00021 const char *const*choices, int numChoices) 00022 : IntCameraParameter(setString, getString, requiresRestart) 00023 { 00024 m_enumValues = choices; 00025 m_numChoices = numChoices; 00026 } 00027 00028 /* 00029 * Check if an enumeration camera parameter has changed. 00030 * Check if the parameter has changed and update the camera if it has. This is called 00031 * from a loop in the parameter checker task. 00032 * @returns true if the camera needs to restart 00033 */ 00034 bool EnumCameraParameter::CheckChanged(bool &changed, char *param) 00035 { 00036 changed = m_changed; 00037 if (m_changed) 00038 { 00039 m_changed = false; 00040 sprintf(param, m_setString, m_enumValues[m_value]); 00041 return m_requiresRestart; 00042 } 00043 return false; 00044 } 00045 00052 void EnumCameraParameter::GetParamFromString(const char *string, int stringLength) 00053 { 00054 char resultString[50]; 00055 if (SearchForParam(m_getString, string, stringLength, resultString) < 0) return; 00056 for (int i = 0; i < m_numChoices; i++) 00057 { 00058 if (strcmp(resultString, m_enumValues[i]) == 0) 00059 { 00060 if (!m_changed) // don't change parameter that's been set in code 00061 { 00062 m_value = i; 00063 } 00064 } 00065 } 00066 } 00067
Generated on Thu Jan 12 2012 22:35:20 for WPILibC++ by
1.7.1