seeds.rb 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  2. #
  3. # Copyright (c) 2016, Electric Power Research Institute (EPRI)
  4. # All rights reserved.
  5. #
  6. # OpenADR ("this software") is licensed under BSD 3-Clause license.
  7. #
  8. # Redistribution and use in source and binary forms, with or without modification,
  9. # are permitted provided that the following conditions are met:
  10. #
  11. # * Redistributions of source code must retain the above copyright notice, this
  12. # list of conditions and the following disclaimer.
  13. #
  14. # * Redistributions in binary form must reproduce the above copyright notice,
  15. # this list of conditions and the following disclaimer in the documentation
  16. # and/or other materials provided with the distribution.
  17. #
  18. # * Neither the name of EPRI nor the names of its contributors may
  19. # be used to endorse or promote products derived from this software without
  20. # specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  23. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  24. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  25. # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  26. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  27. # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  29. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  31. # OF SUCH DAMAGE.
  32. #
  33. # This EPRI software incorporates work covered by the following copyright and permission
  34. # notices. You may not use these works except in compliance with their respective
  35. # licenses, which are provided below.
  36. #
  37. # These works are provided by the copyright holders and contributors "as is" and any express or
  38. # implied warranties, including, but not limited to, the implied warranties of merchantability
  39. # and fitness for a particular purpose are disclaimed.
  40. #
  41. #########################################################################################
  42. # MIT Licensed Libraries
  43. #########################################################################################
  44. #
  45. # * actionmailer 3.2.12 (http://www.rubyonrails.org) - Email composition, delivery, and receiving framework (part of Rails).
  46. # * actionpack 3.2.12 (http://www.rubyonrails.org) - Web-flow and rendering framework putting the VC in MVC (part of Rails).
  47. # * activemodel 3.2.12 (http://www.rubyonrails.org) - A toolkit for building modeling frameworks (part of Rails).
  48. # * activerecord 3.2.12 (http://www.rubyonrails.org) - Object-relational mapper framework (part of Rails).
  49. # * activeresource 3.2.12 (http://www.rubyonrails.org) - REST modeling framework (part of Rails).
  50. # * activesupport 3.2.12 (http://www.rubyonrails.org) - A toolkit of support libraries and Ruby core extensions extracted from the Rails framework.
  51. # * arel 3.0.2 (http://github.com/rails/arel) - Arel is a SQL AST manager for Ruby
  52. # * bootstrap-sass 3.1.1.0 (https://github.com/twbs/bootstrap-sass) - Twitter's Bootstrap, converted to Sass and ready to drop into Rails or Compass
  53. # * builder 3.0.4 (http://onestepback.org) - Builders for MarkUp.
  54. # * bundler 1.12.5 (http://bundler.io) - The best way to manage your application's dependencies
  55. # * capybara 2.4.4 (http://github.com/jnicklas/capybara) - Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb
  56. # * coffee-rails 3.2.2 () - Coffee Script adapter for the Rails asset pipeline.
  57. # * coffee-script-source 1.6.3 (http://jashkenas.github.com/coffee-script/) - The CoffeeScript Compiler
  58. # * docile 1.1.5 (https://ms-ati.github.io/docile/) - Docile keeps your Ruby DSLs tame and well-behaved
  59. # * edn 1.0.0 () - 'edn implements a reader for Extensible Data Notation by Rich Hickey.'
  60. # * erubis 2.7.0 (http://www.kuwata-lab.com/erubis/) - a fast and extensible eRuby implementation which supports multi-language
  61. # * execjs 1.4.0 (https://github.com/sstephenson/execjs) - Run JavaScript code from Ruby
  62. # * factory_girl 4.5.0 (https://github.com/thoughtbot/factory_girl) - factory_girl provides a framework and DSL for defining and using model instance factories.
  63. # * factory_girl_rails 4.5.0 (http://github.com/thoughtbot/factory_girl_rails) - factory_girl_rails provides integration between factory_girl and rails 3
  64. # * gem-licenses 0.1.2 (http://github.com/dblock/gem-licenses) - List all gem licenses.
  65. # * hike 1.2.3 (http://github.com/sstephenson/hike) - Find files in a set of paths
  66. # * i18n 0.6.5 (http://github.com/svenfuchs/i18n) - New wave Internationalization support for Ruby
  67. # * jdbc-postgresql 9.2.1000 (https://github.com/rosenfeld/jdbc-postgresql) - PostgresSQL jdbc driver for JRuby
  68. # * journey 1.0.4 (http://github.com/rails/journey) - Journey is a router
  69. # * jquery-rails 3.0.4 (http://rubygems.org/gems/jquery-rails) - Use jQuery with Rails 3
  70. # * json-schema 2.6.2 (http://github.com/ruby-json-schema/json-schema/tree/master) - Ruby JSON Schema Validator
  71. # * mail 2.4.4 (http://github.com/mikel/mail) - Mail provides a nice Ruby DSL for making, sending and reading emails.
  72. # * metaclass 0.0.4 (http://github.com/floehopper/metaclass) - Adds a metaclass method to all Ruby objects
  73. # * mime-types 1.23 (http://mime-types.rubyforge.org/) - This library allows for the identification of a file's likely MIME content type
  74. # * mocha 1.1.0 (http://gofreerange.com/mocha/docs) - Mocking and stubbing library
  75. # * multi_json 1.7.9 (http://github.com/intridea/multi_json) - A common interface to multiple JSON libraries.
  76. # * nokogiri 1.6.5 (http://nokogiri.org) - Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser
  77. # * polyglot 0.3.3 (http://github.com/cjheath/polyglot) - Augment 'require' to load non-Ruby file types
  78. # * rack-test 0.6.2 (http://github.com/brynary/rack-test) - Simple testing API built on Rack
  79. # * railties 3.2.12 (http://www.rubyonrails.org) - Tools for creating, working with, and running Rails applications.
  80. # * rake 10.1.0 (http://rake.rubyforge.org) - Ruby based make-like utility.
  81. # * rspec-core 2.14.3 (http://github.com/rspec/rspec-core) - rspec-core-2.14.3
  82. # * rspec-expectations 2.14.0 (http://github.com/rspec/rspec-expectations) - rspec-expectations-2.14.0
  83. # * rspec-mocks 2.14.1 (http://github.com/rspec/rspec-mocks) - rspec-mocks-2.14.1
  84. # * rspec-rails 2.14.0 (http://github.com/rspec/rspec-rails) - rspec-rails-2.14.0
  85. # * sass 3.2.9 (http://sass-lang.com/) - A powerful but elegant CSS compiler that makes CSS fun again.
  86. # * sass-rails 3.2.6 () - Sass adapter for the Rails asset pipeline.
  87. # * simplecov 0.9.0 (http://github.com/colszowka/simplecov) - Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites
  88. # * spork 1.0.0rc3 (http://github.com/sporkrb/spork) - spork
  89. # * therubyrhino 2.0.2 (http://github.com/cowboyd/therubyrhino) - Embed the Rhino JavaScript interpreter into JRuby
  90. # * thor 0.18.1 (http://whatisthor.com/) - A scripting framework that replaces rake, sake and rubigen
  91. # * tilt 1.4.1 (http://github.com/rtomayko/tilt/) - Generic interface to multiple Ruby template engines
  92. # * treetop 1.4.14 (https://github.com/cjheath/treetop) - A Ruby-based text parsing and interpretation DSL
  93. # * uglifier 2.1.2 (http://github.com/lautis/uglifier) - Ruby wrapper for UglifyJS JavaScript compressor
  94. # * xpath 2.0.0 (http://github.com/jnicklas/xpath) - Generate XPath expressions from Ruby
  95. # * blankslate 2.1.2.4 (http://github.com/masover/blankslate) - BlankSlate extracted from Builder.
  96. # * bourbon 3.1.8 (https://github.com/thoughtbot/bourbon) - Bourbon Sass Mixins using SCSS syntax.
  97. # * coffee-script 2.2.0 (http://github.com/josh/ruby-coffee-script) - Ruby CoffeeScript Compiler
  98. # * diff-lcs 1.2.4 (http://diff-lcs.rubyforge.org/) - Diff::LCS computes the difference between two Enumerable sequences using the McIlroy-Hunt longest common subsequence (LCS) algorithm
  99. # * jquery-ui-rails 4.0.3 (https://github.com/joliss/jquery-ui-rails) - jQuery UI packaged for the Rails asset pipeline
  100. # * parslet 1.4.0 (http://kschiess.github.com/parslet) - Parser construction library with great error reporting in Ruby.
  101. # * rack 1.4.5 (http://rack.github.com/) - a modular Ruby webserver interface
  102. # * rack-cache 1.2 (http://tomayko.com/src/rack-cache/) - HTTP Caching for Rack
  103. # * rack-ssl 1.3.3 (https://github.com/josh/rack-ssl) - Force SSL/TLS in your app.
  104. # * rails 3.2.12 (http://www.rubyonrails.org) - Full-stack web application framework.
  105. # * simplecov-html 0.8.0 (https://github.com/colszowka/simplecov-html) - Default HTML formatter for SimpleCov code coverage tool for ruby 1.9+
  106. # * tzinfo 0.3.37 (http://tzinfo.rubyforge.org/) - Daylight-savings aware timezone library
  107. # * warbler 1.4.0.beta1 (http://caldersphere.rubyforge.org/warbler) - Warbler chirpily constructs .war files of your Rails applications.
  108. #
  109. #########################################################################################
  110. # BSD Licensed Libraries
  111. #########################################################################################
  112. #
  113. # * activerecord-jdbc-adapter 1.2.9.1 (https://github.com/jruby/activerecord-jdbc-adapter) - Copyright (c) 2006-2012 Nick Sieger <nick@nicksieger.com>, Copyright (c) 2006-2008 Ola Bini <ola.bini@gmail.com>
  114. # * jdbc-postgres 9.2.1004 (https://github.com/jruby/activerecord-jdbc-adapter) - Copyright (c) 1997-2011, PostgreSQL Global Development Group
  115. # * d3js 3.5.16 (https://d3js.org/) Copyright (c) 2015 Mike Bostock
  116. #
  117. #########################################################################################
  118. # Ruby Licensed Libraries
  119. #########################################################################################
  120. #
  121. # * json 1.8.0 (http://json-jruby.rubyforge.org/) - JSON implementation for JRuby
  122. # * rubyzip 0.9.9 (http://github.com/aussiegeek/rubyzip) - rubyzip is a ruby module for reading and writing zip files
  123. # * httpclient 2.3.4.1 (http://github.com/nahi/httpclient) - gives something like the functionality of libwww-perl (LWP) in Ruby
  124. # * test-unit 2.5.5 (http://test-unit.rubyforge.org/) - test-unit - Improved version of Test::Unit bundled in Ruby 1.8.x.
  125. #
  126. #########################################################################################
  127. # Public domain - creative commons Licensed Libraries
  128. #########################################################################################
  129. #
  130. # * torquebox 3.1.2 (http://torquebox.org/) - TorqueBox Gem
  131. # * torquebox-cache 3.1.2 (http://torquebox.org/) - TorqueBox Cache Gem
  132. # * torquebox-configure 3.1.2 (http://torquebox.org/) - TorqueBox Configure Gem
  133. # * torquebox-core 3.1.2 (http://torquebox.org/) - TorqueBox Core Gem
  134. # * torquebox-messaging 3.1.2 (http://torquebox.org/) - TorqueBox Messaging Client
  135. # * torquebox-naming 3.1.2 (http://torquebox.org/) - TorqueBox Naming Client
  136. # * torquebox-rake-support 3.1.2 (http://torquebox.org/) - TorqueBox Rake Support
  137. # * torquebox-security 3.1.2 (http://torquebox.org/) - TorqueBox Security Gem
  138. # * torquebox-server 3.1.2 (http://torquebox.org/) - TorqueBox Server Gem
  139. # * torquebox-stomp 3.1.2 (http://torquebox.org/) - TorqueBox STOMP Support
  140. # * torquebox-transactions 3.1.2 (http://torquebox.org/) - TorqueBox Transactions Gem
  141. # * torquebox-web 3.1.2 (http://torquebox.org/) - TorqueBox Web Gem
  142. #
  143. #########################################################################################
  144. # Apache Licensed Libraries
  145. #########################################################################################
  146. #
  147. # * addressable 2.3.8 (https://github.com/sporkmonger/addressable) - URI Implementation
  148. # * bcrypt-ruby 3.0.1 (http://bcrypt-ruby.rubyforge.org) - OpenBSD's bcrypt() password hashing algorithm.
  149. # * database_cleaner 1.4.0 (http://github.com/bmabey/database_cleaner) - Strategies for cleaning databases. Can be used to ensure a clean state for testing.
  150. # * annotate 2.5.0 (http://github.com/ctran/annotate_models) - Annotates Rails Models, routes, fixtures, and others based on the database schema.
  151. # * nvd3 1.8.4 (http://nvd3.org/) Copeyright (c) 2014 Novus Partners - chart library based on d3js
  152. # * smack 3.3.1 (https://www.igniterealtime.org/projects/smack/) - XMPP library
  153. #
  154. #########################################################################################
  155. # LGPL
  156. #########################################################################################
  157. #
  158. # * jruby-1.7.4
  159. # * jruby-jars 1.7.4 (http://github.com/jruby/jruby/tree/master/gem/jruby-jars) - The core JRuby code and the JRuby stdlib as jar
  160. # ** JRuby is tri-licensed GPL, LGPL, and EPL.
  161. #
  162. #########################################################################################
  163. # MPL Licensed Libraries
  164. #########################################################################################
  165. #
  166. # * therubyrhino_jar 1.7.4 (http://github.com/cowboyd/therubyrhino) - Rhino's jars packed for therubyrhino
  167. #
  168. #########################################################################################
  169. # Artistic 2.0
  170. # * mime-types 1.23 (http://mime-types.rubyforge.org/) - This library allows for the identification of a file's likely MIME content type
  171. #
  172. #########################################################################################
  173. #
  174. #########################################################################################
  175. # GPL-2
  176. #########################################################################################
  177. # * mime-types 1.23 (http://mime-types.rubyforge.org/) - This library allows for the identification of a file's likely MIME content type
  178. #
  179. #########################################################################################
  180. # No License Given
  181. #########################################################################################
  182. #
  183. # * spork-testunit 0.0.8 (http://github.com/timcharper/spork-testunit) - spork-testunit
  184. # * sprockets 2.2.2 (http://getsprockets.org/) - Rack-based asset packaging system
  185. #
  186. #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  187. # This file should contain all the record creation needed to seed the database with its default values.
  188. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
  189. #
  190. # Examples:
  191. #
  192. # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
  193. # Mayor.create(name: 'Emanuel', city: cities.first)
  194. # admin user
  195. admin = Account.new(name: "admin")
  196. admin.password = "testing"
  197. admin.password_confirmation = "testing"
  198. admin.is_admin = true
  199. admin.save
  200. admin = Account.find_by_name("admin")
  201. Account.create(name: "nonadmin", password: "testing", password_confirmation: "testing")
  202. vtn_parameters = VtnParameter.first
  203. if vtn_parameters.nil?
  204. vtn_parameters = VtnParameter.create(
  205. vtn_name: "EPRI_VTN",
  206. poll_interval: 10,
  207. endpoint20a_url: 'http://localhost:3000/OpenADR2/Simple/',
  208. endpoint20b_url: 'http://localhost:3000/OpenADR2/Simple/2.0b/'
  209. )
  210. end
  211. # market context
  212. mc = MarketContext.new(name: "http://MarketContext1", description: "", color: '#f60')
  213. mc.save
  214. mc = MarketContext.new(name: "http://MarketContext2", description: "", color: '#666')
  215. mc.save
  216. # resources
  217. ResourceType.create(name: 'resource1', description: 'resource1')
  218. ResourceType.create(name: 'resource2', description: 'resource2')
  219. #event status
  220. event_status = EventStatus.new(name: "none", description: "No event pending")
  221. event_status.save
  222. event_status = EventStatus.new(name: "far", description: "event pending in the far future. The exact definition of how far in the future this refers is dependent upon the market context, but typically means the next day.")
  223. event_status.save
  224. event_status = EventStatus.new(name: "near", description: "event pending in the near future. The exact definition of how near in the future the pending event is active is dependent on the market context")
  225. event_status.save
  226. event_status = EventStatus.new(name: "active", description: "The event has been initiated and is currently active.")
  227. event_status.save
  228. event_status = EventStatus.new(name: "completed", description: "The event has completed.")
  229. event_status.save
  230. event_status = EventStatus.new(name: "cancelled", description: "The event has been canceled.")
  231. event_status.save
  232. # signal type
  233. signal_type = SignalType.new(name: "DELTA", description: "DELTA")
  234. signal_type.save
  235. signal_type = SignalType.new(name: "LEVEL", description: "LEVEL")
  236. signal_type.save
  237. signal_type = SignalType.new(name: "MULTIPLIER", description: "MULTIPLIER")
  238. signal_type.save
  239. signal_type = SignalType.new(name: "PRICE", description: "PRICE")
  240. signal_type.save
  241. signal_type = SignalType.new(name: "PRICE_MULTIPLIER", description: "PRICE_MULTIPLIER")
  242. signal_type.save
  243. signal_type = SignalType.new(name: "PRICE_RELATIVE", description: "PRICE_RELATIVE")
  244. signal_type.save
  245. signal_type = SignalType.new(name: "PRODUCT", description: "PRODUCT")
  246. signal_type.save
  247. signal_type = SignalType.new(name: "SETPOINT", description: "SETPOINT")
  248. signal_type.save
  249. SignalType.create(name: "X_LOAD_CONTROL_CAPACITY", description: "X_LOAD_CONTROL_CAPACITY")
  250. SignalType.create(name: "X_LOAD_CONTROL_LEVEL_OFFSET", description: "X_LOAD_CONTROL_LEVEL_OFFSET")
  251. SignalType.create(name: "X_LOAD_CONTROL_SETPOINT", description: "X_LOAD_CONTROL_SETPOINT")
  252. SignalType.create(name: "X_LOAD_CONTROL_PERCENT_OFFSET", description: "X_LOAD_CONTROL_PERCENT_OFFSET")
  253. SignalName.create(name: "simple", description: "simple")
  254. SignalName.create(name: "SIMPLE", description: "SIMPLE")
  255. SignalName.create(name: "ELECTRICITY_PRICE", description: "ELECTRICITY_PRICE")
  256. SignalName.create(name: "ENERGY_PRICE", description: "ENERGY_PRICE")
  257. SignalName.create(name: "DEMAND_CHARGE", description: "DEMAND_CHARGE")
  258. SignalName.create(name: "BID_PRICE", description: "BID_PRICE")
  259. SignalName.create(name: "BID_LOAD", description: "BID_LOAD")
  260. SignalName.create(name: "BID_ENERGY", description: "BID_ENERGY")
  261. SignalName.create(name: "CHARGE_STATE", description: "CHARGE_STATE")
  262. SignalName.create(name: "LOAD_DISPATCH", description: "LOAD_DISPATCH")
  263. SignalName.create(name: "LOAD_CONTROL", description: "LOAD_CONTROL")
  264. # current value (unused)
  265. current_value = CurrentValue.new(value: "normal", description: "normal")
  266. current_value.save
  267. current_value = CurrentValue.new(value: "moderate", description: "moderate")
  268. current_value.save
  269. current_value = CurrentValue.new(value: "high", description: "high")
  270. current_value.save
  271. current_value = CurrentValue.new(value: "special", description: "special")
  272. current_value.save
  273. # payload types
  274. payload_type = PayloadType.new(value: "0", name: "normal")
  275. payload_type.save
  276. payload_type = PayloadType.new(value: "1", name: "moderate")
  277. payload_type.save
  278. payload_type = PayloadType.new(value: "2", name: "high")
  279. payload_type.save
  280. payload_type = PayloadType.new(value: "3", name: "special")
  281. payload_type.save
  282. response_required_type = ResponseRequiredType.new(name: "always", description: "always")
  283. response_required_type.save
  284. response_required_type = ResponseRequiredType.new(name: "never", description: "never")
  285. response_required_type.save
  286. # report names
  287. ReportName.create(name: "METADATA_HISTORY_USAGE")
  288. ReportName.create(name: "HISTORY_USAGE")
  289. ReportName.create(name: "METADATA_HISTORY_GREENBUTTON")
  290. ReportName.create(name: "HISTORY_GREENBUTTON")
  291. ReportName.create(name: "METADATA_TELEMETRY_USAGE")
  292. ReportName.create(name: "TELEMETRY_USAGE")
  293. ReportName.create(name: "METADATA_TELEMETRY_STATUS")
  294. ReportName.create(name: "TELEMETRY_STATUS")
  295. # data quality
  296. DataQuality.create(name: "No Quality - No Value")
  297. DataQuality.create(name: "No New Value - Previous Value Used")
  298. DataQuality.create(name: "Quality Bad - Non Specific")
  299. DataQuality.create(name: "Quality Bad - Configuration Error")
  300. DataQuality.create(name: "Quality Bad - Not Connected")
  301. DataQuality.create(name: "Quality Bad - Device Failure")
  302. DataQuality.create(name: "Quality Bad - Sensor Failure")
  303. DataQuality.create(name: "Quality Bad - last Known Value")
  304. DataQuality.create(name: "Quality Bad - Comm Failure")
  305. DataQuality.create(name: "Quality Bad - Out of Service")
  306. DataQuality.create(name: "Quality Uncertain - Non Specific")
  307. DataQuality.create(name: "Quality Uncertain - Last Usable Value")
  308. DataQuality.create(name: "Quality Uncertain - Sensor Not Accurate")
  309. DataQuality.create(name: "Quality Uncertain - EU Units Exceeded")
  310. DataQuality.create(name: "Quality Uncertain - Sub Normal")
  311. DataQuality.create(name: "Quality Good - Non Specific")
  312. DataQuality.create(name: "Quality Good - Local Override")
  313. DataQuality.create(name: "Quality Limit - Field/Not")
  314. DataQuality.create(name: "Quality Limit - Field/Low")
  315. DataQuality.create(name: "Quality Limit - Field/High")
  316. DataQuality.create(name: "Quality Limit - Field/Constant")
  317. # reading type
  318. ReadingType.create(name: "Direct Read")
  319. ReadingType.create(name: "Net")
  320. ReadingType.create(name: "Allocated")
  321. ReadingType.create(name: "Estimated")
  322. ReadingType.create(name: "Summed")
  323. ReadingType.create(name: "Derived")
  324. ReadingType.create(name: "Mean")
  325. ReadingType.create(name: "Peak")
  326. ReadingType.create(name: "Hybrid")
  327. ReadingType.create(name: "Contract")
  328. ReadingType.create(name: "Projected")
  329. ReadingType.create(name: "x-RMS")
  330. ReadingType.create(name: "x-notApplicable")
  331. # report type
  332. ReportType.create(name: "reading")
  333. ReportType.create(name: "usage")
  334. ReportType.create(name: "demand")
  335. ReportType.create(name: "setPoint")
  336. ReportType.create(name: "deltaUsage")
  337. ReportType.create(name: "deltaSetPoint")
  338. ReportType.create(name: "deltaDemand")
  339. ReportType.create(name: "baseline")
  340. ReportType.create(name: "deviation")
  341. ReportType.create(name: "avgUsage")
  342. ReportType.create(name: "avgDemand")
  343. ReportType.create(name: "operatingState")
  344. ReportType.create(name: "upRegulationCapacityAvailable")
  345. ReportType.create(name: "downRegulationCapacityAvailable")
  346. ReportType.create(name: "regulationSetpoint")
  347. ReportType.create(name: "storedEnergy")
  348. ReportType.create(name: "targetEnergyStorage")
  349. ReportType.create(name: "availableEnergyStorage")
  350. ReportType.create(name: "price")
  351. ReportType.create(name: "level")
  352. ReportType.create(name: "powerFactor")
  353. ReportType.create(name: "percentUsage")
  354. ReportType.create(name: "percentDemand")
  355. ReportType.create(name: "x-resourceStatus")
  356. # opt type
  357. OptType.create(name: "optIn", description: "optIn")
  358. OptType.create(name: "optOut", description: "optOut")
  359. # opt reason
  360. OptReason.create(name: 'economic', description: 'economic')
  361. OptReason.create(name: 'emergency', description: 'emergency')
  362. OptReason.create(name: 'mustRun', description: 'mustRun')
  363. OptReason.create(name: 'notParticipating', description: 'notParticpating')
  364. OptReason.create(name: 'outageRunStatus', description: 'outageRunStatus')
  365. OptReason.create(name: 'overrideStatus', description: 'overrideStatus')
  366. OptReason.create(name: 'participating', description: 'particpating')
  367. OptReason.create(name: 'x-schedule', description: 'x-schedule')
  368. # services
  369. ServiceType.create(name: 'EiEvent', description: '')
  370. ServiceType.create(name: 'EiReport', description: '')
  371. ServiceType.create(name: 'EiOpt', description: '')
  372. ServiceType.create(name: 'EiRegisterParty', description: '')
  373. # unit types
  374. UnitType.create(name: 'Therm', description: 'Therm')
  375. UnitType.create(name: 'currency', description: 'currency')
  376. UnitType.create(name: 'currencyPerKW', description: 'currencyPerKW')
  377. UnitType.create(name: 'currencyPerKWh', description: 'currencyPerKWh')
  378. UnitType.create(name: 'currrencyPerThm', description: 'currrencyPerThm')
  379. UnitType.create(name: 'current', description: 'current')
  380. UnitType.create(name: 'customUnit', description: 'customUnit')
  381. UnitType.create(name: 'energyApparent', description: 'energyApparent')
  382. UnitType.create(name: 'energyReactive', description: 'energyReactive')
  383. UnitType.create(name: 'energyReal', description: 'energyReal')
  384. UnitType.create(name: 'frequency', description: 'frequency')
  385. UnitType.create(name: 'powerApparent', description: 'powerApparent')
  386. UnitType.create(name: 'powerReactive', description: 'powerReactive')
  387. UnitType.create(name: 'powerReal', description: 'powerReal')
  388. UnitType.create(name: 'pulseCount', description: 'pulseCount')
  389. UnitType.create(name: 'temperature', description: 'temperature')
  390. UnitType.create(name: 'voltage', description: 'voltage')
  391. UnitType.find_by_name('currency').update_attributes(description: 'CURRENCY')
  392. UnitType.find_by_name('currencyPerKW').update_attributes(description: 'CURRENCY_PER_KW')
  393. UnitType.find_by_name('currencyPerKWh').update_attributes(description: 'CURRENCY_PER_K_WH')
  394. UnitType.find_by_name('energyApparent').update_attributes(description: 'ApparentEnergy')
  395. UnitType.find_by_name('energyReactive').update_attributes(description: 'ReactiveEnergy')
  396. UnitType.find_by_name('energyReal').update_attributes(description: 'RealEnergy')
  397. UnitType.find_by_name('powerApparent').update_attributes(description: 'ApparentPower')
  398. UnitType.find_by_name('powerReactive').update_attributes(description: 'ReactivePower')
  399. UnitType.find_by_name('powerReal').update_attributes(description: 'RealPower')
  400. # si scale codes
  401. SiScaleCode.create(name: 'P', description: 'peta: 15')
  402. SiScaleCode.create(name: 'T', description: 'tera: 12')
  403. SiScaleCode.create(name: 'G', description: 'giga: 9')
  404. SiScaleCode.create(name: 'M', description: 'mega: 6')
  405. SiScaleCode.create(name: 'k', description: 'kilo: 3')
  406. SiScaleCode.create(name: 'd', description: 'deci: -1')
  407. SiScaleCode.create(name: 'c', description: 'centi: -2')
  408. SiScaleCode.create(name: 'm', description: 'milli: -3')
  409. SiScaleCode.create(name: 'micro', description: 'micro: -6')
  410. SiScaleCode.create(name: 'n', description: 'nano: -9')
  411. SiScaleCode.create(name: 'none', description: 'none')
  412. SiScaleCode.find_by_name('P').update_attributes(multiplier: 15)
  413. SiScaleCode.find_by_name('T').update_attributes(multiplier: 12)
  414. SiScaleCode.find_by_name('G').update_attributes(multiplier: 9)
  415. SiScaleCode.find_by_name('M').update_attributes(multiplier: 6)
  416. SiScaleCode.find_by_name('k').update_attributes(multiplier: 3)
  417. SiScaleCode.find_by_name('d').update_attributes(multiplier: -1)
  418. SiScaleCode.find_by_name('c').update_attributes(multiplier: -2)
  419. SiScaleCode.find_by_name('m').update_attributes(multiplier: -3)
  420. SiScaleCode.find_by_name('micro').update_attributes(multiplier: -6)
  421. SiScaleCode.find_by_name('n').update_attributes(multiplier: -9)
  422. SiScaleCode.find_by_name('none').update_attributes(multiplier: -100)
  423. # emix units
  424. # :ac, :description, :hertz, :name, :si_scale_code, :unit_type, :units, :voltage
  425. unit_type_currency_per_kwh = UnitType.find_by_name('currencyPerKWh')
  426. unit_type_power_real = UnitType.find_by_name('powerReal')
  427. unit_type_custom = UnitType.find_by_name('customUnit')
  428. Profile.create(name: '2.0a')
  429. Profile.create(name: '2.0b')
  430. si = SiScaleCode.find_by_name('none')
  431. # currencies
  432. CurrencyType.create(name: 'USD', description: 'US Dollar')
  433. CurrencyType.create(name: 'JPY', description: 'Yen')
  434. CurrencyType.create(name: 'EUR', description: 'Euro')
  435. CurrencyType.create(name: 'GBP', description: 'Pound Sterling')
  436. usd = CurrencyType.find_by_name('USD')
  437. # needed for test cases
  438. if unit_type_currency_per_kwh.emix_units.count == 0
  439. EmixUnit.create(unit_type_id: unit_type_currency_per_kwh.id, currency_type_id: usd.id, si_scale_code_id: si.id)
  440. end
  441. if unit_type_power_real.emix_units.count == 0
  442. EmixUnit.create(unit_type_id: unit_type_power_real.id, custom_units: 'W', si_scale_code_id: si.id, hertz: 60, voltage: 120, ac: true)
  443. end
  444. if unit_type_custom.emix_units.count == 0
  445. EmixUnit.create(description: 'CustomUnit', unit_type_id: unit_type_custom.id, custom_units: 'custom', si_scale_code_id: si.id)
  446. end
  447. # EmixUnit.create(name: 'Currency Per KWh (USD)', description: 'currencyPerKWh', unit_type_id: unit_type_currency_per_kwh, units: 'USD', si_scale_code: si)
  448. # EmixUnit.create(name: 'Power Real (W)', description: 'RealPower', unit_type: unit_type_power_real, units: 'W', si_scale_code: si, hertz: 60, voltage: 120, ac: true)
  449. # EmixUnit.create(name: 'Custom', description: 'CustomUnit', unit_type: unit_type_custom, units: 'custom', si_scale_code: si)
  450. EndDeviceAsset.create(name: 'Thermostat')
  451. EndDeviceAsset.create(name: 'Strip_Heater')
  452. EndDeviceAsset.create(name: 'Baseboard_Heater')
  453. EndDeviceAsset.create(name: 'Water_Heater')
  454. EndDeviceAsset.create(name: 'Pool_Pump')
  455. EndDeviceAsset.create(name: 'Sauna')
  456. EndDeviceAsset.create(name: 'Hot_tub')
  457. EndDeviceAsset.create(name: 'Smart_Appliance')
  458. EndDeviceAsset.create(name: 'Irrigation_Pump')
  459. EndDeviceAsset.create(name: 'Managed_Commercial_and_Industrial_Loads')
  460. EndDeviceAsset.create(name: 'Simple_Residential_On_Off_Loads')
  461. EndDeviceAsset.create(name: 'Exterior_Lighting')
  462. EndDeviceAsset.create(name: 'Interior_Lighting')
  463. EndDeviceAsset.create(name: 'Electric_Vehicle')
  464. EndDeviceAsset.create(name: 'Generation_Systems')
  465. EndDeviceAsset.create(name: 'Load_Control_Switch')
  466. EndDeviceAsset.create(name: 'Smart_Inverter')
  467. EndDeviceAsset.create(name: 'EVSE')
  468. EndDeviceAsset.create(name: 'RESU')
  469. EndDeviceAsset.create(name: 'Energy_Management_System')
  470. EndDeviceAsset.create(name: 'Smart_Energy_Module')
  471. EndDeviceAsset.create(name: 'Storage')
  472. # Target
  473. if Target.count == 0
  474. Target.create(name: 'Test Target', tag: 'test', type: 'GroupId')
  475. end
  476. # Time of Use Schedule
  477. if TouSchedule.count == 0
  478. tou_schedule = TouSchedule.new
  479. tou_schedule.name = 'default'
  480. tou_schedule.time_zone = 'UTC'
  481. tou_schedule.is_active = true
  482. tou_schedule.payload_unit_id = EmixUnit.find_by_unit_type_id(UnitType.find_by_name('currencyPerKWh')).id
  483. tou_schedule.signal_type_id = SignalType.find_by_name('LEVEL').id
  484. tou_schedule.market_context_id = MarketContext.first.id
  485. tou_schedule.target_id = Target.last.id
  486. tou_schedule.month_01_season = 'winter'
  487. tou_schedule.month_02_season = 'winter'
  488. tou_schedule.month_03_season = 'winter'
  489. tou_schedule.month_04_season = 'winter'
  490. tou_schedule.month_05_season = 'summer'
  491. tou_schedule.month_06_season = 'summer'
  492. tou_schedule.month_07_season = 'summer'
  493. tou_schedule.month_08_season = 'summer'
  494. tou_schedule.month_09_season = 'summer'
  495. tou_schedule.month_10_season = 'summer'
  496. tou_schedule.month_11_season = 'winter'
  497. tou_schedule.month_12_season = 'winter'
  498. tou_schedule.hour_00_winter = 0.00
  499. tou_schedule.hour_01_winter = 0.00
  500. tou_schedule.hour_02_winter = 0.00
  501. tou_schedule.hour_03_winter = 0.00
  502. tou_schedule.hour_04_winter = 0.00
  503. tou_schedule.hour_05_winter = 0.00
  504. tou_schedule.hour_06_winter = 0.00
  505. tou_schedule.hour_07_winter = 0.00
  506. tou_schedule.hour_08_winter = 0.00
  507. tou_schedule.hour_09_winter = 0.00
  508. tou_schedule.hour_10_winter = 0.00
  509. tou_schedule.hour_11_winter = 0.00
  510. tou_schedule.hour_12_winter = 0.00
  511. tou_schedule.hour_13_winter = 0.00
  512. tou_schedule.hour_14_winter = 0.00
  513. tou_schedule.hour_15_winter = 0.00
  514. tou_schedule.hour_16_winter = 0.00
  515. tou_schedule.hour_17_winter = 0.00
  516. tou_schedule.hour_18_winter = 0.00
  517. tou_schedule.hour_19_winter = 0.00
  518. tou_schedule.hour_20_winter = 0.00
  519. tou_schedule.hour_21_winter = 0.00
  520. tou_schedule.hour_22_winter = 0.00
  521. tou_schedule.hour_23_winter = 0.00
  522. tou_schedule.hour_00_summer = 0.00
  523. tou_schedule.hour_01_summer = 0.00
  524. tou_schedule.hour_02_summer = 0.00
  525. tou_schedule.hour_03_summer = 0.00
  526. tou_schedule.hour_04_summer = 0.00
  527. tou_schedule.hour_05_summer = 0.00
  528. tou_schedule.hour_06_summer = 0.00
  529. tou_schedule.hour_07_summer = 0.00
  530. tou_schedule.hour_08_summer = 0.00
  531. tou_schedule.hour_09_summer = 0.00
  532. tou_schedule.hour_10_summer = 0.00
  533. tou_schedule.hour_11_summer = 0.00
  534. tou_schedule.hour_12_summer = 0.00
  535. tou_schedule.hour_13_summer = 0.00
  536. tou_schedule.hour_14_summer = 0.00
  537. tou_schedule.hour_15_summer = 0.00
  538. tou_schedule.hour_16_summer = 0.00
  539. tou_schedule.hour_17_summer = 0.00
  540. tou_schedule.hour_18_summer = 0.00
  541. tou_schedule.hour_19_summer = 0.00
  542. tou_schedule.hour_20_summer = 0.00
  543. tou_schedule.hour_21_summer = 0.00
  544. tou_schedule.hour_22_summer = 0.00
  545. tou_schedule.hour_23_summer = 0.00
  546. tou_schedule.save!
  547. end
  548. #
  549. # test VENs
  550. # create a ven requires that some associated lookup tables are loaded ahead of time
  551. # leave test VEN creation at the bottom of the file
  552. #
  553. ven = admin.vens.new
  554. ven.name = "TH_VEN"
  555. ven.common_name = "cn1"
  556. ven.save
  557. ven = admin.vens.new
  558. ven.name = "Test_VEN_Name"
  559. ven.common_name = "111111111111"
  560. ven.save
  561. # default VEN used for testing with the QualityLogic test harness
  562. vtn_parameters.ven = ven
  563. vtn_parameters.save