-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
d0c9c44
commit 7a4d9f4
Showing
24 changed files
with
199 additions
and
180 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package automaton.constructor.model.memory | ||
|
||
import automaton.constructor.model.data.MemoryUnitDescriptorData | ||
import kotlinx.serialization.Serializable | ||
|
||
data class Test(val input: List<MemoryUnitDescriptor>) | ||
|
||
@Serializable | ||
data class TestsForSerializing(val tests: List<List<MemoryUnitDescriptorData>>, val automatonType: String) |
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
47 changes: 47 additions & 0 deletions
47
src/main/kotlin/automaton/constructor/utils/ExecutorUtils.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,47 @@ | ||
package automaton.constructor.utils | ||
|
||
import automaton.constructor.model.automaton.Automaton | ||
import automaton.constructor.model.memory.MemoryUnit | ||
import automaton.constructor.model.module.executor.ExecutionStatus | ||
import automaton.constructor.model.module.executor.Executor | ||
import automaton.constructor.model.module.problems | ||
import automaton.constructor.view.module.executor.executionLeafView | ||
|
||
data class ExecutorResult( | ||
val executionResult: String, | ||
val graphic: SettingGroupEditor? | ||
) | ||
|
||
fun getNewExecutorOrNull(automaton: Automaton): Executor? { | ||
if (automaton.problems.isNotEmpty()) { | ||
tornadofx.error( | ||
I18N.messages.getString("ExecutorController.Error.ExecutionFailed"), | ||
automaton.problems.joinToString("\n") { it.message }, | ||
title = I18N.messages.getString("Dialog.error") | ||
) | ||
return null | ||
} | ||
return Executor(automaton) | ||
} | ||
|
||
fun createExecutorAndRun(automaton: Automaton, memory: List<MemoryUnit>? = null): ExecutorResult? { | ||
val executor = getNewExecutorOrNull(automaton) | ||
if (executor == null) { | ||
return null | ||
} | ||
if (memory == null) { | ||
executor.start() | ||
} else { | ||
executor.start(memory) | ||
} | ||
executor.runFor() | ||
val executionResult = when (executor.status) { | ||
ExecutionStatus.ACCEPTED -> I18N.messages.getString("ExecutorController.Executor.Status.Accepted") | ||
ExecutionStatus.REJECTED -> I18N.messages.getString("ExecutorController.Executor.Status.Rejected") | ||
ExecutionStatus.FROZEN -> I18N.messages.getString("ExecutorController.Executor.Status.Frozen") | ||
ExecutionStatus.RUNNING -> I18N.messages.getString("ExecutorController.Executor.Status.Running") | ||
} | ||
val graphic = executor.acceptedExeStates.firstOrNull()?.let { executionLeafView(it) } | ||
automaton.clearExecutionStates() | ||
return ExecutorResult(executionResult, graphic) | ||
} |
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
src/main/kotlin/automaton/constructor/view/TestsResultsFragment.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.