Skip to content

CAT Blocks Support For FBME#10

Open
valentinnodan wants to merge 27 commits intoJetBrains:masterfrom
valentinnodan:dev-cat-templ
Open

CAT Blocks Support For FBME#10
valentinnodan wants to merge 27 commits intoJetBrains:masterfrom
valentinnodan:dev-cat-templ

Conversation

@valentinnodan
Copy link
Collaborator

No description provided.

@valentinnodan valentinnodan changed the base branch from dev-cat-templ to master May 24, 2023 10:52
@qradimir qradimir self-requested a review May 25, 2023 01:41
}

override fun getFBValue(d: String) {
setValue(d.equals("TRUE"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use enum here, with value from line 8-9

Copy link
Collaborator

@qradimir qradimir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Things that we need to consider:

  • Make a cat_visual a gradle subproject of a root gradle project. Currenty it is an independent build
  • Extract samples from cat_visual
  • Extract other functionality that are written in different modules into a separate cat module.
  • Package all functionality into a plugin
  • Write documentation how to run cat instances. Put it on our website (/docs folder)

) : ZoomableBoxScope


abstract interface CustomItem {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a special interface here? It seems to me we can just pass lambda to CanvasContext that will call directly all required composables, instead of wrapping them into CustomItem instances.

fun RadioItem(items: List<String>) {
var color by remember { mutableStateOf(c) }
var selectedValue by remember { mutableStateOf("") }
val isSelectedItem: (String) -> Boolean = { selectedValue == it }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One-liners are not worth of extracting into variable.

}
}

enum class TYPE_ID(val code: Int) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use upper case for type names

import androidx.compose.runtime.mutableStateOf
import java.nio.ByteBuffer

data class SIntField(var defaultValue:Byte, override var content:Byte = 0, override val contentState: MutableState<Byte> = mutableStateOf(defaultValue)): ConnectionField<Byte>(content, contentState) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these classes have lots of common code -- I would suggest extract it in a common superclass.


var ind = 0

override fun response(fieldGetter: (ByteArray) -> Pair<Pair<ConnectionField<out Any>, ByteArray>, String>, ping:Long, callbacks: Map<String, () -> Unit>) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we need to think of utilising kotlin coroutines instead of spawning new threads each time.

import androidx.compose.ui.zIndex

@Composable
fun PositionedBox(children: @Composable () -> Unit, x: Int = 0, y:Int = 0, zIndex: Float = 1f) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If children will be last parameter here, it will allow to use trailing lambda syntax in usages and produce nicer code.

val TANK_VOLUME = 100
val MAX_TEMP = 100

var isInlet: FieldWithCallback<Boolean> = FieldWithCallback(client.getField("stateInlet") as ConnectionField<Boolean>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider to design code in the way that here will be no casts required

if (adapter == null) {
elements.remove(node)
}
return requiredClass.cast(adapter)!!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to merge with master - this code has been changed some time ago.

@@ -0,0 +1,5 @@
package org.fbme.lib.iec61499.declarations

interface SymbolDefinition {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No usages at the moment.

) {
fun convertFBType(): FBTypeDeclaration {
val root = myDocument.rootElement
if (root.getAttribute("UsedInCAT") != null && root.getAttribute("UsedInCAT").value == "True") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular difference between HMIInterfaceTypeDeclaration and ServiceInterfaceFBTypeDeclaration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants