Class: Winsvc::Control
- Inherits:
-
Struct
- Object
- Struct
- Winsvc::Control
- Defined in:
- lib/winsvc.rb
Overview
A control message delivered to the service body. Every instance is frozen.
control :stop :shutdown :preshutdown :pause :continue :power :session_change
event_type Integer|nil — PBT_* (:power), WTS_* (:session_change)
session_id Integer|nil — WTSSESSION_NOTIFICATION.dwSessionId (:session_change)
data String|nil — frozen ASCII-8BIT POWERBROADCAST_SETTING bytes
(≤ 512, truncated beyond) for PBT_POWERSETTINGCHANGE
time Float — Process::CLOCK_MONOTONIC seconds at delivery
Instance Attribute Summary collapse
-
#control ⇒ Object
Returns the value of attribute control.
-
#data ⇒ Object
Returns the value of attribute data.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#session_id ⇒ Object
Returns the value of attribute session_id.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
-
.from_raw(raw) ⇒ Object
Build a frozen Control from one raw C record [code, etype, sid, data, tick].
Instance Method Summary collapse
-
#initialize ⇒ Control
constructor
Every instance is frozen at construction (§2.4).
-
#stop? ⇒ Boolean
True for the stop-class controls (:stop, :shutdown, :preshutdown).
Constructor Details
#initialize ⇒ Control
Every instance is frozen at construction (§2.4).
118 119 120 121 |
# File 'lib/winsvc.rb', line 118 def initialize(*) super freeze end |
Instance Attribute Details
#control ⇒ Object
Returns the value of attribute control
115 116 117 |
# File 'lib/winsvc.rb', line 115 def control @control end |
#data ⇒ Object
Returns the value of attribute data
115 116 117 |
# File 'lib/winsvc.rb', line 115 def data @data end |
#event_type ⇒ Object
Returns the value of attribute event_type
115 116 117 |
# File 'lib/winsvc.rb', line 115 def event_type @event_type end |
#session_id ⇒ Object
Returns the value of attribute session_id
115 116 117 |
# File 'lib/winsvc.rb', line 115 def session_id @session_id end |
#time ⇒ Object
Returns the value of attribute time
115 116 117 |
# File 'lib/winsvc.rb', line 115 def time @time end |
Class Method Details
.from_raw(raw) ⇒ Object
Build a frozen Control from one raw C record [code, etype, sid, data, tick].
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/winsvc.rb', line 129 def self.from_raw(raw) code, etype, sid, data, _tick = raw sym = CONTROL_SYMBOLS[code] || :unknown event_type = sym == :power || sym == :session_change ? etype : nil session_id = sym == :session_change ? sid : nil new(control: sym, event_type: event_type, session_id: session_id, data: data, # already frozen ASCII-8BIT or nil time: Process.clock_gettime(Process::CLOCK_MONOTONIC)) end |
Instance Method Details
#stop? ⇒ Boolean
True for the stop-class controls (:stop, :shutdown, :preshutdown).
124 125 126 |
# File 'lib/winsvc.rb', line 124 def stop? STOP_CLASS.include?(control) end |