C/C++ Sample source code
-- showing console style application for simplicity --
-----   Level 1   -----
( use when no changing of   default configuration,   parameters required )   --




A little about this document
Quick jump to
Screenshots    .cpp source code file sample    .h header file sample     About this document     Log File sample



This documentation was created using the sample application found within     .  
It's intended be used as a reference to understand the simplicity of interracting with the  Model 201   using the combination of VisualC++ and our   M201_SP.DLL   dynamically linked library. The code shown could easily be converted to the very basic ANSI C format  ( most of it already is just that )  since a console output   is used instead of a GUI interface. The Library is included in the archive linked to above and all available   function calls   are well documented.

Shown here is the simplicity required to interract with the  Model 201  using   M201_SP.DLL.  Only two simple function calls,  EX_Run( )  and  EX_Stop( )  into the DLL are required providing that you have connected the   Model 201  to COM-1, a log file containing the data is acceptable, your analog data is connected to channel 0 of the  Model 201.

This documention, shows the main source code file, the header file, and the data log file that is created. Follow the links just above to jump to each.
































































The Application Screenshots
Quick jump to
Screenshots    .cpp source code file sample    .h header file sample     About this document     Log File sample



 
Starting Run
starts automatically using COM-1 and other defaults
Running and logging to disk file
press  'Q'  to exit
Run has stopped
log file closed - key to close the DOS window

































































The C++ Source Code file
Quick jump to
Screenshots    .cpp source code file sample    .h header file sample     About this document     Log File sample




// filename: mainSamp.cpp
// Demonstrates using  "EX_Run()"  and  "EX_Stop()"  to start scanning and logging to disk file using all default settings. 
// Also shows how to setup pointers (in header file) for calling DLL functions and the way to use those pointers.

#include <windows.h>
#include <stdlib.h>
#include <wtypes.h>
#include <conio.h>
#include <stdio.h>
#include "mainSamp.h"

BOOLEAN InitLibFuncs()
{
          hLib201 = LoadLibrary ("M201_SP.dll");   if(!hLib201) return FALSE;
          EX_Run = (P_DLL_EX_RUN)GetProcAddress( hLib201, "EX_Run" );     if( !EX_Run ) return FALSE;
          EX_Stop = (P_DLL_EX_STOP)GetProcAddress( hLib201, "EX_Stop" );     if( !EX_Stop ) return FALSE;
          return TRUE;
}

int __cdecl main()
{
          if(!InitLibFuncs()){ printf( "Failed to find load required DLL and/or find required functions" ); getch(); return 0;}
          printf("Success finding required functions\nStarting RUN - please wait. . .");

          if( !  EX_Run( )  ){ printf( "Failed calling EX_Run()" ); getch(); return 0;}
          printf( "\n\nRUNNING and logging to ScanLog_x.txt\nPress 'Q' to stop run and quit " );

          char cUserInputVal = NULL;
          while(( cUserInputVal != 'Q' ) && ( cUserInputVal != 'q' ))
          {
                    cUserInputVal = (char)getch();
                    switch(cUserInputVal)
                    {
                              case 'Q': case 'q':
                                        if( !  EX_Stop( )  )printf( "Failed calling EX_Stop()" );
                                        else printf( "\n\nSuccess calling EX_Stop()" );
                                        printf( "\npress any key to continue to exit\n" );
                                        getch();
                                        break;
                    }
          }
          return 1;
}









































The C++ Header file
Quick jump to
Screenshots    .cpp source code file sample    .h header file sample     About this document     Log File sample



//filename: mainSamp.h

HMODULE hLib201 = NULL;

typedef   BOOLEAN( *P_DLL_EX_RUN )  (void);
P_DLL_EX_RUN   EX_Run = NULL;

typedef   BOOLEAN( *P_DLL_EX_STOP )  (void);
P_DLL_EX_STOP   EX_Stop = NULL;










































Sample Log File
Quick jump to
Screenshots    .cpp source code file sample    .h header file sample     About this document     Log File sample



Time / s   	0 - 0    	
00000.0   	1.4847893	
00000.1   	1.4847744	
00000.2   	1.4847792	
00000.3   	1.4847816	
00000.3   	1.4847762	
00000.4   	1.4847774	
00000.5   	1.4847816	
00000.6   	1.4847816	
00000.7   	1.4847732	
00000.8   	1.4847816	
00000.9   	1.4847792	
00001.0   	1.4847720	
00001.0   	1.4847762	
00001.1   	1.4847726	
00001.2   	1.4847786	
00001.3   	1.4847738	
00001.4   	1.4847726	
00001.5   	1.4847762	
00001.6   	1.4847726	
00001.7   	1.4847828	
00001.7   	1.4847762	
00001.8   	1.4847792	
00001.9   	1.4847762	
00002.0   	1.4847756	
00002.1   	1.4847792	
00002.2   	1.4847780	
00002.3   	1.4847714	
00002.4   	1.4847756	
00002.4   	1.4847798	
00002.5   	1.4847756	
00002.6   	1.4847786	
00002.7   	1.4847738	
00002.8   	1.4847792	
00002.9   	1.4847786	

Minimal System Interval:	0.08678
Applied Interval:        	0.08704
Subcycles averaged:      	35
Started:                 	Fri Nov 05 14:41:36 2004
Finished:                	Fri Nov 05 14:41:39 2004
Experiment Description:  	none

















Contact us for sales or technical assistance
lawsnlab@lawsonlabs.com

on the web
www.lawsonlabs.com

© Lawson Labs Inc. All rights reserved
Last modified 11-8-04 Tim Van Dusen