diff --git a/.gitignore b/.gitignore index 1ea5843..0330688 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,12 @@ Apex7000_BillValidator_Test\obj\* Apex7000_BillValidator/obj/ Apex7000_BillValidator_Test/bin/ Apex7000_BillValidator_Test/obj/ -Apex7000_BillValidator/bin/ API_Test/bin/ API_Test/obj/ +Apex7000_BillValidator/bin/ docs/ +PyramidNETRS232Installer/bin/ +PyramidNETRS232Installer/obj/ +packages/ +PyramidNETRS232_TestApp_Simple/bin/ +PyramidNETRS232_TestApp_Simple/obj/ diff --git a/API_Test/Properties/AssemblyInfo.cs b/API_Test/Properties/AssemblyInfo.cs index 767c5f4..10246f5 100644 --- a/API_Test/Properties/AssemblyInfo.cs +++ b/API_Test/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("API_Test")] +[assembly: AssemblyTitle("PyramidNETRS232_Test")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("API_Test")] +[assembly: AssemblyProduct("PyramidNETRS232_Test")] [assembly: AssemblyCopyright("Copyright © 2015")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/API_Test/API_Test.csproj b/API_Test/PyramidNETRS232_Test.csproj similarity index 93% rename from API_Test/API_Test.csproj rename to API_Test/PyramidNETRS232_Test.csproj index 6344bde..4fcd7ed 100644 --- a/API_Test/API_Test.csproj +++ b/API_Test/PyramidNETRS232_Test.csproj @@ -6,9 +6,9 @@ {71DEAB9A-CC67-4BD8-9FEC-C5E59ED2A75F} Library Properties - API_Test - API_Test - v4.5.1 + PyramidNETRS232_Test + PyramidNETRS232_Test + v3.5 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 10.0 @@ -16,6 +16,7 @@ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages False UnitTest + true @@ -54,9 +55,9 @@ - + {735220bb-d8e8-4e21-80d9-aea6e41b13ed} - Apex7000_BillValidator + PyramidNETRS232 diff --git a/API_Test/SlaveCodex_Test.cs b/API_Test/SlaveCodex_Test.cs index 9d81c05..e4fb896 100644 --- a/API_Test/SlaveCodex_Test.cs +++ b/API_Test/SlaveCodex_Test.cs @@ -1,8 +1,8 @@ using System; using Microsoft.VisualStudio.TestTools.UnitTesting; -using Apex7000_BillValidator; +using PyramidNETRS232; -namespace API_Test +namespace PyramidNETRS232_Test { [TestClass] public class SlaveCodex_Test diff --git a/Apex7000_BillValidator/ApexValidator.cs b/Apex7000_BillValidator/ApexValidator.cs index 5f5e07e..5908ba5 100644 --- a/Apex7000_BillValidator/ApexValidator.cs +++ b/Apex7000_BillValidator/ApexValidator.cs @@ -5,13 +5,13 @@ using System.IO; using System.Threading; -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// The main class that does the actual "talking" the acceptor. In the context of documentation, /// this object what is referred to as the master and the acceptor is the slave device. /// - public partial class ApexValidator : IDisposable + public partial class PyramidAcceptor : IDisposable { private readonly object mutex = new object(); @@ -66,10 +66,10 @@ public partial class ApexValidator : IDisposable #endregion /// - /// Creates a new ApexValidator using the specified configuration + /// Creates a new PyramidAcceptor using the specified configuration /// /// Operating RS-232 parameters - public ApexValidator(RS232Config config) + public PyramidAcceptor(RS232Config config) { this.config = config; } @@ -369,15 +369,15 @@ private byte[] GenerateNormalMessage() // Toggle message number (ack #) if last message was okay and not a re-send request. data[2] = (byte)(0x10 | Ack); + // Get enable mask from client configuration. On next message, the acceptor + // will update itself and not escrow any notes that are disabled in this mask. + data[3] = config.EnableMask; if(!config.IsEscrowMode) { - // Not escrow mode, all notes are enabled by default - data[3] = 0x7F; - - // Clear escrow mode bit + // Clear escrow mode bit data[4] = 0x00; if (NoteIsEscrowed) @@ -387,10 +387,6 @@ private byte[] GenerateNormalMessage() else { - // Get enable mask from client configuration. On next message, the acceptor - // will update itself and not escrow any notes that are disabled in this mask. - data[3] = config.EnableMask; - // Set escrow mode bit data[4] = 1 << 4; diff --git a/Apex7000_BillValidator/Commands.cs b/Apex7000_BillValidator/Commands.cs index a4d459b..4379e95 100644 --- a/Apex7000_BillValidator/Commands.cs +++ b/Apex7000_BillValidator/Commands.cs @@ -1,7 +1,7 @@  -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { - public partial class ApexValidator + public partial class PyramidAcceptor { /// /// Issue a stack command to the acceptor. Note that the acceptor must diff --git a/Apex7000_BillValidator/DataContracts.cs b/Apex7000_BillValidator/DataContracts.cs index dff6be2..5a49aaf 100644 --- a/Apex7000_BillValidator/DataContracts.cs +++ b/Apex7000_BillValidator/DataContracts.cs @@ -1,5 +1,5 @@  -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// The bill acceptor will pass through a series of "States" during bill processing. The acceptor will always diff --git a/Apex7000_BillValidator/DebugBuffer.cs b/Apex7000_BillValidator/DebugBuffer.cs index 6fb9b3c..3833a3b 100644 --- a/Apex7000_BillValidator/DebugBuffer.cs +++ b/Apex7000_BillValidator/DebugBuffer.cs @@ -1,7 +1,7 @@ using System; using System.Text; -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// Helper entry for describing serial communication transactions diff --git a/Apex7000_BillValidator/EventArgs.cs b/Apex7000_BillValidator/EventArgs.cs index 0455398..7767dff 100644 --- a/Apex7000_BillValidator/EventArgs.cs +++ b/Apex7000_BillValidator/EventArgs.cs @@ -1,6 +1,6 @@ using System; -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// Properties of a state change event diff --git a/Apex7000_BillValidator/Events.cs b/Apex7000_BillValidator/Events.cs index 87bed7b..96b7570 100644 --- a/Apex7000_BillValidator/Events.cs +++ b/Apex7000_BillValidator/Events.cs @@ -1,8 +1,8 @@ using System; -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { - public partial class ApexValidator + public partial class PyramidAcceptor { /// /// Raised when the acceptor reports any event. Events are transient diff --git a/Apex7000_BillValidator/MasterCodex.cs b/Apex7000_BillValidator/MasterCodex.cs index 845332c..e99a273 100644 --- a/Apex7000_BillValidator/MasterCodex.cs +++ b/Apex7000_BillValidator/MasterCodex.cs @@ -1,5 +1,5 @@  -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// \internal diff --git a/Apex7000_BillValidator/Properties/AssemblyInfo.cs b/Apex7000_BillValidator/Properties/AssemblyInfo.cs index 006470c..cea3366 100644 --- a/Apex7000_BillValidator/Properties/AssemblyInfo.cs +++ b/Apex7000_BillValidator/Properties/AssemblyInfo.cs @@ -35,4 +35,4 @@ [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly : InternalsVisibleTo("API_Test")] \ No newline at end of file +[assembly : InternalsVisibleTo("PyramidNETRS232_Test")] \ No newline at end of file diff --git a/Apex7000_BillValidator/Apex7000_BillValidator.csproj b/Apex7000_BillValidator/PyramidNETRS232.csproj similarity index 93% rename from Apex7000_BillValidator/Apex7000_BillValidator.csproj rename to Apex7000_BillValidator/PyramidNETRS232.csproj index 1556d41..4f7f4ea 100644 --- a/Apex7000_BillValidator/Apex7000_BillValidator.csproj +++ b/Apex7000_BillValidator/PyramidNETRS232.csproj @@ -7,8 +7,8 @@ {735220BB-D8E8-4E21-80D9-AEA6E41B13ED} Library Properties - Apex7000_BillValidator - Apex7000_BillValidator + PyramidNETRS232 + PyramidNETRS232 v3.5 512 @@ -33,7 +33,7 @@ TRACE prompt 4 - bin\Release\Apex7000_BillValidator.XML + bin\Release\PyramidNETRS232.xml diff --git a/Apex7000_BillValidator/RS232Config.cs b/Apex7000_BillValidator/RS232Config.cs index 264359d..a1ccc3c 100644 --- a/Apex7000_BillValidator/RS232Config.cs +++ b/Apex7000_BillValidator/RS232Config.cs @@ -1,6 +1,6 @@ using System; -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// Define the operating parameters of your bill acceptor @@ -22,10 +22,8 @@ public class RS232Config /// /// /// String port name e.g. COM4 - public RS232Config(string commPort) - { - new RS232Config(commPort.ToString(), false); - } + public RS232Config(string commPort) : this(commPort.ToString(), false) + { } /// /// Create a new configuration to use for the Apex7000 validator class. diff --git a/Apex7000_BillValidator/SlaveCodex.cs b/Apex7000_BillValidator/SlaveCodex.cs index 980b028..053004f 100644 --- a/Apex7000_BillValidator/SlaveCodex.cs +++ b/Apex7000_BillValidator/SlaveCodex.cs @@ -1,6 +1,6 @@ using System; -namespace Apex7000_BillValidator +namespace PyramidNETRS232 { /// /// Used internally to quickly translate between bytes and the string meaning diff --git a/Apex7000_BillValidator_Test/App.xaml b/Apex7000_BillValidator_Test/App.xaml index fdb1ebb..094ce90 100644 --- a/Apex7000_BillValidator_Test/App.xaml +++ b/Apex7000_BillValidator_Test/App.xaml @@ -1,4 +1,4 @@ - diff --git a/Apex7000_BillValidator_Test/App.xaml.cs b/Apex7000_BillValidator_Test/App.xaml.cs index 7772c43..cd00e99 100644 --- a/Apex7000_BillValidator_Test/App.xaml.cs +++ b/Apex7000_BillValidator_Test/App.xaml.cs @@ -1,6 +1,6 @@ using System.Windows; -namespace Apex7000_BillValidator_Test +namespace PyramidNETRS232_TestApp { /// /// Interaction logic for App.xaml diff --git a/Apex7000_BillValidator_Test/BillBank_Sample.cs b/Apex7000_BillValidator_Test/BillBank_Sample.cs index 2e040fb..e37e616 100644 --- a/Apex7000_BillValidator_Test/BillBank_Sample.cs +++ b/Apex7000_BillValidator_Test/BillBank_Sample.cs @@ -1,10 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -namespace Apex7000_BillValidator_Test +namespace PyramidNETRS232_TestApp { partial class MainWindow : INotifyPropertyChanged { diff --git a/Apex7000_BillValidator_Test/CreditAndEscrow_Sample.cs b/Apex7000_BillValidator_Test/CreditAndEscrow_Sample.cs index d785d05..1aac3e8 100644 --- a/Apex7000_BillValidator_Test/CreditAndEscrow_Sample.cs +++ b/Apex7000_BillValidator_Test/CreditAndEscrow_Sample.cs @@ -1,14 +1,30 @@ -using Apex7000_BillValidator; +using PyramidNETRS232; using System; +using System.Windows; -namespace Apex7000_BillValidator_Test +namespace PyramidNETRS232_TestApp { /// /// This class demonstrates how to handle the OnCredit Event /// partial class MainWindow { - + /// + /// All of this mess is the make the the async manual accept/reject buttons work + /// + private static object manualLock = new object(); + private bool actionTaken = false; + private bool enableManualButtons = false; + public bool EnableManualButtons + { + get { return enableManualButtons; } + set + { + enableManualButtons = value; + NotifyPropertyChanged("EnableManualButtons"); + } + } + private int lastIndex = 0; /// /// If in escrow mode, check that we have the specified index enabled @@ -17,16 +33,10 @@ partial class MainWindow /// private void validator_OnEscrow(object sender, EscrowArgs e) { - var index = e.Index; + lastIndex = e.Index; DoOnUIThread(() => { - - string action = ""; - - // If bill is enabled by our mask, stack the note - bool isEnabled = checkEnableMask(index); - // Here you could also a call to check the user's account balance to make sure they're not // exceeding a specified amount. Remember, returns and rejects can be triggered by a few things: // 1) Reject : Invalid note @@ -34,32 +44,67 @@ private void validator_OnEscrow(object sender, EscrowArgs e) // 3) Return : Note disabled by E/D mask // 4) Return : Host manually send return message because a check failed (e.g. too much money on user account etc.) - - if (isEnabled) + + // If we're already taken action, clear the actionTaken flag. Otherwise enable our + // manual buttons so an action can be taken. + lock (manualLock) { - // Pass Escrow state to UI - State = States.Escrowed; - action = "Escrowed"; - validator.Stack(); - } - else - { - action = "Rejected"; - validator.Reject(); + if (!actionTaken && lastIndex != 0) + EnableManualButtons = true; + else + actionTaken = false; } + }); + } - if (currencyMap.ContainsKey(index)) - Console.WriteLine("{0} ${1}", action, currencyMap[index]); - else - Console.WriteLine("{0} Unknown denomination index: {1}", action, index); - }); + private void btnAccept_Click(object sender, RoutedEventArgs e) + { + validator.Stack(); + + + if (currencyMap.ContainsKey(lastIndex)) + Console.WriteLine("Escrowed ${0}", currencyMap[lastIndex]); + else + Console.WriteLine("Escrowed Unknown denomination index: {0}", lastIndex); + + + lock (manualLock) + { + lastIndex = 0; + + actionTaken = true; + EnableManualButtons = false; + } } + private void btnReject_Click(object sender, RoutedEventArgs e) + { + + validator.Reject(); + + + if (currencyMap.ContainsKey(lastIndex)) + Console.WriteLine("Rejected ${0}", currencyMap[lastIndex]); + else + Console.WriteLine("Rejected Unknown denomination index: {0}", lastIndex); + + lock (manualLock) + { + lastIndex = 0; + actionTaken = true; + EnableManualButtons = false; + } + } + + + + + /// /// On credit, add the val to our bill bank. /// diff --git a/Apex7000_BillValidator_Test/DebugData_Sample.cs b/Apex7000_BillValidator_Test/DebugData_Sample.cs index 9a37764..3121dcd 100644 --- a/Apex7000_BillValidator_Test/DebugData_Sample.cs +++ b/Apex7000_BillValidator_Test/DebugData_Sample.cs @@ -1,11 +1,9 @@ -using Apex7000_BillValidator; +using PyramidNETRS232; using System; using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; -using System.Text; -namespace Apex7000_BillValidator_Test +namespace PyramidNETRS232_TestApp { /// /// Demonstrates how to make use of the debug data diff --git a/Apex7000_BillValidator_Test/MainWindow.xaml b/Apex7000_BillValidator_Test/MainWindow.xaml index 494ad3e..72c951e 100644 --- a/Apex7000_BillValidator_Test/MainWindow.xaml +++ b/Apex7000_BillValidator_Test/MainWindow.xaml @@ -1,13 +1,12 @@ - + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + Title="RS-232 Sample Application 1.0.1" Height="650" Width="800" SnapsToDevicePixels="True" Icon="icon.ico"> -