Class: ONVIF::PtzAction::GetNode

Inherits:
Action
  • Object
show all
Includes:
ONVIF::PtzCommon
Defined in:
lib/ruby_onvif_client/ptz/get_node.rb

Instance Method Summary collapse

Methods included from ONVIF::PtzCommon

#get_configuration_optional_value, #get_min_max, #get_pan_tilt_limits, #get_space_muster, #get_spaces, #get_speed, #get_zoom_limits

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

#run(node_token, cb) ⇒ Object

node_token 的结构 //[ReferenceToken] Token of the requested PTZNode.



9
10
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
# File 'lib/ruby_onvif_client/ptz/get_node.rb', line 9

def run node_token ,cb
    message = create_ptz_onvif_message
    message.body =  ->(xml) do
        xml.wsdl(:GetNode) do
            xml.wsdl :NodeToken, node_token
        end
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            preset_token = xml_doc.at_xpath('//tptz:PTZNode')
            ptz_node = {
                name: value(preset_token, "tt:Name"),
                token: attribute(preset_token, "token")
            }
            ptz_node = get_space_muster(preset_token, "SupportedPTZSpaces", ptz_node)
            ptz_node[:maximum_number_of_presets] = value(preset_token, "tt:MaximumNumberOfPresets")
            ptz_node[:home_supported] = value(preset_token, "tt:HomeSupported")
            ptz_node[:auxiliary_commands] = []
            unless preset_token.at_xpath("tt:AuxiliaryCommands").nil?
                ptz_node[:auxiliary_commands] = []
                preset_token.xpath("tt:AuxiliaryCommands").each do |command|
                    ptz_node[:auxiliary_commands] << command.content
                end
            end
            callback cb, success, ptz_node
        else
            callback cb, success, result
        end
    end
end