Skip to content

Commit

Permalink
[api][desktop]: Improve Calibration
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Apr 8, 2024
1 parent ea969a9 commit e4fa39d
Show file tree
Hide file tree
Showing 41 changed files with 535 additions and 434 deletions.
96 changes: 48 additions & 48 deletions api/schemas/objectbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,214 +4,214 @@
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
"entities": [
{
"id": "1:8996632906249699640",
"lastPropertyId": "13:4967132491159177650",
"id": "1:659766577132862050",
"lastPropertyId": "13:7107587391686688306",
"name": "CalibrationFrameEntity",
"properties": [
{
"id": "1:8753104016604228424",
"id": "1:2268113761903193037",
"name": "id",
"type": 6,
"flags": 1
},
{
"id": "2:5256997905701910721",
"id": "2:1598928230620079098",
"name": "type",
"indexId": "1:6629699679938480062",
"indexId": "1:7442085554692140361",
"type": 5,
"flags": 8
},
{
"id": "3:4250539975904011338",
"name": "camera",
"indexId": "2:8670761666150034104",
"id": "3:7997224882771694883",
"name": "name",
"indexId": "2:6070065848831656560",
"type": 9,
"flags": 2048
},
{
"id": "4:2964126873299902795",
"id": "4:1812743003555250552",
"name": "filter",
"indexId": "3:356806529647771872",
"indexId": "3:5789122857555378891",
"type": 9,
"flags": 2048
},
{
"id": "5:6592821044234392872",
"id": "5:5895526385719301255",
"name": "exposureTime",
"type": 6
},
{
"id": "6:7841731947961734124",
"id": "6:1217849729581288112",
"name": "temperature",
"type": 8
},
{
"id": "7:8769358817044866175",
"id": "7:4483343404132984385",
"name": "width",
"type": 5
},
{
"id": "8:9066846022258802237",
"id": "8:4673309899326922479",
"name": "height",
"type": 5
},
{
"id": "9:6089591003549470592",
"id": "9:4928491775921601028",
"name": "binX",
"type": 5
},
{
"id": "10:1137944585964286888",
"id": "10:7407952871178343222",
"name": "binY",
"type": 5
},
{
"id": "11:75379120605439289",
"id": "11:1772645455690083085",
"name": "gain",
"type": 8
},
{
"id": "12:5234537218429949481",
"id": "12:1957209335781305189",
"name": "path",
"indexId": "4:1409612170773192505",
"indexId": "4:407713126153778253",
"type": 9,
"flags": 2080
},
{
"id": "13:4967132491159177650",
"id": "13:7107587391686688306",
"name": "enabled",
"type": 1
}
],
"relations": []
},
{
"id": "2:2865903592621070186",
"lastPropertyId": "3:4231519923961266979",
"id": "2:2703822036195087198",
"lastPropertyId": "3:4649483922621116787",
"name": "PreferenceEntity",
"properties": [
{
"id": "1:6437649959717305879",
"id": "1:8352093925685013458",
"name": "id",
"type": 6,
"flags": 1
},
{
"id": "2:3424721012607374437",
"id": "2:8332376147713309804",
"name": "key",
"indexId": "5:3959175721933196667",
"indexId": "5:422443843445456626",
"type": 9,
"flags": 34848
},
{
"id": "3:4231519923961266979",
"id": "3:4649483922621116787",
"name": "value",
"type": 9
}
],
"relations": []
},
{
"id": "3:7591326030822090985",
"lastPropertyId": "4:960749109935496711",
"id": "3:134389271270421743",
"lastPropertyId": "4:3302609175063994624",
"name": "SatelliteEntity",
"properties": [
{
"id": "1:8984524405419355357",
"id": "1:9030098363904692142",
"name": "id",
"type": 6,
"flags": 129
},
{
"id": "2:954886680255875455",
"id": "2:111042583962333373",
"name": "name",
"type": 9
},
{
"id": "3:2209800562197387575",
"id": "3:7030648240130620532",
"name": "tle",
"type": 9
},
{
"id": "4:960749109935496711",
"id": "4:3302609175063994624",
"name": "groups",
"type": 30
}
],
"relations": []
},
{
"id": "4:1799461706223884117",
"lastPropertyId": "12:1425111719526355640",
"id": "4:7940094622027054665",
"lastPropertyId": "12:7594216486430476300",
"name": "SimbadEntity",
"properties": [
{
"id": "1:8675363815775912010",
"id": "1:7823466820865818841",
"name": "id",
"type": 6,
"flags": 129
},
{
"id": "2:9134078346895015096",
"id": "2:3815672930103478384",
"name": "name",
"type": 9
},
{
"id": "3:5687549887167089900",
"id": "3:9175198490205670707",
"name": "type",
"type": 5
},
{
"id": "4:425502224150658936",
"id": "4:2382314709752878141",
"name": "rightAscensionJ2000",
"type": 8
},
{
"id": "5:2116112963954541453",
"id": "5:505218497375297076",
"name": "declinationJ2000",
"type": 8
},
{
"id": "6:3944877011180871841",
"id": "6:8873025996435250547",
"name": "magnitude",
"type": 8
},
{
"id": "7:7502412627527780934",
"id": "7:3149730687054027260",
"name": "pmRA",
"type": 8
},
{
"id": "8:2354824452575366292",
"id": "8:3208786528041087924",
"name": "pmDEC",
"type": 8
},
{
"id": "9:266214111788703179",
"id": "9:2691231717244757834",
"name": "parallax",
"type": 8
},
{
"id": "10:3283290633306994233",
"id": "10:5070213892916650707",
"name": "radialVelocity",
"type": 8
},
{
"id": "11:2537767302764251008",
"id": "11:6365445684038101726",
"name": "redshift",
"type": 8
},
{
"id": "12:1425111719526355640",
"id": "12:7594216486430476300",
"name": "constellation",
"type": 5
}
],
"relations": []
}
],
"lastEntityId": "4:1799461706223884117",
"lastIndexId": "5:3959175721933196667",
"lastEntityId": "4:7940094622027054665",
"lastIndexId": "5:422443843445456626",
"lastRelationId": "0:0",
"lastSequenceId": "0:0",
"modelVersion": 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PolarAlignmentController(

@PutMapping("darv/{camera}/{guideOutput}/start")
fun darvStart(
@DeviceOrEntityParam camera: Camera, @DeviceOrEntityParam guideOutput: GuideOutput,
camera: Camera, guideOutput: GuideOutput,
@RequestBody body: DARVStartRequest,
) = polarAlignmentService.darvStart(camera, guideOutput, body)

Expand All @@ -27,7 +27,7 @@ class PolarAlignmentController(

@PutMapping("tppa/{camera}/{mount}/start")
fun tppaStart(
@DeviceOrEntityParam camera: Camera, @DeviceOrEntityParam mount: Mount,
camera: Camera, mount: Mount,
@RequestBody body: TPPAStartRequest,
) = polarAlignmentService.tppaStart(camera, mount, body)

Expand Down
4 changes: 2 additions & 2 deletions api/src/main/kotlin/nebulosa/api/atlas/SkyAtlasController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ class SkyAtlasController(

@GetMapping("satellites/{satellite}/position")
fun positionOfSatellite(
@DeviceOrEntityParam satellite: SatelliteEntity,
satellite: SatelliteEntity,
@LocationParam location: Location,
@DateAndTimeParam dateTime: LocalDateTime,
) = skyAtlasService.positionOfSatellite(location, satellite, dateTime)

@GetMapping("satellites/{satellite}/altitude-points")
fun altitudePointsOfSatellite(
@DeviceOrEntityParam satellite: SatelliteEntity,
satellite: SatelliteEntity,
@LocationParam location: Location,
@DateAndTimeParam dateTime: LocalDate,
@RequestParam(required = false, defaultValue = "1") stepSize: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package nebulosa.api.beans.converters.database

import io.objectbox.converter.PropertyConverter
import java.nio.file.Path

class PathPropertyConverter : PropertyConverter<Path?, String?> {

override fun convertToEntityProperty(databaseValue: String?): Path? {
return databaseValue?.let(Path::of)
}

override fun convertToDatabaseValue(entityProperty: Path?): String? {
return entityProperty?.toString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import nebulosa.api.atlas.SatelliteEntity
import nebulosa.api.atlas.SatelliteRepository
import nebulosa.api.beans.converters.annotation
import nebulosa.api.beans.converters.parameter
import nebulosa.api.calibration.CalibrationFrameEntity
import nebulosa.api.calibration.CalibrationFrameRepository
import nebulosa.api.connection.ConnectionService
import nebulosa.indi.device.Device
import nebulosa.indi.device.camera.Camera
Expand All @@ -24,11 +26,13 @@ import org.springframework.web.server.ResponseStatusException
@Component
class DeviceOrEntityParamMethodArgumentResolver(
private val satelliteRepository: SatelliteRepository,
private val calibrationFrameRepository: CalibrationFrameRepository,
private val connectionService: ConnectionService,
) : HandlerMethodArgumentResolver {

private val entityResolvers = mapOf<Class<*>, (String) -> Any?>(
SatelliteEntity::class.java to { satelliteRepository.find(it.toLong()) },
CalibrationFrameEntity::class.java to { calibrationFrameRepository.find(it.toLong()) },
Device::class.java to { connectionService.device(it) },
Camera::class.java to { connectionService.camera(it) },
Mount::class.java to { connectionService.mount(it) },
Expand All @@ -49,7 +53,7 @@ class DeviceOrEntityParamMethodArgumentResolver(
): Any? {
val requestParam = parameter.annotation<RequestParam>()
val parameterName = requestParam?.name?.ifBlank { null } ?: parameter.parameterName ?: "id"
val parameterValue = webRequest.parameter(parameterName) ?: requestParam?.defaultValue
val parameterValue = webRequest.parameter(parameterName) ?: requestParam?.defaultValue?.ifBlank { null }

val entity = entityByParameterValue(parameter.parameterType, parameterValue)

Expand Down
Loading

0 comments on commit e4fa39d

Please sign in to comment.