Class: ONVIF::PtzAction::GetConfigurations

Inherits:
Action
  • Object
show all
Includes:
ONVIF::PtzCommon
Defined in:
lib/ruby_onvif_client/ptz/get_configurations.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(cb) ⇒ Object



8
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
40
41
42
43
# File 'lib/ruby_onvif_client/ptz/get_configurations.rb', line 8

def run cb
    message = create_ptz_onvif_message
    message.body =  ->(xml) do
        xml.wsdl(:GetConfigurations)
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            configurations = []
            xml_doc.xpath("//tptz:PTZConfiguration").each do |root_node|
                pan_tilt_limits_range = root_node.at_xpath("tt:PanTiltLimits/tt:Range")
                zoom_limits_range = root_node.at_xpath("tt:ZoomLimits/tt:Range")
                configuration = {
                    name: value(root_node, 'tt:Name'),
                    use_count: value(root_node, 'tt:UseCount'),
                    token: attribute(root_node, 'token'),
                    node_token: value(root_node, 'tt:NodeToken')
                }
                configuration = get_configuration_optional_value root_node, configuration
                configuration = get_speed root_node, "DefaultPTZSpeed", configuration
                configuration[:default_ptz_timeout] = value(root_node, "tt:DefaultPTZTimeout")
                configuration[:pan_tilt_limits] = {
                    range: get_pan_tilt_limits(pan_tilt_limits_range)
                }
                configuration[:zoom_limits] = {
                    range: get_zoom_limits(zoom_limits_range)
                }
                configuration[:extension] = ""
                configurations << configuration
            end
            callback cb, success, configurations
        else
            callback cb, success, result
        end
    end
end