jerrym | f157933 | 2013-02-07 01:56:28 +0000 | [diff] [blame] | 1 | /********************************************************************************
|
| 2 | * Project : FIRST Motor Controller
|
| 3 | * File Name : BaeUtilities.h
|
| 4 | * Contributors : JDG, ELF
|
| 5 | * Creation Date : August 12, 2008
|
| 6 | * Revision History : Source code & revision history maintained at sourceforge.WPI.edu
|
| 7 | * File Description : Globally defined values for utilities
|
| 8 | */
|
| 9 | /*----------------------------------------------------------------------------*/
|
| 10 | /* Copyright (c) FIRST 2008. All Rights Reserved. */
|
| 11 | /* Open Source Software - may be modified and shared by FRC teams. */
|
| 12 | /* Must be accompanied by the BSD license file in $(WIND_BASE)/WPILib. */
|
| 13 | /*----------------------------------------------------------------------------*/
|
| 14 |
|
| 15 | #ifndef __BAEUTILITIES_H__
|
| 16 | #define __BAEUTILITIES_H__
|
| 17 |
|
| 18 | /* Constants */
|
| 19 | #define LOG_DEBUG __FILE__,__FUNCTION__,__LINE__,DEBUG_TYPE
|
| 20 | #define LOG_INFO __FILE__,__FUNCTION__,__LINE__,INFO_TYPE
|
| 21 | #define LOG_ERROR __FILE__,__FUNCTION__,__LINE__,ERROR_TYPE
|
| 22 | #define LOG_CRITICAL __FILE__,__FUNCTION__,__LINE__,CRITICAL_TYPE
|
| 23 | #define LOG_FATAL __FILE__,__FUNCTION__,__LINE__,FATAL_TYPE
|
| 24 | #define LOG_DEBUG __FILE__,__FUNCTION__,__LINE__,DEBUG_TYPE
|
| 25 |
|
| 26 | /* Enumerated Types */
|
| 27 |
|
| 28 | /** debug levels */
|
| 29 | enum dprint_type {DEBUG_TYPE, INFO_TYPE, ERROR_TYPE, CRITICAL_TYPE, FATAL_TYPE};
|
| 30 |
|
| 31 | /** debug output setting */
|
| 32 | typedef enum DebugOutputType_enum {
|
| 33 | DEBUG_OFF, DEBUG_MOSTLY_OFF, DEBUG_SCREEN_ONLY, DEBUG_FILE_ONLY, DEBUG_SCREEN_AND_FILE
|
| 34 | }DebugOutputType;
|
| 35 |
|
| 36 | /* Enumerated Types */
|
| 37 |
|
| 38 | /* Utility functions */
|
| 39 |
|
| 40 | /* debug */
|
| 41 | void SetDebugFlag ( DebugOutputType flag );
|
| 42 | void dprintf ( char * tempString, ... ); /* Variable argument list */
|
| 43 |
|
| 44 | /* set FRC ranges for drive */
|
| 45 | double RangeToNormalized(double pixel, int range);
|
| 46 | /* change normalized value to any range - used for servo */
|
| 47 | float NormalizeToRange(float normalizedValue, float minRange, float maxRange);
|
| 48 | float NormalizeToRange(float normalizedValue);
|
| 49 |
|
| 50 | /* system utilities */
|
| 51 | void ShowActivity (char *fmt, ...);
|
| 52 | double ElapsedTime (double startTime);
|
| 53 |
|
| 54 | /* servo panning utilities */
|
| 55 | class Servo;
|
| 56 | double SinPosition (double *period, double sinStart);
|
| 57 | void panInit();
|
| 58 | void panInit(double period);
|
| 59 | void panForTarget(Servo *panServo);
|
| 60 | void panForTarget(Servo *panServo, double sinStart);
|
| 61 |
|
| 62 | /* config file read utilities */
|
| 63 | int processFile(char *inputFile, char *outputString, int lineNumber);
|
| 64 | int emptyString(char *string);
|
| 65 | void stripString(char *string);
|
| 66 |
|
| 67 | #endif
|
| 68 |
|