Class: ONVIF::PtzAction::GetConfigurationOptions

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

c_token 的结构 c_token = “xxxxx” //[ReferenceToken] Token of an existing configuration that the options are intended for.



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
45
46
47
48
49
50
# File 'lib/ruby_onvif_client/ptz/get_configuration_options.rb', line 10

def run c_token, cb
    message = create_ptz_onvif_message
    message.body =  ->(xml) do
        xml.wsdl(:GetConfigurationOptions) do
            xml.wsdl :ConfigurationToken, c_token
        end
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            root_doc = xml_doc.xpath("//tptz:PTZConfigurationOptions")
            pt_control_direction = root_doc.at_xpath("tptz:PTControlDirection")
            configuration = {}
            configuration = get_space_muster(root_doc, "Spaces", nil)
            unless pt_control_direction.nil?
                eflip_mode = []; reverse_mode = []
                pt_control_direction.xpath("tt:EFlip/tt:Mode").each do |mode|
                    eflip_mode << mode.content
                end
                pt_control_direction.xpath("tt:Reverse/tt:Mode").each do |mode|
                    reverse_mode << mode.content
                end
                configuration[:PTControlDirection] = {
                    eflip: {
                        mode: eflip_mode,
                        extension: ""
                    },
                    reverse: {
                        mode: reverse_mode,
                        extension: ""
                    }
                }
            end
            configuration[:ptz_timeout] = get_min_max(root_doc, "tt:PTZTimeout")
            configuration[:extension] = ""
            callback cb, success, configuration
        else
            callback cb, success, result
        end
    end
end