Option Explicit

 

'*****************************************

'MDB2PC

'Beta Version 4

'Receive/Transmit  from MDB2PC Hardware

'9600, 8, 1, None

'(c) Upstate Networks Inc

'September 2000

' Added CTS/DTR handshaking for transmitting from PC to MDB

'****************************************

 

'************************************************************************************

'*                                    COIN ACCEPTOR                                 *

'************************************************************************************

'* ALL VALUES IN HEX  ****               DATA RECEIVED FROM THE PIC              ****

'************************************************************************************

'*********************** BELOW LOW MARK *** ABOVE LOW MARK  *** ABOVE HIGH MARK  ****

'*  COIN INSERTED   *****************************************************************

'*      Nickel      ****       50       ***       56        ***       8C         ****

'*      Dime        ****       51       ***       59        ***       AC         ****

'*      Quarter     ****       52       ***       58        ***       8D         ****

'*      Quarter(1)  ****       52       ***       58        ***       57         ****

'*      $1 CAN*     ***********************       44        *************************

'*      $2 CAN*     ***********************       45        *************************

'************************************************************************************

'*   *Dollars Are Sent Directly To Coin Box                                      ****

'************************************************************************************

'*  MANUAL DISPENSE *****************************************************************

'*      Nickel      ****       90       ***       96        ***       DC*        ****

'*      Dime        ****       91       ***       99        ***       FC         ****

'*      Quarter     ****       92       ***       98        ***       DD         ****

'*      Quarter(1)  ****       92       ***       98        ***       A7         ****

'************************************************************************************

'*   COIN REJECTED  *****************************************************************

'*      Nickel      ****       70       ***       76        ***       BC         ****

'*      Dime        ****       71       ***       79        ***       DC*        ****

'*      Quarter     ****       72       ***       78        ***       BD         ****

'*      Quarter(1)  ****       72       ***       78        ***       87         ****

'*      $1 CAN      ***********************       74        *************************

'*      $2 CAN      ***********************       75        *************************

'************************************************************************************

'* (1) Coin Acceptor set to accept only 22 quarters. (LO 25c)Set on acceptor.    ****

'*  * Note that the values for "Nickel Dispensed Manually Above High Mark" and   ****

'*    "Dime Rejected Above High Mark" are the same value!                        ****

'************************************************************************************

'************************************************************************************

'*                COIN ACCEPTOR STATUS                                           ****

'************************************************************************************

'*          01          ****    Escrow Request                                   ****

'*          02          ****    Changer Payout Busy                              ****

'*          03          ****    No Credit                                        ****

'*          04          ****    Defective Tube Sensor                            ****

'*          05          ****    Double Arrival                                   ****

'*          06          ****    Acceptor Unplugged                               ****

'*          07          ****    Tube Jam                                         ****

'*          08          ****    ROM Checksum Error                               ****

'*          09          ****    Coin Routing Error                               ****

'*          0A          ****    Changer Busy                                     ****

'*          0B          ****    Changer was Reset                                ****

'*          0C          ****    Coin Jam                                         ****

'*          21          ****    Coin not recognized/slug. Returned               ****

'************************************************************************************

 

 

 

 

 

 

' Define constants to make list item updating more readable

' ------------------------------------------------------------------

Const NICKEL = 0

Const DIME = 1

Const QUARTER = 2

Const CANADIAN_DOLLAR = 3

Const CANADIAN_TWO_DOLLAR = 4

 

Const ONE_DOLLAR_BILL = 0

Const TWO_DOLLAR_BILL = 1

Const FIVE_DOLLAR_BILL = 2

Const TEN_DOLLAR_BILL = 3

Const TWENTY_DOLLAR_BILL = 4

 

Const INPUT_BUFFER_COUNT = 0

Const INPUT_BUFFER_LENGHT = 1

Const INPUT_BUFFER_CONTENT = 2

 

Const FAILURE_STRING = "ff"

