Skip to content

Commit

Permalink
[api][desktop]: Support ASCOM Rotator
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed May 20, 2024
1 parent 5425a23 commit d500bc0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 37 deletions.
2 changes: 1 addition & 1 deletion desktop/src/app/rotator/rotator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class RotatorComponent implements AfterViewInit, OnDestroy {
}

private update() {
if (!this.rotator.id) {
if (this.rotator.id) {
this.moving = this.rotator.moving
this.reversed = this.rotator.reversed
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,28 @@ abstract class ASCOMDevice : Device, Resettable {

protected fun <T : AlpacaResponse<*>> Call<T>.doRequest(): T? {
try {
val response = execute().body()
val request = request()
val response = execute()
val body = response.body()

return if (response == null) {
LOG.warn("response has no body. device={}, url={}", name, request().url)
return if (body == null) {
LOG.warn("response has no body. device={}, request={} {}, response={}", name, request.method, request.url, response.code())
null
} else if (response.errorNumber != 0) {
val message = response.errorMessage
} else if (body.errorNumber != 0) {
val message = body.errorMessage

if (message.isNotEmpty()) {
addMessageAndFireEvent("[%s]: %s".format(LocalDateTime.now(), message))
}

// LOG.warn("unsuccessful response. device={}, code={}, message={}", name, response.errorNumber, response.errorMessage)
LOG.warn(
"unsuccessful response. device={}, request={} {}, errorNumber={}, message={}",
name, request.method, request.url, body.errorNumber, body.errorMessage
)

null
} else {
response
body
}
} catch (e: HttpException) {
LOG.error("unexpected response. device=$name", e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,35 +198,12 @@ abstract class AbstractINDIDeviceProvider : INDIDeviceProvider {
}

override fun close() {
cameras().forEach {
it.close()
unregisterCamera(it)
}

mounts().forEach {
it.close()
unregisterMount(it)
}

wheels().forEach {
it.close()
unregisterFilterWheel(it)
}

focusers().forEach {
it.close()
unregisterFocuser(it)
}

rotators().forEach {
it.close()
unregisterRotator(it)
}

gps().forEach {
it.close()
unregisterGPS(it)
}
cameras().onEach(Device::close).onEach(::unregisterCamera)
mounts().onEach(Device::close).onEach(::unregisterMount)
wheels().onEach(Device::close).onEach(::unregisterFilterWheel)
focusers().onEach(Device::close).onEach(::unregisterFocuser)
rotators().onEach(Device::close).onEach(::unregisterRotator)
gps().onEach(Device::close).onEach(::unregisterGPS)

cameras.clear()
mounts.clear()
Expand Down

0 comments on commit d500bc0

Please sign in to comment.