Module: Zklib::DeviceManagement
- Included in:
- Zklib
- Defined in:
- lib/zklib/device_management.rb
Constant Summary collapse
- DEVICE_NAME_KEYWORD =
'~DeviceName'- DISABLE_DEVICE_KEYWORD =
"\u0000\u0000"
Instance Method Summary collapse
-
#disable_device ⇒ Object
Disable attendance machine.
-
#enable_device ⇒ Object
Enable attendance machine.
-
#get_device_name ⇒ Object
Get device name.
-
#power_off_device ⇒ Object
Turn off attendance machine.
-
#restart_device ⇒ Object
Restart attendance machine.
Instance Method Details
#disable_device ⇒ Object
Disable attendance machine
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/zklib/device_management.rb', line 7 def disable_device execute_cmd( command: CMD_DISABLEDEVICE, command_string: DISABLE_DEVICE_KEYWORD ) do |opts| return puts "ERROR: #{options[:error]}" unless opts[:valid] data = opts[:data] if data.length > 7 data.split("\u0000").pop else puts 'ERROR: Invalid disable device response' end end end |
#enable_device ⇒ Object
Enable attendance machine
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/zklib/device_management.rb', line 24 def enable_device execute_cmd( command: CMD_ENABLEDEVICE, command_string: '' ) do |opts| return puts "ERROR: #{options[:error]}" unless opts[:valid] data = opts[:data] if data.length > 7 data.split("\u0000").pop else puts 'ERROR: Invalid enable device response' end end end |
#get_device_name ⇒ Object
Get device name
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/zklib/device_management.rb', line 41 def get_device_name execute_cmd( command: CMD_DEVICE, command_string: DEVICE_NAME_KEYWORD ) do |opts| return puts "ERROR: #{options[:error]}" unless opts[:valid] data = opts[:data] if data.length > 8 data.split("\u0000").pop.tr("#{DEVICE_NAME_KEYWORD}=", '') else puts 'ERROR: Invalid device name response' end end end |
#power_off_device ⇒ Object
Turn off attendance machine
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/zklib/device_management.rb', line 58 def power_off_device execute_cmd( command: CMD_POWEROFF, command_string: '' ) do |opts| return puts "ERROR: #{options[:error]}" unless opts[:valid] data = opts[:data] if data.length > 7 data.split("\u0000").pop else puts 'ERROR: Invalid power off device response' end end end |
#restart_device ⇒ Object
Restart attendance machine
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/zklib/device_management.rb', line 75 def restart_device execute_cmd( command: CMD_RESTART, command_string: '' ) do |opts| return puts "ERROR: #{options[:error]}" unless opts[:valid] data = opts[:data] if data.length > 7 data.split("\u0000").pop else puts 'ERROR: Invalid restart device response' end end end |