Class: NetLinx::Rake::ERB::Push

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/netlinx/rake/erb/push.rb

Overview

Push project to NetLinx master(s).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :push) {|_self| ... } ⇒ Push

Returns a new instance of Push.

Yields:

  • (_self)

Yield Parameters:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/netlinx/rake/erb/push.rb', line 14

def initialize name = :push
  @name = name
  yield self if block_given?
  
  desc "Push project to NetLinx master(s)."
  
  task(name) do
    require 'netlinx-erb'
    
    puts "Pushing files to master(s)..."
    
    # AMX BUG:
    # Make sure FileTransfer isn't running when FTCon.exe is executed.
    # FileTransfer2.exe fails to terminate if it fails to connect to
    # a master controller. This causes the first workspace to remain
    # in memory, even if the workspace settings are changed and
    # FileTransfer2.exe is executed again. Sometimes it ignores the
    # kill signal, so the /f flag is used to force termination.
    # 
    # Reported to AMX support on 2015-03-30.
    # Escalation# 26107
    # If you encounter this bug, report it to AMX:
    # [email protected] or 1-800-932-6993
    if Gem.win_platform?
      IO.popen "taskkill /f /im FileTransfer2.exe 2> nul"
    else
      IO.popen "killall -q -s KILL FileTransfer2.exe"
    end
    
    sleep 0.25 # Let process terminate.
    
    # TODO: Implement ENV['NETLINX_ACTIVE_SYSTEM_ONLY']
    # TODO: Implement filtering by type:
    #   code, master files (code, IR), touch panels,
    #   specific touch panel/device
    
    Dir["*.apw"].first.tap do |apw_file|
      unless apw_file
        puts "NetLinx workspace file not found."
        exit
      end
      
      system "FTCon \"#{apw_file}\""
      puts "Done.\n\n"
    end
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/netlinx/rake/erb/push.rb', line 12

def name
  @name
end