sappho-heatmiser-proxy 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,12 +20,14 @@ module Sappho
20
20
  Sappho::ApplicationAutoFlushLog.instance.info "#{NAME} version #{VERSION} - #{HOMEPAGE}"
21
21
  port = SystemConfiguration.instance.heatmiserPort
22
22
  maxClients = SystemConfiguration.instance.maxClients
23
- server = Sappho::Socket::SafeServer.new('heatmiser proxy', port, maxClients, 15, true)
23
+ server = Sappho::Socket::SafeServer.new('heatmiser proxy', port, maxClients, 10, true)
24
24
  server.serve do
25
25
  | socket, ip | HeatmiserClient.new(socket, ip).communicate
26
26
  end
27
27
  Thread.new do
28
- Heatmiser.new.monitor { server.clientCount > 0 }
28
+ Heatmiser.new.monitor do
29
+ server.clientCount > 0
30
+ end
29
31
  end.join
30
32
  end
31
33
 
@@ -16,7 +16,7 @@ module Sappho
16
16
  include Singleton, Sappho::LogUtilities
17
17
 
18
18
  def initialize
19
- @refreshStatus = false
19
+ @refreshRequested = false
20
20
  @queue = []
21
21
  @mutex = Mutex.new
22
22
  @log = Sappho::ApplicationAutoFlushLog.instance
@@ -25,14 +25,14 @@ module Sappho
25
25
  def refreshStatus clientIP
26
26
  @log.info "client #{clientIP} requests status refresh"
27
27
  @mutex.synchronize do
28
- @refreshStatus = true
28
+ @refreshRequested = true
29
29
  end
30
30
  end
31
31
 
32
- def refreshRequested
32
+ def refreshRequested?
33
33
  @mutex.synchronize do
34
- requested = @refreshStatus
35
- @refreshStatus = false
34
+ requested = @refreshRequested
35
+ @refreshRequested = false
36
36
  requested
37
37
  end
38
38
  end
@@ -48,20 +48,21 @@ module Sappho
48
48
  log.info "clock correction: #{hexString command}"
49
49
  end
50
50
  end
51
- refreshRequested = queue.refreshRequested or yield
51
+ refreshRequested = queue.refreshRequested?
52
+ clientsActive = yield
52
53
  unless command
53
- command = queryCommand if refreshRequested or (Time.now - timestamp) >= config.sampleDelay
54
+ command = queryCommand if refreshRequested or clientsActive or (Time.now - timestamp) >= config.sampleDelay
54
55
  end
55
56
  if command
56
57
  log.debug "sending command: #{hexString command}" if log.debug?
57
58
  socket.close # just in case it wasn't last time around
58
59
  socket.open config.heatmiserHostname, config.heatmiserPort
59
- socket.settle 0.1
60
+ socket.settle 0.01
60
61
  startTime = Time.now
61
62
  socket.write command.pack('c*')
62
63
  reply = socket.read(81).unpack('c*')
63
64
  timestamp = Time.now
64
- socket.settle 0.1
65
+ socket.settle 0.01
65
66
  socket.close
66
67
  log.debug "reply: #{hexString reply}" if log.debug?
67
68
  crcHi = reply.pop & 0xFF
@@ -7,7 +7,7 @@ module Sappho
7
7
  module Heatmiser
8
8
  module Proxy
9
9
  NAME = 'sappho-heatmiser-proxy'
10
- VERSION = '0.1.8'
10
+ VERSION = '0.1.9'
11
11
  AUTHORS = ['Andrew Heald']
12
12
  EMAILS = ['andrew@heald.co.uk']
13
13
  HOMEPAGE = 'https://github.com/sappho/sappho-heatmiser-proxy/wiki'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sappho-heatmiser-proxy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 8
10
- version: 0.1.8
9
+ - 9
10
+ version: 0.1.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Heald