WIP: Простая конфигурация устройств через спецификации #12
No reviewers
Labels
No Label
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kscience/controls-kt#12
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "dev-maxim"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Добавлены некоторые базовые автотесты для создания устройств по спецификациям. Добавлена возможность включения внутри устройства других устройств с их собственными спецификациями. На примере анализатора жидкостей.
WIP: Add simple expressions and equationsto WIP: Простая конфигурация устройств через спецификацииCreate a separate demo project under
demo
instead of doing everything in tests. Replace Russian with English. Remove debug prints. Use device logger when it is needed.@ -16,10 +16,13 @@ kscience{
useSerialization()
commonMain {
api(projects.controlsCore)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
Use libs.versions for version storage or use
spclibs
reference@ -77,0 +78,4 @@
/**
* Create and register a derived state.
*/
public fun <T> derivedState(
What is the reason for this method in the state container? Why
computeValue
does not take parameters?@ -77,0 +80,4 @@
*/
public fun <T> derivedState(
dependencies: List<DeviceState<*>>,
computeValue: () -> T,
Should be suspended
@ -53,0 +53,4 @@
public fun <T> DeviceState.Companion.derived(
scope: CoroutineScope,
dependencies: List<DeviceState<*>>,
computeValue: () -> T
Should use suspended function
@ -57,2 +63,4 @@
}
public fun <T> DeviceState.Companion.fromFlow(
Should be documented
@ -103,0 +134,4 @@
) : DeviceStateWithDependencies<T> {
private val _valueFlow: StateFlow<T>
init {
Don't assign values in init. Use fake constructor if needed
@ -0,0 +1,9 @@
package space.kscience.controls.constructor.dsl.core
/**
* Класс для представления аннотации.
Rewrite comments in English
@ -7,0 +15,4 @@
/**
* Converts a value from this unit to the base unit.
*/
public fun toBase(value: Double): Double
Not clear how we select the base unit. Probably better documentation is needed. Is it better than the external dispatch that is used right now?
@ -0,0 +38,4 @@
val maxPosition: Int = meta["maxPosition"].int ?: 100
// Получить текущую позицию мотора
suspend fun getPosition(): Int = _position
probably better to use
readPosition
instead ofgetPosition
. It communicates what the functions do better.@ -0,0 +41,4 @@
suspend fun getPosition(): Int = _position
// Установить позицию мотора
suspend fun setPosition(value: Int) {
Consider encapsulating those functions.
@ -0,0 +68,4 @@
}
// Реализация устройства клапана
class ValveDevice(
Maybe call it
VirtualValv
or similar to discriminate between virtual devices and real ones.@ -0,0 +82,4 @@
suspend fun setState(value: Boolean) {
_state = value
val stateStr = if (_state) "открыт" else "закрыт"
println("ValveDevice: Клапан теперь $stateStr")
Remove debug prints. Use property subscription for testing. Don't use Russian.
@ -0,0 +120,4 @@
private var _pressure: Double = 0.0
// Получить текущее давление
suspend fun getPressure(): Double = _pressure
readPressure?
@ -0,0 +264,4 @@
// Выполнить забор пробы
suspend fun performSampling() {
println("NeedleDevice: Забор пробы в позиции $position мм")
Remove debug prints. If needed, use device log
@ -0,0 +371,4 @@
) : DeviceBySpec<AnalyzerDevice>(AnalyzerSpec, context, meta) {
val transportationSystem: TransportationSystem
get() = nestedDevices["transportationSystem"] as TransportationSystem
Probably better to use DeviceGroup API?
Checkout
From your project repository, check out a new branch and test the changes.