Class: ONVIF::DeviceManagementAction::GetCapabilities

Inherits:
Action
  • Object
show all
Defined in:
lib/ruby_onvif_client/device_management/get_capabilities.rb

Instance Method Summary collapse

Methods inherited from Action

#attribute, #callback, #create_event_onvif_message, #create_media_onvif_message, #create_ptz_onvif_message, #initialize, #send_message, #value

Constructor Details

This class inherits a constructor from ONVIF::Action

Instance Method Details

#_get_analytics(xml_analytics) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 45

def _get_analytics xml_analytics
    {
        x_addr: value(xml_analytics, '//tt:XAddr'),
        rule_support: value(xml_analytics, '//tt:RuleSupport'),
        ams: value(xml_analytics, '//tt:AnalyticsModuleSupport')
    }
end

#_get_device(xml_device) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 53

def _get_device xml_device
    network_keys = ["IPFilter", "ZeroConfiguration", "IPVersion6", "DynDNS", "Dot11Configuration", 
        "Dot1XConfigurations", "HostnameFromDHCP", "NTP", "DHCPv6"]
    system_keys = ["DiscoveryResolve", "DiscoveryBye", "RemoteDiscovery", "SystemBackup", "SystemLogging",
        "FirmwareUpgrade", "HttpFirmwareUpgrade", "HttpSystemBackup", "HttpSystemLogging", "HttpSupportInformation"]
    security_keys = ["TLS1.0", "TLS1.1", "TLS1.2", "OnboardKeyGeneration", "AccessPolicyConfig", 
        "DefaultAccessPolicy", "Dot1X", "RemoteUserHandling", "X.509Token", "SAMLToken", "KerberosToken", 
        "UsernameToken", "HttpDigest", "RELToken", "SupportedEAPMethods"]
    network = {}; system = {}; security = {}
    network_keys.each do |key|
        network[key.underscore] = value(xml_device, '//tt:' + key) unless value(xml_device, '//tt:' + key) == ''
    end
    system_keys.each do |key|
        system[key.underscore] = value(xml_device, '//tt:' + key) unless value(xml_device, '//tt:' + key) == ''
    end
    security_keys.each do |key|
        security[key.underscore] = value(xml_device, '//tt:' + key) unless value(xml_device, '//tt:' + key) == ''
    end
    return {
        x_addr: value(xml_device, '//tt:XAddr'),
        network: network,
        system: system,
        io: {
            input_connectors: value(xml_device, '//tt:InputConnectors'),
            relay_outputs: value(xml_device, '//tt:RelayOutputs'),
            extension: ""
        },
        security: security
    }
end

#_get_events(xml_events) ⇒ Object



84
85
86
87
88
89
90
91
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 84

def _get_events xml_events
    {
        x_addr: value(xml_events, '//tt:XAddr'),
        wssubscription_policy_support: value(xml_events, '//tt:WSSubscriptionPolicySupport'),
        wspull_point_support: value(xml_events, '//tt:WSPullPointSupport'),
        wspsmis: value(xml_events, '//tt:WSPausableSubscriptionManagerInterfaceSupport')
    }
end

#_get_imaging(xml_imaging) ⇒ Object



93
94
95
96
97
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 93

def _get_imaging xml_imaging
    {
        x_addr: value(xml_imaging, '//tt:XAddr')
    }
end

#_get_media(xml_media) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 99

def _get_media xml_media
    {
        x_addr: value(xml_media, '//tt:XAddr'),
        streaming_capabilities: {
            rtp_multicast: value(xml_media, '//tt:RTPMulticast'),
            rtp_tcp: value(xml_media, '//tt:RTPMulticast'),
            rtp_rtsp_tcp: value(xml_media, '//tt:RTP_RTSP_TCP'),
            extension: ""
        },
        extension: ""
    }
end

#_get_ptz(xml_ptz) ⇒ Object



112
113
114
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 112

def _get_ptz xml_ptz
    {x_addr: value(xml_ptz, '//tt:XAddr')}
end

#run(options, cb) ⇒ Object

options 的结构 <!–0 or more–> [

Category: "All", //nil, 'All', 'Analytics', 'Device', 'Events', 'Imaging', 'Media', 'PTZ'  
           <!--0 or more-->

]



11
12
13
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
# File 'lib/ruby_onvif_client/device_management/get_capabilities.rb', line 11

def run options, cb
    message = Message.new
    message.body =  ->(xml) do
        xml.wsdl(:GetCapabilities) do
            unless options.nil?
                options.each do |option|
                    xml.wsdl :Category, option[:Category]
                end
            end
        end
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            xml_analytics = xml_doc.at_xpath('//tt:Analytics')
            xml_device = xml_doc.at_xpath('//tt:Device')
            xml_events = xml_doc.at_xpath('//tt:Events')
            xml_imaging = xml_doc.at_xpath('//tt:Imaging')
            xml_media = xml_doc.xpath('//tt:Media')
            xml_ptz = xml_doc.xpath('//tt:PTZ')
            success_result = {}
            success_result[:analytics] = _get_analytics(xml_analytics) unless xml_analytics.nil?
            success_result[:device] = _get_device(xml_device) unless xml_device.nil?
            success_result[:events] = _get_events(xml_events) unless xml_events.nil?
            success_result[:imaging] = _get_imaging(xml_imaging) unless xml_imaging.nil?
            success_result[:media] = _get_media(xml_media) unless xml_media.nil?
            success_result[:ptz] = _get_ptz(xml_ptz) unless xml_ptz.nil?
            callback cb, success, success_result
        else
            callback cb, success, result
        end
    end
end