Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add output actions #2094

Merged
merged 1 commit into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@
"maximumWarning": "6kb"
}
]
},
"development": {
"sourceMap": true,
"namedChunks": true
}
}
},
Expand All @@ -108,13 +112,17 @@
},
"production": {
"browserTarget": "OctoDash:build:production"
},
"development": {
"browserTarget": "OctoDash:build:development"
}
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "OctoDash:build"
"browserTarget": "OctoDash:build:production"
}
},
"test": {
Expand Down
31 changes: 23 additions & 8 deletions src/app/control/custom-actions/custom-actions.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ export class CustomActionsComponent {
} else if (command.includes('[!NEOPIXEL]')) {
const values = command.replace('[!NEOPIXEL]', '').split(',');
this.setLEDColor(values[0], values[1], values[2], values[3]);
} else if (command.includes('[!OUTPUT]')) {
const values = command.replace('[!OUTPUT]', '').split(',');
this.setOutput(values[0], values[1]);
} else if (command.includes('[!OUTPUT_PWM]')) {
const values = command.replace('[!OUTPUT_PWM]', '').split(',');
this.setOutputPWM(values[0], values[1]);
} else {
this.printerService.executeGCode(command);
}
Expand All @@ -93,38 +99,38 @@ export class CustomActionsComponent {
}

// [!DISCONNECT]
public disconnectPrinter(): void {
private disconnectPrinter(): void {
this.printerService.disconnectPrinter();
}

// [!STOPDASHBOARD]
public stopOctoDash(): void {
private stopOctoDash(): void {
window.close();
}

// [!RELOAD]
public reloadOctoPrint(): void {
private reloadOctoPrint(): void {
this.systemService.sendCommand('restart');
}

// [!REBOOT]
public rebootPi(): void {
private rebootPi(): void {
this.systemService.sendCommand('reboot');
}

// [!SHUTDOWN]
public shutdownPi(): void {
private shutdownPi(): void {
this.systemService.sendCommand('shutdown');
}

// [!KILL]
public kill(): void {
private kill(): void {
this.shutdownPi();
setTimeout(this.stopOctoDash, 500);
}

// [!WEB]
public openIFrame(url: string): void {
private openIFrame(url: string): void {
this.iFrameURL = url;
const iFrameDOM = document.getElementById('iFrame');
iFrameDOM.style.display = 'block';
Expand All @@ -142,9 +148,18 @@ export class CustomActionsComponent {
}, 500);
}

public setLEDColor(identifier: string, red: string, green: string, blue: string): void {
private setLEDColor(identifier: string, red: string, green: string, blue: string): void {
this.enclosureService.setLEDColor(Number(identifier), Number(red), Number(green), Number(blue));
}

private setOutput(identifier: string, status: string): void {
console.log(identifier);
this.enclosureService.setOutput(Number(identifier), status === 'true' || status === 'on');
}

private setOutputPWM(identifier: string, dutyCycle: string): void {
this.enclosureService.setOutputPWM(Number(identifier), Number(dutyCycle));
}
}

interface ActionToConfirm {
Expand Down
12 changes: 8 additions & 4 deletions src/app/services/enclosure/enclosure.octoprint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class EnclosureOctoprintService implements EnclosureService {
);
}

setLEDColor(identifier: number, red: number, green: number, blue: number): void {
public setLEDColor(identifier: number, red: number, green: number, blue: number): void {
const colorBody: EnclosureColorBody = {
red,
green,
Expand All @@ -67,7 +67,9 @@ export class EnclosureOctoprintService implements EnclosureService {
.subscribe();
}

setOutput(identifier: number, status: boolean): void {
public setOutput(identifier: number, status: boolean): void {
console.log(identifier, status);

const outputBody: EnclosureOutputBody = {
status,
};
Expand All @@ -85,7 +87,9 @@ export class EnclosureOctoprintService implements EnclosureService {
.subscribe();
}

setPWM(identifier: number, dutyCycle: number): void {
public setOutputPWM(identifier: number, dutyCycle: number): void {
console.log(identifier, dutyCycle);

const pwmBody: EnclosurePWMBody = {
/* eslint-disable camelcase */
duty_cycle: dutyCycle,
Expand All @@ -104,7 +108,7 @@ export class EnclosureOctoprintService implements EnclosureService {
.subscribe();
}

setPSUState(state: PSUState): void {
public setPSUState(state: PSUState): void {
if (this.configService.usePSUControl()) {
this.setPSUStatePSUControl(state);
} else if (this.configService.useTpLinkSmartPlug()) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/enclosure/enclosure.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export abstract class EnclosureService {

abstract setOutput(identifier: number, status: boolean): void;

abstract setPWM(identifier: number, dutyCycle: number): void;
abstract setOutputPWM(identifier: number, dutyCycle: number): void;

abstract setPSUState(state: PSUState): void;

Expand Down