Const MDB_FIRMWARE_VERSION = "CC"

Const DISPENSE_TWO_DOLLAR_COIN = "02"

Const ESCROW_REQUEST = "01"

Const BAD_COIN = 821

 

' Varible & Control Prefix Ledgend

' ---------------------------------------

' Long      = lp

' Double    = dp

' Integer   = i

' Variant   = v

' String    = s

' Single    = sp

' Date      = d

' Boolean   = b

' lst       = ListBox

' mnu       = Menu Option

' lbl       = Label

' fra       = Frame

' txt       = TextBox

' cmd       = Command Button

' tmr       = Timer Control

' com       = Comm Control

 

Dim spAmountReceived As Single  ' This is the Count amount of money taken in by the machince.

 

Private Sub cmdClearAll_Click()

    On Error GoTo ErrorHandler

   

    ' Clear all the controls

    Call InitializeCount

 

    ' Clear the activity log, as well as the totals recieved, and any special instructions

    lstActionLog.Clear  ' Clears out the activity log

    lblTotalReceived.Caption = "Total Money Received so far:"

    lblSpecialInstruction.Caption = "Special Instructions:"

   

    Exit Sub

   

ErrorHandler:

    Resume Next

   

End Sub

 

Private Sub cmdDispenseDime_Click()

    On Error GoTo ErrorHandler

       

    ' Dispense a Dime

    comInterface.Output = Chr$(13) & Chr$(&H51)

    comInterface.DTREnable = True

   

    lstActionLog.AddItem "Dispense Dime"

 

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Error In Dispensing Dime, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub cmdDispenseNickel_Click()

    On Error GoTo ErrorHandler

       

    ' Dispense a Nickel

    comInterface.Output = Chr$(13) & Chr$(&H50)

    comInterface.DTREnable = True

   

    ' Update the Activity Log

    lstActionLog.AddItem "Dispense Nickel"

 

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Error In Dispensing Nickel, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

   

End Sub

 

Private Sub cmdDispenseQuarter_Click()

    On Error GoTo ErrorHandler

       

    ' Dispense a Quarter

    comInterface.Output = Chr$(13) & Chr$(&H52)

    comInterface.DTREnable = True

   

    lstActionLog.AddItem "Dispense Quarter"

 

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Error In Dispensing Quarter, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub cmdExit_Click()

    On Error GoTo ErrorHandler

   

    ' Need to check and see if anything in this program

    ' needs to be gracefully exitied before closing the program

    ' to prevent memory leaks

   

    Unload frmMDB2PC

   

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Error In Exit Command Click Routine, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    End

   

End Sub

 

Private Sub cmdResetVarible_Click()

    On Error Resume Next

   

    Call InitializeCount

   

End Sub

 

Private Sub cmdToggleDTR_Click()

   

    On Error GoTo ErrorHandler

   

    If cmdToggleDTR.Caption = "Toggle DTR to False" Then

        ' Set the DTR to False

        comInterface.DTREnable = False

   

        ' Set up the button so the next time the button is pushed

        ' the DTR will be set to true

        cmdToggleDTR.Caption = "Toggle DTR to True"

       

        lstActionLog.AddItem "DTR set to False"

       

    Else

        ' Set the DTR to true

        comInterface.DTREnable = True

       

        ' Set up the button so the next time the button is pushed

        ' the DTR will be set to false

        cmdToggleDTR.Caption = "Toggle DTR to False"

       

        lstActionLog.AddItem "DTR set to True"

   

    End If

   

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Error Setting DTR Command Button, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

   

End Sub

 

Private Sub comInterface_OnComm()

Dim sInputBuffer As String

Dim iResponse As Integer

