Class: ONVIF::PtzAction::GetConfiguration

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

p_c_token 的结构 p_c_token = “xxxxx” //[ReferenceToken] Token of the requested PTZConfiguration.



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

def run p_c_token, cb
    message = create_ptz_onvif_message
    message.body =  ->(xml) do
        xml.wsdl(:GetConfiguration) do
            xml.wsdl :PTZConfigurationToken, p_c_token
        end
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            root_doc = xml_doc.at_xpath("//tptz:PTZConfiguration")
            pan_tilt_limits_range = root_doc.at_xpath("tt:PanTiltLimits/tt:Range")
            zoom_limits_range = root_doc.at_xpath("tt:ZoomLimits/tt:Range")
            configuration = {
                name: value(root_doc, 'tt:Name'),
                use_count: value(root_doc, 'tt:UseCount'),
                token: attribute(root_doc, 'token'),
                node_token: value(root_doc, 'tt:NodeToken')
            }
            configuration = get_configuration_optional_value root_doc, configuration
            configuration = get_speed root_doc, "DefaultPTZSpeed", configuration
            configuration[:default_ptz_timeout] = value(root_doc, "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] = ""
            callback cb, success, configuration
        else
            callback cb, success, result
        end
    end
end