-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.kt
40 lines (33 loc) · 996 Bytes
/
Main.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
* This file is subject to the terms and conditions defined in file 'LICENSE', which is part of this source code package
*
* Author: Felipe González Alarcón
* Email: felipe.gonzalezalarcon94@gmail.com
*
* Project: TruckSim-Telemetry-Kotlin
* Module: TruckSim-Telemetry-Kotlin.main
* Last modified: 09-02-23 01:03
*/
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import scs_sdk.ScsTelemetry
suspend fun main(args: Array<String>) {
coroutineScope {
val telemetry = ScsTelemetry()
launch {
telemetry.watch(delayTime = 2000L)
}
launch {
//Collect only one value
telemetry.telemetryFlow.first {
println("Telemetry data: $it")
true
}
//Collect infinite values
telemetry.telemetryFlow.collect {
println("Telemetry data: $it")
}
}
}
}