Class: Terminal
- Inherits:
-
Object
- Object
- Terminal
- Includes:
- Redis::Objects
- Defined in:
- app/models/terminal.rb
Class Method Summary collapse
- .actual_modified_at ⇒ Object
- .as_json(*args) ⇒ Object
- .condition ⇒ Object
-
.config ⇒ Object
CONDITON.
- .disable ⇒ Object
-
.enable ⇒ Object
STATES.
- .enabled? ⇒ Boolean
- .ip ⇒ Object
- .keyword ⇒ Object
- .payment_in_progress? ⇒ Boolean
-
.ping ⇒ Object
ACTIONS.
- .providers_updated_at ⇒ Object
- .providers_updated_at=(value) ⇒ Object
- .reboot ⇒ Object
- .recalibrate ⇒ Object
- .reload ⇒ Object
- .state ⇒ Object
- .state=(value) ⇒ Object
- .to_json(*args) ⇒ Object
Class Method Details
.actual_modified_at ⇒ Object
46 47 48 |
# File 'app/models/terminal.rb', line 46 def self.actual_modified_at self.modified_at.value || DateTime.now end |
.as_json(*args) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'app/models/terminal.rb', line 106 def self.as_json(*args) { :address => Terminal.address.value, :modified_at => Terminal.actual_modified_at, :logo_url => Terminal.logo_url, :keyword => Terminal.keyword, :support_phone => Terminal.support_phone.value, :groups => Group.all.map{|x| x.as_json}, :providers => Provider.active.map{|x| x.as_json}, :promotions => Promotion.active.order(Promotion.arel_table[:priority]).limit(6).map{|x| x.provider_id} } end |
.condition ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'app/models/terminal.rb', line 123 def self.condition { :ip => ip, :state => Terminal.state, :banknotes => Payment.merge_banknotes(Payment.uncollected), :cash => Payment.merge_cash(Payment.uncollected.cash), :cashless => Payment.merge_cash(Payment.uncollected.cashless), :providers_updated_at => Terminal.providers_updated_at, :queues => { :payments => Sidekiq::Queue.new('payments').size, :pings => Sidekiq::Queue.new('pings').size, :orders => Sidekiq::Queue.new('orders').size, :sync => Sidekiq::Queue.new('sync').size }, :cash_acceptor => { :error => Smartware.cash_acceptor.error, :model => Smartware.cash_acceptor.model, :version => Smartware.cash_acceptor.version }, :printer => { :error => Smartware.printer.error, :model => Smartware.printer.model, :version => Smartware.printer.version }, :modem => { :error => Smartware.modem.error, :signal_level => Smartware.modem.signal_level, :balance => Smartware.modem.balance, :model => Smartware.modem.model, :version => Smartware.modem.version }, :watchdog => { :error => Smartware.watchdog.error, :model => Smartware.watchdog.model, :version => Smartware.watchdog.version }, :card_reader => { :error => Smartware.card_reader.error, :model => Smartware.card_reader.model, :version => Smartware.card_reader.version }, :version => Smartkiosk::Client::VERSION } end |
.config ⇒ Object
CONDITON
81 82 83 |
# File 'app/models/terminal.rb', line 81 def self.config @config ||= Smartkiosk::Config::YAML.new(Application.root.join 'config/services/application.yml') end |
.disable ⇒ Object
30 31 32 |
# File 'app/models/terminal.rb', line 30 def self.disable self.state = 'disabled' end |
.enable ⇒ Object
STATES
26 27 28 |
# File 'app/models/terminal.rb', line 26 def self.enable self.state = 'active' end |
.enabled? ⇒ Boolean
89 90 91 |
# File 'app/models/terminal.rb', line 89 def self.enabled? self.state == 'active' end |
.ip ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/models/terminal.rb', line 93 def self.ip orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true UDPSocket.open do |s| s.connect '64.233.187.99', 1 s.addr.last end rescue '0.0.0.0' ensure Socket.do_not_reverse_lookup = orig end |
.keyword ⇒ Object
85 86 87 |
# File 'app/models/terminal.rb', line 85 def self.keyword config.keyword end |
.payment_in_progress? ⇒ Boolean
34 35 36 |
# File 'app/models/terminal.rb', line 34 def self.payment_in_progress? self.payment_in_progress.value == "true" end |
.ping ⇒ Object
ACTIONS
61 62 63 |
# File 'app/models/terminal.rb', line 61 def self.ping PingWorker.perform_async end |
.providers_updated_at ⇒ Object
50 51 52 |
# File 'app/models/terminal.rb', line 50 def self.providers_updated_at self.providers_updates[self.config.host] rescue nil end |
.providers_updated_at=(value) ⇒ Object
54 55 56 |
# File 'app/models/terminal.rb', line 54 def self.providers_updated_at=(value) self.providers_updates = {self.config.host => value} end |
.reboot ⇒ Object
69 70 71 |
# File 'app/models/terminal.rb', line 69 def self.reboot Smartguard::Client.reboot_async end |
.recalibrate ⇒ Object
73 74 75 76 |
# File 'app/models/terminal.rb', line 73 def self.recalibrate Smartware.user_interface.delete_calibration Smartware.user_interface.restart_ui end |
.reload ⇒ Object
65 66 67 |
# File 'app/models/terminal.rb', line 65 def self.reload Smartguard::Client.restart_async end |
.state ⇒ Object
38 39 40 |
# File 'app/models/terminal.rb', line 38 def self.state self.actual_state.value || 'active' end |
.state=(value) ⇒ Object
42 43 44 |
# File 'app/models/terminal.rb', line 42 def self.state=(value) self.actual_state = value end |
.to_json(*args) ⇒ Object
119 120 121 |
# File 'app/models/terminal.rb', line 119 def self.to_json(*args) as_json.to_json end |