/// <summary> /// Handle cash box notifications /// </summary> /// <param name="pollResponse">Poll response from device</param> private void HandleCashBox(Rs232ResponseMessage pollResponse) { IsCashBoxPresent = pollResponse.IsCashBoxPresent; if (pollResponse.IsCashBoxPresent) { // Only report an attached cash box if we've reported it missing if (!_apexState.CashBoxAttachedReported && _apexState.CashBoxRemovalReported) { Logger?.Info("{0} Reporting cash box attached", GetType().Name); CashBoxAttached(); _apexState.CashBoxAttachedReported = true; } // Clear the cash box removal flag so the next removal can raise and event _apexState.CashBoxRemovalReported = false; } else { if (!_apexState.CashBoxRemovalReported) { Logger?.Info("{0} Reporting cash box removed", GetType().Name); CashBoxRemoved(); _apexState.CashBoxRemovalReported = true; } // Clear the cash box attached flag so the next attachment can raise and event _apexState.CashBoxAttachedReported = false; } }
/// <summary> /// Handle event notifications /// </summary> /// <param name="pollResponse">Poll response from device</param> private void HandleEvents(Rs232ResponseMessage pollResponse) { // Report on any active events if (pollResponse.Event == Rs232Event.None) { return; } Logger?.Info("{0} Setting events(s): {1}", GetType().Name, pollResponse.Event); EventReported(pollResponse.Event); }
/// <summary> /// Handle state change actions /// </summary> /// <param name="pollResponse">Poll response from device</param> private void HandleState(Rs232ResponseMessage pollResponse) { // Report on any state change if (_apexState.LastState == pollResponse.State) { return; } var args = new StateChangeArgs(_apexState.LastState, pollResponse.State); StateChanged(args); Logger?.Info("{0} Entering state: {1}", GetType().Name, pollResponse.State); _apexState.LastState = pollResponse.State; }
/// <summary> /// Perform escrow actions /// </summary> /// <param name="pollResponse">Poll response from device</param> /// <remarks>If not in escrow mode no actions will be performed</remarks> private void HandleEscrow(Rs232ResponseMessage pollResponse) { if (!Config.IsEscrowMode || !pollResponse.State.HasFlag(Rs232State.Escrowed)) { return; } // Handle escrow state if (!pollResponse.CreditIndex.HasValue) { Logger?.Error("{0} Escrow state entered without a credit message", GetType().Name); } else { BillInEscrow(pollResponse.CreditIndex.Value); } }
/// <summary> /// Handle credit notifications /// </summary> /// <param name="pollResponse">Poll response from device</param> private void HandleCredit(Rs232ResponseMessage pollResponse) { // Report any available credit if (!pollResponse.Event.HasFlag(Rs232Event.Stacked)) { return; } if (!pollResponse.CreditIndex.HasValue) { Logger?.Error("{0} Stack event issued without a credit message", GetType().Name); } else { Logger?.Info("{0} Reporting credit index: {1}", GetType().Name, pollResponse.CreditIndex); CreditIndexReported(pollResponse.CreditIndex.Value); } }