Topic
  • 5 replies
  • Latest Post - ‏2013-05-13T09:10:19Z by burziofra
jester76
jester76
68 Posts

Pinned topic layout column using skip list?

‏2012-09-25T22:00:49Z |
Hello,

Is there a way to create layout column using skiplist(s) / variables. I know layout only accepts attribute or dxl. But is there a backdoor way of creating one using other data/variables.

I tried using include etc but no luck.

If I write data to files and read it back the performance goes into trucnhes. I have a module with 33000 objects in it which I am trying to do a baseline comparison on in readonly mode.

Any thoughts?
Regards
Jester
Updated on 2012-09-27T11:02:47Z at 2012-09-27T11:02:47Z by Mathias Mamsch
  • Peter_Albert
    Peter_Albert
    250 Posts

    Re: layout column using skip list?

    ‏2012-09-26T07:32:47Z  
    See https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14786169&#14786169 for an include file to be used in layout DXL which allows you to compare attribute values between baselines.

    Regards,

    Peter
  • Mathias Mamsch
    Mathias Mamsch
    1983 Posts

    Re: layout column using skip list?

    ‏2012-09-26T20:26:48Z  

    What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
     

    // this function returns the special DXL layout code for fetching the 
    // memory address for the cache from sFileName and then get the text to display 
    // from the in memory skip list.
    string colCode (string sFileName) {
       // escape the filename, since we need to put it to DXL code 
       Buffer bufFile = create() 
       int i; for (i = 0; i < length sFileName; i++) {
          if (sFileName[i] == '\\') bufFile += "\\"
          bufFile += sFileName[i]
       }
     
       string sResult = " 
    noError() 
    // read the memory address from the file 
    Stream x = read \"" (stringOf bufFile) "\"
    lastError() 
     
    // if the file exists we will get a Stream here
    if (!null x) {
       // read the memory address
       int adSkip = 0 
       x >> adSkip 
       if (adSkip != 0) {
          // get the Skip cache 
          Skip sk = addr_ adSkip 
     
          // look up the object in the skip, fetch the text and display it
          int nr = obj.\"Absolute Number\" 
          string sDisplayVal = \"\"
          if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
       } else {
          // now what? 
       }
     
    } else {
      // You might want to show some dummy text here, that the cache does not exist
    }
    "
        delete bufFile 
        return sResult
    }
     
    // This is our cache. Key = AbsNo  Value = string to display
    Skip skBuffer = create() 
     
    // This is the file where we store the cache address 
    string sCacheFileName = tempFileName () 
     
    // write the memory address of the skip to the temp file 
    Stream x = write sCacheFileName
    x << ((addr_ skBuffer) int) ""
    close x
     
     
    // calculate our stuff, put it to the skip list ... 
    // key = absNo   value = string to display 
     
    Object o; for o in current Module do {
        int nr = o."Absolute Number" 
        // put your heavily calculated stuff here ... 
        put (skBuffer, nr, "This is object " nr "!!")
    }
     
    // Now lets insert a DXL Layout Column 
    Column c = insert column 0 // insert column 
    // Give it the code. You might want to give it a title maybe
    dxl (c, colCode(sCacheFileName) ) 
     
     
    // This is the GUI we are using to host the data cache 
    // As long as it is alive our cache will be valid 
    // Show a progressbar for long calculations, will you? 
    DB gui = centered "Calculating ... " 
     
    // When the user closes the GUI our cache will die. 
    // now we will delete the tempFile, so the layout DXL will not try to access the 
    // memory addresses anymore.
    void onClose (DB x) {
        deleteFile sCacheFileName
        hide x 
        // delete the column, or let it show its dummy text 
        delete c
    }
     
    // close callback works very reliably. 
    close (gui, false, onClose) 
     
    // show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout 
    // column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
    // tool to display cached DXL Layouts.
     
    show gui
    

     


    Have fun with this, regards, Mathias

     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    Updated on 2014-01-09T10:58:18Z at 2014-01-09T10:58:18Z by iron-man
  • Mathias Mamsch
    Mathias Mamsch
    1983 Posts

    Re: layout column using skip list?

    ‏2012-09-27T11:02:47Z  

    What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">// this function returns the special DXL layout code for fetching the // memory address for the cache from sFileName and then get the text to display // from the in memory skip list. string colCode (string sFileName) { // escape the filename, since we need to put it to DXL code Buffer bufFile = create() int i; for (i = 0; i < length sFileName; i++) { if (sFileName[i] == '\\') bufFile += "\\" bufFile += sFileName[i] } string sResult = " noError() // read the memory address from the file Stream x = read \"" (stringOf bufFile) "\" lastError() // if the file exists we will get a Stream here if (!null x) { // read the memory address int adSkip = 0 x >> adSkip if (adSkip != 0) { // get the Skip cache Skip sk = addr_ adSkip // look up the object in the skip, fetch the text and display it int nr = obj.\"Absolute Number\" string sDisplayVal = \"\" if (find (sk, nr, sDisplayVal)) { display sDisplayVal } } else { // now what? } } else { // You might want to show some dummy text here, that the cache does not exist } " delete bufFile return sResult } // This is our cache. Key = AbsNo Value = string to display Skip skBuffer = create() // This is the file where we store the cache address string sCacheFileName = tempFileName () // write the memory address of the skip to the temp file Stream x = write sCacheFileName x << ((addr_ skBuffer) int) "" close x // calculate our stuff, put it to the skip list ... // key = absNo value = string to display Object o; for o in current Module do { int nr = o."Absolute Number" // put your heavily calculated stuff here ... put (skBuffer, nr, "This is object " nr "!!") } // Now lets insert a DXL Layout Column Column c = insert column 0 // insert column // Give it the code. You might want to give it a title maybe dxl (c, colCode(sCacheFileName) ) // This is the GUI we are using to host the data cache // As long as it is alive our cache will be valid // Show a progressbar for long calculations, will you? DB gui = centered "Calculating ... " // When the user closes the GUI our cache will die. // now we will delete the tempFile, so the layout DXL will not try to access the // memory addresses anymore. void onClose (DB x) { deleteFile sCacheFileName hide x // delete the column, or let it show its dummy text delete c } // close callback works very reliably. close (gui, false, onClose) // show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout // column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager // tool to display cached DXL Layouts. show gui </pre>

     


    Have fun with this, regards, Mathias

     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    I forgot to mention something. Do not try to modify the Skip list from the layout DXL or any other DXL context, except the GUI context. DXL will free resources, so if you put a string to the skip from the DXL layout, then after the calculation of the layout the string will immediately be freed and crashes will occur, if you do not make sure that string goes to the string table.

    The other thing that I should have mentioned is, you can change the values in the skip list from the GUI. You could for example have a radio box to switch the column between a different display of informtion, or a refresh button, that recalculates the DXL layout. You can calculate the results from a timer to have background calculation, instead of calculating them all at once, blocking DOORS. This makes up for a very nice user experience.

    Regards, Mathias


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
  • burziofra
    burziofra
    2 Posts

    Re: layout column using skip list?

    ‏2013-05-13T07:58:40Z  

    What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">// this function returns the special DXL layout code for fetching the // memory address for the cache from sFileName and then get the text to display // from the in memory skip list. string colCode (string sFileName) { // escape the filename, since we need to put it to DXL code Buffer bufFile = create() int i; for (i = 0; i < length sFileName; i++) { if (sFileName[i] == '\\') bufFile += "\\" bufFile += sFileName[i] } string sResult = " noError() // read the memory address from the file Stream x = read \"" (stringOf bufFile) "\" lastError() // if the file exists we will get a Stream here if (!null x) { // read the memory address int adSkip = 0 x >> adSkip if (adSkip != 0) { // get the Skip cache Skip sk = addr_ adSkip // look up the object in the skip, fetch the text and display it int nr = obj.\"Absolute Number\" string sDisplayVal = \"\" if (find (sk, nr, sDisplayVal)) { display sDisplayVal } } else { // now what? } } else { // You might want to show some dummy text here, that the cache does not exist } " delete bufFile return sResult } // This is our cache. Key = AbsNo Value = string to display Skip skBuffer = create() // This is the file where we store the cache address string sCacheFileName = tempFileName () // write the memory address of the skip to the temp file Stream x = write sCacheFileName x << ((addr_ skBuffer) int) "" close x // calculate our stuff, put it to the skip list ... // key = absNo value = string to display Object o; for o in current Module do { int nr = o."Absolute Number" // put your heavily calculated stuff here ... put (skBuffer, nr, "This is object " nr "!!") } // Now lets insert a DXL Layout Column Column c = insert column 0 // insert column // Give it the code. You might want to give it a title maybe dxl (c, colCode(sCacheFileName) ) // This is the GUI we are using to host the data cache // As long as it is alive our cache will be valid // Show a progressbar for long calculations, will you? DB gui = centered "Calculating ... " // When the user closes the GUI our cache will die. // now we will delete the tempFile, so the layout DXL will not try to access the // memory addresses anymore. void onClose (DB x) { deleteFile sCacheFileName hide x // delete the column, or let it show its dummy text delete c } // close callback works very reliably. close (gui, false, onClose) // show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout // column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager // tool to display cached DXL Layouts. show gui </pre>

     


    Have fun with this, regards, Mathias

     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    Mathias,

    I've tried your example but I wasn't able to make it run, I am quite new about DXL, so I beg your pardon...

    The main problem seems to be the passing of information between the sResult and the "normal" code, no way to see the bufFile variable inside the string code. Are there some "special" way to write the code that will be interpreted as text string (those inside the sResult?). I mean, we have to take into account any CR/LF or is it enough to put the \" escape char before any " character?

    I simplified as much as possible the code, the essential thing is the possibility to pass information to each view's object (the Skip List addr_ ).

    This is my snippet version:

    string colCode1 (string sFileName)
    {
     Buffer bufFile = create()
     
     bufFile = sFileName ""
     ack "prova di stop \n"  bufFile "\n"
     
     string sResult = "display bufFile \"\" "
     
     return sResult

     The call is done as:

    dxl (c, colCode1(sCacheFileName) )

    The result is:

    -E- DXL: <Line:1> incorrectly concatenated tokens

    -E- DXL: <Line:1> incorrect arguments for function (display)

    -E- DXL: <Line:1> undeclared variable (bufFile)

    -I- DXL: all done with 3 errors and 0 warnings

    -I- DXL: execution halted

     

    Any help will be appreciate!

       Thank you,

      Franco Burzio

    Updated on 2013-05-13T08:05:41Z at 2013-05-13T08:05:41Z by burziofra
  • burziofra
    burziofra
    2 Posts

    Re: layout column using skip list?

    ‏2013-05-13T09:10:19Z  

    What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">// this function returns the special DXL layout code for fetching the // memory address for the cache from sFileName and then get the text to display // from the in memory skip list. string colCode (string sFileName) { // escape the filename, since we need to put it to DXL code Buffer bufFile = create() int i; for (i = 0; i < length sFileName; i++) { if (sFileName[i] == '\\') bufFile += "\\" bufFile += sFileName[i] } string sResult = " noError() // read the memory address from the file Stream x = read \"" (stringOf bufFile) "\" lastError() // if the file exists we will get a Stream here if (!null x) { // read the memory address int adSkip = 0 x >> adSkip if (adSkip != 0) { // get the Skip cache Skip sk = addr_ adSkip // look up the object in the skip, fetch the text and display it int nr = obj.\"Absolute Number\" string sDisplayVal = \"\" if (find (sk, nr, sDisplayVal)) { display sDisplayVal } } else { // now what? } } else { // You might want to show some dummy text here, that the cache does not exist } " delete bufFile return sResult } // This is our cache. Key = AbsNo Value = string to display Skip skBuffer = create() // This is the file where we store the cache address string sCacheFileName = tempFileName () // write the memory address of the skip to the temp file Stream x = write sCacheFileName x << ((addr_ skBuffer) int) "" close x // calculate our stuff, put it to the skip list ... // key = absNo value = string to display Object o; for o in current Module do { int nr = o."Absolute Number" // put your heavily calculated stuff here ... put (skBuffer, nr, "This is object " nr "!!") } // Now lets insert a DXL Layout Column Column c = insert column 0 // insert column // Give it the code. You might want to give it a title maybe dxl (c, colCode(sCacheFileName) ) // This is the GUI we are using to host the data cache // As long as it is alive our cache will be valid // Show a progressbar for long calculations, will you? DB gui = centered "Calculating ... " // When the user closes the GUI our cache will die. // now we will delete the tempFile, so the layout DXL will not try to access the // memory addresses anymore. void onClose (DB x) { deleteFile sCacheFileName hide x // delete the column, or let it show its dummy text delete c } // close callback works very reliably. close (gui, false, onClose) // show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout // column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager // tool to display cached DXL Layouts. show gui </pre>

     


    Have fun with this, regards, Mathias

     

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

     

    Mathias,

    I am quite new to DXL (so I beg your pardon...) and I wasn't able to make it run.

    I've tried to reduce to the following the solution to reduce any possible "noise"

    string colCode1 (string sFileName)
    {
        Buffer bufFile = create()
     int i;
     bufFile = sFileName ""
        ack "prova di stop \n"  bufFile "\n"
     
     string sResult = "display bufFile \"\" "
     
     return sResult

    }

    dxl (c, colCode1(sCacheFileName) )

     

    The main problem is the fact that bufFile is not recognised as a variable, so there is no way to pass info from the external to the code that will be send to the viwew's column via DXL(set) command. So if it isn't possible to pass the sCacheFileName the solution is not useful at all.

    This is what i've obtained:

    -E- DXL: <Line:1> incorrectly concatenated tokens

    -E- DXL: <Line:1> incorrect arguments for function (display)

    -E- DXL: <Line:1> undeclared variable (bufFile)

    -I- DXL: all done with 3 errors and 0 warnings

    -I- DXL: execution halted

     

     

    Any help will be appreciate!!

     Franco Burzio