Class: McProtocolE::Frame1e::Device

Inherits:
Object
  • Object
show all
Defined in:
lib/mc_protocol_e/frame_1e/device.rb

Overview

This class shows a device.

Defined Under Namespace

Modules: Code, Type

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, type:) ⇒ Device

Constructor.

Parameters:

  • code (String)

    device code

  • type (Symbol)

    device type



35
36
37
38
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 35

def initialize(code:, type:)
  @code = code
  @type = type
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



30
31
32
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 30

def code
  @code
end

Class Method Details

.annunciatorObject



52
53
54
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 52

def self.annunciator
  new(code: Code::ANNUNCIATOR, type: Type::BIT)
end

.counter_coilObject



80
81
82
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 80

def self.counter_coil
  new(code: Code::COUNTER_COIL, type: Type::BIT)
end

.counter_contactObject



76
77
78
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 76

def self.counter_contact
  new(code: Code::COUNTER_CONTACT, type: Type::BIT)
end

.counter_current_valueObject



72
73
74
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 72

def self.counter_current_value
  new(code: Code::COUNTER_CURRENT_VALUE, type: Type::WORD)
end

.data_registerObject



84
85
86
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 84

def self.data_register
  new(code: Code::DATA_REGISTER, type: Type::WORD)
end

.file_registerObject



92
93
94
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 92

def self.file_register
  new(code: Code::FILE_REGISTER, type: Type::WORD)
end

.inputObject



40
41
42
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 40

def self.input
  new(code: Code::INPUT, type: Type::BIT)
end

.internal_relayObject



48
49
50
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 48

def self.internal_relay
  new(code: Code::INTERNAL_RELAY, type: Type::BIT)
end


88
89
90
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 88

def self.link_register
  new(code: Code::LINK_REGISTER, type: Type::WORD)
end


56
57
58
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 56

def self.link_relay
  new(code: Code::LINK_RELAY, type: Type::BIT)
end

.outputObject



44
45
46
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 44

def self.output
  new(code: Code::OUTPUT, type: Type::BIT)
end

.timer_coilObject



68
69
70
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 68

def self.timer_coil
  new(code: Code::TIMER_COIL, type: Type::BIT)
end

.timer_contactObject



64
65
66
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 64

def self.timer_contact
  new(code: Code::TIMER_CONTACT, type: Type::BIT)
end

.timer_current_valueObject



60
61
62
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 60

def self.timer_current_value
  new(code: Code::TIMER_CURRENT_VALUE, type: Type::WORD)
end

Instance Method Details

#bit?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 96

def bit?
  type == Type::BIT
end

#to_bObject



104
105
106
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 104

def to_b
  code
end

#word?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/mc_protocol_e/frame_1e/device.rb', line 100

def word?
  type == Type::WORD
end