Class: Elemac::Outputs

Inherits:
Object
  • Object
show all
Defined in:
lib/elemac/outputs.rb

Instance Method Summary collapse

Constructor Details

#initialize(device:) ⇒ Outputs

Returns a new instance of Outputs.



7
8
9
10
11
12
13
14
# File 'lib/elemac/outputs.rb', line 7

def initialize(device:)
	@device = device
	# TODO: check loaded sensors
	@out_a = @out_b = @out_c = @out_d = @out_e = true
	@out_f = true
	@out_g = true
	# more unavailable now
end

Instance Method Details

#dimm_outputsObject



58
59
60
# File 'lib/elemac/outputs.rb', line 58

def dimm_outputs
	[out_f] # and more...
end

#out_aObject



16
17
18
19
# File 'lib/elemac/outputs.rb', line 16

def out_a
	throw 'Output A unavailable' unless @out_a
	PowerOutput.new(device: @device, index: 0)
end

#out_bObject



20
21
22
23
# File 'lib/elemac/outputs.rb', line 20

def out_b
	throw 'Output B unavailable' unless @out_b
	PowerOutput.new(device: @device, index: 1)
end

#out_cObject



24
25
26
27
# File 'lib/elemac/outputs.rb', line 24

def out_c
	throw 'Output C unavailable' unless @out_c
	PowerOutput.new(device: @device, index: 2)
end

#out_dObject



28
29
30
31
# File 'lib/elemac/outputs.rb', line 28

def out_d
	throw 'Output D unavailable' unless @out_d
	PowerOutput.new(device: @device, index: 3)
end

#out_eObject



32
33
34
35
# File 'lib/elemac/outputs.rb', line 32

def out_e
	throw 'Output E unavailable' unless @out_e
	PowerOutput.new(device: @device, index: 4)
end

#out_fObject



36
37
38
39
# File 'lib/elemac/outputs.rb', line 36

def out_f
	throw 'Output F unavailable' unless @out_f
	PwmOutput.new(device: @device, index: 5, dim_index: 0)
end

#out_gObject



40
41
42
43
# File 'lib/elemac/outputs.rb', line 40

def out_g
	throw 'Output G unavailable' unless @out_g
	TtlOutput.new(device: @device, index: 6)
end

#outputs_availableObject



45
46
47
# File 'lib/elemac/outputs.rb', line 45

def outputs_available
	['a','b','c','d','e','f','g'] # and more...
end

#power_outputsObject



49
50
51
52
53
54
55
56
# File 'lib/elemac/outputs.rb', line 49

def power_outputs
	outputs = []
	outputs << out_a if @out_a
	outputs << out_b if @out_b
	outputs << out_c if @out_c
	outputs << out_d if @out_d
	outputs << out_e if @out_e
end

#ttl_outputsObject



62
63
64
# File 'lib/elemac/outputs.rb', line 62

def ttl_outputs
	[out_g] # and more...
end