diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml
new file mode 100644
index 0000000..7759597
--- /dev/null
+++ b/.github/workflows/pull_request.yaml
@@ -0,0 +1,44 @@
+name: Pull Request CI
+
+on:
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ test_2x:
+ runs-on: ubuntu-18.04
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ - name: Run Tests
+ run: |
+ echo $(pwd)
+ echo $(ls)
+ docker pull nrel/openstudio:2.9.1
+ docker run --name test --rm -d -t -v $(pwd):/work -w /work nrel/openstudio:2.9.1
+ docker exec -t test pwd
+ docker exec -t test ls
+ docker exec -t test which openstudio
+ docker exec -t test openstudio openstudio_version
+ docker exec -t test bundle update
+ docker exec -t test bundle exec rake
+ docker kill test
+ test_3x:
+ runs-on: ubuntu-18.04
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+ - name: Run Tests
+ run: |
+ echo $(pwd)
+ echo $(ls)
+ docker pull nrel/openstudio:3.0.0
+ docker run --name test --rm -d -t -v $(pwd):/work -w /work nrel/openstudio:3.0.0
+ docker exec -t test pwd
+ docker exec -t test ls
+ docker exec -t test which openstudio
+ docker exec -t test openstudio openstudio_version
+ docker exec -t test bundle update
+ docker exec -t test bundle exec rake
+ docker kill test
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 2e0cc80..6188801 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,6 @@
output
-.DS_Store
\ No newline at end of file
+.DS_Store
+config.rb
+Gemfile.lock
+ViewData.zip
+ViewModel.zip
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..373f0fd
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,5 @@
+source 'http://rubygems.org'
+
+gem 'rake'
+
+gem 'rest-client'
\ No newline at end of file
diff --git a/README.md b/README.md
index cd838c4..ab7b4d1 100644
--- a/README.md
+++ b/README.md
@@ -2,4 +2,6 @@
Exporter of OpenStudio Model to [vA3C](http://va3c.github.io/) JSON format. This reporting measure exports an OpenStudio model to the [vA3C](http://va3c.github.io/) JSON format. Additional user data is added to all surfaces in the export. The JSON file is configured into an html file and rendered using Three.js.
-A huge thanks goes out to [Theo Armour](https://github.com/theo-armour) and the [vA3C team](http://va3c.github.io/) for helping figure out how to do all this stuff.
\ No newline at end of file
+A huge thanks goes out to [Theo Armour](https://github.com/theo-armour) and the [vA3C team](http://va3c.github.io/) for helping figure out how to do all this stuff.
+
+Type `rake` to build html for measures and app
\ No newline at end of file
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..154c7b5
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,107 @@
+#require 'bundler'
+#Bundler.setup
+
+require 'rake'
+require 'rest-client'
+require 'fileutils'
+require 'open3'
+
+begin
+ require_relative 'config'
+rescue LoadError
+ require 'openstudio'
+ $OPENSTUDIO_EXE = OpenStudio::getOpenStudioCLI
+end
+
+def get_clean_env
+ new_env = {}
+ new_env['BUNDLER_ORIG_MANPATH'] = nil
+ new_env['BUNDLER_ORIG_PATH'] = nil
+ new_env['BUNDLER_VERSION'] = nil
+ new_env['BUNDLE_BIN_PATH'] = nil
+ new_env['RUBYLIB'] = nil
+ new_env['RUBYOPT'] = nil
+ new_env['GEM_PATH'] = nil
+ new_env['GEM_HOME'] = nil
+ new_env['BUNDLE_GEMFILE'] = nil
+ new_env['BUNDLE_PATH'] = nil
+ new_env['BUNDLE_WITHOUT'] = nil
+
+ return new_env
+end
+
+desc 'Build html files for measures and OS App'
+task :build do
+
+ in_file = ""
+ app_file = ""
+ removing = false
+ File.open('report.html.in', 'r') do |file|
+ file.each_line do |line|
+
+ if md = /\n"
+ end
+
+ in_file += line
+
+ if /\/\/ BEGIN_REMOVE/.match(line)
+ removing = true
+ next
+ elsif /\/\/ END_REMOVE/.match(line)
+ removing = false
+ next
+ elsif removing
+ next
+ end
+
+ app_file += line
+
+ end
+ end
+
+ File.open(File.join(File.dirname(__FILE__), 'ViewModel/resources/report.html.in'), 'w') do |file|
+ file << in_file
+ end
+
+ File.open(File.join(File.dirname(__FILE__), 'ViewData/resources/report.html.in'), 'w') do |file|
+ file << in_file
+ end
+
+ File.open(File.join(File.dirname(__FILE__), 'geometry_preview.html'), 'w') do |file|
+ file << app_file
+ end
+
+ FileUtils.cp('va3c.rb', File.join(File.dirname(__FILE__), 'ViewModel/resources/va3c.rb'))
+
+ FileUtils.cp('va3c.rb', File.join(File.dirname(__FILE__), 'ViewData/resources/va3c.rb'))
+
+ cmd = "\"#{$OPENSTUDIO_EXE}\" measure --update_all ."
+ puts cmd
+ stdout_str, stderr_str, status = Open3.capture3(get_clean_env, cmd)
+end
+
+desc 'Run Measure Tests'
+task :test do
+
+ Dir.chdir("#{File.join(File.dirname(__FILE__), 'ViewModel/tests/')}")
+ cmd = "\"#{$OPENSTUDIO_EXE}\" ViewModel_Test.rb"
+ puts cmd
+ view_model_stdout, view_model_stderr, status = Open3.capture3(get_clean_env, cmd)
+ view_model_result = status.success?
+
+ Dir.chdir("#{File.join(File.dirname(__FILE__), 'ViewData/tests/')}")
+ cmd = "\"#{$OPENSTUDIO_EXE}\" ViewData_Test.rb"
+ puts cmd
+ view_data_stdout, view_data_stderr, status = Open3.capture3(get_clean_env, cmd)
+ view_data_result = status.success?
+
+ puts view_model_stdout if !view_model_result
+ puts view_data_stdout if !view_data_result
+ puts "Test failed" if !(view_model_result && view_data_result)
+end
+
+task :default => [:build, :test]
\ No newline at end of file
diff --git a/ViewData/measure.rb b/ViewData/measure.rb
index dd2d1ca..7d52fbf 100644
--- a/ViewData/measure.rb
+++ b/ViewData/measure.rb
@@ -48,7 +48,7 @@ def energyPlusOutputRequests(runner, user_arguments)
end
#define the arguments that the user will input
- def arguments()
+ def arguments(model = nil)
args = OpenStudio::Ruleset::OSArgumentVector.new
chs = OpenStudio::StringVector.new
@@ -326,14 +326,26 @@ def run(runner, user_arguments)
# convert the model to vA3C JSON format
start_time = Time.now
#puts "converting model to vA3C"
- json = VA3C.convert_model(model)
+ json = nil
+ model_clone = model.clone(true).to_Model
+ begin
+ # try to use new implementation
+ ft = OpenStudio::Model::ThreeJSForwardTranslator.new
+ three_scene = ft.modelToThreeJS(model_clone, true)
+ json = JSON::parse(three_scene.toJSON(false), {:symbolize_names=>true})
+ runner.registerInfo("Used new ThreeScene translator.")
+ rescue NameError, StandardError
+ # use old Ruby implementation
+ runner.registerInfo("Using Ruby VA3C translator.")
+ json = VA3C.convert_model(model_clone)
+ end
#puts "finished converting model, elapsed time #{Time.now-start_time}"
- json['metadata'][:variables] = meta_variables
+ json[:metadata][:variables] = meta_variables
json[:times] = [times]
json[:variables] = variables
- json['object'][:children].each do |child|
+ json[:object][:children].each do |child|
name = child[:userData][:name].upcase
surface = surface_data.find{|x| x[:surface_name] == name}
diff --git a/ViewData/measure.xml b/ViewData/measure.xml
index f026dde..75c3e71 100644
--- a/ViewData/measure.xml
+++ b/ViewData/measure.xml
@@ -1,9 +1,15 @@
+