Top Level Namespace

Includes:
Ansible, Ansible::KNX, Ansible::ZWave, Socket::Constants

Defined Under Namespace

Modules: Ansible, OpenZWave Classes: DPT10, DPT9, DPT9_Float, EIBAddr, EIBBuffer, EIBConnection, EIBInt16, EIBInt32, EIBInt8, OZW_ValueID_id, OZW_ValueID_id1, OrbiterProxy, String

Constant Summary collapse

ENUM_RE =

a generic Rexegp to parse C/C++ enums, must substitute %s in-place with enumeration name

%q(.* 
    enum \s* %s \s* 
    \{  
        ([^\{\}]*) 
    \}\;
)
ENUM_RE_LINE =

e.g. Type_ValueChanged, /**< A node value has been updated from the Z-Wave network. */

/^ \s*  ([a-z_]+)  (\s*=\s*)* (\d*)  .*  \/\*\*\< \s (.*) \s \*\/$/ix

Constants included from Ansible::KNX

Ansible::KNX::APCICODES, Ansible::KNX::KNX_COMMAND_TOPIC, Ansible::KNX::KNX_MONITOR_TOPIC, Ansible::KNX::KNX_URL, Ansible::KNX::PRIOCLASSES, Ansible::KNX::TPDUCODES

Constants included from Ansible::ZWave

Ansible::ZWave::RefreshedNodes, Ansible::ZWave::THRIFT_URL, Ansible::ZWave::ThriftPort, Ansible::ZWave::ZWAVE_MONITOR_TOPIC

Constants included from Ansible

Ansible::STOMP_URL, Ansible::VERSION

Instance Method Summary collapse

Methods included from Ansible

root

Instance Method Details

#addr2str(a, ga = false) ⇒ Object

addr2str: Convert an integer to an EIB address string, in the form “1/2/3” or “1.2.3”



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ansible/knx/knx_tools.rb', line 28

def addr2str(a, ga=false)
    str=""
    if a.is_a?Array then
        #~ a = a[0]*256+a[1]
        a = a.pack('c*').unpack('n')[0]
    end
    if (ga)
        str = "#{(a >> 11) & 0xf}/#{(a >> 8) & 0x7}/#{a & 0xff}"
    else
        str = "#{a >> 12}.#{(a >> 8) & 0xf}.#{a & 0xff}"
    end
    return(str)
end

#decode_framedata(data) ⇒ Object



57
58
59
60
61
62
63
64
# File 'lib/ansible/knx/knx_tools.rb', line 57

def decode_framedata(data)
    case data
    when Fixnum then "0x"+data.to_s(16).upcase
    when Array then data.collect{|b| "0x"+b.to_s(16).upcase}
    when String then data.unpack('C*').collect{|b| "0x"+b.to_s(16).upcase}
    else data
    end
end

#frame_inspect(frame) ⇒ Object



66
67
68
69
70
71
# File 'lib/ansible/knx/knx_tools.rb', line 66

def frame_inspect(frame)
    return "#{Time.now.strftime('%a %d/%m/%Y %H:%M:%S %Z')}: #{Ansible::KNX::APCICODES[frame.apci]}" +  
    " prio=#{Ansible::KNX::PRIOCLASSES[frame.prio_class]}" + " len=#{frame.datalength}" +
    " from #{addr2str(frame.src_addr)} to #{addr2str(frame.dst_addr, frame.daf)}" +
    " data=" + decode_framedata(frame.datalength > 1 ? frame.data : frame.apci_data).inspect   
end

#str2addr(s) ⇒ Object

str2addr: Parse an address string into an unsigned 16-bit integer



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ansible/knx/knx_tools.rb', line 43

def str2addr(s)
    if m = s.match(/(\d*)\/(\d*)\/(\d*)/)
        a, b, c = m[1].to_i, m[2].to_i, m[3].to_i
        return ((a & 0x01f) << 11) | ((b & 0x07) << 8) | ((c & 0xff))
    end
    if m = s.match(/(\d*)\/(\d*)/)
        a,b = m[1].to_i, m[2].to_i
        return ((a & 0x01f) << 11) | ((b & 0x7FF))
    end
    if s.start_with?("0x")
        return (s.to_i & 0xffff)
    end
end