⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hpe1463a.c

📁 CVI教程,用于信号采集系统的多任务开发软件.学习简单,功能实用.
💻 C
📖 第 1 页 / 共 5 页
字号:
/*****************************************************************************  *  Copyright 1998 National Instruments Corporation.  All Rights Reserved.   *  *****************************************************************************//***************************************************************************** *  Hewlett-Packard E1463A 32-Channel Switch Instrument Driver                                *  LabWindows/CVI 5.0 Instrument Driver                                      *  Original Release: 3/31/98                                   *  By: SZ, National Instruments                               *      PH. (512) 795-8248   Fax (512) 794-5678                               *                                                                            *  Modification History:                                                     *                                                                            *       3/31/98 - Instrument Driver Created.                   *                                                                            *****************************************************************************/#include <string.h>#include <stdio.h>  #include <formatio.h>#include <utility.h>#include <ctype.h>#include "hpe1463a.h"/***************************************************************************** *--------------------- Hidden Attribute Declarations -----------------------* *****************************************************************************/#define HPE1463A_ATTR_OPC_TIMEOUT                      (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 1L)    /* ViInt32 */#define HPE1463A_ATTR_CHANNEL_MATRIX                   (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 101L)  /* ViAddr */#define HPE1463A_ATTR_ORIGINAL_SOURCE_CHANNEL_INDEX    (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 102L)  /* ViInt32, channel-based */#define HPE1463A_ATTR_CONFIGURATION_CHANNEL_INDEX      (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 103L)  /* ViInt32, channel-based */#define HPE1463A_ATTR_IS_MUX_CHANNEL                   (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 104L)  /* ViBoolean, channel-based */#define HPE1463A_ATTR_MAXIMUM_DEPTH                    (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 105L)  /* ViInt32 */#define HPE1463A_ATTR_SETTLING_MOMENT                  (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 106L)  /* ViReal64 */ #define HPE1463A_ATTR_SWITCH_STATE_L                   (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 107L)  /* ViInt32 */#define HPE1463A_ATTR_SWITCH_STATE_H                   (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 108L)  /* ViInt32 *//***************************************************************************** *---------------------------- Useful Macros --------------------------------* *****************************************************************************/    /*- VXI Offsets for the Switch Control Registers ------------------------*/#define VXI_STATUS_CONTROL_REGISTER                           4#define VXI_RELAY_CONTROL_REGISTER_L                          6#define VXI_RELAY_CONTROL_REGISTER_H                          8    /*- VXI flags for the Status/Control Register ---------------------------*/#define HPE1463A_VAL_SOFT_RESET_BIT                         (1<<0)    /*- Miscellaneous -------------------------------------------------------*/#define BUFFER_SIZE                             512L        #define HPE1463A_VAL_ALL_NC                     0x0#define HPE1463A_VAL_NONE                       0    /*- List of channels passed to the Ivi_BuildChannelTable function -------*/ #define CHANNEL_LIST                            "00NO,01NO,02NO,03NO,04NO,05NO,06NO,07NO,"\                                                "08NO,09NO,10NO,11NO,12NO,13NO,14NO,15NO,"\                                                "16NO,17NO,18NO,19NO,20NO,21NO,22NO,23NO,"\                                                "24NO,25NO,26NO,27NO,28NO,29NO,30NO,31NO,"\                                                "00C,01C,02C,03C,04C,05C,06C,07C,"\                                                "08C,09C,10C,11C,12C,13C,14C,15C,"\                                                "16C,17C,18C,19C,20C,21C,22C,23C,"\                                                "24C,25C,26C,27C,28C,29C,30C,31C,"\                                                "00NC,01NC,02NC,03NC,04NC,05NC,06NC,07NC,"\                                                "08NC,09NC,10NC,11NC,12NC,13NC,14NC,15NC,"\                                                "16NC,17NC,18NC,19NC,20NC,21NC,22NC,23NC,"\                                                "24NC,25NC,26NC,27NC,28NC,29NC,30NC,31NC,"    /* Defined values for the flags in the channel matrix */#define HPE1463A_VAL_CHANNELS_DIRECTLY_CONNECTED   (1<<0)      /*  The two channels are connected without any      */                                                               /*  interceding configuration channels.             */                                                               /*  Either of the two channels may be a             */                                                               /*  configuration channel.                          */                                                                            #define HPE1463A_VAL_CHANNELS_EXPLICITLY_CONNECTED (1<<1)      /*  The user has connected the two channels         */                                                               /*  explicitly by calling either hpe1463a_Connect   */                                                               /*  or hpe1463a_SetPath.  Neither channel can be    */                                                               /*  a configuration channel.                        */#define HPE1463A_VAL_DIRECT_CONNECTION_IMPOSSIBLE  (1<<2)      /*  These channels can never be directly conected   */#define HPE1463A_VAL_RESERVED_FOR_RECURSION        (1<<3)      /*  This flag is always set on the first column. It */                                                               /*  is temporarily set for a channel before        */                                                               /*  entering the recursive call. This prevents the */                                                               /*  channel from being used in the recursive call. */                                                                                /* Defined macros for accessing flags in the channel matrix */#define hpe1463a_ChannelsAreDirectlyConnected(ch1, ch2)                               \                        ((connections[ch1][ch2] & HPE1463A_VAL_CHANNELS_DIRECTLY_CONNECTED) != 0)#define hpe1463a_ChannelsAreExplicitlyConnected(ch1, ch2)                               \                        ((connections[ch1][ch2] & HPE1463A_VAL_CHANNELS_EXPLICITLY_CONNECTED) != 0)#define hpe1463a_DirectConnectionIsPossible(ch1, ch2)                                     \                        ((connections[ch1][ch2] & HPE1463A_VAL_DIRECT_CONNECTION_IMPOSSIBLE) == 0)#define hpe1463a_RecursionOnChannelIsAllowed(ch)                          \                        ((connections[ch][1] & HPE1463A_VAL_RESERVED_FOR_RECURSION) == 0)#define hpe1463a_MarkChannelsAsDirectlyConnected(ch1, ch2)                            \                        {                                                            \                        connections[ch1][ch2] |= HPE1463A_VAL_CHANNELS_DIRECTLY_CONNECTED;\                        connections[ch2][ch1] |= HPE1463A_VAL_CHANNELS_DIRECTLY_CONNECTED;\                        }#define hpe1463a_MarkChannelsAsExplicitlyConnected(ch1, ch2)                            \                        {                                                            \                        connections[ch1][ch2] |= HPE1463A_VAL_CHANNELS_EXPLICITLY_CONNECTED;\                        connections[ch2][ch1] |= HPE1463A_VAL_CHANNELS_EXPLICITLY_CONNECTED;\                        }#define hpe1463a_PreventRecursionOnChannel(ch)                          \                        {                                                               \                        connections[ch][1] |= HPE1463A_VAL_RESERVED_FOR_RECURSION;\                        }#define hpe1463a_MarkChannelsAsNotDirectlyConnected(ch1, ch2)                                \                        {                                                   \                        connections[ch1][ch2] &= ~HPE1463A_VAL_CHANNELS_DIRECTLY_CONNECTED;\                        connections[ch2][ch1] &= ~HPE1463A_VAL_CHANNELS_DIRECTLY_CONNECTED;\                        }#define hpe1463a_MarkChannelsAsNotExplicitlyConnected(ch1, ch2)                                \                        {                                                   \                        connections[ch1][ch2] &= ~HPE1463A_VAL_CHANNELS_EXPLICITLY_CONNECTED;\                        connections[ch2][ch1] &= ~HPE1463A_VAL_CHANNELS_EXPLICITLY_CONNECTED;\                        }#define hpe1463a_AllowRecursionOnChannel(ch)                          \                        {                                                               \                        connections[ch][1] &= ~HPE1463A_VAL_RESERVED_FOR_RECURSION;\                        }/***************************************************************************** *-------------- Utility Function Declarations (Non-Exported) ---------------* *****************************************************************************/static ViStatus hpe1463a_InitAttributes (ViSession vi);static ViStatus hpe1463a_DefaultInstrSetup (ViSession openInstrSession);static ViStatus hpe1463a_SourceChannelConflict (ViSession vi, ViConstString channel1,                                                 ViConstString channel2,                                                ViBoolean *hasConflict);static ViStatus hpe1463a_VerifySourceChannelConflict (ViSession vi,                                                       ViConstString channel1,                                                       ViConstString channel2);static ViStatus hpe1463a_IsEitherAConfigChannel (ViSession vi,                                                  ViConstString channel1,                                                  ViConstString channel2,                                                 ViBoolean *atLeastOneIsAConfigChannel);static ViStatus hpe1463a_VerifyIsEitherAConfigChannel (ViSession vi,                                                        ViConstString channel1,                                                        ViConstString channel2);static ViStatus hpe1463a_IsUnconnectedConfigChannel (ViSession vi,                                                      ViConstString channel,                                                     ViBoolean *isUnconnectedConfigChannel);static ViStatus hpe1463a_GetConfigChannelInfo (ViSession vi,                                                ViConstString channel,                                               ViBoolean *isConfigChannel,                                               ViInt32 *ndxConnectedToChannel);static ViStatus hpe1463a_GetPossiblePath (ViSession vi,                                           ViConstString channel1,                                          ViConstString channel2,                                           ViInt32 maxDepth,                                          ViString *path);static ViStatus hpe1463a_GetPossiblePathRecursively (ViSession vi,                                                      ViInt32 ndxChannel1,                                                      ViInt32 ndxChannel2,                                                      ViInt32 **connections,                                                      ViInt32 numChannels,                                                      ViString *path,                                                      ViInt32 oldSize,                                                     ViInt32 maxRemainingSteps,                                                     ViInt32 *numSteps);static ViStatus hpe1463a_GetExistingPath (ViSession vi,                                           ViConstString channel1,                                          ViConstString channel2,                                           ViString *path);static ViStatus hpe1463a_GetExistingPathRecursively (ViSession vi,                                                      ViInt32 ndxChannel1,                                                      ViInt32 ndxChannel2,                                                      ViInt32 **connections,                                                      ViInt32 numChannels,                                                      ViString *path,                                                      ViInt32 oldSize);static ViStatus hpe1463a_GetFirstAndLastChannelInPath (ViSession vi,                                                        ViConstString path,                                                       ViChar firstChannel[],                                                       ViChar lastChannel[]);static ViString hpe1463a_FormatPathLegErrorElab (ViConstString channel1,                                                 ViConstString channel2,                                                 ViChar elabBuf[]);static ViStatus hpe1463a_VerifyNotConnectedMux (ViSession vi,                                                 ViConstString channel);static ViStatus hpe1463a_VerifyPath (ViSession vi, ViConstString path);static ViStatus hpe1463a_VerifyPathRecursively (ViSession vi,                                                 ViConstString path,                                                ViInt32 offset,                                                ViInt32 ndxPrevLast,                                                ViInt32 **connections);static ViStatus hpe1463a_ConnectPathOnInstrument (ViSession vi, ViSession io,                                                  ViConstString path);static ViStatus hpe1463a_IsConnectedMuxChannel (ViSession vi,                                                 ViConstString channel,                                                ViBoolean *muxChannelConnected);static ViStatus hpe1463a_MarkPathAsConnected (ViSession vi, ViConstString path);static ViStatus hpe1463a_MarkPathAsDisconnected (ViSession vi, ViConstString path);static ViStatus hpe1463a_MarkAllAsDisconnected (ViSession vi);static ViStatus hpe1463a_MarkOriginalSourceRecursively (ViSession vi,                                                         ViInt32 ndxChannel,                                                         ViInt32 originalIndex,                                                         ViInt32 numChannels,                                                         ViInt32 **connections);static ViStatus hpe1463a_RecalculateSourceInformation (ViSession vi,                                                       ViInt32 **connections,                                                       ViInt32 ndxTheSource);static ViStatus hpe1463a_MarkConnectionAlongPath (ViSession vi, ViConstString channel1,                                                   ViConstString channel2);static ViStatus hpe1463a_DeleteConnectionAlongPath (ViSession vi, ViConstString channel1,                                                     ViConstString channel2);static ViStatus hpe1463a_IsPathSupported (ViSession vi, ViInt32 ndxChannel1,                                           ViInt32 ndxChannel2,                                           ViInt32 **connections,                                           ViInt32 maxDepth,                                          ViBoolean *result);static ViStatus hpe1463a_IsPathAvailable (ViSession vi, ViInt32 ndxChannel1,                                           ViInt32 ndxChannel2,                                           ViInt32 **connections,                                           ViInt32 maxDepth,                                          ViBoolean *result);static ViStatus hpe1463a_IsPathAvailableRecursively (ViSession vi,                                                      ViInt32 ndxChannel1,                                                      ViInt32 ndxChannel2,                                                      ViInt32 **connections,                                                      ViInt32 numChannels,                                                     ViInt32 maxDepth,                                                     ViBoolean *result);static ViStatus hpe1463a_ImplicitConnectionExists (ViSession vi,                                                   ViConstString channel1,                                                   ViConstString channel2,                                                    ViBoolean *connectionExists);                                                   static void hpe1463a_CalculatePathLegSize (ViConstString channel1,                                            ViConstString channel2,                                           ViInt32 *legSize);static void hpe1463a_CleanPath (ViChar string[]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -