-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathProgram.cs
More file actions
90 lines (74 loc) · 2.54 KB
/
Program.cs
File metadata and controls
90 lines (74 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CashCode.Net;
namespace CashCodeTest
{
class Program
{
static int Sum = 0;
static CashCodeBillValidator c = new CashCodeBillValidator("COM4", 9600);
static void Main(string[] args)
{
try
{
c.BillReceived += new BillReceivedHandler(c_BillReceived);
c.BillStacking += new BillStackingHandler(c_BillStacking);
c.BillCassetteStatusEvent += new BillCassetteHandler(c_BillCassetteStatusEvent);
c.BillException += new BillExceptionHandler(c_BillException);
c.ConnectBillValidator();
if (c.IsConnected)
{
c.PowerUpBillValidator();
c.StartListening();
c.EnableBillValidator();
Console.ReadKey();
c.AcceptBill();
c.DisableBillValidator();
Console.ReadKey();
c.EnableBillValidator();
Console.ReadKey();
c.RejectBill();
c.StopListening();
}
c.Dispose();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
static void c_BillCassetteStatusEvent(object Sender, BillCassetteEventArgs e)
{
Console.WriteLine(e.Status.ToString());
}
static void c_BillStacking(object Sender, BillStackedEventArgs e)
{
Console.WriteLine("Купюра в стеке");
e.Hold = true;
//if (Sum > 100)
//{
// e.Cancel = true;
// Console.WriteLine("Превышен лимит единовременной оплаты");
//}
}
static void c_BillReceived(object Sender, BillReceivedEventArgs e)
{
if (e.Status == BillRecievedStatus.Rejected)
{
Console.WriteLine(e.RejectedReason);
}
else if (e.Status == BillRecievedStatus.Accepted)
{
Sum += e.Value;
Console.WriteLine("Bill accepted! " + e.Value + " руб. Общая сумму: " + Sum.ToString());
}
}
static void c_BillException(object Sender, BillExceptionEventArgs e)
{
Console.WriteLine(e.Message);
c.Dispose();
}
}
}