INNER CODE UNIT · Kotlin

pollingExecutor

vogler75/automation-gateway · source/lib-plc4x/src/main/kotlin/Plc4xDriver.kt:57

    private fun pollingExecutor(id: Long) {
        if (isConnected() && pollingTopics.isNotEmpty()) {
            if (pollingRequestId > pollingResponseId) {
                logger.warning("Polling request id [${pollingRequestId}] is still pending (response id [${pollingResponseId})].")
            }
            val localRequestId = ++pollingRequestId
            val builder: PlcReadRequest.Builder = plc!!.readRequestBuilder()
            pollingTopics.forEach {
                builder.addTagAddress(it.key.topicName, it.key.topicNode)
            }
            logger.finest { "Poll request [${localRequestId}] for [${pollingTopics.size}] items..." }
            try {
                val request = builder.build()
                val response = request.execute()
                response.orTimeout(pollingTimeout, TimeUnit.MILLISECONDS)
                response.whenComplete { readResponse, throwable ->
                    ++pollingResponseId
                    if (readResponse != null) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…