'*****************************************************************************
'
' Module: Spectrum.inc
'
' Purpose:
'
'    This module contains definitions required when calling the Spectrum API 
'    routines from Visual Basic or Visual Basic for Applications (VBA).
'
'    *************************************************************************
'    *                                                                       *
'    *     Produced by:       Veriteq Instruments Inc.                       *
'    *                                                                       *
'    *                        Suite 113                                      *
'    *                        10451 Shellbridge Way                          *
'    *                        Richmond, British Columbia                     *
'    *                        Canada.   V6X 2W8                              *
'    *                                                                       *
'    *************************************************************************
'
'*****************************************************************************



'/////////////////////////////////////////////////////////////////////////////
' Miscellaneous definitions.
'/////////////////////////////////////////////////////////////////////////////

Option Explicit



'/////////////////////////////////////////////////////////////////////////////
' Define the status codes returned by the Spectrum API routines. Ensure 
' they are not the same as the dialog box button IDs (1-9).
'/////////////////////////////////////////////////////////////////////////////

Global Const SPC_SC_Success                  =      0
Global Const SPC_SC_UnknownError             =     -1
Global Const SPC_SC_Cancelled                =     -2
Global Const SPC_SC_InvMemoryAddress         =     -3
Global Const SPC_SC_InvComPortNumber         =     -4
Global Const SPC_SC_InvLoggerAddress         =     -5
Global Const SPC_SC_InvLoggerHandle          =     -6
Global Const SPC_SC_InvLoggerMode            =     -7
Global Const SPC_SC_InvChannelIndex          =     -8
Global Const SPC_SC_InvSerialNumber          =     -9
Global Const SPC_SC_FailStartTimer           =    -10
Global Const SPC_SC_FailAllocateMemory       =    -11
Global Const SPC_SC_FailDisableChannel       =    -12
Global Const SPC_SC_FailEnableChannel        =    -13
Global Const SPC_SC_FailClearDataPtr         =    -14
Global Const SPC_SC_FailClearWrapFlag        =    -15
Global Const SPC_SC_FailProgramLogger        =    -16
Global Const SPC_SC_InvTemperature           =    -17
Global Const SPC_SC_InvHumidity              =    -18
Global Const SPC_SC_InvSampleInterval        =    -19
Global Const SPC_SC_FieldReadOnly            =    -20
Global Const SPC_SC_FailCreateSpl            = -10000
Global Const SPC_SC_FailOpenSpl              = -10001
Global Const SPC_SC_FailReadSpl              = -10002
Global Const SPC_SC_InvSplFormat             = -10003
Global Const SPC_SC_InvSplDescription        = -10004
Global Const SPC_SC_InvSplStartTime          = -10005
Global Const SPC_SC_InvSplSystemBlock        = -10006
Global Const SPC_SC_InvSplSample             = -10007
Global Const SPC_SC_InvSplChecksum           = -10008
Global Const SPC_SC_InvSplUsername           = -10009
Global Const SPC_SC_InvSplPassword           = -10010
Global Const SPC_SC_InvSplCreationTime       = -10011
Global Const SPC_SC_NoSplChanEnabled         = -10012
Global Const SPC_SC_FailAllocateCom          = -20000
Global Const SPC_SC_FailAllocateCom1         = -20001
Global Const SPC_SC_FailAllocateCom2         = -20002
Global Const SPC_SC_FailAllocateCom3         = -20003
Global Const SPC_SC_FailAllocateCom4         = -20004
Global Const SPC_SC_FailSetupCom             = -20010
Global Const SPC_SC_FailSetupCom1            = -20011
Global Const SPC_SC_FailSetupCom2            = -20012
Global Const SPC_SC_FailSetupCom3            = -20013
Global Const SPC_SC_FailSetupCom4            = -20014
Global Const SPC_SC_FailCommCom              = -20020
Global Const SPC_SC_FailCommCom1             = -20021
Global Const SPC_SC_FailCommCom2             = -20022
Global Const SPC_SC_FailCommCom3             = -20023
Global Const SPC_SC_FailCommCom4             = -20024
Global Const SPC_SC_InvLoggerData            = -20030
Global Const SPC_SC_InvHardwareModel         = -20031
Global Const SPC_SC_DifferentLogger          = -20032
Global Const SPC_SC_FailPrintDoc             = -30000
Global Const SPC_SC_FailOpenClipbrd          = -30001
Global Const SPC_SC_FailEmptyClipbrd         = -30002
Global Const SPC_SC_FailCloseClipbrd         = -30003
Global Const SPC_SC_FailCopyToClipbrd        = -30004
Global Const SPC_SC_FailCreateExpFile        = -30005
Global Const SPC_SC_FailCreateBitmap         = -30006
Global Const SPC_SC_FailCopyBitmap           = -30007
Global Const SPC_SC_FailSelectBitmap         = -30008
Global Const SPC_SC_FailLoadBitmap           = -30009



