-
-
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
16 changed files
with
370 additions
and
35 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
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
58 changes: 58 additions & 0 deletions
58
nebulosa-siril/src/main/kotlin/nebulosa/siril/command/DumpHeader.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,58 @@ | ||
package nebulosa.siril.command | ||
|
||
import nebulosa.common.concurrency.latch.CountUpDownLatch | ||
import nebulosa.common.exec.CommandLineListener | ||
import nebulosa.fits.FitsHeader | ||
import nebulosa.fits.FitsHeaderCard | ||
import nebulosa.image.format.Header | ||
import nebulosa.log.debug | ||
import nebulosa.log.loggerFor | ||
import java.util.concurrent.TimeUnit | ||
import java.util.concurrent.atomic.AtomicBoolean | ||
|
||
data class DumpHeader(private val header: Header = FitsHeader()) : SirilCommand<Header>, CommandLineListener { | ||
|
||
private val latch = CountUpDownLatch(1) | ||
private val started = AtomicBoolean() | ||
private val finished = AtomicBoolean() | ||
|
||
override fun onLineRead(line: String) { | ||
if (finished.get()) return | ||
|
||
if (started.get()) { | ||
val card = line.replaceFirst("log: ", "").trimStart() | ||
|
||
try { | ||
with(FitsHeaderCard.from(card)) { | ||
header.add(this) | ||
|
||
LOG.debug { line } | ||
|
||
if (key == "END") { | ||
finished.set(true) | ||
latch.reset() | ||
} | ||
} | ||
} catch (ignored: Throwable) { | ||
} | ||
} else if (line.contains("FITS header for currently loaded image", true)) { | ||
started.set(true) | ||
} | ||
} | ||
|
||
override fun write(commandLine: SirilCommandLine): Header { | ||
return try { | ||
commandLine.registerCommandLineListener(this) | ||
commandLine.write("dumpheader") | ||
latch.await(15, TimeUnit.SECONDS) | ||
header | ||
} finally { | ||
commandLine.unregisterCommandLineListener(this) | ||
} | ||
} | ||
|
||
companion object { | ||
|
||
@JvmStatic private val LOG = loggerFor<DumpHeader>() | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
nebulosa-siril/src/main/kotlin/nebulosa/siril/command/Exit.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
Oops, something went wrong.