domotics-core 0.2.4 → 0.2.6

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
  SHA1:
3
- metadata.gz: 02ebecc7f97e80de2536f358cecad8575b774fe0
4
- data.tar.gz: 5883efe2e1f49b13f602956ddfcbbc79f532709e
3
+ metadata.gz: d0df5b7aed0f74551c9630ea84e66e006c0b095c
4
+ data.tar.gz: 7b682e057b6b50a7d3c298c802ba319509addb61
5
5
  SHA512:
6
- metadata.gz: e27789dbc3e14975c31f149778d2855b28b63c019e3e0afd341fd693e43469bd8ff6f279d4cda8802233400487eee5738f226e98b4f5030bcb9fea624f94407e
7
- data.tar.gz: 9ba2b8410f2e8b945f577f0988906e1bdd4adc8d569dad18231c27126b53fe3b707caf3291d063086841062e2fe3a4ad2d66b0d734b3ff2df5492913bb0bd4c1
6
+ metadata.gz: d6cd5037e04cfd22ac710ac87ed0c122d45933b7312764eface9213d5564384d91a96a8ba4e457906960a068ca463f26c0bdbf1fb701dc84892310ef46354bb4
7
+ data.tar.gz: 881b28a9040dcdc5109b5355a804cd1d30263b4a8ac9a31e72152ae401192759afa54b4dc35b16110a6e9264fd777e8c900b2c32af9097faef5bb61a5df054bd
@@ -1,8 +1,11 @@
1
1
  module Domotics::Core
2
2
  class FileCameraDevice < Device #__as__ :file_camera
3
+
3
4
  attr_accessor :mode
4
5
  attr_reader :current_file_name, :camera_element
6
+
5
7
  def initialize(args = {})
8
+ @sensors = []
6
9
  @current_file_name = nil
7
10
  @mode = args[:mode] || :watch
8
11
  # Emulate element
@@ -24,6 +27,11 @@ module Domotics::Core
24
27
  end
25
28
  super
26
29
  end
30
+
31
+ def register_sensor(sensor)
32
+ @sensors << sensor
33
+ end
34
+
27
35
  def event_handler(event)
28
36
  return if File.extname(event.name) != @file_ext
29
37
  # Wait untill close file and rename it
@@ -41,10 +49,13 @@ module Domotics::Core
41
49
  @current_file_name = nil
42
50
  FileUtils.rm "#{@path}/#{event.name}"
43
51
  end
52
+ @sensors.each { |sensor| sensor.state_changed :motion_detection }
44
53
  end
54
+
45
55
  def current_link
46
56
  "#{@camera_element.room.name}/#{@camera_element.name}/file/#{Time.now.to_i}#{@file_ext}"
47
57
  end
58
+
48
59
  def current_file
49
60
  IO.read @current_file_name if @current_file_name
50
61
  end
@@ -1,6 +1,6 @@
1
1
  module Domotics
2
2
  module Core
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.6"
4
4
  end
5
5
  end
6
6
 
@@ -1,6 +1,11 @@
1
1
  module Domotics
2
2
  module FileCamera
3
3
  module DigitalSensor
4
+ def initialize(args = {})
5
+ @device ||= args[:device]
6
+ @device && @device.register_sensor(self)
7
+ super
8
+ end
4
9
  end
5
10
  end
6
11
  end
@@ -60,4 +60,12 @@ class DomoticsElementsTestCase < Test::Unit::TestCase
60
60
  sleep 0.01
61
61
  assert_equal room.last_event(btn.name), :state_changed => :long_tap
62
62
  end
63
+
64
+ def test_camera_motion_sensor
65
+ room = Domotics::Core::Room[:test]
66
+ cam_mt = room.cam_motion
67
+ %x{echo "[test foto content]" > /tmp/test_foto.jpg}
68
+ sleep 0.5
69
+ assert_equal room.last_event(cam_mt.name), :state_changed => :motion_detection
70
+ end
63
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: domotics-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - goredar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: domotics-arduino