'/////////////////////////////////////////////////////////////////////////////
' Define the types.
'/////////////////////////////////////////////////////////////////////////////

' Define the baud rates.
Global Const SPC_BaudRate_57600 = 57600
Global Const SPC_BaudRate_38400 = 38400
Global Const SPC_BaudRate_19200 = 19200
Global Const SPC_BaudRate_9600  = 9600
Global Const SPC_BaudRate_4800  = 4800
Global Const SPC_BaudRate_2400  = 2400
Global Const SPC_BaudRate_Auto  = -1



' Define the packet sizes.
Global Const SPC_PacketSize_512  = 512
Global Const SPC_PacketSize_256  = 256
Global Const SPC_PacketSize_128  = 128
Global Const SPC_PacketSize_64   = 64
Global Const SPC_PacketSize_32   = 32
Global Const SPC_PacketSize_16   = 16
Global Const SPC_PacketSize_Auto = -1



'/////////////////////////////////////////////////////////////////////////////
' Define some structures.
'/////////////////////////////////////////////////////////////////////////////

' Define the population structure.
Type SPT_Population
   ulLoggerAddress As Long
   szSerialNumber(0 to 8) As Byte
   szDescription(0 to 40) As Byte
   aucPadding(0 to 9) as Byte ' Pad to 16 byte boundary.
End Type



'/////////////////////////////////////////////////////////////////////////////
' Define the Spectrum API routines.
'/////////////////////////////////////////////////////////////////////////////

Declare Function SPAPI_GetApiDate Lib "spectrum.dll" _
   (ByVal pszApiDate As String) As Long

Declare Function SPAPI_GetApiVersion Lib "spectrum.dll" _
   (ByVal pszApiDate As String) As Long

Declare Function SPAPI_GetProtocol Lib "spectrum.dll" _
   (ByRef pbPhase2 As Long) As Long

Declare Function SPAPI_GetTemperatureScale Lib "spectrum.dll" _
   (ByRef pbCelsius As Long) As Long

Declare Function SPAPI_SetProtocol Lib "spectrum.dll" _
   (ByVal bPhase2 As Long) As Long

Declare Function SPAPI_SetTemperatureScale Lib "spectrum.dll" _
   (ByVal bCelsius As Long) As Long

Declare Function SPDLG_ClearLogger Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long) As Long

Declare Function SPDLG_ExploreNetwork Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long) As Long

Declare Function SPDLG_SetupChannels Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long) As Long

Declare Function SPDLG_SetupDescription Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long) As Long

Declare Function SPDLG_SetupLogger Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long) As Long

Declare Function SPDLG_SetupSampleInterval Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long) As Long

Declare Function SPDLG_TransferSamples Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long, _
    ByVal pszLoggerFileName As String) As Long

Declare Function SPLGR_ClearLogger Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long) As Long

Declare Function SPLGR_CreateLoggerObject Lib "spectrum.dll" _
   (ByRef pulLoggerHandle As Long) As Long

