Class: EnergyPlus::EpErrFile

Inherits:
Object
  • Object
show all
Defined in:
lib/energyplus/EpErrFile.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ EpErrFile

Returns a new instance of EpErrFile.



24
25
26
27
28
29
30
31
# File 'lib/energyplus/EpErrFile.rb', line 24

def initialize(path)
  @path = path.expand_path
  @warnings = []
  @severe_errors = []
  @fatal_errors = []
  @initialized = false
  @successful = false
end

Instance Method Details

#dirnameObject



64
65
66
# File 'lib/energyplus/EpErrFile.rb', line 64

def dirname
  @path.dirname
end

#fatal_error_countObject

the worst error



96
97
98
99
# File 'lib/energyplus/EpErrFile.rb', line 96

def fatal_error_count
    init if not initialized?
    @fatal_errors.size
end

#fatal_errorsObject



78
79
80
81
# File 'lib/energyplus/EpErrFile.rb', line 78

def fatal_errors
  init if not initialized?
  @fatal_errors
end

#initObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/energyplus/EpErrFile.rb', line 33

def init
  @initialized = true

  if @path.exist?
    File.open(@path) do |f|
      text = ''
      text << f.read
      @valid = true
      @warnings = parse("Warning", text)
      @severe_errors = parse("Severe", text)
      @fatal_errors = parse("Fatal", text)
      if text =~ /\s\*{13} EnergyPlus Completed Successfully/
        @successful = true
      end
    end
  end
end

#initialized?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/energyplus/EpErrFile.rb', line 56

def initialized?
  @initialized
end

#parse(id, text) ⇒ Object

work horse



102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/energyplus/EpErrFile.rb', line 102

def parse(id, text)
  storage = []
  this_text = text
  # match first id label and continue matching across lines while seeing the continue label "**   ~~~   **"
  regex = /\*\*\s*#{id}\s*\*\*.*?\n(\s+\*\*\s\s\s~~~\s\s\s\*\*.*?\n)*/m
  while match_data = this_text.match(regex)
    this_string = match_data.to_s.gsub(/.*\*\*\s*#{id}\s*\*\*/, '').gsub(/.*\*\*\s\s\s~~~\s\s\s\*\*/, '').gsub(/\s*\n/, "\n")
    storage.push(this_string)
    this_text = match_data.post_match
  end
  return storage.uniq
end

#pathObject



60
61
62
# File 'lib/energyplus/EpErrFile.rb', line 60

def path
  @path
end

#severe_error_countObject

severe errors are not as bad as fatal



90
91
92
93
# File 'lib/energyplus/EpErrFile.rb', line 90

def severe_error_count
    init if not initialized?
    @severe_errors.size
end

#severe_errorsObject



73
74
75
76
# File 'lib/energyplus/EpErrFile.rb', line 73

def severe_errors
  init if not initialized?
  @severe_errors
end

#successful?Boolean

Returns:

  • (Boolean)


115
116
117
118
# File 'lib/energyplus/EpErrFile.rb', line 115

def successful?
  init if not initialized?
  @successful
end

#valid?Boolean

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/energyplus/EpErrFile.rb', line 51

def valid?
  init if not initialized?
  @valid
end

#warning_countObject

just a warning



84
85
86
87
# File 'lib/energyplus/EpErrFile.rb', line 84

def warning_count
  init if not initialized?
  warnings.size
end

#warningsObject



68
69
70
71
# File 'lib/energyplus/EpErrFile.rb', line 68

def warnings
  init if not initialized?
  @warnings
end