# ABCCardTerminalMonitor

    class ABCCardTerminalMonitor

CardTerminal helper class for monitoring detected CardTerminals.

Monitors for disconnection and battery level. If a delegate has been set will call callback functions once a CardTerminal disconnect or when a CardTerminal hits a pre-set battery threshold level.

- `delegate`

  Delegate, set this to the class acting as delegate for this class using the ABCCardTerminalMonitorProtocol

  #### Declaration

  Swift

      var delegate: ABCCardTerminalMonitorProtocol?

- `abcTerminalFactory`

  Main instance of the AB Circle Terminal Factory.

  #### Declaration

  Swift

      private let abcTerminalFactory: ABCircleTerminalFactory

- `terminalsToMonitor`

  CardTerminals to monitor

  #### Declaration

  Swift

      private var terminalsToMonitor: [String : CardTerminalToMonitor]

- `timer`

  Timer (used for automatically updating the Card Terminal list and information)

  #### Declaration

  Swift

      private var timer: DispatchSourceTimer?

- `timerRefreshRateInSeconds`

  Timer refresh rate in seconds

  #### Declaration

  Swift

      private var timerRefreshRateInSeconds: UInt16

- `batteryThreshold`

  Battery threshold to monitor

  #### Declaration

  Swift

      private var batteryThreshold: UInt8

- `timerQueue`

  Queue for timer

  #### Declaration

  Swift

      private let timerQueue: DispatchQueue

- `monitorRunning`

  Flag indicating if monitor is running

  #### Declaration

  Swift

      private var monitorRunning: Bool

- `init()`

  Initialiser.

  #### Declaration

  Swift

      init()

- `deinit`

  De-initialiser

  #### Declaration

  Swift

      deinit

- `startMonitoring(refreshRateInSeconds:batteryThreshold:)`

  Start monitoring CardTerminals using the entered values for refresh rate and battery threshold.

  #### Declaration

  Swift

      func startMonitoring(refreshRateInSeconds: UInt16 = 1, batteryThreshold: UInt8 = 20)

  #### Parameters

  `refreshRateInSeconds` | Monitor refresh rate in seconds
  `batteryThreshold` | Battery threshold to monitor for

- `stopMonitoring()`

  Stop monitoring CardTerminals

  #### Declaration

  Swift

      func stopMonitoring()

- `isMonitorRunning`

  Flag indicating if the monitor is currently running or not

  #### Declaration

  Swift

      var isMonitorRunning: Bool { get }

- `setBatteryThreshold(batteryThreshold:)`

  Set the battery threshold to monitor for all connected readers. Notes:

  - Setting this to 0 will disable monitoring the battery level

  - Setting a different value from the previous value will reset the notice

  #### Declaration

  Swift

      func setBatteryThreshold(batteryThreshold: UInt8)

  #### Parameters

  `batteryThreshold` | Threshold value from 0 to 100%

- `setMonitorRefreshRate(refreshRateInSeconds:)`

  Set the monitor refresh rate in seconds. This is the frequency where the monitors updates the information of the monitored CardTerminals. Note: setting this to 0 will disable monitoring completely.

  #### Declaration

  Swift

      func setMonitorRefreshRate(refreshRateInSeconds: UInt16)

  #### Parameters

  `refreshRateInSeconds` | refresh rate in seconds

- `onBatteryThresholdReached(terminalName:batteryThreshold:)`

  Function called when the battery threshold of a CardTerminal has been reached If a delegate has been set, will call the implemented callback function of the delegate.

  #### Declaration

  Swift

      private func onBatteryThresholdReached(terminalName: String, batteryThreshold: UInt8)

  #### Parameters

  `terminalName` | Name of the terminal that reached the battery threshold
  `batteryThreshold` | Value of the battery threshold

- `onDisconnected(terminalName:)`

  Function called when a CardTerminal has disconnected If a delegate has been set, will call the implemented callback function of the delegate.

  #### Declaration

  Swift

      private func onDisconnected(terminalName: String)

  #### Parameters

  `terminalName` | Name of the terminal that has disconnected

- `startMonitor()`

  Starts the CardTerminal monitor

  #### Declaration

  Swift

      private func startMonitor()

- `stopMonitor()`

  Stops the CardTerminal monitor

  #### Declaration

  Swift

      private func stopMonitor()

- `monitorCardTerminals()`

  Callback function called by the timer which does all the monitoring @objc

  #### Declaration

  Swift

      private func monitorCardTerminals()

- `checkDisconnectedTerminals(terminals:)`

  Checks if a CardTerminal has disconnected

  #### Declaration

  Swift

      private func checkDisconnectedTerminals(terminals: [CardTerminal])

  #### Parameters

  `terminals` | latest CardTerminal list to check against

- `checkBatteryLevel()`

  Checks if a CardTerminal has reached the battery threshold

  #### Declaration

  Swift

      private func checkBatteryLevel()

- `removeMonitoredTerminal(terminalName:)`

  Removes a monitored CardTerminal from the internal list

  #### Declaration

  Swift

      private func removeMonitoredTerminal(terminalName: String)

  #### Parameters

  `terminalName` | Name of monitored CardTerminal to remove.

- `refreshMonitoredTerminals(terminals:)`

  Refreshes the internal list of monitored CardTerminals

  #### Declaration

  Swift

      private func refreshMonitoredTerminals(terminals: [CardTerminal])

  #### Parameters

  `terminals` | latest CardTerminal list to check against

Copyright (c) 2018-2024, AB Circle Ltd. All rights reserved.

Generated by jazzy ♪♫ v0.14.3, a Realm project.