CI setup and Readme changes

This commit is contained in:
Alexander Nozik 2020-06-07 21:16:19 +03:00
parent 3982f02f64
commit f6d2626c4a
5 changed files with 46 additions and 22 deletions

17
.github/workflows/gradle.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Gradle build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build with Gradle
run: ./gradlew build

View File

@ -1,2 +1,4 @@
# dataforge-control [![JetBrains Research](https://jb.gg/badges/research.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
# DataForge-control
Data acquisition framework based on DataForge Data acquisition framework based on DataForge

View File

@ -18,8 +18,11 @@ import kotlinx.coroutines.withContext
import kotlin.properties.ReadOnlyProperty import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
/**
* A stand-alone [ReadOnlyDeviceProperty] implementation not directly attached to a device
*/
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
open class SimpleReadOnlyDeviceProperty( open class IsolatedReadOnlyDeviceProperty(
override val name: String, override val name: String,
default: MetaItem<*>?, default: MetaItem<*>?,
override val descriptor: PropertyDescriptor, override val descriptor: PropertyDescriptor,
@ -64,14 +67,14 @@ private class ReadOnlyDevicePropertyDelegate<D : DeviceBase>(
val default: MetaItem<*>?, val default: MetaItem<*>?,
val descriptor: PropertyDescriptor = PropertyDescriptor.empty(), val descriptor: PropertyDescriptor = PropertyDescriptor.empty(),
private val getter: suspend (MetaItem<*>?) -> MetaItem<*> private val getter: suspend (MetaItem<*>?) -> MetaItem<*>
) : ReadOnlyProperty<D, SimpleReadOnlyDeviceProperty> { ) : ReadOnlyProperty<D, IsolatedReadOnlyDeviceProperty> {
override fun getValue(thisRef: D, property: KProperty<*>): SimpleReadOnlyDeviceProperty { override fun getValue(thisRef: D, property: KProperty<*>): IsolatedReadOnlyDeviceProperty {
val name = property.name val name = property.name
return owner.resolveProperty(name) { return owner.resolveProperty(name) {
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
SimpleReadOnlyDeviceProperty( IsolatedReadOnlyDeviceProperty(
name, name,
default, default,
descriptor, descriptor,
@ -79,7 +82,7 @@ private class ReadOnlyDevicePropertyDelegate<D : DeviceBase>(
owner::propertyChanged, owner::propertyChanged,
getter getter
) )
} as SimpleReadOnlyDeviceProperty } as IsolatedReadOnlyDeviceProperty
} }
} }
@ -87,7 +90,7 @@ fun <D : DeviceBase> D.reading(
default: MetaItem<*>? = null, default: MetaItem<*>? = null,
descriptorBuilder: PropertyDescriptor.() -> Unit = {}, descriptorBuilder: PropertyDescriptor.() -> Unit = {},
getter: suspend (MetaItem<*>?) -> MetaItem<*> getter: suspend (MetaItem<*>?) -> MetaItem<*>
): ReadOnlyProperty<D, SimpleReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate( ): ReadOnlyProperty<D, IsolatedReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate(
this, this,
default, default,
PropertyDescriptor.invoke(descriptorBuilder), PropertyDescriptor.invoke(descriptorBuilder),
@ -98,7 +101,7 @@ fun <D : DeviceBase> D.readingValue(
default: Value? = null, default: Value? = null,
descriptorBuilder: PropertyDescriptor.() -> Unit = {}, descriptorBuilder: PropertyDescriptor.() -> Unit = {},
getter: suspend () -> Any getter: suspend () -> Any
): ReadOnlyProperty<D, SimpleReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate( ): ReadOnlyProperty<D, IsolatedReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate(
this, this,
default?.let { MetaItem.ValueItem(it) }, default?.let { MetaItem.ValueItem(it) },
PropertyDescriptor.invoke(descriptorBuilder), PropertyDescriptor.invoke(descriptorBuilder),
@ -109,7 +112,7 @@ fun <D : DeviceBase> D.readingNumber(
default: Number? = null, default: Number? = null,
descriptorBuilder: PropertyDescriptor.() -> Unit = {}, descriptorBuilder: PropertyDescriptor.() -> Unit = {},
getter: suspend () -> Number getter: suspend () -> Number
): ReadOnlyProperty<D, SimpleReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate( ): ReadOnlyProperty<D, IsolatedReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate(
this, this,
default?.let { MetaItem.ValueItem(it.asValue()) }, default?.let { MetaItem.ValueItem(it.asValue()) },
PropertyDescriptor.invoke(descriptorBuilder), PropertyDescriptor.invoke(descriptorBuilder),
@ -123,7 +126,7 @@ fun <D : DeviceBase> D.readingMeta(
default: Meta? = null, default: Meta? = null,
descriptorBuilder: PropertyDescriptor.() -> Unit = {}, descriptorBuilder: PropertyDescriptor.() -> Unit = {},
getter: suspend MetaBuilder.() -> Unit getter: suspend MetaBuilder.() -> Unit
): ReadOnlyProperty<D, SimpleReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate( ): ReadOnlyProperty<D, IsolatedReadOnlyDeviceProperty> = ReadOnlyDevicePropertyDelegate(
this, this,
default?.let { MetaItem.NodeItem(it) }, default?.let { MetaItem.NodeItem(it) },
PropertyDescriptor.invoke(descriptorBuilder), PropertyDescriptor.invoke(descriptorBuilder),
@ -133,7 +136,7 @@ fun <D : DeviceBase> D.readingMeta(
) )
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
class SimpleDeviceProperty( class IsolatedDeviceProperty(
name: String, name: String,
default: MetaItem<*>?, default: MetaItem<*>?,
descriptor: PropertyDescriptor, descriptor: PropertyDescriptor,
@ -141,7 +144,7 @@ class SimpleDeviceProperty(
updateCallback: (name: String, item: MetaItem<*>?) -> Unit, updateCallback: (name: String, item: MetaItem<*>?) -> Unit,
getter: suspend (MetaItem<*>?) -> MetaItem<*>, getter: suspend (MetaItem<*>?) -> MetaItem<*>,
private val setter: suspend (oldValue: MetaItem<*>?, newValue: MetaItem<*>) -> MetaItem<*>? private val setter: suspend (oldValue: MetaItem<*>?, newValue: MetaItem<*>) -> MetaItem<*>?
) : SimpleReadOnlyDeviceProperty(name, default, descriptor, scope, updateCallback, getter), DeviceProperty { ) : IsolatedReadOnlyDeviceProperty(name, default, descriptor, scope, updateCallback, getter), DeviceProperty {
override var value: MetaItem<*>? override var value: MetaItem<*>?
get() = super.value get() = super.value
@ -179,13 +182,13 @@ private class DevicePropertyDelegate<D : DeviceBase>(
val descriptor: PropertyDescriptor = PropertyDescriptor.empty(), val descriptor: PropertyDescriptor = PropertyDescriptor.empty(),
private val getter: suspend (MetaItem<*>?) -> MetaItem<*>, private val getter: suspend (MetaItem<*>?) -> MetaItem<*>,
private val setter: suspend (oldValue: MetaItem<*>?, newValue: MetaItem<*>) -> MetaItem<*>? private val setter: suspend (oldValue: MetaItem<*>?, newValue: MetaItem<*>) -> MetaItem<*>?
) : ReadOnlyProperty<D, SimpleDeviceProperty> { ) : ReadOnlyProperty<D, IsolatedDeviceProperty> {
override fun getValue(thisRef: D, property: KProperty<*>): SimpleDeviceProperty { override fun getValue(thisRef: D, property: KProperty<*>): IsolatedDeviceProperty {
val name = property.name val name = property.name
return owner.resolveProperty(name) { return owner.resolveProperty(name) {
@OptIn(ExperimentalCoroutinesApi::class) @OptIn(ExperimentalCoroutinesApi::class)
SimpleDeviceProperty( IsolatedDeviceProperty(
name, name,
default, default,
descriptor, descriptor,
@ -194,7 +197,7 @@ private class DevicePropertyDelegate<D : DeviceBase>(
getter, getter,
setter setter
) )
} as SimpleDeviceProperty } as IsolatedDeviceProperty
} }
} }
@ -203,7 +206,7 @@ fun <D : DeviceBase> D.writing(
descriptorBuilder: PropertyDescriptor.() -> Unit = {}, descriptorBuilder: PropertyDescriptor.() -> Unit = {},
getter: suspend (MetaItem<*>?) -> MetaItem<*>, getter: suspend (MetaItem<*>?) -> MetaItem<*>,
setter: suspend (oldValue: MetaItem<*>?, newValue: MetaItem<*>) -> MetaItem<*>? setter: suspend (oldValue: MetaItem<*>?, newValue: MetaItem<*>) -> MetaItem<*>?
): ReadOnlyProperty<D, SimpleDeviceProperty> = DevicePropertyDelegate( ): ReadOnlyProperty<D, IsolatedDeviceProperty> = DevicePropertyDelegate(
this, this,
default, default,
PropertyDescriptor.invoke(descriptorBuilder), PropertyDescriptor.invoke(descriptorBuilder),
@ -214,7 +217,7 @@ fun <D : DeviceBase> D.writing(
fun <D : DeviceBase> D.writingVirtual( fun <D : DeviceBase> D.writingVirtual(
default: MetaItem<*>, default: MetaItem<*>,
descriptorBuilder: PropertyDescriptor.() -> Unit = {} descriptorBuilder: PropertyDescriptor.() -> Unit = {}
): ReadOnlyProperty<D, SimpleDeviceProperty> = writing( ): ReadOnlyProperty<D, IsolatedDeviceProperty> = writing(
default, default,
descriptorBuilder, descriptorBuilder,
getter = { it ?: default }, getter = { it ?: default },
@ -224,7 +227,7 @@ fun <D : DeviceBase> D.writingVirtual(
fun <D : DeviceBase> D.writingVirtual( fun <D : DeviceBase> D.writingVirtual(
default: Value, default: Value,
descriptorBuilder: PropertyDescriptor.() -> Unit = {} descriptorBuilder: PropertyDescriptor.() -> Unit = {}
): ReadOnlyProperty<D, SimpleDeviceProperty> = writing( ): ReadOnlyProperty<D, IsolatedDeviceProperty> = writing(
MetaItem.ValueItem(default), MetaItem.ValueItem(default),
descriptorBuilder, descriptorBuilder,
getter = { it ?: MetaItem.ValueItem(default) }, getter = { it ?: MetaItem.ValueItem(default) },
@ -235,7 +238,7 @@ fun <D : DeviceBase> D.writingDouble(
descriptorBuilder: PropertyDescriptor.() -> Unit = {}, descriptorBuilder: PropertyDescriptor.() -> Unit = {},
getter: suspend (Double) -> Double, getter: suspend (Double) -> Double,
setter: suspend (oldValue: Double?, newValue: Double) -> Double? setter: suspend (oldValue: Double?, newValue: Double) -> Double?
): ReadOnlyProperty<D, SimpleDeviceProperty> { ): ReadOnlyProperty<D, IsolatedDeviceProperty> {
val innerGetter: suspend (MetaItem<*>?) -> MetaItem<*> = { val innerGetter: suspend (MetaItem<*>?) -> MetaItem<*> = {
MetaItem.ValueItem(getter(it.double ?: Double.NaN).asValue()) MetaItem.ValueItem(getter(it.double ?: Double.NaN).asValue())
} }

View File

@ -22,7 +22,9 @@ dependencies{
} }
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach { tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "11" kotlinOptions {
jvmTarget = "11"
}
} }
javafx{ javafx{

View File

@ -22,7 +22,7 @@ class DemoDevice(parentScope: CoroutineScope = GlobalScope) : DeviceBase() {
parentScope.coroutineContext + executor.asCoroutineDispatcher() parentScope.coroutineContext + executor.asCoroutineDispatcher()
) )
val timeScale: SimpleDeviceProperty by writingVirtual(5000.0.asValue()) val timeScale: IsolatedDeviceProperty by writingVirtual(5000.0.asValue())
var timeScaleValue by timeScale.double() var timeScaleValue by timeScale.double()
val resetScale: Action by action { val resetScale: Action by action {