WIP: Простая конфигурация устройств через спецификации #12

Draft
kolpakov.mm wants to merge 2 commits from dev-maxim into dev
Owner

Добавлены некоторые базовые автотесты для создания устройств по спецификациям. Добавлена возможность включения внутри устройства других устройств с их собственными спецификациями. На примере анализатора жидкостей.

Добавлены некоторые базовые автотесты для создания устройств по спецификациям. Добавлена возможность включения внутри устройства других устройств с их собственными спецификациями. На примере анализатора жидкостей.
kolpakov.mm added 1 commit 2024-10-10 21:22:25 +03:00
kolpakov.mm added 1 commit 2024-10-24 18:20:03 +03:00
kolpakov.mm changed title from WIP: Add simple expressions and equations to WIP: Простая конфигурация устройств через спецификации 2024-10-24 18:27:54 +03:00
altavir requested changes 2024-10-31 15:47:30 +03:00
altavir left a comment
Owner

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.

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")
Owner

Use libs.versions for version storage or use spclibs reference

Use libs.versions for version storage or use `spclibs` reference
@ -77,0 +78,4 @@
/**
* Create and register a derived state.
*/
public fun <T> derivedState(
Owner

What is the reason for this method in the state container? Why computeValue does not take parameters?

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,
Owner

Should be suspended

Should be suspended
@ -53,0 +53,4 @@
public fun <T> DeviceState.Companion.derived(
scope: CoroutineScope,
dependencies: List<DeviceState<*>>,
computeValue: () -> T
Owner

Should use suspended function

Should use suspended function
@ -57,2 +63,4 @@
}
public fun <T> DeviceState.Companion.fromFlow(
Owner

Should be documented

Should be documented
@ -103,0 +134,4 @@
) : DeviceStateWithDependencies<T> {
private val _valueFlow: StateFlow<T>
init {
Owner

Don't assign values in init. Use fake constructor if needed

Don't assign values in init. Use fake constructor if needed
@ -0,0 +1,9 @@
package space.kscience.controls.constructor.dsl.core
/**
* Класс для представления аннотации.
Owner

Rewrite comments in English

Rewrite comments in English
@ -7,0 +15,4 @@
/**
* Converts a value from this unit to the base unit.
*/
public fun toBase(value: Double): Double
Owner

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?

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
Owner

probably better to use readPosition instead of getPosition. It communicates what the functions do better.

probably better to use `readPosition` instead of `getPosition`. It communicates what the functions do better.
@ -0,0 +41,4 @@
suspend fun getPosition(): Int = _position
// Установить позицию мотора
suspend fun setPosition(value: Int) {
Owner

Consider encapsulating those functions.

Consider encapsulating those functions.
@ -0,0 +68,4 @@
}
// Реализация устройства клапана
class ValveDevice(
Owner

Maybe call it VirtualValv or similar to discriminate between virtual devices and real ones.

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")
Owner

Remove debug prints. Use property subscription for testing. Don't use Russian.

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
Owner

readPressure?

readPressure?
@ -0,0 +264,4 @@
// Выполнить забор пробы
suspend fun performSampling() {
println("NeedleDevice: Забор пробы в позиции $position мм")
Owner

Remove debug prints. If needed, use device log

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
Owner

Probably better to use DeviceGroup API?

Probably better to use DeviceGroup API?
This pull request is marked as a work in progress.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin dev-maxim:dev-maxim
git checkout dev-maxim
Sign in to join this conversation.
No description provided.