Class: ONVIF::DeviceManagementAction::SetSystemDateAndTime

Inherits:
Action
  • Object
show all
Defined in:
lib/ruby_onvif_client/device_management/set_system_date_and_time.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

#run(system_date_time, cb) ⇒ Object

system_date_time 的结构 {

type: 'Manual', //  'Manual', 'NTP'
ds: false // DaylightSavings [booblean]
time_zone: {//optional
    tz: 'xxxxx'// string TimeZone -> TZ  [token]
}
date_time: {//optional
    year: 2013 // int
    month: 6   // int 1 to 12
    day: 26 // int 1 to 31
    hour: 5  // int 0 to 23
    minute: 31 //int 0 to 59
    second: 44 //int 0 to 61 (typically 59)
}

}



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
51
52
# File 'lib/ruby_onvif_client/device_management/set_system_date_and_time.rb', line 22

def run system_date_time, cb
    message = Message.new namespaces: {:'xmlns:sch' => 'http://www.onvif.org/ver10/schema'}
    message.body =  ->(xml) do
        xml.wsdl(:SetSystemDateAndTime) do
            xml.wsdl :DateTimeType, system_date_time[:type]
            xml.wsdl :DaylightSavings, system_date_time[:ds]
            unless options[:time_zone].nil?
                xml.wsdl(:TimeZone) do
                    xml.sch :TZ, system_date_time[:time_zone][:tz]
                end
            end
            unless options[:date_time].nil?
                xml.wsdl(:UTCDateTime) do
                    xml.sch :Time do
                        xml.sch :Hour, system_date_time[:date_time][:hour]
                        xml.sch :Minute, system_date_time[:date_time][:minute]
                        xml.sch :Second, system_date_time[:date_time][:second]
                    end
                    xml.sch :Date do
                        xml.sch :Year, system_date_time[:date_time][:year]
                        xml.sch :Month, system_date_time[:date_time][:month]
                        xml.sch :Day, system_date_time[:date_time][:day]
                    end
                end
            end
        end
    end
    send_message message do |success, result|
        callback cb, success, result
    end
end