Class: Evolis::PremiumSdk::Cmd

Inherits:
SdkBase
  • Object
show all
Defined in:
lib/evolis/premium_sdk/cmd.rb

Constant Summary collapse

TIMEOUT =

Default timeout for CMD service

'3000'

Constants inherited from SdkBase

SdkBase::SETTINGS

Instance Attribute Summary

Attributes inherited from SdkBase

#active_session

Instance Method Summary collapse

Methods inherited from SdkBase

#active_session?, #call_rpc, #list_settings, #print_setting, #request, #response, #sanitize_parameters, #valid_base64?, #valid_settings?

Constructor Details

#initialize(host, port) ⇒ Cmd

Initializes the class and sets SDK host and port

Parameters:

  • host (String)

    host or IP for SDK

  • port (String, Fixnum)

    port for SDK



13
14
15
# File 'lib/evolis/premium_sdk/cmd.rb', line 13

def initialize(host, port)
  super(host, port, 'CMD')
end

Instance Method Details

#get_status(device) ⇒ String

Retrieves the binary status of a device

Parameters:

  • device (String)

    printer name

Returns:

  • (String)

    binary status of the device, see SDK document



35
36
37
38
39
# File 'lib/evolis/premium_sdk/cmd.rb', line 35

def get_status(device)
  call_rpc('GetStatus', {
      device: device
  })
end

#reset_com(device, timeout = TIMEOUT) ⇒ true

Reset communications with a device

Parameters:

  • device (String)

    printer name

  • timeout (String) (defaults to: TIMEOUT)

    communication timeout

Returns:

  • (true)

    if reset successful



46
47
48
49
50
51
# File 'lib/evolis/premium_sdk/cmd.rb', line 46

def reset_com(device, timeout = TIMEOUT)
  call_rpc('ResetCom', {
      timeout: timeout,
      device:  device
  })
end

#send_command(device, command, timeout = TIMEOUT) ⇒ String

Sends commands in text or binary format

Parameters:

  • device (String)

    printer name

  • command (String)

    command, in clear text or base64-encoded format

  • timeout (String) (defaults to: TIMEOUT)

    communication timeout

Returns:

  • (String)

    response to the sent command



23
24
25
26
27
28
29
# File 'lib/evolis/premium_sdk/cmd.rb', line 23

def send_command(device, command, timeout = TIMEOUT)
  call_rpc('SendCommand', {
      command: command,
      timeout: timeout,
      device:  device
  })
end