OpenKNX / Kaenx-Creator

Create your own KnxProd Files with UI.
MIT License
70 stars 20 forks source link

Addon check para for choose #46

Closed olterion closed 1 month ago

olterion commented 1 month ago

Add check for ParameterRefRef with same RefId as choose block in dynamic section.

thewhobox commented 1 month ago

What if the ParameterRefRef is in an other ParameterBlock?

olterion commented 1 month ago

Yes you are absolutely right. Now I have added a search for ParameterRef also in ParameterBlocks above the choose object.

thewhobox commented 1 month ago

Why so complicated? A recursive method which checks if it is a parameterref and the searching id or if not check all child items

In Pseudo-Code:

if(!IsSearchedParaRefRef(vbase.Dynamic[0], dco.ParameterRefObject)
    actions.Add([...]);

bool IsSearchedParaRefRef(DynItem item, ParameterRef paraRef) {
    if(item is DynParameter dynPara) {
        if(dynPara.ParameterRefObject == paraRef) return true;
    }

    if(dynPara.Items != null) {
        foreach(DynItem child in dynPara.Items) {
            if(IsSearchedParaRefRef(child, paraRef)) return true;
        }
    }
    return false;
}
olterion commented 1 month ago

Yes its complicated.

With your solution it is not necessary where the ParameterRef Id is written in dynamic section. But here is a example which shows, that only one same RefId as choose RefId is not sufficient.

`

`

Block 1: image

Block 2: image

With your solution, the ParamRefId of both choose is found in Block 1 and no error will be shown.

The correct solution has be recognize, that the ParameterRef in the Block of the choose is missing. mit_und_ohne_choose_parameter.zip

thewhobox commented 1 month ago

Did you import your knxprod and tested it?

The ETS doesnt care in which ParameterBlock the ParameterRef and in which the choose is. They can also be in different Channels. As long there is an ParameterRef or an Assign. I get listet both ComObjects as i would expect the ETS do it. image

olterion commented 1 month ago

Yes, I think we can refuse this pull request. I had a big mistake in my mind to understand how the "choose" is displayed in the ETS. Only the parameters are displayed and never the choose. The choose is only in XML to get into the branches if there is a change at the parameter value. In some original knxprod there are many choose without appropriate parameter. In that case we have many errors in the check helper.

thewhobox commented 1 month ago

You can activate an parameterRef in many ways. The simplest is with an parameterRefRef. But you can also use an assign.

I will close this. If you have any other questitons for chooses feel free to open it again or just comment.