Topic
  • 8 replies
  • Latest Post - ‏2019-04-24T14:08:18Z by MerlinUK
Markus01
Markus01
49 Posts

Pinned topic Proxy Port, and Flow Direction in Table View

‏2019-04-15T20:30:29Z | api java rhapsody table

Dear all,

I'm using RHY 8.3.1 iFix3.

Im trying to visualize the direction of flow properties in a table view, but have not really a good result.

In my example I'm using two blocks having each one a  proxy port. The proxy ports are typed by an equal interface block, and one proxy port is reversed (conjugated). The interface block contains flow properties with the direction "in" . As one proxy port is reversed i'ld like to visualize the flow direction for each block together with the flow inside a table view. Meaning once the flow property has the direction "in" the reversed proxy port should visualize "out" for the other flow property.

I suppose that I have to use the userdefined method for a column inside the table layout, however, I couldn't find a way to get the flow direction.

It would be fantastic if anybody has an idea.

Best regards

Markus 

  • MerlinUK
    MerlinUK
    395 Posts
    ACCEPTED ANSWER

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-24T14:08:18Z  
    • Markus01
    • ‏2019-04-23T07:39:09Z

    Dear Andy,

    thanks for your fantastic answer!

    I played around with your code and as I changed the context from port to flow. The required results came up, without any problem.

    However, I do not understand inside the code, why the column 1 ends up with port, and column 4 with flow. I understand that the column 0 is the block(class), but I would have expected, that column 1 deals with "Is Port Conj" column and column 2 with the port. Or did I think in the wrong direction.

    Best regards

    Markus

    I would guess (havent checked this) but since column 1 is a string - it is skipped by getCellElements 

  • MerlinUK
    MerlinUK
    395 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-16T10:39:54Z  

    Hi Markus

    The direction is stored in a tag

    Small example attached - hope it helps ! 

    Attachments

    Updated on 2019-04-16T10:41:16Z at 2019-04-16T10:41:16Z by MerlinUK
  • Markus01
    Markus01
    49 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-16T11:00:46Z  
    • MerlinUK
    • ‏2019-04-16T10:39:54Z

    Hi Markus

    The direction is stored in a tag

    Small example attached - hope it helps ! 

    Hi Andy,

    unfortunately your zip file has no contents inside/or is corrupted. Could you pleare upload it again?

    My problem is that the conjugated proxy port should switch the flow directions "out" to "in" and "in" to "out". Hence, I do not want to list the direction of the flows directly by the IB but using proxy ports which are typed by InterfaceBlocks. One idea I had was to use the "getIsReversed()" method together witht the tag information and display the results stepwise. However, I haven't got that working properly.

     

    Best regards

    Markus

     

     

  • MerlinUK
    MerlinUK
    395 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-16T11:44:46Z  
    • Markus01
    • ‏2019-04-16T11:00:46Z

    Hi Andy,

    unfortunately your zip file has no contents inside/or is corrupted. Could you pleare upload it again?

    My problem is that the conjugated proxy port should switch the flow directions "out" to "in" and "in" to "out". Hence, I do not want to list the direction of the flows directly by the IB but using proxy ports which are typed by InterfaceBlocks. One idea I had was to use the "getIsReversed()" method together witht the tag information and display the results stepwise. However, I haven't got that working properly.

     

    Best regards

    Markus

     

     

    Hi Markus

    The sample did it by IB - quite a simple example - it just did a getTag("direction") on each of the flow properties. Of course that information is only in the Interface Block so as you say you will have to check if the port is conjugated - then get its type - get the flow properties - and manually change the direction in your code if the port is conjugated

    Cheers

    Andy

  • 9xMe
    9xMe
    13 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-16T15:47:37Z  

    Hi Markus,

     

    I wanted to created a table, with flow property with From to to (out to In); and also have the satisfaction of requirement to the attribute.

    Some thing like this: 

    Req ID: Input: Output;

    Could you guide me out

     

    Regards

    Ram

  • Markus01
    Markus01
    49 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-16T22:26:24Z  
    • MerlinUK
    • ‏2019-04-16T11:44:46Z

    Hi Markus

    The sample did it by IB - quite a simple example - it just did a getTag("direction") on each of the flow properties. Of course that information is only in the Interface Block so as you say you will have to check if the port is conjugated - then get its type - get the flow properties - and manually change the direction in your code if the port is conjugated

    Cheers

    Andy

    Dear Andy,

    thanks for your feedback.

    I tried several things but I got stuck in how to find the relevant flow property (attribute) to modify the direction tag to visualize it inside the table view. I have attached my sample model and a screenshot of the table view. It would be fantatic, if you could give me a hint how I could solve my problem, to update the flow direction.

    Best regards and many thanks in advance

    Markus

    String dir;
    int i;
    
    //Typecast from IRPModelElement to IRPPort
    IRPPort p = (IRPPort) cellElement;
    
    //rtn==1 if reversed port, else ==0
    int rtn=p.getIsReversed();
    
    //Get InterfaceBlock which is typed by the port
    IRPClassifier ib=p.getContract();
    IRPCollection col=ib.getAttributes();
    
    // loop over all attributes of the Interface Block
    for(i=1; i <= col.getCount(); i++)
    {
    // check if the reference is a attribute
    if (col.getItem(i) instanceof IRPAttribute)
    {
    IRPAttribute attr = (IRPAttribute)col.getItem(i);
    
        if (rtn==1) {
            IRPAttribute latt = (IRPAttribute)col.getItem(i); 
            IRPTag t= latt.getTag("direction"); 
            return t.getValue();
         } else {
         return "nothing to change";
         }
    
    }
    }
    return "";
    

     

    Updated on 2019-04-16T22:33:39Z at 2019-04-16T22:33:39Z by Markus01
  • MerlinUK
    MerlinUK
    395 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-17T17:04:07Z  
    • Markus01
    • ‏2019-04-16T22:26:24Z

    Dear Andy,

    thanks for your feedback.

    I tried several things but I got stuck in how to find the relevant flow property (attribute) to modify the direction tag to visualize it inside the table view. I have attached my sample model and a screenshot of the table view. It would be fantatic, if you could give me a hint how I could solve my problem, to update the flow direction.

    Best regards and many thanks in advance

    Markus

    <pre class="html dw" dir="ltr">String dir; int i; //Typecast from IRPModelElement to IRPPort IRPPort p = (IRPPort) cellElement; //rtn==1 if reversed port, else ==0 int rtn=p.getIsReversed(); //Get InterfaceBlock which is typed by the port IRPClassifier ib=p.getContract(); IRPCollection col=ib.getAttributes(); // loop over all attributes of the Interface Block for(i=1; i <= col.getCount(); i++) { // check if the reference is a attribute if (col.getItem(i) instanceof IRPAttribute) { IRPAttribute attr = (IRPAttribute)col.getItem(i); if (rtn==1) { IRPAttribute latt = (IRPAttribute)col.getItem(i); IRPTag t= latt.getTag("direction"); return t.getValue(); } else { return "nothing to change"; } } } return ""; </pre>

     

    Hi Marcus - there are two issues here - firstly your code is iterating over all of the flow properties - so you will only ever get the last one reported 

    The second issue is that in order to report the 'actual ' direction of the attribute for this specific row - you need two pieces of information:

    (a) The attribute (so you can get its original direction)

    (b) The port (so you can check if its inverted

    The native method only gives you the 'cell element' - ie the context from your pattern

    Thankfully there is a way to get the second piece of information but its not at all obvious !

    The method also gives you a row and a column as integers - which initially seem useless since without a reference to the table itself all you have are numbers

    However if you edit your user defined implementation and then click Show Java Source - you will see that there is a handle to the table you can use in your code:

     

     

    By using the view variable, coupled with the row and column variables you can get the data from other columns in that row - so your method to report the actual direction would look like this:

     

    //Column 1 is the Port, Column 4 is the Flow Property
    
    IRPCollection col = view.getCellElements(row, 1);
    Object o = col.getItem(1);
    if (o == null)
    return "NO PORT FOUND";
    IRPPort p = (IRPPort) o;
    
    IRPCollection col2 = view.getCellElements(row, 4);
    Object o2 = col2.getItem(1);
    if (o2 == null)
    return ("NO FLOW PROPERTY FOUND");
    IRPAttribute a = (IRPAttribute)o2;
    
    IRPTag t = a.getTag("direction");
    if (t ==null)
    return "NO TAG FOUND";
            String originalValue = t.getValue();
            if (p.getIsReversed()==0)
                    return originalValue;
            else {
                     if (originalValue.equals("In"))
                    return "Out";
                 else  if (originalValue.equals("Out"))
                    return "In";
                 else 
                    return t.getValue();
            }
    

     

    Sample model attached (Rhapsody 8.3.1) - but I did find a weird defect in the table - each second attribute doesnt get reported - I've sent it to development for investigation

    Hope that helps !

    Andy

     

     

      

     

    Attachments

  • Markus01
    Markus01
    49 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-23T07:39:09Z  
    • MerlinUK
    • ‏2019-04-17T17:04:07Z

    Hi Marcus - there are two issues here - firstly your code is iterating over all of the flow properties - so you will only ever get the last one reported 

    The second issue is that in order to report the 'actual ' direction of the attribute for this specific row - you need two pieces of information:

    (a) The attribute (so you can get its original direction)

    (b) The port (so you can check if its inverted

    The native method only gives you the 'cell element' - ie the context from your pattern

    Thankfully there is a way to get the second piece of information but its not at all obvious !

    The method also gives you a row and a column as integers - which initially seem useless since without a reference to the table itself all you have are numbers

    However if you edit your user defined implementation and then click Show Java Source - you will see that there is a handle to the table you can use in your code:

     

     

    By using the view variable, coupled with the row and column variables you can get the data from other columns in that row - so your method to report the actual direction would look like this:

     

    <pre class="java dw" dir="ltr">//Column 1 is the Port, Column 4 is the Flow Property IRPCollection col = view.getCellElements(row, 1); Object o = col.getItem(1); if (o == null) return "NO PORT FOUND"; IRPPort p = (IRPPort) o; IRPCollection col2 = view.getCellElements(row, 4); Object o2 = col2.getItem(1); if (o2 == null) return ("NO FLOW PROPERTY FOUND"); IRPAttribute a = (IRPAttribute)o2; IRPTag t = a.getTag("direction"); if (t ==null) return "NO TAG FOUND"; String originalValue = t.getValue(); if (p.getIsReversed()==0) return originalValue; else { if (originalValue.equals("In")) return "Out"; else if (originalValue.equals("Out")) return "In"; else return t.getValue(); } </pre>

     

    Sample model attached (Rhapsody 8.3.1) - but I did find a weird defect in the table - each second attribute doesnt get reported - I've sent it to development for investigation

    Hope that helps !

    Andy

     

     

      

     

    Dear Andy,

    thanks for your fantastic answer!

    I played around with your code and as I changed the context from port to flow. The required results came up, without any problem.

    However, I do not understand inside the code, why the column 1 ends up with port, and column 4 with flow. I understand that the column 0 is the block(class), but I would have expected, that column 1 deals with "Is Port Conj" column and column 2 with the port. Or did I think in the wrong direction.

    Best regards

    Markus

  • MerlinUK
    MerlinUK
    395 Posts

    Re: Proxy Port, and Flow Direction in Table View

    ‏2019-04-24T14:08:18Z  
    • Markus01
    • ‏2019-04-23T07:39:09Z

    Dear Andy,

    thanks for your fantastic answer!

    I played around with your code and as I changed the context from port to flow. The required results came up, without any problem.

    However, I do not understand inside the code, why the column 1 ends up with port, and column 4 with flow. I understand that the column 0 is the block(class), but I would have expected, that column 1 deals with "Is Port Conj" column and column 2 with the port. Or did I think in the wrong direction.

    Best regards

    Markus

    I would guess (havent checked this) but since column 1 is a string - it is skipped by getCellElements