Declare Function SPLGR_DeleteLoggerObject Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long) As Long

Declare Function SPLGR_GetChannelDescription Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lChannelIndex As Long, _
    ByVal pszChannelDescription As String) As Long

Declare Function SPLGR_GetChannelEnabled Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lChannelIndex As Long, _
    ByRef pbChannelEnabled As Long) As Long

Declare Function SPLGR_GetChannelValue Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lChannelIndex As Long, _
    ByRef pdChannelValue As Double) As Long

Declare Function SPLGR_GetChannelSamples Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lChannelIndex As Long, _
    ByRef padChannelSamples As Double) As Long

Declare Function SPLGR_GetChannelUnits Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lChannelIndex As Long, _
    ByVal pszChannelUnits As String) As Long

Declare Function SPLGR_GetDescription Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal pszDescription As String) As Long

Declare Function SPLGR_GetFirmwareVersion Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal pszFirmwareVersion As String) As Long

Declare Function SPLGR_GetHardwareModel Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal pszHardwareModel As String) As Long

Declare Function SPLGR_GetHardwareRevision Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal pszHardwareRevision As String) As Long

Declare Function SPLGR_GetSampleCount Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByRef plSampleCount As Long) As Long

Declare Function SPLGR_GetSampleInterval Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByRef plSampleInterval As Long) As Long

Declare Function SPLGR_GetSampleStartTime Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByRef plSampleStartTime As Long) As Long

Declare Function SPLGR_GetSerialNumber Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal pszSerialNumber As String) As Long

Declare Function SPLGR_ReadChannelValues Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long) As Long

Declare Function SPLGR_ReadLogger Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal ulLoggerAddress As Long, _
    ByVal pszLoggerFileName As String) As Long

Declare Function SPLGR_ReadLoggerFile Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal pszLoggerFileName As String) As Long

Declare Function SPLGR_SetChannelDescription Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal lChannelIndex As Long, _
    ByVal pszChannelDescription As String) As Long

Declare Function SPLGR_SetChannelEnabled Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal lChannelIndex As Long, _
    ByVal bChannelEnabled As Long) As Long

Declare Function SPLGR_SetChannelUnits Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal lChannelIndex As Long, _
    ByVal pszChannelUnits As String) As Long

Declare Function SPLGR_SetDescription Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal pszDescription As String) As Long

Declare Function SPLGR_SetSampleInterval Lib "spectrum.dll" _
   (ByVal ulLoggerHandle As Long, _
    ByVal lComPortNumber As Long, _
    ByVal plSampleInterval As Long) As Long

Declare Function SPNWK_GetPopulation Lib "spectrum.dll" _
   (ByVal lComPortNumber As Long, _
    ByVal lMaxCount As Long, _
    ByRef pPopulation As SPT_Population, _
    ByRef plActualCount As Long) As Long

Declare Function SPUTL_FormatDate Lib "spectrum.dll" _
   (ByVal lTime As Long, _
    ByVal pszDateText As String) As Long

Declare Function SPUTL_FormatDateAndTime Lib "spectrum.dll" _
   (ByVal lTime As Long, _
    ByVal pszDateAndTimeText As String) As Long

Declare Function SPUTL_FormatStatusCode Lib "spectrum.dll" _
   (ByVal lStatusCode As Long, _
    ByVal pszStatusText As String) As Long

Declare Function SPUTL_FormatTime Lib "spectrum.dll" _
   (ByVal lTime As Long, _
    ByVal pszTimeText As String) As Long

Declare Function SPUTL_LoggerAddrToSerialNum Lib "spectrum.dll" _
   (ByVal ulLoggerAddress As Long, _
    ByVal pszSerialNumber As String) As Long

Declare Function SPUTL_SerialNumToLoggerAddr Lib "spectrum.dll" _
   (ByVal pszSerialNumber As String, _
    ByRef pulLoggerAddress As Long) As Long
