-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
129 changed files
with
2,112 additions
and
1,773 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/algorithms/TwilightDiscreteFunction.kt → ...osa/api/atlas/TwilightDiscreteFunction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rvices/ephemeris/BodyEphemerisProvider.kt → .../atlas/ephemeris/BodyEphemerisProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ices/ephemeris/CachedEphemerisProvider.kt → ...tlas/ephemeris/CachedEphemerisProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...i/services/ephemeris/EphemerisProvider.kt → .../api/atlas/ephemeris/EphemerisProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/ephemeris/HorizonsEphemerisProvider.kt → ...as/ephemeris/HorizonsEphemerisProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
...ulosa/api/controllers/CameraController.kt → .../nebulosa/api/cameras/CameraController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,68 @@ | ||
package nebulosa.api.controllers | ||
package nebulosa.api.cameras | ||
|
||
import jakarta.validation.Valid | ||
import jakarta.validation.constraints.NotBlank | ||
import nebulosa.api.connection.ConnectionService | ||
import nebulosa.api.data.requests.CameraStartCaptureRequest | ||
import nebulosa.api.services.CameraService | ||
import nebulosa.api.services.EquipmentService | ||
import nebulosa.indi.device.camera.Camera | ||
import org.hibernate.validator.constraints.Range | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@RestController | ||
class CameraController( | ||
private val equipmentService: EquipmentService, | ||
private val connectionService: ConnectionService, | ||
private val cameraService: CameraService, | ||
) { | ||
|
||
@GetMapping("attachedCameras") | ||
fun attachedCameras(): List<Camera> { | ||
return equipmentService.cameras() | ||
return connectionService.cameras() | ||
} | ||
|
||
@GetMapping("camera") | ||
fun camera(@RequestParam @Valid @NotBlank name: String): Camera { | ||
return requireNotNull(equipmentService.camera(name)) | ||
return requireNotNull(connectionService.camera(name)) | ||
} | ||
|
||
@PostMapping("cameraConnect") | ||
fun connect(@RequestParam @Valid @NotBlank name: String) { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
cameraService.connect(camera) | ||
} | ||
|
||
@PostMapping("cameraDisconnect") | ||
fun disconnect(@RequestParam @Valid @NotBlank name: String) { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
cameraService.disconnect(camera) | ||
} | ||
|
||
@GetMapping("cameraIsCapturing") | ||
fun isCapturing(@RequestParam @Valid @NotBlank name: String): Boolean { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
return cameraService.isCapturing(camera) | ||
} | ||
|
||
@PostMapping("cameraSetpointTemperature") | ||
fun setpointTemperature(@RequestParam @Valid @NotBlank name: String, @RequestParam @Valid @Range(min = -50, max = 50) temperature: Double) { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
cameraService.setpointTemperature(camera, temperature) | ||
} | ||
|
||
@PostMapping("cameraCooler") | ||
fun cooler(@RequestParam @Valid @NotBlank name: String, @RequestParam value: Boolean) { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
cameraService.cooler(camera, value) | ||
} | ||
|
||
@PostMapping("cameraStartCapture") | ||
fun startCapture(@RequestParam @Valid @NotBlank name: String, @RequestBody @Valid body: CameraStartCaptureRequest) { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
cameraService.startCapture(camera, body) | ||
} | ||
|
||
@PostMapping("cameraAbortCapture") | ||
fun abortCapture(@RequestParam @Valid @NotBlank name: String) { | ||
val camera = requireNotNull(equipmentService.camera(name)) | ||
val camera = requireNotNull(connectionService.camera(name)) | ||
cameraService.abortCapture(camera) | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
api/src/main/kotlin/nebulosa/api/cameras/CameraEventHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package nebulosa.api.cameras | ||
|
||
import io.reactivex.rxjava3.subjects.PublishSubject | ||
import jakarta.annotation.PostConstruct | ||
import nebulosa.api.services.MessageService | ||
import nebulosa.indi.device.PropertyChangedEvent | ||
import nebulosa.indi.device.camera.Camera | ||
import nebulosa.indi.device.camera.CameraAttached | ||
import nebulosa.indi.device.camera.CameraDetached | ||
import nebulosa.indi.device.camera.CameraEvent | ||
import org.greenrobot.eventbus.EventBus | ||
import org.greenrobot.eventbus.Subscribe | ||
import org.greenrobot.eventbus.ThreadMode | ||
import org.springframework.stereotype.Component | ||
import java.util.concurrent.TimeUnit | ||
|
||
@Component | ||
class CameraEventHandler( | ||
private val eventBus: EventBus, | ||
private val messageService: MessageService, | ||
) { | ||
|
||
private val throttler = PublishSubject.create<CameraEvent>() | ||
|
||
@PostConstruct | ||
private fun initialize() { | ||
eventBus.register(this) | ||
|
||
throttler | ||
.throttleLast(1000, TimeUnit.MILLISECONDS) | ||
.subscribe { sendUpdate(it.device!!) } | ||
} | ||
|
||
@Subscribe(threadMode = ThreadMode.ASYNC) | ||
fun onCameraEvent(event: CameraEvent) { | ||
when (event) { | ||
is PropertyChangedEvent -> { | ||
throttler.onNext(event) | ||
} | ||
is CameraAttached -> { | ||
messageService.sendMessage(CAMERA_ATTACHED, event.device) | ||
} | ||
is CameraDetached -> { | ||
messageService.sendMessage(CAMERA_DETACHED, event.device) | ||
} | ||
} | ||
} | ||
|
||
fun sendUpdate(device: Camera) { | ||
messageService.sendMessage(CAMERA_UPDATED, device) | ||
} | ||
|
||
companion object { | ||
|
||
const val CAMERA_UPDATED = "CAMERA_UPDATED" | ||
const val CAMERA_ATTACHED = "CAMERA_ATTACHED" | ||
const val CAMERA_DETACHED = "CAMERA_DETACHED" | ||
} | ||
} |
Oops, something went wrong.