tinderfridge 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinderfridge/device/configuration.rb +16 -0
- data/lib/tinderfridge/device.rb +2 -12
- data/lib/tinderfridge/device_info.txt +1 -0
- data/lib/tinderfridge/devices/bricklet_industrial_dual_ac_in/bricklet_industrial_dual_ac_in.json +11 -0
- data/lib/tinderfridge/devices/bricklet_segment_display_4x7_v2/bricklet_segment_display_4x7_v2.rb +1 -1
- data/lib/tinderfridge/ip_connection.rb +5 -4
- data/lib/tinderfridge/shared/logger.rb +34 -19
- data/lib/tinderfridge/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8269237b83fcfd5a052cdcc9cb9f702bbca2f8e093a918dca330418679cf0496
|
4
|
+
data.tar.gz: ff1e59646d0b04205e1f5151d6710c2f0834e2822dab3e842fd627c5a1878140
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb2db92d210948ce317538ef9826ec34e2171061f91f01ea4aa6964edd5379f8274e624cdfa5078618d7ebff4029f8c776c404324587c3344fb08ce9d58d9449
|
7
|
+
data.tar.gz: 2944c853d896630f99b2d305a8b76782fb67158199bfa108ca3ff7432e2c5381710bfdecca993d398bd60b26a0bf1eaefb81d8ef7afc1ba49c8574d255d37915
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Tinkerforge
|
2
|
+
class Device
|
3
|
+
|
4
|
+
# Returns configuration data for the device (a mutable Hash).
|
5
|
+
def config
|
6
|
+
@config ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
# Sets configuration data (a Hash) for the device.
|
10
|
+
def config=(configuration)
|
11
|
+
raise(ArgumentError, 'Invalid configuration') unless configuration.class == Hash
|
12
|
+
@config = configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/lib/tinderfridge/device.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'tinkerforge/ip_connection'
|
2
2
|
require 'tinderfridge/shared/logger'
|
3
|
+
require 'tinderfridge/device/configuration'
|
3
4
|
|
4
5
|
module Tinkerforge
|
5
6
|
|
@@ -76,7 +77,7 @@ module Tinkerforge
|
|
76
77
|
def initialize(uid, ipcon, device_identifier, device_display_name)
|
77
78
|
original_initialize(uid, ipcon, device_identifier, device_display_name)
|
78
79
|
if respond_to? 'get_identity'
|
79
|
-
logger_debug "Created
|
80
|
+
logger_debug "Created #{self.class}"
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -141,17 +142,6 @@ module Tinkerforge
|
|
141
142
|
].compact.to_h
|
142
143
|
end
|
143
144
|
|
144
|
-
# Returns configuration data for the device (a mutable Hash).
|
145
|
-
def config
|
146
|
-
@config ||= {}
|
147
|
-
end
|
148
|
-
|
149
|
-
# Sets configuration data (a Hash) for the device.
|
150
|
-
def config=(configuration)
|
151
|
-
raise(ArgumentError, 'Invalid configuration') unless configuration.class == Hash
|
152
|
-
@config = configuration
|
153
|
-
end
|
154
|
-
|
155
145
|
# Opens the online documentation for the device (Mac OS only).
|
156
146
|
#
|
157
147
|
# When the URL for the documentation is not known, does nothing.
|
@@ -145,3 +145,4 @@
|
|
145
145
|
2165 DC Bricklet 2.0 Tinkerforge::BrickletDCV2 bricklet_dc_v2
|
146
146
|
2166 Silent Stepper Bricklet 2.0 Tinkerforge::BrickletSilentStepperV2 bricklet_silent_stepper_v2
|
147
147
|
2171 GPS Bricklet 3.0 Tinkerforge::BrickletGPSV3 bricklet_gps_v3
|
148
|
+
2174 Industrial Dual AC In Bricklet Tinkerforge::BrickletIndustrialDualACIn bricklet_industrial_dual_ac_in
|
data/lib/tinderfridge/devices/bricklet_industrial_dual_ac_in/bricklet_industrial_dual_ac_in.json
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"dimensions": [
|
3
|
+
40,
|
4
|
+
40,
|
5
|
+
16
|
6
|
+
],
|
7
|
+
"weight": 29,
|
8
|
+
"documentation_en_url": "https://www.tinkerforge.com/en/doc/Hardware/Bricklets/Industrial_Dual_AC_In.html",
|
9
|
+
"versions_identifier": "bricklets:industrial_dual_ac_in",
|
10
|
+
"released": "2023-05-12"
|
11
|
+
}
|
@@ -20,9 +20,10 @@ module Tinkerforge
|
|
20
20
|
|
21
21
|
# Creates a TCP/IP connection to the given host and port. Logs events if event logging is enabled.
|
22
22
|
def connect(host, port)
|
23
|
-
logger_debug "Connecting to
|
23
|
+
logger_debug "Connecting to %s:%s" % [host, port]
|
24
|
+
ts = Time.now.to_f
|
24
25
|
original_connect(host, port)
|
25
|
-
logger_debug "Connected to
|
26
|
+
logger_debug "Connected to %s:%s (%5.3fs)" % [host, port, Time.now.to_f - ts]
|
26
27
|
end
|
27
28
|
|
28
29
|
alias original_disconnect disconnect
|
@@ -148,14 +149,14 @@ module Tinkerforge
|
|
148
149
|
require "tinkerforge/#{dev_info[2][1]}"
|
149
150
|
Tinkerforge.const_get(dev_info[2][0]).new enum_data[0], self
|
150
151
|
else
|
151
|
-
logger_warn "
|
152
|
+
logger_warn "[ #{enum_data[0]} ] Unknown Device Identifier: #{enum_data[5]}"
|
152
153
|
nil
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
156
157
|
def logger_log_enum(enum_data)
|
157
158
|
logger_debug(
|
158
|
-
"
|
159
|
+
"[ #{enum_data[0]} ] Device " +
|
159
160
|
['available', 'connected', 'disconnected'][enum_data[6]] +
|
160
161
|
( enum_data[6] == 2 ? '' : " (Device Identifier: #{enum_data[5]})" )
|
161
162
|
)
|
@@ -14,33 +14,48 @@ module Tinkerforge
|
|
14
14
|
Tinkerforge.logger
|
15
15
|
end
|
16
16
|
|
17
|
-
def logger_debug(
|
18
|
-
|
19
|
-
logger.debug(msg)
|
20
|
-
end
|
17
|
+
def logger_debug(message='', &block)
|
18
|
+
logger_log(0, message, &block)
|
21
19
|
end
|
22
20
|
|
23
|
-
def logger_info(
|
24
|
-
|
25
|
-
logger.info(msg)
|
26
|
-
end
|
21
|
+
def logger_info(message='', &block)
|
22
|
+
logger_log(1, message, &block)
|
27
23
|
end
|
28
24
|
|
29
|
-
def logger_warn(
|
30
|
-
|
31
|
-
logger.warn(msg)
|
32
|
-
end
|
25
|
+
def logger_warn(message='', &block)
|
26
|
+
logger_log(2, message, &block)
|
33
27
|
end
|
34
28
|
|
35
|
-
def logger_error(
|
36
|
-
|
37
|
-
|
38
|
-
|
29
|
+
def logger_error(message='', &block)
|
30
|
+
logger_log(3, message, &block)
|
31
|
+
end
|
32
|
+
|
33
|
+
def logger_fatal(message='', &block)
|
34
|
+
logger_log(4, message, &block)
|
39
35
|
end
|
40
36
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
37
|
+
def logger_log(level, message='', &block)
|
38
|
+
return unless logger
|
39
|
+
|
40
|
+
if message.empty? and block_given?
|
41
|
+
message = yield
|
42
|
+
end
|
43
|
+
|
44
|
+
if respond_to? 'uid_string'
|
45
|
+
message = "[ #{uid_string} ] #{message}"
|
46
|
+
end
|
47
|
+
|
48
|
+
case level
|
49
|
+
when 0
|
50
|
+
logger.debug(message)
|
51
|
+
when 1
|
52
|
+
logger.info(message)
|
53
|
+
when 2
|
54
|
+
logger.warn(message)
|
55
|
+
when 3
|
56
|
+
logger.error(message)
|
57
|
+
when 4
|
58
|
+
logger.fatal(message)
|
44
59
|
end
|
45
60
|
end
|
46
61
|
|
data/lib/tinderfridge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinderfridge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lllist.eu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tinkerforge
|
@@ -38,6 +38,7 @@ extra_rdoc_files: []
|
|
38
38
|
files:
|
39
39
|
- lib/tinderfridge.rb
|
40
40
|
- lib/tinderfridge/device.rb
|
41
|
+
- lib/tinderfridge/device/configuration.rb
|
41
42
|
- lib/tinderfridge/device_collection.rb
|
42
43
|
- lib/tinderfridge/device_info.rb
|
43
44
|
- lib/tinderfridge/device_info.txt
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- lib/tinderfridge/devices/bricklet_industrial_digital_in_4_v2/bricklet_industrial_digital_in_4_v2.json
|
88
89
|
- lib/tinderfridge/devices/bricklet_industrial_digital_out_4_v2/bricklet_industrial_digital_out_4_v2.json
|
89
90
|
- lib/tinderfridge/devices/bricklet_industrial_dual_0_20ma_v2/bricklet_industrial_dual_0_20ma_v2.json
|
91
|
+
- lib/tinderfridge/devices/bricklet_industrial_dual_ac_in/bricklet_industrial_dual_ac_in.json
|
90
92
|
- lib/tinderfridge/devices/bricklet_industrial_dual_ac_relay/bricklet_industrial_dual_ac_relay.json
|
91
93
|
- lib/tinderfridge/devices/bricklet_industrial_dual_analog_in_v2/bricklet_industrial_dual_analog_in_v2.json
|
92
94
|
- lib/tinderfridge/devices/bricklet_industrial_dual_relay/bricklet_industrial_dual_relay.json
|