Class: OpenC3::ProcessStatusModel

Inherits:
Model show all
Defined in:
lib/openc3/models/process_status_model.rb

Overview

Stores the status about an process.

Constant Summary collapse

PRIMARY_KEY =
'openc3_process_status'

Instance Attribute Summary collapse

Attributes inherited from Model

#name, #plugin, #scope, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#check_disable_erb, #create, #deploy, #destroy, #destroyed?, filter, find_all_by_plugin, from_json, get_all_models, get_model, handle_config, set, store, store_queued, #undeploy, #update

Constructor Details

#initialize(name:, state: nil, process_type: nil, detail: nil, output: nil, updated_at: nil, plugin: nil, scope:) ⇒ ProcessStatusModel

END NOTE



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/openc3/models/process_status_model.rb', line 52

def initialize(
  name:,
  state: nil,
  process_type: nil,
  detail: nil,
  output: nil,
  updated_at: nil,
  plugin: nil,
  scope:
)
  super("#{scope}__#{PRIMARY_KEY}", name: name, updated_at: updated_at, plugin: plugin, scope: scope)
  @state = state
  @process_type = process_type
  @detail = detail
  @output = output
end

Instance Attribute Details

#detailObject

Returns the value of attribute detail.



32
33
34
# File 'lib/openc3/models/process_status_model.rb', line 32

def detail
  @detail
end

#outputObject

Returns the value of attribute output.



33
34
35
# File 'lib/openc3/models/process_status_model.rb', line 33

def output
  @output
end

#process_typeObject

Returns the value of attribute process_type.



31
32
33
# File 'lib/openc3/models/process_status_model.rb', line 31

def process_type
  @process_type
end

#stateObject

Returns the value of attribute state.



30
31
32
# File 'lib/openc3/models/process_status_model.rb', line 30

def state
  @state
end

Class Method Details

.all(scope:) ⇒ Object



45
46
47
48
49
# File 'lib/openc3/models/process_status_model.rb', line 45

def self.all(scope:)
  all = super("#{scope}__#{PRIMARY_KEY}")
  # Sort by the time and reverse to put newest (latest timestamp) on top
  all.sort_by { |key, value| value['updated_at'] }.reverse
end

.get(name:, scope:) ⇒ Object

NOTE: The following three class methods are used by the ModelController and are reimplemented to enable various Model class methods to work



37
38
39
# File 'lib/openc3/models/process_status_model.rb', line 37

def self.get(name:, scope:)
  super("#{scope}__#{PRIMARY_KEY}", name: name)
end

.names(scope:) ⇒ Object



41
42
43
# File 'lib/openc3/models/process_status_model.rb', line 41

def self.names(scope:)
  super("#{scope}__#{PRIMARY_KEY}")
end

Instance Method Details

#as_json(*a) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
# File 'lib/openc3/models/process_status_model.rb', line 69

def as_json(*a)
  {
    'name' => @name,
    'state' => @state,
    'process_type' => @process_type,
    'detail' => @detail,
    'output' => @output,
    'plugin' => @plugin,
    'updated_at' => @updated_at
  }
end