Main Page Namespace List Compound List File List Namespace Members Compound Members

# tStatus.h

Go to the documentation of this file.

    00001
    00005 /*
    00006    © Copyright 2005-2006,
    00007    National Instruments Corporation.
    00008    All rights reserved.
    00009
    00010    File:        tStatus.h
    00011    Originated:  10 March 2005
    00012 */
    00013
    00014 #ifndef ___fantom_tStatus_h___
    00015 #define ___fantom_tStatus_h___
    00016
    00017 // includes ...
    00018
    00019 #ifndef ___fantom_platform_h___
    00020    #include "platform.h"
    00021 #endif
    00022
    00023 #include <string.h>
    00024
    00025
    00026 // defines...
    00027
    00028 #define nFANTOM_mLocation __FILE__, __LINE__
    00029
    00030 #define nFANTOM_ForceToWarning(s)     (((s) >= 0 ) ? (s) : -(s))
    00031 #define nFANTOM_ForceToFatal(s)       (((s) <= 0 ) ? (s) : -(s))
    00032
    00036 namespace nFANTOM100
    00037 {
    00038    // forward declarations...
    00039
    00040    // typedefs...
    00041
    00042    // classes...
    00043    const ViInt32 kStatusOffset = -142000; // 0xFFFDD550
    00044    const ViStatus kStatusSuccess = VI_SUCCESS;
    00045
    00051    enum tFANTOMStatus
    00052    {
    00053       kStatusFirst                        = (kStatusOffset + 0),
    00054
    00057       kStatusPairingFailed                = (kStatusOffset + -5),    // 0x54B
    00058
    00060       kStatusBluetoothSearchFailed        = (kStatusOffset + -6),    // 0x54A
    00061
    00063       kStatusSystemLibraryNotFound        = (kStatusOffset + -7),    // 0x549
    00064
    00066       kStatusUnpairingFailed              = (kStatusOffset + -8),    // 0x548
    00067
    00069       kStatusInvalidFilename              = (kStatusOffset + -9),    // 0x547
    00070
    00072       kStatusInvalidIteratorDereference   = (kStatusOffset + -10),   // 0x546
    00073
    00075       kStatusLockOperationFailed          = (kStatusOffset + -11),   // 0x545
    00076
    00078       kStatusSizeUnknown                  = (kStatusOffset + -12),   // 0x544
    00079
    00081       kStatusDuplicateOpen                = (kStatusOffset + -13),   // 0x543
    00082
    00085       kStatusEmptyFile                    = (kStatusOffset + -14),   // 0x542
    00086
    00088       kStatusFirmwareDownloadFailed       = (kStatusOffset + -15),   // 0x541
    00089
    00091       kStatusPortNotFound                 = (kStatusOffset + -16),   // 0x540
    00092
    00094       kStatusNoMoreItemsFound             = (kStatusOffset + -17),   // 0x53F
    00095
    00097       kStatusTooManyUnconfiguredDevices   = (kStatusOffset + -18),   // 0x53E
    00098
    00100       kStatusCommandMismatch              = (kStatusOffset + -19),   // 0x53D
    00101
    00103       kStatusIllegalOperation             = (kStatusOffset + -20),   // 0x53C
    00104
    00107       kStatusBluetoothCacheUpdateFailed   = (kStatusOffset + -21),   // 0x53B
    00108
    00110       kStatusNonNXTDeviceSelected         = (kStatusOffset + -22),   // 0x53A
    00111
    00113       kStatusRetryConnection              = (kStatusOffset + -23),   // 0x539
    00114
    00116       kStatusPowerCycleNXT                = (kStatusOffset + -24),   // 0x538
    00117
    00119       kStatusFeatureNotImplemented        = (kStatusOffset + -99),   // 0x4ED
    00120
    00122       kStatusFWIllegalHandle              = (kStatusOffset + -189),  // 0x493
    00123
    00125       kStatusFWIllegalFileName            = (kStatusOffset + -190),  // 0x492
    00126
    00128       kStatusFWOutOfBounds                = (kStatusOffset + -191),  // 0x491
    00129
    00131       kStatusFWModuleNotFound             = (kStatusOffset + -192),  // 0x490
    00132
    00134       kStatusFWFileExists                 = (kStatusOffset + -193),  // 0x48F
    00135
    00137       kStatusFWFileIsFull                 = (kStatusOffset + -194),  // 0x48E
    00138
    00140       kStatusFWAppendNotPossible          = (kStatusOffset + -195),  // 0x48D
    00141
    00143       kStatusFWNoWriteBuffers             = (kStatusOffset + -196),  // 0x48C
    00144
    00146       kStatusFWFileIsBusy                 = (kStatusOffset + -197),  // 0x48B
    00147
    00149       kStatusFWUndefinedError             = (kStatusOffset + -198),  // 0x48A
    00150
    00152       kStatusFWNoLinearSpace              = (kStatusOffset + -199),  // 0x489
    00153
    00155       kStatusFWHandleAlreadyClosed        = (kStatusOffset + -200),  // 0x488
    00156
    00158       kStatusFWFileNotFound               = (kStatusOffset + -201),  // 0x487
    00159
    00161       kStatusFWNotLinearFile              = (kStatusOffset + -202),  // 0x486
    00162
    00164       kStatusFWEndOfFile                  = (kStatusOffset + -203),  // 0x485
    00165
    00167       kStatusFWEndOfFileExpected          = (kStatusOffset + -204),  // 0x484
    00168
    00170       kStatusFWNoMoreFiles                = (kStatusOffset + -205),  // 0x483
    00171
    00173       kStatusFWNoSpace                    = (kStatusOffset + -206),  // 0x482
    00174
    00176       kStatusFWNoMoreHandles              = (kStatusOffset + -207),  // 0x481
    00177
    00179       kStatusFWUnknownErrorCode           = (kStatusOffset + -208),  // 0x480
    00180
    00181       kStatusLast                         = (kStatusOffset + -999)
    00182    };
    00183
    00188    class tStatus
    00189    {
    00190       public:
    00191
    00192          // methods
    00193
    00195
    00200          inline tStatus( void ) :
    00201                _code( VI_SUCCESS ),
    00202                _lineNumber( 0 )
    00203          {
    00204             _fileName[0] = '\0';
    00205          }
    00206
    00207
    00209
    00214          inline tStatus( const tStatus& status ) :
    00215                _code( status._code ),
    00216                _lineNumber( status._lineNumber )
    00217          {
    00218             ::strcpy( _fileName, "" );
    00219             ::strncat( _fileName, status._fileName, kMaxFileNameLength - 1 );
    00220          }
    00221
    00222
    00224
    00233          inline tStatus( ViStatus code, const char* fileName, ViUInt32 lineNumber ) :
    00234                _code( code ),
    00235                _lineNumber( lineNumber )
    00236          {
    00237             ::strcpy( _fileName, "" );
    00238             ::strncat( _fileName, reinterpret_cast<const char*>( fileName ), kMaxFileNameLength - 1 );
    00239          }
    00240
    00241
    00243          inline ~tStatus()
    00244          {
    00245          }
    00246
    00247
    00249
    00252          inline ViStatus getCode( void ) const
    00253          {
    00254             return _code;
    00255          }
    00256
    00257
    00259
    00262          inline const char* getFileName( void ) const
    00263          {
    00264             return _fileName;
    00265          }
    00266
    00267
    00269          //   generated.
    00274          inline ViUInt32 getLineNumber( void ) const
    00275          {
    00276             return _lineNumber;
    00277          }
    00278
    00279
    00281          //   appropriate.
    00293          inline void setCode( ViStatus code, const char* fileName, ViUInt32 lineNumber )
    00294          {
    00295             if(( isSuccess() && code != VI_SUCCESS ) || ( isNotFatal() && code < VI_SUCCESS ))
    00296             {
    00297                _code = code;
    00298                _lineNumber = lineNumber;
    00299                ::strcpy( _fileName, "" );
    00300                ::strncat( _fileName, fileName, kMaxFileNameLength - 1 );
    00301             }
    00302          }
    00303
    00304
    00306
    00315          inline void assign( const tStatus& status )
    00316          {
    00317             setCode( status.getCode(), status.getFileName(), status.getLineNumber());
    00318          }
    00319
    00320
    00322
    00325          inline void clear( void )
    00326          {
    00327             _code = VI_SUCCESS;
    00328             _lineNumber = 0;
    00329             _fileName[0] = '\0';
    00330          }
    00331
    00332
    00334
    00340          inline bool isFatal( void ) const
    00341          {
    00342             return ( _code < VI_SUCCESS );
    00343          }
    00344
    00346
    00352          inline bool isNotFatal( void ) const
    00353          {
    00354             return !isFatal();
    00355          }
    00356
    00357
    00359
    00365          inline bool isWarning( void ) const
    00366          {
    00367             return ( _code > VI_SUCCESS );
    00368          }
    00369
    00370
    00372
    00378          inline bool isSuccess( void ) const
    00379          {
    00380             return ( _code == VI_SUCCESS );
    00381          }
    00382
    00383       private:
    00384
    00385          // declared private to prevent assignment
    00386          tStatus& operator=(const tStatus& rhs);
    00387
    00388          enum
    00389          {
    00390             kMaxFileNameLength = 101
    00391          };
    00392
    00393          ViStatus _code;
    00394          ViChar   _fileName[ kMaxFileNameLength ];
    00395          ViUInt32 _lineNumber;
    00396    };
    00397
    00398
    00399    // declarations for globally-scoped globals...
    00400    inline ViStatus convertStatus( ViUInt8 firmwareStatus )
    00401    {
    00402       ViStatus status;
    00403       switch (firmwareStatus)
    00404       {
    00405       // each of these cases corresponds to a unique status code returned by the firmware
    00406       case 0x00 : status = kStatusSuccess;
    00407          break;
    00408       case 0x81 : status = kStatusFWNoMoreHandles; // No more available handles
    00409          break;
    00410       case 0x82 : status = kStatusFWNoSpace;   // No space
    00411          break;
    00412       case 0x83 : status = kStatusFWNoMoreFiles; // No more files
    00413          break;
    00414       case 0x84 : status = kStatusFWEndOfFileExpected; // End of file expected
    00415          break;
    00416       case 0x85 : status = kStatusFWEndOfFile; // End of file reached
    00417          break;
    00418       case 0x86 : status = kStatusFWNotLinearFile; // Not a linear file
    00419          break;
    00420       case 0x87 : status = kStatusFWFileNotFound; // File not found
    00421          break;
    00422       case 0x88 : status = kStatusFWHandleAlreadyClosed; // Handle is already closed
    00423          break;
    00424       case 0x89 : status = kStatusFWNoLinearSpace; // No linear space available
    00425          break;
    00426       case 0x8A : status = kStatusFWUndefinedError; // Undefined error
    00427          break;
    00428       case 0x8B : status = kStatusFWFileIsBusy; // File is busy
    00429          break;
    00430       case 0x8C : status = kStatusFWNoWriteBuffers; // No write buffers available
    00431          break;
    00432       case 0x8D : status = kStatusFWAppendNotPossible; // Append not possible
    00433          break;
    00434       case 0x8E : status = kStatusFWFileIsFull; // File is full
    00435          break;
    00436       case 0x8F : status = kStatusFWFileExists; // File already exists
    00437          break;
    00438       case 0x90 : status = kStatusFWModuleNotFound; // Module not found
    00439          break;
    00440       case 0x91 : status = kStatusFWOutOfBounds; // Out of module I/O map boundary
    00441          break;
    00442       case 0x92 : status = kStatusFWIllegalFileName; // Illegal file name
    00443          break;
    00444       case 0x93 : status = kStatusFWIllegalHandle; // Illegal handle
    00445          break;
    00446       default :
    00447          status = kStatusFWUnknownErrorCode;
    00448       }
    00449       return status;
    00450    }
    00451
    00452    // prototypes...
    00453
    00454 } // namespace nFANTOM100
    00455
    00456 // inline functions and function macros...
    00457
    00458 #endif // ___fantom_tStatus_h___

© Copyright 2005-2006, National Instruments Corporation. All rights reserved.