forked from diseks/CashCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
78 lines (67 loc) · 2.36 KB
/
Program.cs
File metadata and controls
78 lines (67 loc) · 2.36 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CashCode.Net;
namespace CashCodeTest
{
class Program
{
static int Sum = 0;
static void Main(string[] args)
{
try
{
using (CashCodeBillValidator c = new CashCodeBillValidator(CashCode.Test.Properties.Settings.Default.Port, 9600))
{
c.BillReceived += new BillReceivedHandler(c_BillReceived);
c.BillStacking += new BillStackingHandler(c_BillStacking);
c.BillCassetteStatusEvent += new BillCassetteHandler(c_BillCassetteStatusEvent);
c.ConnectBillValidator();
if (c.IsConnected)
{
c.PowerUpBillValidator();
c.StartListening();
c.EnableBillValidator();
Console.ReadKey();
c.DisableBillValidator();
Console.ReadKey();
c.EnableBillValidator();
Console.ReadKey();
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, System.ComponentModel.CancelEventArgs e)
{
Console.WriteLine("Купюра в стеке");
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());
}
}
}
}