Dim iTemp As Integer    ' This is a varible that holds counts

 

   On Error GoTo ErrorHandler

  

   Select Case comInterface.CommEvent

        ' Errors

        Case comBreak                   'A Break was received

       

        ' Case comDCTO                    'CD timeout

       

        Case comCTSTO                   'CTS timeout

            ' Log the activity

            lstActionLog.AddItem "CTS Timeout"

       

        Case comDSRTO                   'DSR timeout

            ' Log the activity

            lstActionLog.AddItem "DSR Timeout"

       

        Case comFrame                   'Framing error

            ' Log the activity

            lstActionLog.AddItem "Framing Error"

       

        Case comOverrun                 'Data Lost

            ' Log the activity

            lstActionLog.AddItem "Comm overrun, Data Lost"

       

        Case comRxOver                  'Receive Buffer overflow

            ' Log the activity

            lstActionLog.AddItem "Receive Buffer overflow"

       

        Case comRxParity                'Parity Error

            ' Log the activity

            lstActionLog.AddItem "Parity Error"

       

        Case comTxFull                  'Transmit buffer full

   

        'Events

        Case comEvCD                    'Change in the CD line

       

        Case comEvCTS                   'Change in the CTS line

            ' this is the output routine for transmitting

            ' outbuffersize set to 32 bytes

            ' Old code.

            comInterface.DTREnable = False

            'END transmit one character on change of CTS line

        

        Case comEvDSR                   'Change in the DSR line

       

        Case comEvRing                  'Change in the Ring indicator

       

        Case comEvReceive               'Received RThreshold # of Chars

            Do While comInterface.InBufferCount > 0

                ' The MDB has sent this string of characters to the PC

                ' First we will read that into a string varible.

                ' Then based on what that string is we will accumulate totals and counts

               

                ' Added 11/29/2000

                ' Author: James Ness

                ' Note: I added a Trim$ function to the line so that if some of the

                '            two character code events happen, it will take five characters

                '            but the last three may be spaces.  This will help so as not to

                '            throw off the SELECT CASE check.

                sInputBuffer$ = Trim$(Left$(comInterface.Input, 5))

               

                'Begin Coins Accepted *******************************************************

                Select Case sInputBuffer$

                    Case ("08 50")  'Nickel received below low mark

                        lstCoin.List(NICKEL) = "Nickel " & "(Tube Low)"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(NICKEL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(NICKEL) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the nickel received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.05

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a Nickel, Warning Nickel Tube Low"

                       

                    Case ("08 56")  'Nickel received

                        lstCoin.List(NICKEL) = "Nickel received"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(NICKEL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(NICKEL) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the nickel received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.05

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a Nickel"

                       

                    Case ("08 8C") 'Nickel received and Nickel tube full    '*

                        lstCoin.List(NICKEL) = "Nickel received " & "(Tube Full)"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(NICKEL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(NICKEL) = Trim$(CStr(iTemp%))

                        

                        ' Accumulate the nickel received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.05

                      

                        ' Log the activity

                        lstActionLog.AddItem "Received a Nickel, Warning Nickel Tube Full"

                       

                    Case ("08 51")  'Dime received below low mark

                        lstCoin.List(DIME) = "Dime " & "(Tube Low)"

                        

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(DIME))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(DIME) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.1

                    

                        ' Log the activity

                        lstActionLog.AddItem "Received a Dime, Warning Dime Tube Low"

                       

                    Case ("08 59")  'Dime received

                        lstCoin.List(DIME) = "Dime received "

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(DIME))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(DIME) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the nickel received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.1

                       

                        ' Log the activity

                        lstActionLog.AddItem "Received a Dime"

                       

                    Case ("08 AC") 'Dime received and Dime tube full

                        lstCoin.List(DIME) = "Dime received " & "(Tube Full)"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(DIME))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(DIME) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the nickel received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.1

                       

                        ' Log the activity

                        lstActionLog.AddItem "Received a Dime, Warning Dime Tube Full"

                                               

                    Case ("08 52")  'Quarter received below low mark

                        lstCoin.List(QUARTER) = "Quater " & "(Tube Low)"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(QUARTER))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(QUARTER) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.25

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a Quater, Warning Quater Tube Low"

                   

                    Case ("08 58")  'Quarter received

                        lstCoin.List(QUARTER) = "Quater "

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(QUARTER))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(QUARTER) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.25

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a Quater"

                   

                    Case ("08 8D") 'Quarter received and Quarter tube full

                        lstCoin.List(QUARTER) = "Quarter " & "(Tube Low)"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(QUARTER))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(QUARTER) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.25

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a Quarter, Warning Quarter Tube Low"

                   

                    Case ("08 57")  'Quarter received and quarter tube full '*

                        lstCoin.List(QUARTER) = "Quarter received " & "(Tube Full)"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(QUARTER))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(QUARTER) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the nickel received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 0.25

                       

                        ' Log the activity

                        lstActionLog.AddItem "Received a Quarter, Warning Quarter Tube Full"

                       

                    Case ("08 44")  'One dollar received                    '********************

                         lstCoin.List(CANADIAN_DOLLAR) = "Canadian Dollar "

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(CANADIAN_DOLLAR))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(CANADIAN_DOLLAR) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 1

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a Canadian Dollar Coin"

                       

                    Case ("08 45")     'Two dollars received                 '********************

                         lstCoin.List(CANADIAN_TWO_DOLLAR) = "Canadian Two Dollar"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstCoinCount.List(CANADIAN_TWO_DOLLAR))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstCoinCount.List(CANADIAN_TWO_DOLLAR) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 2

                    

                        ' Log the activity

                        lstActionLog.AddItem "Received a Canadian Two Dollar Coin"

                       

                    'Begin Bills Accepted

                    Case ("30 89") '$1 bill accepted

                         lstBill.List(ONE_DOLLAR_BILL) = "$1"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstBillCount.List(ONE_DOLLAR_BILL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstBillCount.List(ONE_DOLLAR_BILL) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 1

                   

                        ' Log the activity

                        lstActionLog.AddItem "Received a One Dollar Bill - ($1)"

 

                    Case ("30 8A") '$2 bill accepted

                         lstBill.List(TWO_DOLLAR_BILL) = "$2"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstBillCount.List(TWO_DOLLAR_BILL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstBillCount.List(TWO_DOLLAR_BILL) = Trim$(CStr(iTemp%))

                        

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 2

                       

                        ' Log the activity

                        lstActionLog.AddItem "Received a Two Dollar Bill - ($2)"

                       

                    Case ("30 8B") '$5 bill accepted

                         lstBill.List(FIVE_DOLLAR_BILL) = "$5"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstBillCount.List(FIVE_DOLLAR_BILL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstBillCount.List(FIVE_DOLLAR_BILL) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 5

                        

                        ' Log the activity

                        lstActionLog.AddItem "Received a Five Dollar Bill - ($5)"

                       

                    Case ("30 8C") '$10 bill accepted

                         lstBill.List(TEN_DOLLAR_BILL) = "$10"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstBillCount.List(TEN_DOLLAR_BILL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstBillCount.List(TEN_DOLLAR_BILL) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 10

                       

                        ' Log the activity

                        lstActionLog.AddItem "Received a Ten Dollar Bill - ($10)"

                       

                    Case ("30 8D") '$20 bill accepted

                         lstBill.List(TWENTY_DOLLAR_BILL) = "$20"

                       

                        ' Convert the current count that is stored in a list box text field into

                        ' an integer.  Then add one to the integer number and reassign that

                        ' value to the list box item.

                        iTemp% = CInt(lstBillCount.List(TWENTY_DOLLAR_BILL))

                        iTemp% = iTemp% + 1

                       

                        ' Now convert the number back to a string varible and update the

                        ' listbox item.

                        lstBillCount.List(TWENTY_DOLLAR_BILL) = Trim$(CStr(iTemp%))

                       

                        ' Accumulate the dime received into the total collected so far.

                        spAmountReceived! = spAmountReceived! + 20

                       

                        ' Log the activity

                        lstActionLog.AddItem "Received a Twenty Dollar Bill - ($20)"

                       

                    'Begin Coins Dispensed ***************************************************

                   

                    Case DISPENSE_TWO_DOLLAR_COIN

                        lblSpecialInstruction.Caption = "Dispensing coin"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing coin"

                                           

                    Case ("08 90")  ' Dispensing Nickel

                        lblSpecialInstruction.Caption = "Dispensing Nickel"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Nickel - Code (08 90) "

                        

                    Case ("08 96")  'Dispensing Nickel

                        lblSpecialInstruction.Caption = "Dispensing Nickel"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Nickel - Code (08 96)"

                     

                    Case ("08 91")  ' Dispensing Dime

                        lblSpecialInstruction.Caption = "Dispensing Dime"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Dime - Code (08 91)"

                   

                    Case 899  'Dispensing Dime

                        lblSpecialInstruction.Caption = "Dispensing Dime"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Dime - Code (899)"

                       

                    Case ("08 FC") 'Dispensing Dime

                        lblSpecialInstruction.Caption = "Dispensing Dime"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Dime - Code (08 FC)"

                       

                    Case ("08 92")  ' Dispensing Quarter

                        lblSpecialInstruction.Caption = "Dispensing Quarter"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Quarter - Code (08 92)"

                   

                    Case ("08 98")  'Dispensing Quarter         '*

                        lblSpecialInstruction.Caption = "Dispensing Quarter"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Quarter - Code (08 92)"

                   

                    Case ("08 DD") 'Dispensing Quarter          '*

                        lblSpecialInstruction.Caption = "Dispensing Quarter"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Quarter - Code (08 DD)"

                   

                    Case ("08 A7") 'Dispensing Quarter          '*

                        lblSpecialInstruction.Caption = "Dispensing Quarter"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dispensing Quarter - Code (08 A7)"

                   

                    'Begin Coins Rejected  **********************************************************

                    Case ("08 70") 'Nickel rejected

                        lblSpecialInstruction.Caption = "Nickel rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Nickel rejected - Code (08 70)"

                   

                    Case ("08 76") 'Nickel Rejected

                        lblSpecialInstruction.Caption = "Nickel rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Nickel rejected - Code (08 76)"

                   

                    Case ("08 BC") 'Nickel rejected

                        lblSpecialInstruction.Caption = "Nickel rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Nickel rejected - Code (08 BC)"

                   

                    Case ("08 71") 'Dime rejected

                        lblSpecialInstruction.Caption = "Dime rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dime rejected - Code (08 71)"

                   

                    Case ("08 79") 'Dime rejected

                        lblSpecialInstruction.Caption = "Dime rejected"

                        

                        ' Log the activity

                        lstActionLog.AddItem "Dime rejected - Code (08 79)"

 

                    Case ("08 72") 'Quarter rejected

                        lblSpecialInstruction.Caption = "Quarter rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Quarter rejected - Code (08 72)"

                   

                    Case ("08 78") 'Quarter rejected

                        lblSpecialInstruction.Caption = "Quarter rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Quarter rejected - Code (08 78)"

                   

                    Case ("08 BD") 'Quarter rejected

                        lblSpecialInstruction.Caption = "Quarter rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Quarter rejected - Code (08 BD)"

                    

                    Case ("08 74") '$1 rejected

                        lblSpecialInstruction.Caption = "Dollar Coin rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Dollar Coin rejected - Code (08 74)"

                   

                    Case ("08 75") '$2 rejected

                        lblSpecialInstruction.Caption = "Two Dollar Coin rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Two Dollar Coin rejected - Code (08 75)"

                   

                    'NOTE!!!! The values 08,09,0A,0B,0C, and 0D may be sent from the MDB upon start    *

                    '         up and will give a false 'action' listed below!    DJ 9/27/00            *

           

                    '*The following are the special actions produced by the MDB*

                    'Coin Acceptor

                    Case ("08 01") 'one$                    ' Escrow Request

                        lblSpecialInstruction.Caption = "Coin Returned"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Coin Returned - Code (08 01)"

                   

                    Case BAD_COIN   ' Bad Coin/slug

                        lblSpecialInstruction.Caption = "Bad Coin or Slug"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Coin Returned - Code (821)"

                   

                    Case ("f")  ' not working until circuit is actually turned off

                        lblSpecialInstruction.Caption = "Failure"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Failure - Code (f)"

                        ' MDB ckt overloaded PC buffer with dispensing signals

                   

                    Case MDB_FIRMWARE_VERSION

                        lblSpecialInstruction.Caption = Trim$(Left$(comInterface.Input, 14))

                       

                        ' Log the activity

                        lstActionLog.AddItem lblSpecialInstruction.Caption

                   

                    Case ("08 03")  'No credit

                        lblSpecialInstruction.Caption = "No credit"

                       

                        ' Log the activity

                        lstActionLog.AddItem "No credit- Code (08 03)"

                       

                    Case ("08 04") 'Defective tube sensor

                        lblSpecialInstruction.Caption = "Defective sensor"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Defective sensor - Code (08 03)"

                    

                    Case ("08 05") 'Double arrival          'Coins inserted to close together

                        lblSpecialInstruction.Caption = "Double Arrival"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Double Arrival - Code (08 05)"

                       

                    Case ("08 06") 'Acceptor unplugged

                        lblSpecialInstruction.Caption = "Acceptor unplugged"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Double Arrival - Code (08 05)"

                       

                    Case ("08 07") 'Tube Jam                'Coin jammed in tube

                        lblSpecialInstruction.Caption = "Tube Jam"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Tube Jam - Code (08 07)"

                   

                    Case ("08 08") 'ROM Checksum error

                        lblSpecialInstruction.Caption = "Checksum error"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Checksum error - Code (08 08)"

                   

                    Case ("08 09") 'Coin routing error

                        lblSpecialInstruction.Caption = "Routing error"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Routing error - Code (08 09)"

                       

                    Case ("08 0A") 'changer busy

                        lblSpecialInstruction.Caption = "Changer busy"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Changer busy - Code (08 0A)"

                       

                    Case Chr$("08 0B") 'Changer was reset

                        lblSpecialInstruction.Caption = "Changer reset"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Changer reset - Code (08 0B)"

                       

                    Case ("08 0C") 'Coin Jam

                        lblSpecialInstruction.Caption = "Coin jam"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Coin jam - Code (08 0C)"

                   

                    'Bill Validator

                    Case ("30 01") 'Defective motor

                        lblSpecialInstruction.Caption = "Defective motor"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Defective motor - Code (30 01)"

                   

                    Case ("30 02") 'Sensor problem

                        lblSpecialInstruction.Caption = "Sensor problem"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Sensor problem - Code (30 02)"

                   

                    Case ("30 03") 'Validator Busy

                        lblSpecialInstruction.Caption = "Validator Busy"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Validator Busy - Code (30 03)"

                   

                    Case ("30 04") 'ROM checksum error

                        lblSpecialInstruction.Caption = "ROM Checksum Error"

                       

                        ' Log the activity

                        lstActionLog.AddItem "ROM Checksum Error - Code (30 04)"

                   

                    Case ("30 05") 'Validator jammed

                        lblSpecialInstruction.Caption = "Validator jammed"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Validator jammed - Code (30 05)"

                   

                    Case ("30 06") 'Validator was reset

                        lblSpecialInstruction.Caption = "Validator was reset"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Validator was reset - Code (30 06)"

                   

                    Case ("30 07") 'Bill Removed

                        lblSpecialInstruction.Caption = "Bill Removed"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Bill Removed - Code (30 07)"

                   

                    Case ("30 08") 'Cash box out of position

                        lblSpecialInstruction.Caption = "Cash box out of position"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Cash box out of position - Code (30 08)"

                   

                    Case ("30 09") 'Unit disabled

                        lblSpecialInstruction.Caption = "Unit disabled"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Unit disabled - Code (30 09)"

                    

                    Case ("30 0A") 'Invalid escrow request

                        lblSpecialInstruction.Caption = "Invalid escrow request"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Invalid escrow request - Code (30 0A)"

                   

                    Case ("30 0B") 'Bill rejected

                        lblSpecialInstruction.Caption = "Bill rejected"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Bill rejected - Code (30 0B)"

                   

                    Case ("30 14") 'Bill not accepted

                        lblSpecialInstruction.Caption = "Bill not accepted"

                       

                        ' Log the activity

                        lstActionLog.AddItem "Bill not accepted - Code (30 14)"

               

                End Select

               

                ' Display the total Money received so far

                lblTotalReceived.Caption = "Total Money Received so far: " & Format$(spAmountReceived!, "###0.00")       ' Returns "$$$.cc"

               

                ' Update the Debugging Section

                lstDebuggingValue.List(INPUT_BUFFER_COUNT) = comInterface.InBufferCount

                lstDebuggingValue.List(INPUT_BUFFER_LENGHT) = comInterface.InputLen

                lstDebuggingValue.List(INPUT_BUFFER_COUNT) = comInterface.Input

               

                ' Log event to the text log file.

                Open App.Path & "\log.txt" For Append As #1

                Print #1, Date$, Time$, comInterface.Input

               

                Close #1

               

            Loop

       

        Case comEvSend  'There are SThreshold number of characters in the transmit buffer

   

    End Select

 

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Communications Error, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

   

End Sub

 

Private Sub Form_Load()

 

    On Error GoTo ErrorHandler

   

    ' Update the screen displays right away on the screen right away

    Call UpdateClock

    Call UpdateTotalRecived

    Call InitializeCount

 

    ' Initialize varibles and controls

    spAmountReceived! = 0

    comInterface.DTREnable = False

    comInterface.PortOpen = True

   

    Exit Sub

   

ErrorHandler:

    lstActionLog.AddItem "Error in form load, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

   

End Sub

 

Private Sub lstBill_Click()

    On Error GoTo ErrorHandler

   

    lstBillCount.ListIndex = lstBill.ListIndex

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error lining up list boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub lstBillCount_Click()

    On Error GoTo ErrorHandler

   

    lstBill.ListIndex = lstBillCount.ListIndex

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error lining up list boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub lstCoin_Click()

    On Error GoTo ErrorHandler

   

    lstCoinCount.ListIndex = lstCoin.ListIndex

   

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error lining up list boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub lstCoinCount_Click()

    On Error GoTo ErrorHandler

   

    lstCoin.ListIndex = lstCoinCount.ListIndex

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error lining up list boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub lstDebugging_Click()

    On Error GoTo ErrorHandler

   

    lstDebuggingValue.ListIndex = lstDebugging.ListIndex

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error lining up list boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub lstDebuggingValue_Click()

    On Error GoTo ErrorHandler

   

    lstDebugging.ListIndex = lstDebuggingValue.ListIndex

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error lining up list boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Private Sub mnuFileExit_Click()

    Unload frmMDB2PC

   

End Sub

 

Private Sub mnuHelpAbout_Click()

Dim sDisplay As String

Dim iResponse As Integer

 

    On Error Resume Next

   

    ' Display the about menu option.

    sDisplay$ = "The MDB Interface is a product developed by Upstate Networks Inc. (UNI)" & vbCr

    sDisplay$ = sDisplay$ & "US Patent 5,822,215" & vbCr

    sDisplay$ = sDisplay$ & "The MDB Interface program was developed by" & vbCr

    sDisplay$ = sDisplay$ & "Chris Smolen, Dave Lovy, Dan Johnson" & vbCr

    sDisplay$ = sDisplay$ & "and James Ness." & vbCr

    

    iResponse = MsgBox(sDisplay$, vbInformation, "About the MDB Interface")

 

End Sub

 

Private Sub mnuHelpTip_Click()

Dim sDisplay As String

Dim iResponse As Integer

 

    On Error Resume Next

   

    ' Display the help menu option.

    sDisplay$ = "BRIEF HELP STATEMENTS" & vbCr & vbCr

    sDisplay$ = sDisplay$ & "The MDB Interface program was written in Visual Basic" & vbCr

    sDisplay$ = sDisplay$ & "This early version has been written to accept and intercept" & vbCr

    sDisplay$ = sDisplay$ & "signals generated by the Coinco Coin Acceptor which follows" & vbCr

    sDisplay$ = sDisplay$ & "the MDB standard.  The MDB Interface program receives a" & vbCr

    sDisplay$ = sDisplay$ & "code from the Coin Acceptor and decodes it for the user." & vbCr

    

    iResponse = MsgBox(sDisplay$, vbInformation, "Tips on the MDB Interface")

 

End Sub

 

Private Sub tmrInterface_Timer()

    On Error GoTo ErrorHandler

   

    Call UpdateClock

   

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error Updating clock, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Public Sub UpdateClock()

    On Error GoTo ErrorHandler

   

    lblClock.Caption = Format$(Now, "Hh:Nn:Ss")

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error updating clock, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Public Sub UpdateTotalRecived()

    On Error GoTo ErrorHandler

   

    lblTotalReceived.Caption = "Count Money Received so far: " & Format$(spAmountReceived!, "Currency")

 

    Exit Sub

   

ErrorHandler:

    Debug.Print "Error Updating Count, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub

 

Public Sub InitializeCount()

 

    On Error GoTo ErrorHandler

   

    ' Clear out any contents that might be in the list boxes

    lstCoin.Clear

    lstCoinCount.Clear

    lstBill.Clear

    lstBillCount.Clear

    lstActionLog.Clear

    lstDebugging.Clear

    lstDebuggingValue.Clear

   

    ' Initialize Running Counts

    lstCoin.AddItem "Nickel"

    lstCoinCount.AddItem "0"

    lstCoin.AddItem "Dime"

    lstCoinCount.AddItem "0"

    lstCoin.AddItem "Quarter"

    lstCoinCount.AddItem "0"

    lstCoin.AddItem "Canadian Dollar"

    lstCoinCount.AddItem "0"

    lstCoin.AddItem "Canadian Two Dollar"

    lstCoinCount.AddItem "0"

   

    lstBill.AddItem "$1"

    lstBillCount.AddItem "0"

    lstBill.AddItem "$2"

    lstBillCount.AddItem "0"

    lstBill.AddItem "$5"

    lstBillCount.AddItem "0"

    lstBill.AddItem "$10"

    lstBillCount.AddItem "0"

    lstBill.AddItem "$20"

    lstBillCount.AddItem "0"

   

    lstDebugging.AddItem "In Buffer Count"

    lstDebugging.AddItem "Input Buffer Lenght"

    lstDebugging.AddItem "Buffer Content"

 

    lstDebuggingValue.AddItem " "

    lstDebuggingValue.AddItem " "

    lstDebuggingValue.AddItem " "

 

    lstCoin.ListIndex = 0

    lstBill.ListIndex = 0

    lstDebugging.ListIndex = 0

   

    Exit Sub

   

ErrorHandler:

    Debug.Print "Initializing Varibles and List boxes, " & Trim$(Err.Description) & " - " & Trim$(CStr(Err.Number))

    Resume Next

 

End Sub