Skip to content

Commit

Permalink
Merge branch 'dev' into feature/auto-focus
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed May 25, 2024
2 parents 31d1391 + 3828e2b commit 574ea0b
Show file tree
Hide file tree
Showing 50 changed files with 465 additions and 251 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nebulosa.api.cameras.CameraEventHandler
import nebulosa.api.focusers.FocuserEventHandler
import nebulosa.api.guiding.GuideOutputEventHandler
import nebulosa.api.mounts.MountEventHandler
import nebulosa.api.rotators.RotatorEventHandler
import nebulosa.api.wheels.WheelEventHandler
import nebulosa.indi.device.DeviceConnectionEvent
import nebulosa.indi.device.DeviceEvent
Expand All @@ -13,6 +14,7 @@ import nebulosa.indi.device.filterwheel.FilterWheel
import nebulosa.indi.device.focuser.Focuser
import nebulosa.indi.device.guide.GuideOutput
import nebulosa.indi.device.mount.Mount
import nebulosa.indi.device.rotator.Rotator
import org.springframework.stereotype.Component

@Component
Expand All @@ -22,6 +24,7 @@ class ConnectionEventHandler(
private val focuserEventHandler: FocuserEventHandler,
private val wheelEventHandler: WheelEventHandler,
private val guideOutputEventHandler: GuideOutputEventHandler,
private val rotatorEventHandler: RotatorEventHandler,
) : DeviceEventHandler.EventReceived {

@Suppress("CascadeIf")
Expand All @@ -33,6 +36,7 @@ class ConnectionEventHandler(
else if (device is Mount) mountEventHandler.sendUpdate(device)
else if (device is Focuser) focuserEventHandler.sendUpdate(device)
else if (device is FilterWheel) wheelEventHandler.sendUpdate(device)
else if (device is Rotator) rotatorEventHandler.sendUpdate(device)

if (device is GuideOutput) guideOutputEventHandler.sendUpdate(device)
}
Expand Down
8 changes: 4 additions & 4 deletions api/src/main/kotlin/nebulosa/api/indi/INDIController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class INDIController(
}

@Synchronized
@PutMapping("listener/{device}/start")
fun startListening(device: Device) {
@PutMapping("{device}/listen")
fun listen(device: Device) {
indiService.registerDeviceToSendMessage(device)
}

@Synchronized
@PutMapping("listener/{device}/stop")
fun stopListening(device: Device) {
@PutMapping("{device}/unlisten")
fun unlisten(device: Device) {
indiService.unregisterDeviceToSendMessage(device)
}
}
26 changes: 14 additions & 12 deletions api/src/main/kotlin/nebulosa/api/indi/INDIEventHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,45 @@ import java.util.*
@Subscriber
class INDIEventHandler(
private val messageService: MessageService,
) : LinkedList<String>() {
) {

private val canSendEvents = HashSet<String>()
private val canSendEvents = HashSet<Device>(8)
private val messages = LinkedList<String>()

@Subscribe(threadMode = ThreadMode.ASYNC)
fun onDeviceEvent(event: DeviceEvent<*>) {
when (event) {
is DevicePropertyChanged -> sendINDIPropertyChanged(event)
is DevicePropertyDeleted -> sendINDIPropertyDeleted(event)
is DeviceMessageReceived -> if (event.device == null) addFirst(event.message)
else sendINDIMessageReceived(event)
is DeviceMessageReceived -> event.device?.also { sendINDIMessageReceived(event) } ?: messages.addFirst(event.message)
is DeviceDetached<*> -> unregisterDevice(event.device)
}
}

fun registerDevice(device: Device) {
canSendEvents.add(device.id)
canSendEvents.add(device)
}

fun unregisterDevice(device: Device) {
canSendEvents.remove(device.id)
canSendEvents.remove(device)
}

fun sendINDIPropertyChanged(event: DevicePropertyEvent) {
if (event.device.id in canSendEvents) {
fun messages(): List<String> = messages

private fun sendINDIPropertyChanged(event: DevicePropertyEvent) {
if (event.device in canSendEvents) {
messageService.sendMessage(INDIMessageEvent(DEVICE_PROPERTY_CHANGED, event))
}
}

fun sendINDIPropertyDeleted(event: DevicePropertyEvent) {
if (event.device.id in canSendEvents) {
private fun sendINDIPropertyDeleted(event: DevicePropertyEvent) {
if (event.device in canSendEvents) {
messageService.sendMessage(INDIMessageEvent(DEVICE_PROPERTY_DELETED, event))
}
}

fun sendINDIMessageReceived(event: DeviceMessageReceived) {
if (event.device != null && event.device!!.id in canSendEvents) {
private fun sendINDIMessageReceived(event: DeviceMessageReceived) {
if (event.device != null && event.device in canSendEvents) {
messageService.sendMessage(INDIMessageEvent(DEVICE_MESSAGE_RECEIVED, event))
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/kotlin/nebulosa/api/indi/INDIService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class INDIService(
}

fun messages(): List<String> {
return indiEventHandler
return indiEventHandler.messages()
}

fun properties(device: Device): Collection<PropertyVector<*, *>> {
Expand Down
2 changes: 1 addition & 1 deletion desktop/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ try {
return false
})

const events: InternalEventType[] = ['WHEEL.RENAMED', 'LOCATION.CHANGED', 'CALIBRATION.CHANGED']
const events: InternalEventType[] = ['WHEEL.RENAMED', 'LOCATION.CHANGED', 'CALIBRATION.CHANGED', 'ROI.SELECTED']

for (const item of events) {
ipcMain.handle(item, (_, data) => {
Expand Down
55 changes: 48 additions & 7 deletions desktop/src/app/about/about.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,54 @@
<p-tag class="flex" styleClass="text-lg" value="0.1.0" />
<p-tag class="flex" styleClass="text-lg" value="Ceres" severity="success" />
</p>
<p class="text-md text-gray-400">© 2022-2024 Tiago Melo <img src="assets/icons/brazil.png" class="mx-1" style="width: 16px"> All rights reserved</p>
<p>This software is WIP, comes with absolutely no warranty and the copyright holder is not liable or responsible for anything.</p>

<div class="flex align-items-center gap-2 flex-wrap">
<a target="_blank" href="https://www.paypal.com/donate/?hosted_button_id=U8TGGJTKSZUCA">
<img src="assets/images/donate-with-paypal-blue.svg" style="height: 31px;">
</a>
<p class="text-sm text-gray-400 mt-0">
© 2022-2024 Tiago Melo
<img src="assets/icons/brazil.png" class="mx-1" style="width: 16px">
All rights reserved
</p>
<div style="height: 128px">
<p-tabView>
<p-tabPanel header="Disclaimer">
<p>This software is WIP, comes with absolutely no warranty and the copyright holder is not liable or responsible for anything.</p>
</p-tabPanel>
<p-tabPanel header="Icons">
<div class="w-full flex flex-column overflow-y-auto" style="height: 99px">
<a target="_blank" href="https://www.flaticon.com/free-icon/information_9195785">Information icon by Anggara - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/sky_3982229">Sky icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/target_3207593">Target icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/camera-lens_5708327">Camera icon by juicy_fish - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/telescope_4011463">Telescope icon by Smashicons - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/observatory_2256076">Observatory icon by Nikita Golubev -
Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/focus_3801224">Focus icon by FetchLab - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/switch_404449">Switch icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/image_4371206">Image icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/image-processing_6062419">Image processing icon by juicy_fish -
Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/star_740882">Star icon by Vectors Market - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/rotate_3303063">Rotate icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/rgb-print_7664547">Color wheel icon by BomSymbols - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/cogwheel_3953226">Settings icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/contrast_439842">Sun icon by DinosoftLabs - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/full-moon_9689786">Moon icon by vectorsmarket15 - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/jupiter_1086078">Planet icon by monkik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/asteroid_1086068">Asteroid icon by monkik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/satellite_1086093">Satellite icon by monkik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/witch-hat_5606276">Witch hat icon by Luvdat - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/picture_2659360">Picture icon by Freepik - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/magnifier_13113714">Magnifier icon by Pop Vectors - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/calculator_7182540">Calculator icon by Iconic Panda - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/target_10542035">Target icon by Arkinasi - Flaticon</a>
<a target="_blank" href="https://www.flaticon.com/free-icon/stack_3342239">Stack icon by Pixel perfect - Flaticon</a>
<a target="_blank" href="https://thenounproject.com/icon/random-dither-4259782/">Random Dither icon by Arthur Shlain</a>
</div>
</p-tabPanel>
</p-tabView>
</div>
</div>
<div class="col-12 flex align-items-center justify-content-center gap-2 flex-wrap">
<a target="_blank" href="https://www.paypal.com/donate/?hosted_button_id=U8TGGJTKSZUCA">
<img src="assets/images/donate-with-paypal-blue.svg" style="height: 31px;">
</a>
</div>
</div>
12 changes: 6 additions & 6 deletions desktop/src/app/alignment/alignment.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div class="col-4 align-items-center">
<span class="p-float-label">
<p-inputNumber styleClass="p-inputtext-sm border-0 max-w-full" [(ngModel)]="tppaRequest.stepDuration"
[showButtons]="true" [min]="1" [max]="60" (ngModelChange)="savePreference()" />
[showButtons]="true" [min]="1" [max]="60" (ngModelChange)="savePreference()" scrollableNumber />
<label>Step duration (s)</label>
</span>
</div>
Expand Down Expand Up @@ -110,14 +110,14 @@
<div class="col-4">
<span class="p-float-label">
<p-inputNumber styleClass="p-inputtext-sm border-0 max-w-full" [(ngModel)]="darvRequest.initialPause"
[showButtons]="true" [min]="1" [max]="60" (ngModelChange)="initialPauseChanged()" />
[showButtons]="true" [min]="1" [max]="60" (ngModelChange)="initialPauseChanged()" scrollableNumber />
<label>Initial pause (s)</label>
</span>
</div>
<div class="col-4">
<span class="p-float-label">
<p-inputNumber styleClass="p-inputtext-sm border-0 max-w-full" [(ngModel)]="darvRequest.exposureTime"
[showButtons]="true" [min]="1" [max]="600" (ngModelChange)="driftForChanged()" />
[showButtons]="true" [min]="1" [max]="600" (ngModelChange)="driftForChanged()" scrollableNumber />
<label>Drift for (s)</label>
</span>
</div>
Expand All @@ -141,13 +141,13 @@
</div>
<div class="grid mt-1">
<div class="col-12 flex-column justify-content-center text-sm overflow-y-auto max-h-7rem p-0">
<span>1. Locate a star in the Meridian and close to declination 0.</span>
<span>1. Locate a star near the south meridian and close to declination 0.</span>
<span>2. Start DARV and wait for routine to complete.</span>
<span>3. If you see V shaped track, adjust the Azimuth and repeat the step 2 till you get a line.</span>
<span>4. Locate a star in the Eastern or Western horizon and close to declination 0.</span>
<span>4. Locate a star in the eastern or western horizon and close to declination 0.</span>
<span>5. Start DARV and wait for routine to complete.</span>
<span>6. If you see V shaped track, adjust the Altitude and repeat the step 5 till you get a line.</span>
<span>7. Increase the drift time and repeat the step 1 to get a more accurate alignment.</span>
<span>7. Increase the drift time and repeat the step 1 to refine the alignment.</span>
</div>
</div>
</p-tabPanel>
Expand Down
12 changes: 7 additions & 5 deletions desktop/src/app/alignment/alignment.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,18 @@ export class AlignmentComponent implements AfterViewInit, OnDestroy {
}

@HostListener('window:unload')
ngOnDestroy() {
this.darvStop()
this.tppaStop()
async ngOnDestroy() {
try {
await this.darvStop()
} finally {
await this.tppaStop()
}
}

async cameraChanged() {
if (this.camera.id) {
const camera = await this.api.camera(this.camera.id)
Object.assign(this.camera, camera)
this.loadPreference()
}
}

Expand Down Expand Up @@ -326,7 +328,7 @@ export class AlignmentComponent implements AfterViewInit, OnDestroy {
}

darvStop() {
this.api.darvStop(this.camera)
return this.api.darvStop(this.camera)
}

async tppaStart() {
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { MenuItemComponent } from '../shared/components/menu-item/menu-item.comp
import { MoonComponent } from '../shared/components/moon/moon.component'
import { SlideMenuComponent } from '../shared/components/slide-menu/slide-menu.component'
import { LocationDialog } from '../shared/dialogs/location/location.dialog'
import { ScrollableNumberDirective } from '../shared/directives/input-number-scrollable'
import { NoDropdownDirective } from '../shared/directives/no-dropdown.directive'
import { StopPropagationDirective } from '../shared/directives/stop-propagation.directive'
import { LocationInterceptor } from '../shared/interceptors/location.interceptor'
Expand Down Expand Up @@ -109,6 +110,7 @@ import { SettingsComponent } from './settings/settings.component'
HistogramComponent,
HomeComponent,
ImageComponent,
ScrollableNumberDirective,
INDIComponent,
INDIPropertyComponent,
LocationDialog,
Expand Down
15 changes: 8 additions & 7 deletions desktop/src/app/atlas/atlas.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@
<div class="flex w-full align-items-center px-4 gap-2">
<span class="p-float-label">
<p-inputNumber [min]="1" [max]="30" class="w-full" [step]="1" [showButtons]="true"
inputStyleClass="p-inputtext-sm border-0 w-full" [(ngModel)]="closeApproachDays" />
inputStyleClass="p-inputtext-sm border-0 w-full" [(ngModel)]="closeApproachDays"
scrollableNumber />
<label>Days</label>
</span>
<span class="p-float-label">
<p-inputNumber [min]="1" [max]="100" class="w-full" [step]="0.1" [showButtons]="true"
inputStyleClass="p-inputtext-sm border-0 w-full" locale="en" [(ngModel)]="closeApproachDistance" />
inputStyleClass="p-inputtext-sm border-0 w-full" locale="en" [(ngModel)]="closeApproachDistance"
scrollableNumber />
<label>Distance (LD)</label>
</span>
<p-button [disabled]="refreshing" (onClick)="closeApproachesForMinorPlanets()"
Expand Down Expand Up @@ -350,7 +352,7 @@
<div class="col-4">
<span class="p-float-label">
<p-inputNumber [min]="0" [max]="90" class="w-full" [step]="0.1" [maxFractionDigits]="1" [showButtons]="true"
inputStyleClass="p-inputtext-sm border-0 w-full" locale="en" [(ngModel)]="skyObjectFilter.radius" />
inputStyleClass="p-inputtext-sm border-0 w-full" locale="en" [(ngModel)]="skyObjectFilter.radius" scrollableNumber />
<label>Radius (°)</label>
</span>
</div>
Expand Down Expand Up @@ -428,12 +430,11 @@
<div class="flex flex-column align-items-center">
<div class="flex align-items-center justify-content-center gap-2">
<p-inputNumber [disabled]="refreshing || !useManualDateTime" [(ngModel)]="dateTimeHour" [showButtons]="true" [min]="0"
[max]="23"
class="w-fit" [format]="false" [allowEmpty]="false" (ngModelChange)="dateTimeChanged(false)"
styleClass="p-inputtext-sm border-0" [style]="{width: '54px'}" />
[max]="23" class="w-fit" [format]="false" [allowEmpty]="false" (ngModelChange)="dateTimeChanged(false)"
styleClass="p-inputtext-sm border-0" [style]="{width: '54px'}" scrollableNumber />
<p-inputNumber [disabled]="refreshing || !useManualDateTime" [(ngModel)]="dateTimeMinute" [showButtons]="true" [min]="0"
[max]="59" class="w-fit" [format]="false" [allowEmpty]="false" (ngModelChange)="dateTimeChanged(false)"
styleClass="p-inputtext-sm border-0" [style]="{width: '54px'}" />
styleClass="p-inputtext-sm border-0" [style]="{width: '54px'}" scrollableNumber />
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/app/calculator/formula/formula.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<span class="p-float-label">
<p-inputNumber [(ngModel)]="item.value" (ngModelChange)="calculateFormula()"
[minFractionDigits]="item.minFractionDigits ?? 0" [maxFractionDigits]="item.maxFractionDigits ?? 4"
[showButtons]="true" styleClass="border-0 p-inputtext-sm" locale="en" />
[showButtons]="true" styleClass="border-0 p-inputtext-sm" locale="en" scrollableNumber />
<label>{{ item.label }}</label>
</span>
</div>
Expand Down
Loading

0 comments on commit 574ea0b

Please sign in to comment.