class Mmana2nec::NecProcessor
Public Class Methods
write(intermediate_format, output_file)
click to toggle source
# File lib/mmana2nec/nec_processor.rb, line 3 def self.write intermediate_format, output_file file = File.open(output_file, "w", crlf_newline: true) # Comment end file.puts("CM Generated by mmana2nec") file.puts("CE") # Wires intermediate_format.wires.each_with_index do |w, index| index = index + 1 end_one = w[:end_one] end_two = w[:end_two] segments = w[:segments] gw = ["GW", index, segments, end_one[:x], end_one[:y], end_one[:z], end_two[:x], end_two[:y], end_two[:z], "%f" % (w[:diameter] / 2.0)] file.puts(gw.join(" ")) end file.puts("GE 1") # Frequency file.puts("FR 0 1 0 0 #{intermediate_format.frequency} 0") # Source intermediate_format.sources.each do |source| excitation_type = 0 #Only supported type now wire = source[:wire] segment = source[:segment] voltage = source[:voltage] phase = source[:phase] source = ["EX", excitation_type, wire, segment, 0, voltage, phase] file.puts(source.join(" ")) end # END file.puts("EN") file.close end