Method: WorkflowRunner#result

Defined in:
lib/openstudio/workflow_runner.rb

#resultObject



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/openstudio/workflow_runner.rb', line 132

def result
  if @openstudio_2
    super
  else
    os_result = super

    current_step = @workflow.currentStep

    if current_step.empty?
      raise 'Cannot find current_step'
    end

    current_step = current_step.get

    if current_step.step[:result].nil?
      # skipped, prepareForUserScriptRun was not called
      current_step.step[:result] = {}
      current_step.step[:result][:started_at] = timeString
      current_step.step[:result][:step_result] = 'Skip'
    else
      current_step.step[:result][:step_result] = os_result.value.valueName
    end

    current_step.step[:result][:completed_at] = timeString

    # TODO: restore stdout and stderr

    # TODO: check for created files

    current_step.step[:result][:step_errors] = []
    os_result.errors.each do |error|
      current_step.step[:result][:step_errors] << error.logMessage
    end

    current_step.step[:result][:step_warnings] = []
    os_result.warnings.each do |warning|
      current_step.step[:result][:step_warnings] << warning.logMessage
    end

    current_step.step[:result][:step_info] = []
    os_result.info.each do |info|
      current_step.step[:result][:step_info] << info.logMessage
    end

    unless os_result.initialCondition.empty?
      current_step.step[:result][:initial_condition] = os_result.initialCondition.get.logMessage
      current_step.step[:result][:step_initial_condition] = os_result.initialCondition.get.logMessage
    end

    unless os_result.finalCondition.empty?
      current_step.step[:result][:final_condition] = os_result.finalCondition.get.logMessage
      current_step.step[:result][:step_final_condition] = os_result.finalCondition.get.logMessage
    end

    current_step.step[:result][:step_values] = []
    os_result.attributes.each do |attribute|
      result = nil
      if attribute.valueType == 'Boolean'.to_AttributeValueType
        result = { name: attribute.name, value: attribute.valueAsBoolean, type: 'Boolean' }
      elsif attribute.valueType == 'Double'.to_AttributeValueType
        result = { name: attribute.name, value: attribute.valueAsDouble, type: 'Double' }
      elsif attribute.valueType == 'Integer'.to_AttributeValueType
        result = { name: attribute.name, value: attribute.valueAsInteger, type: 'Integer' }
      elsif attribute.valueType == 'Unsigned'.to_AttributeValueType
        result = { name: attribute.name, value: attribute.valueAsUnsigned, type: 'Integer' }
      elsif attribute.valueType == 'String'.to_AttributeValueType
        result = { name: attribute.name, value: attribute.valueAsString, type: 'String' }
      end

      current_step.step[:result][:step_values] << result unless result.nil?
    end

    return WorkflowStepResult_Shim.new(current_step.step[:result])
  end
end