Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
initial user input graphs, no multiple generators yet
  • Loading branch information
rrc12004 committed Mar 30, 2019
1 parent a7e2af6 commit 6be5d9f
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 282 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -25,6 +25,7 @@
"chart.js": "^2.7.3",
"core-js": "^2.6.3",
"hammerjs": "^2.0.8",
"moment": "^2.24.0",
"rxjs": "^6.2.2",
"rxjs-compat": "^6.2.2",
"zone.js": "^0.8.29"
Expand Down
@@ -1,12 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { NamesService } from './names.service';
import { DataService } from './data.service';

describe('NamesService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: NamesService = TestBed.get(NamesService);
const service: DataService = TestBed.get(NamesService);
expect(service).toBeTruthy();
});
});
108 changes: 108 additions & 0 deletions src/app/services/data.service.ts
@@ -0,0 +1,108 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class DataService {

convChart = [
['l1.l2.voltage', '400001', 'L1 - L2 Voltage', 'RO', 'WORD', 'Volts AC'],
['l2.l3.voltage', '400002', 'L2 - L3 Voltage', 'RO', 'WORD', 'Volts AC'],
['l3.l1.voltage', '400003', 'L3 - L1 Voltage', 'RO', 'WORD', 'Volts AC'],
['l1.l0.voltage', '400004', 'L1 - L0 Voltage', 'RO', 'WORD', 'Volts AC'],
['l2.l0.voltage', '400005', 'L2 - L0 Voltage', 'RO', 'WORD', 'Volts AC'],
['l3.l0.voltage', '400006', 'L3 - L0 Voltage', 'RO', 'WORD', 'Volts AC'],
['l1.current', '400007', 'L1 Current', 'RO', 'WORD', 'Amps AC'],
['l2.current', '400008', 'L2 Current', 'RO', 'WORD', 'Amps AC'],
['l3.current', '400009', 'L3 Current', 'RO', 'WORD', 'Amps AC'],
['frequency', '400010', 'Frequency', 'RO', 'WORD', 'Hz X 100'],
['total.kw', '400011', 'Total kW', 'RO', 'WORD', 'kW'],
['rate.kw', '400012', 'Percent of Rated kW', 'RO', 'WORD', '% Rated kW'],
['total.pf', '400013', 'Total Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'],
['l1.kw', '400014', 'L1 kW', 'RO', 'WORD', 'kW'],
['l1.pf', '400015', 'L1 Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'],
['l2.kw', '400016', 'L2 kW', 'RO', 'WORD', 'kW'],
['l2.pf', '400017', 'L2 Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'],
['l3.kw', '400018', 'L3 kW', 'RO', 'WORD', 'kW'],
['l3.pf', '400019', 'L3 Power Factor', 'RO', 'SWORD', 'PF X 100 (SIGNED)'],
['total.kvar', '400020', 'Total kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'],
['l1.kvar', '400021', 'L1 kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'],
['l2.kvar', '400022', 'L2 kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'],
['l3.kvar', '400023', 'L3 kVAR', 'RO', 'SWORD', 'kVAR (SIGNED)'],
['total.kva', '400024', 'Total kVA', 'RO', 'WORD', 'kVA'],
['l1.kva', '400025', 'L1 kVA', 'RO', 'WORD', 'kVA'],
['l2.kva', '400026', 'L2 kVA', 'RO', 'WORD', 'kVA'],
['l3.kva', '400027', 'L3 kVA', 'RO', 'WORD', 'kVA'],
[, '400028', 'Current Lead/Lag', 'RO', 'WORD',
'Bits 0-1 Total Current - Leading = 10 Lagging = 01 Bits 2-3 L1 Current -' +
'Leading = 10 Lagging = 01 Bits 4-5 L2 Current - Leading = 10 Lagging = 01 Bits 6-7 L3 Current - Leading = 10 Lagging = 01'],
[, '400029', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'],
[, '400030', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'],
[, '400031', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'],
[, '400032', 'Reserved For Future Use', 'RO', 'WORD', 'Returns 0 (zero)'],
['oil.pressure', '400033', 'Oil Pressure*', 'RO', 'WORD', 'kPa/psi'],
['coolant.temp', '400034', 'Coolant Temperature*', 'RO', 'SWORD', 'Degrees C/Degrees F'],
['engine.rpm', '400035', 'Engine Speed*', 'RO', 'WORD', 'RPM'],
['battery.voltage', '400036', 'Local Battery Voltage*', 'RO', 'WORD', 'Volts DC X 10'],
['fuel.pressure', '400037', 'Fuel Pressure*', 'RO', 'WORD', 'kPa/psi DDEC/MDEC/ADEC only'],
['fuel.temp', '400038', 'Fuel Temperature*', 'RO', 'SWORD', 'Degrees C/Degrees F DDEC/MDEC/ADEC only'],
['fuel.rate', '400039', 'Fuel Rate*', 'RO', 'WORD', 'Liters/Hour X 100 or Gallons/Hour X 100 DDEC only'],
[, '400040', 'Used Last Run*', 'RO', 'WORD', 'Liters/Gallons DDEC only'],
['coolant.pressure', '400041', 'Coolant Pressure*', 'RO', 'WORD', 'kPa/psi DDEC only'],
['coolant.level', '400042', 'Coolant Level*', 'RO', 'WORD', '% X 10 DDEC only'],
['oil.temp', '400043', 'Lube Oil Temperature*', 'RO', 'SWORD', 'Degrees C/Degrees F DDEC/MDEC/ADEC/Waukesha only'],
['oil.level', '400044', 'Oil Level*', 'RO', 'WORD', '% X 10 DDEC only'],
['crankcase.pressure', '400045', 'Crankcase Pressure*', 'RO', 'WORD', 'kPa/psi DDEC only'],
['ambient.temp', '400046', 'Ambient Temperature *', 'RO', 'SWORD', 'Degrees C/Degrees F DDEC only'],
['ecm.battery.voltage', '400047', 'ECM Battery Voltage*', 'RO', 'WORD', 'Volts DC X 10 DDEC/MDEC/ADEC only'],
[, '400048', 'ECM Status', 'RO', 'WORD', '0 = DDEC-Equipped, 1 = Non-ECM, 2 = MDEC/ADEC-Equipped'],
['intake.temp', '400049', 'Intake Air Temperature', 'RO', 'SWORD', 'Degrees C/Degrees F MDEC/ADEC/Waukesha only'],
['intake.pressure', '400050', 'Intake Air Pressure', 'RO', 'WORD', 'Degrees C/Degrees F MDEC/ADEC only']
];

constructor() { }

getUnits(metric) {
let conv;
for (conv of this.convChart) {
if (conv[0] === metric) {
return conv[5];
}
}
}

convertNames(input, type) { // "type" you are converting to
let conv;
if (type === 'layman') {
for (conv of this.convChart) {
if (conv[0] === input) {
return conv[2];
}
}
} else if (type === 'metric') {
for (conv of this.convChart) {
if (conv[2] === input) {
return conv[0];
}
}
}
}

getAllNames(type) {
if (type === 'layman') {
const layArray = [];
let conv;
for (conv of this.convChart) {
layArray.push(conv[2]);
}
return layArray;
} else if (type === 'metric') {
const metArray = [];
let conv;
for (conv of this.convChart) {
metArray.push(conv[2]);
}
return metArray;
}
}
}
182 changes: 0 additions & 182 deletions src/app/services/names.service.ts

This file was deleted.

67 changes: 64 additions & 3 deletions src/app/services/visualize.service.ts
@@ -1,5 +1,7 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Chart } from 'chart.js';

@Injectable({
providedIn: 'root'
Expand All @@ -8,12 +10,71 @@ export class VisualizeService {

constructor(private http: HttpClient) { }

getData(token, query) {
return this.http.get('http://sd5-backend.engr.uconn.edu/data/query' + query, {
createChart(labels, data, laymanDataVal) {
return new Chart('canvas', {
type: 'line',
data: {
labels: labels,
datasets: [{
label: laymanDataVal,
fill: false,
data: data,
backgroundColor: [
'rgba(153, 102, 255, 0.2)',
'rgba(255, 159, 64, 0.2)'
],
borderColor: 'blue',
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}

getDataForVis(token, time, func, gens, data): Observable<Object> {
const body = {
'time': {
'start': time,
'aggregator': func
},
'filters': [
{
'tags': [{
'type': 'literal_or',
'tagk': 'generator',
'filter': gens,
'groupBy': true
}],
'id': 'gen'
}
],
'metrics': [
{
'id': 'a',
'metric': data,
'filter': 'gen',
'fillPolicy': { 'policy': 'nan' }
}
],
'expressions': [
{
'id': 'e',
'expr': 'a'
}
]
};
return this.http.post('http://sd5-backend.engr.uconn.edu/data/query/exp', body, {
headers: {
Authorization: 'Bearer ' + token
}
});
}

}

0 comments on commit 6be5d9f

Please sign in to comment.