Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed May 18, 2024
2 parents b1d09fb + 2bc4d7d commit 01b0dde
Show file tree
Hide file tree
Showing 20 changed files with 474 additions and 478 deletions.
4 changes: 2 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootJar
plugins {
kotlin("jvm")
id("org.springframework.boot") version "3.2.5"
id("io.spring.dependency-management") version "1.1.4"
id("io.spring.dependency-management") version "1.1.5"
kotlin("plugin.spring")
kotlin("kapt")
id("io.objectbox")
Expand Down Expand Up @@ -46,7 +46,7 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-undertow")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
kapt("org.springframework:spring-context-indexer:6.1.6")
kapt("org.springframework:spring-context-indexer:6.1.7")
testImplementation(project(":nebulosa-astrobin-api"))
testImplementation(project(":nebulosa-skycatalog-stellarium"))
testImplementation(project(":nebulosa-test"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum class TPPAState {
SLEWING,
SLEWED,
SETTLING,
EXPOSURING,
SOLVING,
SOLVED,
COMPUTED,
Expand Down
15 changes: 11 additions & 4 deletions api/src/main/kotlin/nebulosa/api/alignment/polar/tppa/TPPATask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ data class TPPATask(
}

if (!finished.get()) {
sendEvent(TPPAState.SOLVING, event)
sendEvent(TPPAState.EXPOSURING, event)
}
}
is DelayEvent -> {
Expand Down Expand Up @@ -130,13 +130,15 @@ data class TPPATask(

// SLEWING.
if (mount != null) {
if (alignment.state in 1..2 && !mountMoveState[alignment.state]) {
if (alignment.state.ordinal in 1..2 && !mountMoveState[alignment.state.ordinal]) {
MountMoveTask(mount, mountMoveRequest).use {
sendEvent(TPPAState.SLEWING)
it.execute(cancellationToken)
mountMoveState[alignment.state] = true
mountMoveState[alignment.state.ordinal] = true
}

if (cancellationToken.isDone) break

rightAscension = mount.rightAscension
declination = mount.declination
sendEvent(TPPAState.SLEWED)
Expand All @@ -149,7 +151,7 @@ data class TPPATask(

if (cancellationToken.isDone) break

sendEvent(TPPAState.SOLVING)
sendEvent(TPPAState.EXPOSURING)

// CAPTURE.
cameraCaptureTask.execute(cancellationToken)
Expand All @@ -158,6 +160,8 @@ data class TPPATask(
break
}

sendEvent(TPPAState.SOLVING)

// ALIGNMENT.
val radius = if (mount == null) 0.0 else ATTEMPT_RADIUS * (noSolutionAttempts + 1)

Expand Down Expand Up @@ -229,6 +233,9 @@ data class TPPATask(

continue
}
is ThreePointPolarAlignmentResult.Cancelled -> {
break
}
}
}

Expand Down
73 changes: 39 additions & 34 deletions api/src/test/kotlin/AstrobinEquipmentGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import nebulosa.astrobin.api.AstrobinService
import nebulosa.astrobin.api.Camera
import nebulosa.astrobin.api.Sensor
import nebulosa.astrobin.api.Telescope
import nebulosa.log.loggerFor
import java.nio.file.Path
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executors
Expand All @@ -11,13 +12,14 @@ import kotlin.math.max

object AstrobinEquipmentGenerator {

@JvmStatic private val SENSORS = ConcurrentHashMap<Long, Sensor>()
@JvmStatic private val CAMERAS = ConcurrentHashMap<Long, Camera>()
@JvmStatic private val TELESCOPES = ConcurrentHashMap<Long, Telescope>()
@JvmStatic private val SENSORS = ConcurrentHashMap<Long, Sensor>(1024)
@JvmStatic private val CAMERAS = ConcurrentHashMap<Long, Camera>(4092)
@JvmStatic private val TELESCOPES = ConcurrentHashMap<Long, Telescope>(4092)
@JvmStatic private val OBJECT_MAPPER = ObjectMapper()
@JvmStatic private val CAMERA_PATH = Path.of("data", "astrobin", "cameras.json")
@JvmStatic private val TELESCOPE_PATH = Path.of("data", "astrobin", "telescopes.json")
@JvmStatic private val EXECUTOR_SERVICE = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())
@JvmStatic private val LOG = loggerFor<AstrobinEquipmentGenerator>()

data class CameraEquipment(
val id: Long, val name: String, val sensor: String,
Expand All @@ -33,51 +35,53 @@ object AstrobinEquipmentGenerator {
fun main(args: Array<String>) {
val astrobin = AstrobinService()

val task1 = EXECUTOR_SERVICE.submit {
for (i in 1..99) {
val sensors = astrobin.sensors(i).execute().body()
?.takeIf { it.results.isNotEmpty() }?.results ?: break

println("SENSOR: $i")

sensors.forEach { SENSORS[it.id] = it }
val a = EXECUTOR_SERVICE.submit {
for (page in 1..99) {
astrobin.sensors(page).execute().body()
?.takeIf { it.results.isNotEmpty() }
?.results
?.forEach { SENSORS[it.id] = it }
?.also { LOG.info("sensor: $page") }
?: break
}
}

val task2 = EXECUTOR_SERVICE.submit {
for (i in 1..99) {
val cameras = astrobin.cameras(i).execute().body()
?.takeIf { it.results.isNotEmpty() }?.results ?: break

println("CAMERA: $i")
val b = EXECUTOR_SERVICE.submit {
for (page in 1..99) {
astrobin.cameras(page).execute().body()
?.takeIf { it.results.isNotEmpty() }
?.results
?.forEach { CAMERAS[it.id] = it }
?.also { LOG.info("camera: $page") }
?: break

cameras.forEach { CAMERAS[it.id] = it }
}
}

val task3 = EXECUTOR_SERVICE.submit {
for (i in 1..99) {
val telescopes = astrobin.telescopes(i).execute().body()
?.takeIf { it.results.isNotEmpty() }?.results ?: break

println("TELESCOPE: $i")

telescopes.forEach { TELESCOPES[it.id] = it }
val c = EXECUTOR_SERVICE.submit {
for (page in 1..99) {
astrobin.telescopes(page).execute().body()
?.takeIf { it.results.isNotEmpty() }
?.results
?.forEach { TELESCOPES[it.id] = it }
?.also { LOG.info("telescope: $page") }
?: break
}
}

task1.get()
task2.get()
task3.get()
a.get()
b.get()
c.get()

println("CAMERA SIZE: ${CAMERAS.size}")
println("SENSOR SIZE: ${SENSORS.size}")
println("TELESCOPE SIZE: ${TELESCOPES.size}")
LOG.info("cameras: ${CAMERAS.size}")
LOG.info("sensors: ${SENSORS.size}")
LOG.info("telescopes: ${TELESCOPES.size}")

val output = HashSet<Any>(max(CAMERAS.size, TELESCOPES.size))

for ((key, value) in CAMERAS) {
val sensor = SENSORS[value.sensor] ?: continue
if (!value.isValid) continue
val sensor = SENSORS[value.sensor]?.takeIf { it.isValid } ?: continue

val name = "%s %s".format(value.brandName, value.name).replace("(color)", "").replace("(mono)", "").trim()
val sensorName = "%s %s".format(sensor.brandName, sensor.name)
Expand All @@ -88,8 +92,9 @@ object AstrobinEquipmentGenerator {
output.clear()

for ((key, value) in TELESCOPES) {
if (!value.isValid) continue
val name = "%s %s".format(value.brandName, value.name)
output.add(TelescopeEquipment(key, name, value.aperture, value.maxFocalLength))
output.add(TelescopeEquipment(key, name, value.aperture, max(value.minFocalLength, value.maxFocalLength)))
}

TELESCOPE_PATH.outputStream().use { OBJECT_MAPPER.writeValue(it, output) }
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0-RC2")
classpath("org.jetbrains.kotlin:kotlin-allopen:2.0.0-RC2")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.0-RC3")
classpath("org.jetbrains.kotlin:kotlin-allopen:2.0.0-RC3")
classpath("com.adarshr:gradle-test-logger-plugin:4.0.0")
classpath("io.objectbox:objectbox-gradle-plugin:3.8.0")
classpath("io.objectbox:objectbox-gradle-plugin:4.0.0")
}

repositories {
Expand Down
9 changes: 6 additions & 3 deletions desktop/app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,6 @@ function createWindow(options: OpenWindow<any>, parent?: BrowserWindow) {
}

if (serve) {
const debug = require('electron-debug')
debug({ showDevTools: false })

window.loadURL(`http://localhost:4200/${options.path}?data=${data}`)
} else {
const url = new URL(join('file:', __dirname, `index.html`) + `#/${options.path}?data=${data}`)
Expand Down Expand Up @@ -505,7 +502,13 @@ try {
const [width] = window.getSize()
const maxHeight = screen.getPrimaryDisplay().workAreaSize.height
const height = Math.max(options?.minHeight ?? 0, Math.min(data, maxHeight))

// https://github.com/electron/electron/issues/16711#issuecomment-1311824063
const resizable = window.isResizable()
window.setResizable(true)
window.setSize(width, height)
window.setResizable(resizable)

console.info('window auto resized:', width, height)

return true
Expand Down
Loading

0 comments on commit 01b0dde

Please sign in to comment.