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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3c51a0740fb7714bbb9012543195df2539e310653510dfd6f6b4972aaf4b7dd
4
- data.tar.gz: d02f24ea04041305ac5cc7b40c73e651451bca9caff08be1476bc592ac9fe56b
3
+ metadata.gz: 8269237b83fcfd5a052cdcc9cb9f702bbca2f8e093a918dca330418679cf0496
4
+ data.tar.gz: ff1e59646d0b04205e1f5151d6710c2f0834e2822dab3e842fd627c5a1878140
5
5
  SHA512:
6
- metadata.gz: 8d8e2423d20924eb5bcb96083268c337d3dbbb571f395d1d6861ce39de4f2391784de84674b59875fea61a0dc9aca7085aa41c7a7274362394582a6453d5cf5a
7
- data.tar.gz: 838806023856f1f566b4f49ce73b04ff6d1bae47b395e7b7d089ee288e1ed0ad85396fda76d7401866dea848b0288fd6be4a6cc1a8e306c0a11a192f09582445
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
@@ -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 %s '%s'" % [self.class, uid_string]
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
@@ -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
+ }
@@ -61,7 +61,7 @@ module Tinkerforge
61
61
  elsif c == ':' and out.size == 16
62
62
  colon = true
63
63
  else
64
- raise "Can not display '#{text}'"
64
+ raise "Can not display character '#{c}'"
65
65
  end
66
66
  end
67
67
 
@@ -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 #{host}:#{port}"
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 #{host}:#{port}"
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 "Unknown Device Identifier: #{enum_data[5]} (UID: #{enum_data[0]})"
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
- "Device '#{enum_data[0]}' " +
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(msg)
18
- if logger
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(msg)
24
- if logger
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(msg)
30
- if logger
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(msg)
36
- if logger
37
- logger.error(msg)
38
- end
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 logger_fatal(msg)
42
- if logger
43
- logger.fatal(msg)
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
 
@@ -3,7 +3,7 @@ require 'tinkerforge/version'
3
3
  module Tinkerforge
4
4
 
5
5
  # Tinderfridge version.
6
- TINDERFRIDGE_VERSION = '0.15.0'
6
+ TINDERFRIDGE_VERSION = '0.16.0'
7
7
 
8
8
  # About Tinkerforge & Tinderfridge.
9
9
  def self.about
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.15.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-02-06 00:00:00.000000000 Z
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