Lawson Labs, Inc.              
Ph  800 321-5355
Ph  610 725-8800
Fax 610 725-9344
www.lawsonlabs.com                                    
lawsnlab@lawsonlabs.com 


M401 Visual C++ Demo Application

Release History

Changes 01.16.2007.10

Change analog input range selection from option boxes to a combo box.

Changes 09.15.2006.9

- Uses the new DLL function - Pub_IsFirmwareVersionGreaterThanEqualTo, to check
if the firmware version on the M401 connected to the index supports 
Pub_GetScanTime, Pub_GetTimeDiff, before calling the functions.

- Click File -> Get RTC - Host time diff, to get Host time - RTC time in seconds



Changes 08.23.2006.8
- Demonstrates how to use of the new DLL function - Pub_GetScanTime
- Removed formatting error in multi-channel scan log file.

Changes 12.16.2005.7

- Load the new function -  Pub_GetLastError from M40x.dll. Call Pub_GetLastError every 
  few seconds to check if indices still connected to M401.

- BUGFIX - index's extended scan settings interpreted as extra settings by LoadExtraSettings.

- RETURN_CODE expanded to include new values - INVALID_STATE, RESERVED1,RESERVED2,
  RESERVED3,RESERVED4, NOT_CONNECTED.

- Graph is preserved when the application is refreshed.

- Graph plotting code streamlined

- Graph plotting fixed. Graph time base is fixed at 5 seconds.


Change 11.23.2005.6

- Supports 7V AD range

- Supports extended scanning. This demp application must be used with M40x.dll version
  11.15.2005 or later.

- Like the VB demo app, the VC demp app no longer prompts for the log file name 
 at the start of scan, instead, it generates the file name by combining 
the IP address and current data and time ('_' delimited)

- Format voltages for display/logging based on the AD range for atleast 22-bits.

- BUGFIXED -  In mult-chan scan and multi-chan-cal scan, digital input not aligned with corresponding
scan in the log file


Changes 09.07.2005.2
Increase voltage display precision - number of decimal places for smaller AD ranges


Changes 09.06.2005.1
- New AD range +/- 0.045 V
- Menu->Exit fix

Changes 12.17.2004

-  A bug present in all previous version would cause the application to crash on
   exit if there was no m401.cfg file in the directorly. This is bug is fixed in 
   this version.
   

Changes 11.29.2004.0

- additional comments added.

Changes 10.19.2004.2

- Supports +/- 0.2 V custom voltage range

Changes 11.24.2003.0

- The application demonstrates using the 4 methods of scan acquisition by the dll.
  See M401dll.txt for more detail. Polling the dll be performed in 2 ways by the VC 
  applicaiton: polling the dll in a timer, polling the dll in a separate thread.

- Priority of the second thread in the dll whethe event thread or polling can be 
  changed from "Thread Priority" menu.


Changes- 11.5.2003

Lack of synchronization between the main thread and the second - lowest priority thread
(don't confuse with the thread in the dll), which reads and updates scan data (when 
"USE_THREAD" in Callback.cfg file), may cause the application to crash when
user switches between indices, which are scanning.This is fixed from this version on 
by using a "mutex".The second thread must acquire the mutex before it can read
or update the new scan data likewise the main thread must acquire the mutex before
switching indices, the mutext ensures these two operations don't overlap causing a crash.
A deadlock will occur in the following situation: the second thread acquires the mutex, 
reads new scan data from the dll, and is in the process of updating controls on the
main dialog(Note: if a thread other than the main thread thread updates a MFC control a 
update message is sent to the message queue and the thread is blocked till the main
thread dispatches and acknowledge the message) at this instant if user attempts to switches
indices the main application thread will block (mutex held by the other thread), the other
thread cannot finish the update and release the mutex because it is waiting for MFC
update acknowledgement from the main thread! This is avoided by running the message 
queue for a while so that the second thread can finish updating and release the mutex 
when the main thread fails to acquire the mutex after blocking for 100ms.





Changes - 10.6.2003

- IDC_Scan_Error text box, which printed "scan error" has been changed to a rich edit 
  control. If a scan error (buffer overflow, checksum or a data missing ) error occurs
  then "scan error" will be printed inside the rich edit control in red color and the 
  "Show_Error" button gets enabled.



Changes - 07.30.2003

- After entering the ip address user must press enter to get the new 
  ip address validated and preserved in the list box if "connect" is 
  not going to be pressed immediately.
  
- Code to Load from and save to M40x.cfg file made more robust. Earlier, the
   corruption of a single line in the config file (M40x.cfg) would lead to use of 
  default config, no attempt was made to salvage remaining config information.
  
 


Changes- 07.22.2003


- Starting from this version, VC demo application will support 3 ways
  of data acquisition while scanning. The 3 ways are 

  Using callbacks, the dll calls the callback function for the index,
  specifed in the call to Pub_SetCallbacFunc, when scan data becomes 
  available. However, to use this approach you need to access dll
  function from the main thread (with a message pump). 
  See CM40VCxDlg::OnBlockRecv(), the common callback for all the indices
  in this demo app. This is the default method for data acq.


  Not using callbacks, demo application uses this method when it finds
  the keyword "NO_CALLBACK" in the cfg file. Demo calls Pub_NoCallback to
  direct dll not to use windows messaging for data acq from network. 
  Instead, a separate thread inside dll is created which monitors 
  data on all M401 TCP/IP connections. There is no restriction on type
  of thread which can access dll function. There are two ways in which
  demo will acquire data depending on settings in cfg file. If application
  finds the "USE_THREAD" keyword in cfg file it will create a separate thread,
  with the lowest priority, in the application, to poll the dll for scan data 
  using the new "Pub_ReadScanData" function of the dll. In the absence 
  of "USE_THREAD" keyword a timer is set to call Pub_ReadScanData to read
  data from the dll

  When using the "NO_CALLBACK" method make sure that the 
  calling thread releases CPU between consecutive calls to 
  Pub_EndScan for use by the lower priority data acquisition
  thread in the dll. Sleep a few milli secs between
  calls to Pub_EndScan. See CM40xVCDlg::OnEndScan()


- Each keyword in callback.cfg file must be inserted on a separate line


- This demo version shows how to use "Pub_ReadScanData", to read 
  voltage values while scanning. 


- See CM40xDlg::OnInitDialog, CM40xDlg::ThreadProc
  (data acq thread's function)
  







- A clock at the bottom of the dialog shows current time.

- 
  Checkboxes to indicate Buffer Overflow, Checksum, Data missing error, in
  Main dialog (M40xDlg.cpp), are REMOVED. Instead, when any of the above errors
  occur while scanning, "scan error" is printed in text box above "Show Error"
  button which gets enabled. Click on "Show Error" button to get more
  information on error.

  A new dialog box CScan_Error_Dlg has been added with checkboxes for Buffer
  Overflow,  Checksum, Data missing error. This dialog box is shown when "
  Show Error" button is  clicked.
  
  The above change was made because user could accidentally check the error
  checkboxes.


Functions added since last release


- CM40xVCDlg::ReadNewScanData

- CM40xVCDlg::EnableShowError

- CM40xVCDlg::DisableShowError

- CM40xVCDlg::OnShowError

-  CM40xVCDlg::OnTimerProc

- CM40xDlg::ThreadProc


