Difference between revisions of "Building monitoring"

From Earlham CS Department
Jump to navigation Jump to search
(Buildings)
 
(83 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Energy Display Scripts Outline version 1.0==
+
==General==
#Java scripts harvest data directly from Modbus
+
* [[Energy Monitoring Hardware|Equipment Details]] (keep current!)
#Perl scripts collects this data and put it in the Postgress database "energy" under the table "electrical_energy"
 
#*electrical_energy attributes:
 
#**area - what building.
 
#**preal - kW hours for that instant.
 
#**date - date of harvest.
 
#A final perl script (display/production|development/js-file-gen.pl) accesses this data and generates a .png graph using the Google graph API
 
#* This script takes one parameter for either the production or development branches.
 
#The images generated (day, week, month, year) are put in a html frame on a [http://proto.cs.earlham.edu/~energy/production/eDisplay/ page] to display the data.
 
#*This page refreshes every 5 minutes
 
  
==Energy Display Scripts Outline version 2.0==
+
==Buildings==
===Postgres db===
+
* Contact Daryl about Siemans (Tyler, Stanley, CST)
* Data stored in databse 'energy' under table 'electrical_energy'
+
* Central Switch - IB, CP, GC
* 'electrical energy' has the following attributes:
+
* EH - (good luck)
**area - which building.
+
* AWC - GC - (GC, 10-16-14, needs hooked up)
**preal - kW hours for that instant.
+
* Tyler - GC - (GC, 10-16-14, Steve Belec said that he will be receiving a walk-through from the contractors)
**date - date of harvest.
+
* Stanley - GC - (GC, 10-16-14, need direct access for configuration over powerconfig)
 +
* New Building - GC - (GC, 1-23-14, waiting for Siemens system designers to get here to hopefully explain Tyler, Stanley and the new building)
  
===data_gen.py===
+
==EGX100==
* generates a JSON file filled with data from a sql call to the database.
+
[[Energy Monitoring Hardware]]
* requires Python 2.5
 
*file run by cron
 
  
*Main(building_file)
+
==Siemens==
**Called from main loop.
+
[[Siemens Sentron Pac3200]]
**Calls CreateBuildingList(), ConnectToDatabase(), GetAllData(), EncodeData(), DisconnectFromDatabase()
 
 
*CreateBuildingList(building_file)
 
**Called by Main().
 
**For each building in building_file add to a python list.
 
**return that list.
 
 
*ConnectToDatabase()
 
**Called by Main().
 
**connects to 'energy' databse in Postgres
 
**returns database connection and the current name of database.
 
  
*GetAllData(db connection, building list)
+
==PowerLogic==
** Called by Main().
+
[[PowerLogic PM800]]
** makes a python dict of all data
 
** calls GetBuildingData()
 
** replace unwanted dates from older buildings
 
** calls EqualizeDataValues()
 
 
*GetBuildingData(dbconnection, building)
 
**called from GetAllData()
 
** calls SetSQLQuery()
 
** returns rows from sql call and row count
 
 
*SetSQLQuery(building)
 
** called from GetBuildingData()
 
** Makes a sql call to the databse energy from the table electrical_energy
 
** returns rows from sql call and row count
 
 
*EqualizeDataValues(all_data, dates)
 
** fills null values for dates of newer buildings.
 
** returns all data
 
 
*EncodeData(all_data, dates)
 
** Called by Main().
 
** sorts all_data by date
 
** dumps data in JSON file, note: columns are organized alphabetically.
 
** initializes gviz metadata
 
** calls LoadData().
 
** writes JSON file which JS reads from.
 
 
*LoadData()
 
** Called by EncodeData()
 
** gviz api call
 
** encodes data to JSON file with headers.
 
 
*DisconnectFromDatabase()
 
**Called by Main().
 
**disconnects from database 'energy'.
 
  
===main.js===
+
[[Sepam Series 20]]
*non-function
 
**creates several global variables.
 
***whichBiuldings: an array of booleans signifying which buildings get drawn
 
***buildingColors: an array of colors for each of the buttons and colors on the graph, change them here and only here.
 
***startDate, endDate: range on the graph, by default they are one week ago and today respectively, if the page was reached through a permalink these get modified.
 
***lineChartJSONData: this is the json file which data_gen.py makes, it's placed as a global so it doesn't have to be reloaded everytime a building is checked or unchecked.
 
  
*flipAndRedraw
+
[[Category:export]]
**called when a button is pressed
 
**flips values in the global whichBuildings[]
 
**calls drawLineChart() provided whichBuildings has at least 1 true value.
 
 
 
*flip(val)
 
** takes a boolean and returns its opposite.
 
 
 
*redrawVis(values[])
 
**Takes an array of booleans
 
**calls DrawLineChart()
 
 
*drawLineChart(buildingArray[], colors[])
 
**called when index.html loads and when RedrawVis() is called.
 
**takes an array of booleans processed by RedrawVis()
 
**creates a Dashboard
 
**creates a data table with the data source as the json file data-gen.py makes.
 
**creates a chart wrapper, this is where you can adjust basic settings about the main chart.
 
**creates a control wrapper, this creates the controling bar on the bottom. This is where you can adjust the starting range for the control wrapper.
 
**creates a listener for the 'statechange' event on the controlWrapper, when the control range is updated the dates are saved. When a building is unchecked and the graph redrawn, the selection stays the same.
 
**creates a listener for the 'ready' event on the chartWrapper. When chartWrapper is ready (all drawn) resizeControls is called.
 
**deletes columns in data table depending on the booleans that are in values[], the more columns that are deleted the better the performance.
 
**binds the chart wrapper and the control wrapper together, draws the chart.
 
 
 
*equalArrays(arr1, arr2)
 
**checks if the contents of arr1 are equal to arr2, returns true if they are, false otherwise.
 
 
*parseDate(urlArg[])
 
**takes the array of strings from a permalink and returns them as a date object
 
 
 
*parseInts(strArray[])
 
**takes the array of strings from a permalink and returns them as an array of integers.
 
 
 
*parseButtons()
 
**Takes button arguments from the permalink and unchecks the buttons on index.html accordingly using jQuery's removeClass medthod.
 
 
 
*removeIndices()
 
**processes and array to return containing indices of which columns delete and therefore not draw.
 
 
 
*genPermalink()
 
**generates a permalink to the chart's state and which buttons are checked. The format of the permalink is (url)/?(startDate, yyyy-mm-dd)%(endDate, yyyy-mm-dd)%(buttons, 0123)
 
**writes permalink to text box on index.html
 
 
 
*redrawControls()
 
**Accesses where the svg paths for the control are using getElementByTagName() and sets them using jQuery's attr method.
 
**This is called every time the graph sends a 'ready' event.
 
 
 
===HTML+CSS===
 
*index.html, the file people load.
 
**A small script detecting browser type adds the chrome class to #page-title. Without this page-title in chrome draws incorrectly, this is a chrome specific bug the tag draws correctly in all other browsers.
 
*includes jquery.minm.1.7.2, for gviz api
 
*main.js, draws graphs, handles data.
 
*bootratp-button.js, enables buttons to behave like checkboxes. Toggling these buttons updates a global array of booleans held in main.js, and then redraws the graph depending on which are selected.
 
*main.css, styling (some css3).
 
**there are several blank css elements for the buttons in the beginning, keep these lines where they are as main.js accesses them by an index and gives them a background-color attribute.
 
 
 
===Improvements and Bugs===
 
*Performance
 
**More resolution in the graph will come at the expense of performance, right now points on the graph are averaged values from each hour. It would be better for graph readability if points were every, let's say, two minutes, however the graph would be unusable. Already the control chart is graphing every 30 lines of data, perhaps as the data range expands there could be less points on the chart itself and when the range is small it could show more resolution.
 
 
 
==Harvest Scripts ==
 
 
 
There is a unique harvest script for every individual building, but the only differences between these scripts are the value of the ip number and the .
 
The harvest scripts are called by cron every minute.
 
 
 
'''Procedure for the Script'''
 
*0. Sets a timestamp.
 
*1. Sets a variable $pReal to the return value of java --cp with the following arguments:
 
filepath to the production directory, ModbusReadDemand, the ip number of the EGX100 of the building in question,  the amperage correction of the building in question. <br>
 
This return value represents electrical energy usage.
 
*2. Connects to the energy database.
 
*3. Inserts into the electrical_energy table (located within the energy database) a row for the energy usage of the building in question at the time of the timestamp.
 
 
 
==Building Monitoring Data==
 
<table border="1">
 
                          <tr><td>Buildings </td> </tr>
 
<tr> <td>Building </td>     <td> Installed? </td> <td> EGX100 IP </td>              <td> Directly off main switch?  </td> <td>Amperage Correction </td>  <td>Feed Size (Amps) </td> <td> Square Footage* </td> <td> Occupancy </td> </tr>
 
<tr>  <td>Bundy </td>  <td> Yes </td>          <td>159.28.165.100 </td>        <td>No </td>               <td>31.25 </td> <td> 800 </td><td> </td> <td> </td> </tr>
 
<tr>  <td>Barrett </td> <td> Yes </td>                <td>159.28.165.101</td>      <td>No      </td>                    <td>15.625  </td> <td> 1600 </td> <td> </td><td> </td> </tr>
 
<tr>    <td>Wilson </td>  <td> Yes </td>                  <td>159.28.165.102</td>    <td>No </td>                      <td>62.5      </td> <td> 300/400 </td><td> </td><td> </td> </tr>
 
<tr>    <td>Warren </td>  <td> Yes </td>              <td>159.28.165.103</td>      <td>No </td>                      <td>62.5    </td> <td> 300/400 </td><td> </td> <td> </td> </tr>
 
<tr>  <td>Mills </td>    <td> No </td>              <td>159.28.165.104</td>      <td>No </td>                      <td>unknown      </td> <td>unknown</td><td> </td> <td> </td> </tr>
 
<tr>  <td>Olvey Andis  </td>  <td> Yes </td>            <td>159.28.165.105</td>    <td>No      </td>                      <td>31.25    </td> <td> 800 </td> <td> </td><td> </td> </tr>
 
<tr><td>Hoerner</td>     <td> No </td>            <td> </td>                              <td>No</td> <td> </td> <td> </td><td> </td><td> </td> </tr>
 
<tr><td>Carpenter   </td> <td> No </td>          <td> </td>                                  <td>No </td> <td> </td> <td> </td> <td> </td><td> </td> </tr>
 
<tr><td>Lilly Library </td> <td> No </td>        <td> </td>                                <td>No </td> <td> </td> <td> </td>  <td> 61,000 </td> <td> </td> </tr>
 
<tr><td>Runyon </td> <td> No </td>              <td> </td>                                <td>Yes </td> <td> </td> <td> </td> <td> </td><td> </td> </tr>
 
<tr><td>Stanley </td> <td> No </td>              <td> </td>                                <td> No</td> <td> </td> <td> </td> <td> </td><td> </td> </tr>
 
<tr><td>Dennis </td>   <td> No </td>            <td> </td>                                <td>No</td> <td> </td> <td> </td><td> </td><td> </td> </tr>
 
<tr><td>Noyes </td>   <td> No </td>              <td> </td>                              <td>No</td> <td> </td> <td> </td><td> </td><td> </td> </tr>
 
<tr><td>Tyler    </td>           <td> No </td>              <td> </td>                              <td>No</td> <td> </td> <td> </td><td> </td><td> </td> </tr>
 
<tr><td>LBC     </td>           <td> No </td>              <td> </td>                              <td>Yes</td> <td> </td> <td> </td><td> </td><td> </td> </tr>
 
<tr><td>Stout       </td>             <td> No </td>                <td> </td>                        <td>no</td> <td> </td> <td> </td><td> </td><td> </td> </tr>
 
<tr> <td> Remainder </td>        <td> No </td>                <td> </td>                        <td> No</td>                        <td>Unknown</td> <td>(Total Feed Size - Measured Feed Sizes)</td> </tr>
 
</table>
 
 
 
* : By Square Footage we mean the summed square footage of all the floors
 
Mills energy usage can be calculated as:  Total_of_the_U - (Warren + Wilson)
 
 
 
== Correct EGX100 Pin States ==
 
<table border="1">
 
<tr> <td>Pin Number</td> <td> 1 </td>  <td> 2 </td> <td> 3 </td>  <td> 4 </td><td> 5 </td><td> 6 </td></tr>
 
<tr> <td>Up | Down</td> <td>Up</td> <td>Down</td><td>Down</td><td>Down</td><td>Down</td><td>Down</td></tr>
 
</table>
 
 
 
== EGX100 and Voltage Modulator ==
 
The V- port on the Voltage Modulator connects to port #6 on the EGX100 <br>
 
The V+ port on the Voltage Modulator connects to port #7 on the EGX100 <br>
 
 
 
== EGX100 and Enercept==
 
A red network wire goes to port #3 on the EGX100.  <br>
 
A purple network wire goes to port #4 on the EGX100.  <br>
 
A green network wire does to port #5 on the EGX100 <br>
 
 
 
Where do these wires connect to the Enercept? The magnets are in the breaker box, so I couldn't see them. <br>
 
 
 
== EGX100 and the Procurve Networking Box ==
 
A full network cable comes from the ethernet port on the EGX100 to the Procurve Networking Box
 
 
 
==Documentation==
 
* [[Media:Campus-Electrical-Schematic.pdf| Campus Electrical Schematic]]
 
* [[pm8-mib|MIB for the PM8]] (device mounted on the main switchgear)
 
* [[Media:enercept-registers.pdf|Register list]] for the Enercept/EGX100s (devices mounted in each of the buildings)
 
* [[Media:Enercept_Meter.pdf|Enercept Meter Installation Guide]]
 
* [[Media:EGX_100_installation.pdf| EGX100 Installation Guide]]
 
* [[Media:EGX_100_userguide.pdf| EGX100 User Guide]]
 

Latest revision as of 14:54, 4 January 2017

General

Buildings

  • Contact Daryl about Siemans (Tyler, Stanley, CST)
  • Central Switch - IB, CP, GC
  • EH - (good luck)
  • AWC - GC - (GC, 10-16-14, needs hooked up)
  • Tyler - GC - (GC, 10-16-14, Steve Belec said that he will be receiving a walk-through from the contractors)
  • Stanley - GC - (GC, 10-16-14, need direct access for configuration over powerconfig)
  • New Building - GC - (GC, 1-23-14, waiting for Siemens system designers to get here to hopefully explain Tyler, Stanley and the new building)

EGX100

Energy Monitoring Hardware

Siemens

Siemens Sentron Pac3200

PowerLogic

PowerLogic PM800

Sepam Series 20