Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Aug 26, 2024
2 parents 53838ce + 5d7df2e commit f8b00e2
Show file tree
Hide file tree
Showing 46 changed files with 197 additions and 152 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
*.dll binary
*.so binary
*.zip binary
*.bmp binary
2 changes: 2 additions & 0 deletions api/src/main/kotlin/nebulosa/api/cameras/CameraSerializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class CameraSerializer(private val capturesPath: Path) : StdSerializer<Camera>(C
gen.writeStartObject()
gen.writeStringField("type", value.type.name)
gen.writeStringField("sender", value.sender.id)
gen.writeStringField("driverName", value.driverName)
gen.writeStringField("driverVersion", value.driverVersion)
gen.writeStringField("id", value.id)
gen.writeStringField("name", value.name)
gen.writeBooleanField("connected", value.connected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class FocuserSerializer : StdSerializer<Focuser>(Focuser::class.java) {
gen.writeStartObject()
gen.writeStringField("type", value.type.name)
gen.writeStringField("sender", value.sender.id)
gen.writeStringField("driverName", value.driverName)
gen.writeStringField("driverVersion", value.driverVersion)
gen.writeStringField("id", value.id)
gen.writeStringField("name", value.name)
gen.writeBooleanField("connected", value.connected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import nebulosa.indi.device.guider.GuideOutputEvent

fun interface GuideOutputEventAware {

fun handleGuideOutputEvent(event: GuideOutputEvent<*>)
fun handleGuideOutputEvent(event: GuideOutputEvent)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ import org.springframework.stereotype.Component
@Subscriber
class GuideOutputEventHub(
private val messageService: MessageService,
) : DeviceEventHub<GuideOutput, GuideOutputEvent<*>>(DeviceType.GUIDE_OUTPUT), GuideOutputEventAware {
) : DeviceEventHub<GuideOutput, GuideOutputEvent>(DeviceType.GUIDE_OUTPUT), GuideOutputEventAware {

@Subscribe(threadMode = ThreadMode.ASYNC)
override fun handleGuideOutputEvent(event: GuideOutputEvent<*>) {
override fun handleGuideOutputEvent(event: GuideOutputEvent) {
if (event.device.type == DeviceType.GUIDE_OUTPUT) {
when (event) {
is PropertyChangedEvent -> if (event.device.canPulseGuide) onNext(event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class GuideOutputSerializer : StdSerializer<GuideOutput>(GuideOutput::class.java
gen.writeStartObject()
gen.writeStringField("type", value.type.name)
gen.writeStringField("sender", value.sender.id)
gen.writeStringField("driverName", value.driverName)
gen.writeStringField("driverVersion", value.driverVersion)
gen.writeStringField("id", value.id)
gen.writeStringField("name", value.name)
gen.writeBooleanField("connected", value.connected)
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/kotlin/nebulosa/api/mounts/MountSerializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class MountSerializer : StdSerializer<Mount>(Mount::class.java) {
gen.writeStartObject()
gen.writeStringField("type", value.type.name)
gen.writeStringField("sender", value.sender.id)
gen.writeStringField("driverName", value.driverName)
gen.writeStringField("driverVersion", value.driverVersion)
gen.writeStringField("id", value.id)
gen.writeStringField("name", value.name)
gen.writeBooleanField("connected", value.connected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class RotatorSerializer : StdSerializer<Rotator>(Rotator::class.java) {
gen.writeStartObject()
gen.writeStringField("type", value.type.name)
gen.writeStringField("sender", value.sender.id)
gen.writeStringField("driverName", value.driverName)
gen.writeStringField("driverVersion", value.driverVersion)
gen.writeStringField("id", value.id)
gen.writeStringField("name", value.name)
gen.writeBooleanField("connected", value.connected)
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/kotlin/nebulosa/api/wheels/WheelSerializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class WheelSerializer : StdSerializer<FilterWheel>(FilterWheel::class.java) {
gen.writeStartObject()
gen.writeStringField("type", value.type.name)
gen.writeStringField("sender", value.sender.id)
gen.writeStringField("driverName", value.driverName)
gen.writeStringField("driverVersion", value.driverVersion)
gen.writeStringField("id", value.id)
gen.writeStringField("name", value.name)
gen.writeBooleanField("connected", value.connected)
Expand Down
2 changes: 1 addition & 1 deletion desktop/electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"target": ["portable"]
},
"portable": {
"splashImage": "dist/assets/images/splash.png"
"splashImage": "dist/assets/images/splash.bmp"
},
"mac": {
"icon": "dist/assets/icons",
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 @@ -48,6 +48,7 @@ import { CameraExposureComponent } from '../shared/components/camera-exposure/ca
import { CameraInfoComponent } from '../shared/components/camera-info/camera-info.component'
import { DeviceChooserComponent } from '../shared/components/device-chooser/device-chooser.component'
import { DeviceListMenuComponent } from '../shared/components/device-list-menu/device-list-menu.component'
import { DeviceNameComponent } from '../shared/components/device-name/device-name.component'
import { DialogMenuComponent } from '../shared/components/dialog-menu/dialog-menu.component'
import { HistogramComponent } from '../shared/components/histogram/histogram.component'
import { LocationComponent } from '../shared/components/location/location.dialog'
Expand Down Expand Up @@ -117,6 +118,7 @@ import { StackerComponent } from './stacker/stacker.component'
CrossHairComponent,
DeviceChooserComponent,
DeviceListMenuComponent,
DeviceNameComponent,
DialogMenuComponent,
DropdownOptionsPipe,
EnumPipe,
Expand Down
9 changes: 1 addition & 8 deletions desktop/src/app/camera/camera.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div class="container px-4 pt-2 pb-1">
<div class="grid py-1 flex align-items-center">
<div class="col-8 align-items-center gap-2">
<p-floatLabel>
<input
pInputText
readonly
[value]="camera.name"
class="p-inputtext-sm border-0 w-full" />
<label>Camera</label>
</p-floatLabel>
<neb-device-name [device]="camera" />
<p-button
*ngIf="!camera || camera.connected"
[disabled]="!camera || running"
Expand Down
9 changes: 1 addition & 8 deletions desktop/src/app/filterwheel/filterwheel.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div class="container px-4 py-3">
<div class="grid flex align-items-center">
<div class="col-12 align-items-center gap-2">
<p-floatLabel>
<input
pInputText
readonly
[value]="wheel.name"
class="p-inputtext-sm border-0 w-full" />
<label>Filter Wheel</label>
</p-floatLabel>
<neb-device-name [device]="wheel" />
<p-button
*ngIf="wheel.connected"
[disabled]="!wheel || moving"
Expand Down
9 changes: 1 addition & 8 deletions desktop/src/app/focuser/focuser.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div class="container px-4 py-3">
<div class="grid flex align-items-center">
<div class="col-12 align-items-center gap-2">
<p-floatLabel>
<input
pInputText
readonly
[value]="focuser.name"
class="p-inputtext-sm border-0 w-full" />
<label>Focuser</label>
</p-floatLabel>
<neb-device-name [device]="focuser" />
<p-button
*ngIf="focuser.connected"
[disabled]="!focuser || focuser.moving"
Expand Down
9 changes: 1 addition & 8 deletions desktop/src/app/mount/mount.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div class="container px-4 py-3">
<div class="grid flex align-items-center">
<div class="col-8 align-items-center gap-2">
<p-floatLabel>
<input
pInputText
readonly
[value]="mount.name"
class="p-inputtext-sm border-0 w-full" />
<label>Mount</label>
</p-floatLabel>
<neb-device-name [device]="mount" />
<p-button
*ngIf="mount.connected"
[disabled]="mount.slewing || mount.parking"
Expand Down
9 changes: 1 addition & 8 deletions desktop/src/app/rotator/rotator.component.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<div class="container px-4 py-3">
<div class="grid flex align-items-center">
<div class="col-12 align-items-center gap-2">
<p-floatLabel>
<input
pInputText
readonly
[value]="rotator.name"
class="p-inputtext-sm border-0 w-full" />
<label>Rotator</label>
</p-floatLabel>
<neb-device-name [device]="rotator" />
<p-button
*ngIf="rotator.connected"
[disabled]="rotator.moving"
Expand Down
Binary file added desktop/src/assets/images/splash.bmp
Binary file not shown.
20 changes: 20 additions & 0 deletions desktop/src/shared/components/device-name/device-name.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Component, Input, ViewEncapsulation } from '@angular/core'
import type { Device } from '../../types/device.types'

@Component({
selector: 'neb-device-name',
template: `
<div class="flex flex-column justify-content-center gap-0">
<span class=font-bold>{{ device.name }}</span>
<div class="flex flex-row align-items-center text-xs text-gray-400 gap-2">
<span>DRIVER: {{ device.driverName }}</span>
<span>VERSION: {{ device.driverVersion }}</span>
</div>
</div>
`,
encapsulation: ViewEncapsulation.None,
})
export class DeviceNameComponent {
@Input({ required: true })
readonly device!: Device
}
2 changes: 2 additions & 0 deletions desktop/src/shared/types/camera.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ export interface CameraNamingFormatDialog {
export const DEFAULT_CAMERA: Camera = {
type: 'CAMERA',
sender: '',
driverName: '',
driverVersion: '',
id: '',
exposuring: false,
hasCoolerControl: false,
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/shared/types/device.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface Device {
readonly sender: string
readonly id: string
readonly name: string
readonly driverName: string
readonly driverVersion: string
connected: boolean
}

Expand Down
2 changes: 2 additions & 0 deletions desktop/src/shared/types/focuser.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface FocuserPreference {
export const DEFAULT_FOCUSER: Focuser = {
type: 'FOCUSER',
sender: '',
driverName: '',
driverVersion: '',
id: '',
moving: false,
position: 0,
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/shared/types/guider.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export interface GuiderChartInfo {
export const DEFAULT_GUIDE_OUTPUT: GuideOutput = {
type: 'CAMERA',
sender: '',
driverName: '',
driverVersion: '',
id: '',
canPulseGuide: false,
pulseGuiding: false,
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/shared/types/mount.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ export interface MountPreference {
export const DEFAULT_MOUNT: Mount = {
type: 'MOUNT',
sender: '',
driverName: '',
driverVersion: '',
id: '',
slewing: false,
tracking: false,
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/shared/types/rotator.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface RotatorPreference {
export const DEFAULT_ROTATOR: Rotator = {
type: 'ROTATOR',
sender: '',
driverName: '',
driverVersion: '',
id: '',
name: '',
moving: false,
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
Expand Up @@ -58,6 +58,8 @@ export function makeFilter(wheel: Wheel, filters: Filter[], shutterPosition: num
export const DEFAULT_WHEEL: Wheel = {
type: 'WHEEL',
sender: '',
driverName: '',
driverVersion: '',
id: '',
count: 0,
position: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nebulosa.indi.client

import nebulosa.indi.client.connection.INDIProccessConnection
import nebulosa.indi.client.connection.INDISocketConnection
import nebulosa.indi.client.device.DriverInfo
import nebulosa.indi.client.device.INDIDeviceProtocolHandler
import nebulosa.indi.client.device.auxiliary.INDIGPS
import nebulosa.indi.client.device.auxiliary.INDIGuideOutput
Expand Down Expand Up @@ -48,32 +49,32 @@ data class INDIClient(val connection: INDIConnection) : INDIDeviceProtocolHandle
override val input
get() = connection.input

override fun newCamera(name: String, executable: String): Camera {
return CAMERAS[executable]?.create(this, name) ?: INDICamera(this, name)
override fun newCamera(driverInfo: DriverInfo): Camera {
return CAMERAS[driverInfo.executable]?.create(this, driverInfo) ?: INDICamera(this, driverInfo)
}

override fun newMount(name: String, executable: String): Mount {
return INDIMount(this, name)
override fun newMount(driverInfo: DriverInfo): Mount {
return INDIMount(this, driverInfo)
}

override fun newFocuser(name: String, executable: String): Focuser {
return INDIFocuser(this, name)
override fun newFocuser(driverInfo: DriverInfo): Focuser {
return INDIFocuser(this, driverInfo)
}

override fun newFilterWheel(name: String, executable: String): FilterWheel {
return INDIFilterWheel(this, name)
override fun newFilterWheel(driverInfo: DriverInfo): FilterWheel {
return INDIFilterWheel(this, driverInfo)
}

override fun newRotator(name: String, executable: String): Rotator {
return INDIRotator(this, name)
override fun newRotator(driverInfo: DriverInfo): Rotator {
return INDIRotator(this, driverInfo)
}

override fun newGPS(name: String, executable: String): GPS {
return INDIGPS(this, name)
override fun newGPS(driverInfo: DriverInfo): GPS {
return INDIGPS(this, driverInfo)
}

override fun newGuideOutput(name: String, executable: String): GuideOutput {
return INDIGuideOutput(this, name)
override fun newGuideOutput(driverInfo: DriverInfo): GuideOutput {
return INDIGuideOutput(this, driverInfo)
}

override fun start() {
Expand Down Expand Up @@ -109,9 +110,9 @@ data class INDIClient(val connection: INDIConnection) : INDIDeviceProtocolHandle
)

@JvmStatic
private fun <T : Device> Class<out T>.create(handler: INDIClient, name: String): T {
return getConstructor(INDIClient::class.java, String::class.java)
.newInstance(handler, name)
private fun <T : Device> Class<out T>.create(handler: INDIClient, driverInfo: DriverInfo): T {
return getConstructor(INDIClient::class.java, DriverInfo::class.java)
.newInstance(handler, driverInfo)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package nebulosa.indi.client.device

import nebulosa.indi.protocol.TextVector

data class DriverInfo(
@JvmField val name: String,
@JvmField val executable: String,
@JvmField val version: String,
@JvmField val interfaceType: Int,
) {

companion object {

@JvmStatic
fun from(message: TextVector<*>): DriverInfo? {
return DriverInfo(
message.device,
message["DRIVER_EXEC"]?.value?.takeIf { it.isNotBlank() } ?: return null,
message["DRIVER_VERSION"]?.value?.takeIf { it.isNotBlank() } ?: return null,
message["DRIVER_INTERFACE"]?.value?.toIntOrNull() ?: return null,
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@ internal abstract class INDIDevice : Device {

abstract override val sender: INDIClient

override val properties = linkedMapOf<String, PropertyVector<*, *>>()
override val messages = LinkedList<String>()
abstract val driverInfo: DriverInfo

override val id by lazy { type.code + "." + name.encodeUtf8().md5().hex() }
final override val properties = linkedMapOf<String, PropertyVector<*, *>>()
final override val messages = LinkedList<String>()
final override val id by lazy { type.code + "." + name.encodeUtf8().md5().hex() }
final override val snoopedDevices = ArrayList<Device>(4)

override val name
get() = driverInfo.name

@Volatile override var connected = false
protected set

override val snoopedDevices = ArrayList<Device>(4)
final override val driverName
get() = driverInfo.executable

final override val driverVersion
get() = driverInfo.version

private fun addMessageAndFireEvent(text: String) {
synchronized(messages) {
Expand Down
Loading

0 comments on commit f8b00e2

Please sign in to comment.