Skip to content

Commit

Permalink
Merge pull request #1 from UnchartedBull/harleyg-local
Browse files Browse the repository at this point in the history
Introduce Boot Grace Time
  • Loading branch information
harleyg321 authored Apr 9, 2020
2 parents 8deee98 + c343a65 commit c3c71d6
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 16 deletions.
73 changes: 70 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"electron-store": "^5.1.1",
"lodash": "^4.17.15",
"ngx-spinner": "^9.0.2",
"rxjs": "~6.5.4",
"rxjs": "~6.5.5",
"tslib": "^1.11.1",
"zone.js": "~0.10.3"
},
Expand Down
6 changes: 3 additions & 3 deletions src/app/job-status/job-status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<div class="job-info__progress-percentage">{{ job.progress }}<span style="font-size: 40%">%</span></div>
</div>
<span class="job-info__filename">{{ job.filename }}</span> <br />
<span class="job-info__filament">{{ job.filamentAmount }}g Filament</span> <br />
<span class="job-info__time"><span
class="job-info__time-left">{{ job.timeLeft.value }}</span>{{ job.timeLeft.unit }} left,
<span class="job-info__filament" *ngIf="job.filamentAmount !== null">{{ job.filamentAmount }}g Filament</span> <br />
<span class="job-info__time"><span *ngIf="job.timeLeft.value !== null"><span
class="job-info__time-left">{{ job.timeLeft.value }}</span>{{ job.timeLeft.unit }} left,</span>
elapsed: {{ job.timePrinted.value }}{{ job.timePrinted.unit }}</span>
</div>
<div class="job-info__file-loaded" *ngIf="job && !isPrinting() && isFileLoaded()" (swipe)="cancelLoadedFile()">
Expand Down
8 changes: 4 additions & 4 deletions src/app/job.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ export class JobService {
async (data: OctoprintJobAPI): Promise<void> => {
let job: Job = null;
if (data.job && data.job.file.name) {
this.printing = ['Printing', 'Pausing', 'Paused', 'Cancelling'].includes(data.state);
this.printing = ['Printing', 'Pausing', 'Paused', 'Cancelling', 'Printing from SD'].includes(data.state);
try {
job = {
status: data.state,
filename: data.job.file.display.replace('.gcode', '').replace('.ufp', ''),
thumbnail: await this.fileService.getThumbnail(data.job.file.path),
thumbnail: (data.job.file.origin == 'sdcard') ? undefined : await this.fileService.getThumbnail(data.job.file.path),
progress: Math.round((data.progress.filepos / data.job.file.size) * 100),
filamentAmount: this.service.convertFilamentLengthToAmount(
filamentAmount: (data.job.filament === null) ? null : this.service.convertFilamentLengthToAmount(
this.getTotalAmountOfFilament(data.job.filament),
),
timeLeft: {
value: this.service.convertSecondsToHours(data.progress.printTimeLeft),
value: (data.progress.printTimeLeft === null) ? null : this.service.convertSecondsToHours(data.progress.printTimeLeft),
unit: 'h',
},
timePrinted: {
Expand Down
2 changes: 1 addition & 1 deletion src/app/layer-progress/layer-progress.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span class="layer-indication" *ngIf="layerProgress">
<span class="layer-indication" *ngIf="layerProgress && !(layerProgress.current === 0 && layerProgress.total === 0)">
Layer <span class="layer-indication__current-layer">{{ layerProgress.current }}</span> of {{ layerProgress.total }}
</span>
10 changes: 9 additions & 1 deletion src/app/notification/notification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ export class NotificationService {
private observable: Observable<Notification>;
private observer: Observer<Notification>;
private hideNotifications = false;
private bootGrace = true;

public constructor() {
this.observable = new Observable((observer: Observer<Notification>): void => {
this.observer = observer;
setTimeout((): void => {
this.bootGrace = false;
}, 30000);
}).pipe(shareReplay(1));
}

Expand All @@ -27,7 +31,7 @@ export class NotificationService {
}

public setError(heading: string, text: string): void {
if (!this.hideNotifications) {
if ((!this.hideNotifications && !this.bootGrace) || (this.bootGrace && !text.endsWith('0 Unknown Error'))) {
this.observer.next({ heading, text, type: 'error' });
}
}
Expand All @@ -45,6 +49,10 @@ export class NotificationService {
public getObservable(): Observable<Notification> {
return this.observable;
}

public getBootGrace(): boolean {
return this.bootGrace;
}
}

export interface Notification {
Expand Down
16 changes: 13 additions & 3 deletions src/app/printer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@ export class PrinterService {
);
}
});
} else if (error.status === 0) {
this.router.navigate(['/standby']);
this.notificationService.disableNotifications();
} else if (error.status === 0 && this.notificationService.getBootGrace()) {
const printerStatus: PrinterStatusAPI = {
status: `connecting ...`,
nozzle: {
current: 0,
set: 0,
},
heatbed: {
current: 0,
set: 0,
},
};
observer.next(printerStatus);
} else {
const printerStatus: PrinterStatusAPI = {
status: `error (${error.status})`,
Expand Down

0 comments on commit c3c71d6

Please sign in to comment.