Skip to content

Commit

Permalink
[desktop]: Use the selected Focuser from Sequencer
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Oct 17, 2024
1 parent 369df9e commit 1e77f69
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
5 changes: 3 additions & 2 deletions desktop/src/app/filterwheel/filterwheel.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,20 @@
</div>
<div
*ngIf="filter"
class="grid">
class="grid mt-1">
<div class="col-12 flex align-items-center justify-content-between gap-2">
<neb-device-chooser
title="FOCUSER"
icon="mdi mdi-image-filter-center-focus"
[disabled]="!canChangeFocusOffset"
[devices]="focusers"
[(device)]="focuser"
(deviceChange)="focuserChanged()"
(deviceConnect)="focuserChanged()"
style="max-width: 60%" />
<p-floatLabel>
<p-inputNumber
[disabled]="!wheel.connected || moving || !focuser?.connected"
[disabled]="!wheel.connected || moving || !focuser?.connected || !canChangeFocusOffset"
[(ngModel)]="focuserOffset"
[min]="focuserMinPosition"
[max]="focuserMaxPosition"
Expand Down
27 changes: 20 additions & 7 deletions desktop/src/app/filterwheel/filterwheel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export class FilterWheelComponent implements AfterContentInit, OnDestroy, Tickab
return this.mode === 'CAPTURE'
}

get canChangeFocusOffset() {
return this.mode === 'CAPTURE'
}

get canEdit() {
return this.mode === 'CAPTURE'
}
Expand Down Expand Up @@ -98,7 +102,7 @@ export class FilterWheelComponent implements AfterContentInit, OnDestroy, Tickab
})

electronService.on('FOCUSER.DETACHED', (event) => {
if (event.device.id === this.focuser?.id) {
if (this.mode === 'CAPTURE' && event.device.id === this.focuser?.id) {
ngZone.run(() => {
this.focuser = undefined
this.updateFocusOffset()
Expand Down Expand Up @@ -181,11 +185,13 @@ export class FilterWheelComponent implements AfterContentInit, OnDestroy, Tickab
this.ticker.register(this, 30000)
})

this.focusers = await this.api.focusers()
if (this.mode === 'CAPTURE') {
this.focusers = await this.api.focusers()

if (this.focusers.length === 1) {
this.focuser = this.focusers[0]
await this.focuserChanged()
if (this.focusers.length === 1 && !this.focuser) {
this.focuser = this.focusers[0]
await this.focuserChanged()
}
}
}

Expand All @@ -203,7 +209,14 @@ export class FilterWheelComponent implements AfterContentInit, OnDestroy, Tickab
private async loadCameraStartCaptureForDialogMode(data?: WheelDialogInput) {
if (data) {
this.mode = data.mode
this.focuser = data.focuser

await this.wheelChanged(data.wheel)

if (this.focuser) {
await this.focuserChanged()
}

Object.assign(this.request, data.request)
}
}
Expand Down Expand Up @@ -378,8 +391,8 @@ export class FilterWheelComponent implements AfterContentInit, OnDestroy, Tickab
return this.app.close(this.makeCameraStartCapture())
}

static async showAsDialog(service: BrowserWindowService, mode: WheelDialogMode, wheel: Wheel, request: CameraStartCapture) {
const result = await service.openWheelDialog({ mode, wheel, request })
static async showAsDialog(service: BrowserWindowService, mode: WheelDialogMode, wheel: Wheel, request: CameraStartCapture, focuser?: Focuser) {
const result = await service.openWheelDialog({ mode, wheel, request, focuser })

if (result) {
Object.assign(request, result)
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/app/sequencer/sequencer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ export class SequencerComponent implements AfterContentInit, OnDestroy, Tickable
}

protected async showWheelDialog(sequence: Sequence) {
if (this.plan.wheel && (await FilterWheelComponent.showAsDialog(this.browserWindowService, 'SEQUENCER', this.plan.wheel, sequence))) {
if (this.plan.wheel && (await FilterWheelComponent.showAsDialog(this.browserWindowService, 'SEQUENCER', this.plan.wheel, sequence, this.plan.focuser))) {
this.savePreference()
}
}
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/shared/types/wheel.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { CameraStartCapture } from './camera.types'
import type { Device } from './device.types'
import type { Focuser } from './focuser.types'

export type WheelDialogMode = 'CAPTURE' | 'SEQUENCER' | 'FLAT_WIZARD'

Expand All @@ -13,6 +14,7 @@ export interface Wheel extends Device {
export interface WheelDialogInput {
mode: WheelDialogMode
wheel: Wheel
focuser?: Focuser
request: CameraStartCapture
}

Expand Down

0 comments on commit 1e77f69

Please sign in to comment.