Skip to content

Commit

Permalink
Update test panel for custom commands and gpio and change default sav…
Browse files Browse the repository at this point in the history
…e to both
  • Loading branch information
SudharsanSukumar committed Nov 8, 2016
1 parent b338810 commit 0ca4255
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 72 deletions.
1 change: 1 addition & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class MyApp {
{ title: 'Device Manager', component: DeviceManagerPage }
];
this.settingsService = _settingsService;
this.settingsService.changeConsoleLog('both');
}

initializeApp() {
Expand Down
5 changes: 0 additions & 5 deletions src/components/chart/chart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,6 @@ export class SilverNeedleChart {

this.cursorAnchors[this.numYCursors + 2].translate(this.chart.plotLeft - 12, this.chart.yAxis[this.activeChannels[this.numYCursors] - 1].toPixels(initialValue) - 6);
}
console.log(this.chart.yAxis[this.activeChannels[this.numYCursors] - 1].plotLinesAndBands, this.numYCursors);
let lineNum = this.chart.yAxis[this.activeChannels[this.numYCursors] - 1].plotLinesAndBands.length - 1;
this.chart.yAxis[this.activeChannels[this.numYCursors] - 1].plotLinesAndBands[lineNum].svgElem.element.id = 'cursor' + (this.numYCursors + 2);
this.chart.yAxis[this.activeChannels[this.numYCursors] - 1].plotLinesAndBands[lineNum].svgElem.css({
Expand Down Expand Up @@ -923,12 +922,9 @@ export class SilverNeedleChart {
yCor = this.chart.yAxis[this.activeChannels[this.activeCursor - 3] - 1].toPixels(this.chart.yAxis[this.activeChannels[this.activeCursor - 3] - 1].min);
}
let lineNum = this.chart.yAxis[this.activeChannels[this.activeCursor - 3] - 1].plotLinesAndBands.length - 1;
console.log(lineNum * (this.activeCursor - 3));
this.chart.yAxis[this.activeChannels[this.activeCursor - 3] - 1].plotLinesAndBands[lineNum * (this.activeCursor - 3)].options.value = yVal;
if (this.timelineView) {
console.log('timeline');
this.timelineChart.yAxis[0].plotLinesAndBands[this.activeCursor - 3].options.value = yVal;
console.log('after timeline');
this.timelineChart.yAxis[0].plotLinesAndBands[this.activeCursor - 3].render();
}
this.cursorPositions[this.activeCursor - 3] = {
Expand Down Expand Up @@ -2332,7 +2328,6 @@ export class SilverNeedleChart {
return;
}
let value = trigPosition * this.currentBufferArray[this.numSeries[0]].dt;
console.log(this.triggerPlotLine);
this.triggerPlotLine.options.value = value;
this.timelineTriggerPlotLine.options.value = value;
this.triggerPlotLine.render();
Expand Down
54 changes: 30 additions & 24 deletions src/components/function-gen/function-gen.component.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import {Component, EventEmitter} from '@angular/core';
import {ModalController, PopoverController, ToastController} from 'ionic-angular';
import { Component, EventEmitter } from '@angular/core';
import { ModalController, PopoverController, ToastController } from 'ionic-angular';

//Pages
import {ModalFgenPage} from '../../pages/fgen-modal/fgen-modal';
import { ModalFgenPage } from '../../pages/fgen-modal/fgen-modal';

//Components
import {DeviceComponent} from '../../components/device/device.component';
import {GenPopover} from '../../components/gen-popover/gen-popover.component';
import { DeviceComponent } from '../../components/device/device.component';
import { GenPopover } from '../../components/gen-popover/gen-popover.component';

//Services
import {DeviceManagerService} from '../../services/device/device-manager.service';
import { DeviceManagerService } from '../../services/device/device-manager.service';

//Interfaces
import {SettingsObject} from '../instruments/awg/awg-instrument.component';
import { SettingsObject } from '../instruments/awg/awg-instrument.component';

@Component({
templateUrl: 'function-gen.html',
selector: 'fgen'
templateUrl: 'function-gen.html',
selector: 'fgen'
})
export class FgenComponent {
export class FgenComponent {
public showDutyCycle: boolean;
public waveType: string;
public frequency: string;
Expand All @@ -36,12 +36,11 @@ export class FgenComponent {
public toastCtrl: ToastController;
public showSettings: boolean = true;
public showChanSettings: boolean[] = [true];

constructor(_deviceManagerService: DeviceManagerService,
_modalCtrl: ModalController,
_popoverCtrl: PopoverController,
_toastCtrl: ToastController)
{

constructor(_deviceManagerService: DeviceManagerService,
_modalCtrl: ModalController,
_popoverCtrl: PopoverController,
_toastCtrl: ToastController) {
this.modalCtrl = _modalCtrl;
this.popoverCtrl = _popoverCtrl;
this.toastCtrl = _toastCtrl;
Expand All @@ -59,7 +58,7 @@ export class FgenComponent {
this.dutyCycle = '50';
this.powerOn = false;
}

//Toggle dropdown
toggleWave(waveType: string) {
if (this.powerOn) {
Expand All @@ -75,7 +74,7 @@ export class FgenComponent {
toggleAwgSettings() {
this.showSettings = !this.showSettings;
}

//Toggle power to awg
togglePower() {
let chans = [];
Expand Down Expand Up @@ -136,6 +135,13 @@ export class FgenComponent {
},
(err) => {
console.log('AWG Set Regular Failed');
this.stop(chans);
let toast = this.toastCtrl.create({
message: 'Error Setting AWG Parameters. Please Try Again. If Problem Persists, Reset The Device',
showCloseButton: true,
position: 'bottom'
});
toast.present();
},
() => {

Expand Down Expand Up @@ -191,7 +197,7 @@ export class FgenComponent {
//Open function generator / awg modal
openFgen(num) {
let modal = this.modalCtrl.create(ModalFgenPage, {
value: num,
value: num,
waveType: this.waveType,
frequency: this.frequency,
amplitude: this.amplitude,
Expand All @@ -204,22 +210,22 @@ export class FgenComponent {

openPopover(event) {
let genPopover = this.popoverCtrl.create(GenPopover, {
dataArray: this.supportedSignalTypes
});
dataArray: this.supportedSignalTypes
});
genPopover.present({
ev: event
});
genPopover.onDidDismiss(data=> {
genPopover.onDidDismiss(data => {
this.toggleWave(data.option);
});
}

//Determines if active wave type is a square wave
isSquare() {
if (this.waveType === 'square') {
return true;
}
return false;
}

}
49 changes: 40 additions & 9 deletions src/components/instruments/awg/awg-instrument.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import 'rxjs/Rx';

//Components
import {InstrumentComponent} from '../instrument.component';
import {AwgChannelComponent} from './awg-channel.component';
import { InstrumentComponent } from '../instrument.component';
import { AwgChannelComponent } from './awg-channel.component';

//Services
import {TransportService} from '../../../services/transport/transport.service';
import { TransportService } from '../../../services/transport/transport.service';

//Interfaces
import {SettingsObject} from './awg-instrument.component';
import { SettingsObject } from './awg-instrument.component';

@Injectable()
export class AwgInstrumentComponent extends InstrumentComponent {
Expand All @@ -30,7 +30,7 @@ export class AwgInstrumentComponent extends InstrumentComponent {
for (let channel in _awgInstrumentDescriptor) {
if (channel !== 'numChans') {
this.chans.push(new AwgChannelComponent(_awgInstrumentDescriptor[channel]));
}
}
}
}

Expand Down Expand Up @@ -122,8 +122,24 @@ export class AwgInstrumentComponent extends InstrumentComponent {
return Observable.create((observer) => {
this.transport.writeRead(this.endpoint, JSON.stringify(command), 'json').subscribe(
(arrayBuffer) => {
let data = JSON.parse(String.fromCharCode.apply(null, new Int8Array(arrayBuffer.slice(0))));
console.log(String.fromCharCode.apply(null, new Int8Array(arrayBuffer.slice(0))));
let data;
try {
data = JSON.parse(String.fromCharCode.apply(null, new Int8Array(arrayBuffer.slice(0))));
}
catch (e) {
console.log(e);
console.log('Error parsing JSON response');
observer.error(e);
return;
}
console.log(data);
if ((data.awg !== undefined && data.awg['1'][0].statusCode > 0) || data.statusCode !== undefined) {
console.log('statuscode error');
observer.error('Error Setting AWG Parameters. Status Code');
return;
}
console.log('no status code error');
observer.next(data);
observer.complete();

Expand Down Expand Up @@ -154,8 +170,23 @@ export class AwgInstrumentComponent extends InstrumentComponent {
return Observable.create((observer) => {
this.transport.writeRead(this.endpoint, JSON.stringify(command), 'json').subscribe(
(arrayBuffer) => {
let data = JSON.parse(String.fromCharCode.apply(null, new Int8Array(arrayBuffer.slice(0))));
let data;
try {
data = JSON.parse(String.fromCharCode.apply(null, new Int8Array(arrayBuffer.slice(0))));
}
catch (e) {
console.log(e);
console.log('Error parsing run response');
observer.error(e);
return;
}
console.log(data);
if ((data.awg !== undefined && data.awg['1'][0].statusCode > 0) || data.statusCode !== undefined) {
console.log('statuscode error');
observer.error('Error running AWG. Status Code');
return;
}
console.log('no status code error');
observer.next(data);
observer.complete();
},
Expand Down
49 changes: 36 additions & 13 deletions src/components/trigger/trigger.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { PopoverController } from 'ionic-angular';
import { PopoverController, ToastController } from 'ionic-angular';

//Components
import { TriggerPopover } from '../trigger-popover/trigger-popover.component';
Expand All @@ -14,6 +14,7 @@ import { DeviceManagerService } from '../../services/device/device-manager.servi
selector: 'trigger'
})
export class TriggerComponent {
public toastCtrl: ToastController;
public delay: string = '0';
public lowerThresh: string = '-30';
public upperThresh: string = '0';
Expand All @@ -26,8 +27,9 @@ export class TriggerComponent {
public activeDevice: DeviceComponent;
public level: string = '0';

constructor(_popoverCtrl: PopoverController, _devMngSrv: DeviceManagerService) {
constructor(_popoverCtrl: PopoverController, _devMngSrv: DeviceManagerService, _toastCtrl: ToastController) {
this.popoverCtrl = _popoverCtrl;
this.toastCtrl = _toastCtrl;
this.devMngSrv = _devMngSrv;
this.activeDevice = this.devMngSrv.devices[this.devMngSrv.activeDeviceIndex];
}
Expand All @@ -37,18 +39,18 @@ export class TriggerComponent {
}

openGenPopover(event) {
let chanArray = [];
for (let i = 0; i < this.activeDevice.instruments.osc.numChans; i++) {
chanArray.push('Osc Ch ' + (i + 1));
}
/*for (let i = 0; i < this.triggerComponent.activeDevice.instruments.la.numChans; i++) {
chanArray.push('La ' + (i + 1));
}*/
chanArray.push('Ext');
let chanArray = [];
for (let i = 0; i < this.activeDevice.instruments.osc.numChans; i++) {
chanArray.push('Osc Ch ' + (i + 1));
}
/*for (let i = 0; i < this.triggerComponent.activeDevice.instruments.la.numChans; i++) {
chanArray.push('La ' + (i + 1));
}*/
chanArray.push('Ext');

let genPopover = this.popoverCtrl.create(GenPopover, {
dataArray: chanArray
});
let genPopover = this.popoverCtrl.create(GenPopover, {
dataArray: chanArray
});

genPopover.present({
ev: event
Expand All @@ -61,7 +63,28 @@ export class TriggerComponent {
});
}

forceTrigger() {
this.activeDevice.instruments.trigger.forceTrigger([1]).subscribe(
(data) => {
console.log(data);
},
(err) => {
console.log(err);
},
() => { }
);
}

setupLevel() {
if (parseFloat(this.level) * 1000 > this.activeDevice.instruments.osc.chans[0].inputVoltageMax ||
parseFloat(this.level) * 1000 - 30 < this.activeDevice.instruments.osc.chans[0].inputVoltageMin) {
let toast = this.toastCtrl.create({
message: 'Selected Level Value Is Not In Osc Input Voltage Range And May Not Trigger',
showCloseButton: true,
position: 'bottom'
});
toast.present();
}
this.upperThresh = (parseFloat(this.level) * 1000).toString();
this.lowerThresh = (parseFloat(this.upperThresh) - 30).toString();
console.log(this.upperThresh, this.lowerThresh);
Expand Down
2 changes: 1 addition & 1 deletion src/components/trigger/trigger.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</ion-col>
<ion-col center text-center class="interact-button-col">
<div><button ion-button class="text-button-side disable-hover">Force</button></div>
<div><button ion-button class="text-button-side disable-hover" (click)="forceTrigger()">Force</button></div>
</ion-col>
</ion-row>
<ion-row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<ion-item class="dev-menu-item">
<ion-label stacked>Hostname / IP</ion-label>
<ion-input [(ngModel)]="addDeviceIp"></ion-input>
<button ion-button class="connect-button" item-right (click)="attemptConnect(addDeviceIp)">Add</button>
<button ion-button class="connect-button disable-hover" item-right (click)="attemptConnect(addDeviceIp)">Add</button>
</ion-item>
</ion-label>
</ion-item>
Expand All @@ -34,7 +34,7 @@
{{selectedSimulatedDevice}}
<ion-icon name="arrow-dropdown"></ion-icon>
</button>
<button ion-button class="connect-button" item-right (click)="openSimDevice()">Add</button>
<button ion-button class="connect-button disable-hover" item-right (click)="openSimDevice()">Add</button>
</ion-item>
</ion-label>
</ion-item>
Expand All @@ -47,7 +47,7 @@
<ion-item class="dev-menu-item">
<ion-label stacked>Bridge</ion-label>
<ion-input [(ngModel)]="deviceBridgeAddress"></ion-input>
<button ion-button class="connect-button" item-right (click)="attemptConnect(addDeviceIp)">Add</button>
<button ion-button class="connect-button disable-hover" item-right (click)="attemptConnect(addDeviceIp)">Add</button>
</ion-item>
</ion-label>
</ion-item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
{
background-color: #535353;
border: solid black 1px;
border-radius: 0px;
}

.first-tab-container .device-manager-card
Expand Down Expand Up @@ -86,7 +87,7 @@
border: solid black 1px;
margin-top: 2px;
margin-bottom: 2px;
padding: 2px 0px 2px 4px;
padding: 0px 0px 2px 4px;

}

Expand Down
2 changes: 2 additions & 0 deletions src/pages/protocol-test-panel/protocol-test-panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ <h4 class="sendBodyHeader">Templates:</h4>
<drop-down-menu class="sendCommand" [itemNames]="dcCommands" (valueChange)="onDcCommandChange($event)"></drop-down-menu>
<drop-down-menu class="sendCommand" [itemNames]="oscCommands" (valueChange)="onOscCommandChange($event)"></drop-down-menu>
<drop-down-menu class="sendCommand" [itemNames]="triggerCommands" (valueChange)="onTriggerCommandChange($event)"></drop-down-menu>
<drop-down-menu class="sendCommand" [itemNames]="gpioCommands" (valueChange)="onGpioCommandChange($event)"></drop-down-menu>
<drop-down-menu class="sendCommand" [itemNames]="customCommands" (valueChange)="onCustomCommandChange($event)"></drop-down-menu>
</div>
</div>
<textarea class="sendBody" [(ngModel)]="sendBody"></textarea>
Expand Down
Loading

0 comments on commit 0ca4255

Please sign in to comment.