29
Signametrics
*
* Copy both SM4040.DLL and SM4040.LIB to the project directory.
*
***********************************************************************/
// #define WINAPI __stdcall
#include <windows.h>
#include <string.h>
#ifdef _Windows
#define _WINDOWS
#endif
#include “SM4040.H”
// functions declarations and error codes.
#include “ScanUser.H”
// All functions, range and rate info and function declarations.
int main(void){
int I, iScan = 0;
// Address first Scanner in the system
char
Read[16];
char
strMsg[256];
i = SCANInit(iScan");
// initialize SM4040
if(i<0)
MessageBox(0,"Initialization ERROR !", "Startup SM4040 DLL",MB_OK);
// Show Error
SCANSetConfig(iScan,TwoWire);
// Set to TwoWire configuration
SCANSelectChannel(iScan,32); // Close Channel 32 relay, and necessary path relays
MessageBox(0,strMsg, "Channel 32 is closed and settled",MB_OK);
// Show status
return
0L;
5.3 Visual Basic Front Panel Application
The Visual Basic front panel application,
SM4040.EXE,
is an interactive control panel for the SM4040 Scanners.
When it loads it will take a few seconds to initialize before the front panel is displayed.
The push buttons labeled and menus provide means to configure the Scanner and select channels. The panel has
several capabilities which are enabled and disabled according to the type of Scanner detected, and the current
configuration.
The source code file
GLOBAL.BAS
(in the installed
VisBasic
sub directory) contains the function declarations and
the various ranges, rates and other parameters that are required. These definitions are the duplicates of the “C”
header files required to write Visual Basic applications which interact with the driver DLL, along with some global
variables required for this particular front-panel application.
5.3.1 Visual Basic Simple Application
The following is a very simple panel application for VisualBasic, which is included with the installed software. The
two files, Global.Bas and SimplePanel.frm are presented here. This GUI panel contains six objects; a text box to
input channel to select, three option buttons to set configuration, a button to apply the channel selection and a text
line for displaying errors.
Global.bas module file contents:
Option Explicit
'function declarations
Declare Function SCANInit Lib "sm4040.dll" _
(ByVal nScanner As Long) As Long
Declare Function SCANSetConfig Lib "sm4040.dll" _
(ByVal nScanner As Long, ByVal Config As Long) As Long
Declare Function SCANErrString Lib "sm4040.dll" _
(ByVal nError As Long, ByVal errString As String, ByVal stringlen As Long) As Long
Declare Function SCANSelectChannel Lib "sm4040.dll" _
(ByVal nScanner As Long, ByVal nChannel As Long) As Long
'Configuration definitions for :
Global Const TwoWire = 0
Global Const FourWire = 7
Summary of Contents for SM4020
Page 61: ...Signametrics 60...