From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Actor Framework Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

Actor Framework Sequence Diagram Parser

Hello everyone,

For the purpose of preparing some materials about AF I found myself preparing sequence diagrams multiple times. Since this was a tedious task I decided to use some tools and make it easier. In the process I wrote a small Python script that is parsing DETT traces created by AF_Debug_Trace=TRUE in the project.

The python script parsed out the information about AF events and prepared syntaxt needed for PlantUML tools available online. The translated UML was saved to file and copied to clipboard. Then you can paste it to the online tool and you get nice looking and easy to read diagrams of the sequence of Actors' activities.

Steps to generate the diagram:

1. Install Python3

2. Install the packages required for the script to work: easygui, pyperclip

     Installing the packages can be done with cmd command "pip install easygui" and "pip install pyperclip"

     easygui is used to ask the user for paths to txt files

     Pyperclip is used to copy the final string into clipboard

3. Enable AF_Debug_Trace in your AF project

4. Generate trace from your project

5. Save the trace in TXT file

6. Run the parser script in windows cmd line "python C:\YourPathHere\AFParser.py"

7. If everything went well your web browser should open and go to page http://www.planttext.com/planttext

8. Once you're there you can Ctrl + V the text from clipboard, click Refresh and you get your diagram.

I know that this is an annoying list of steps but once you go through them you will find them to be quick. If you want to make them even faster you can create a BAT file that would just run the CMD line from step 6. I include a file like this in the attachments. Notice that it uses an absolute path so you need to modify it to point to your script.

Example Diagram generated this way:

Example.pngActorDiagram.pngProxyDiagram.png

You can also preview a movie visualizing how you go though the steps.

Attached you can find the python script.

NOTE. If you find thet the "message sent" events are not captured by your DETT you need to remove and add again the conditional disable structure in the Message Enqueuer.vi. There seems to be something wrong with that structure, but once you replace it with something exactly the same, it works fine again.

I hope this is useful for someone.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Download All
Comments
T.L.
Member
Member
on

Hi Piotr,

this is exactly what i want to have.

But its a feature of afw provided with LV2015 and i'm tied to LV2014.Is it possibe, to downconvert LV2015's afw to LV2014?

Best regards

Thomas

Oli_Wachno
Active Participant Active Participant
Active Participant
on

I think the AF_Debug_Trace is not available with versions <2015

https://decibel.ni.com/content/docs/DOC-44158

PrimaryKey
NI Employee (retired)
on

Well the only thing you need to do is to install on some other machine LV2015, convert the AF libraries to previous version (i think everything should be compatible) and you have it.

Alternatively you can just add the functionality to send the user defined trace events yourself to the AF VIs.

Alternatively you can add your own events, take my parser and modify it to parse your events, and model that

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
justACS
Active Participant Active Participant
Active Participant
on

I did the original development in LV 2014, and I may still have a copy around.  I'll look for it.

mike_nrao
Member
Member
on

Very awesome tool! Thanks.

But, please rename this from 'Activity Diagram' to 'Sequence Diagram'.

cirrusio
Active Participant
Active Participant
on

LV and Python working in symbiotic love...wonderful!  Thanks for the work, Piotr.  Can't wait to give it a try!

Allen, are you referring to the AF debug trace tool?  I would be interested in this too.

AristosQueue (NI)
NI Employee (retired)
on

I agree with Michael. "Sequence diagram" is the common name for this sort of diagram. More people will find this if you name it accordingly.

And, thanks. This is the sort of diagram I hoped someone would generate when niACS made the debug traces available.

Elijah_K
Active Participant
Active Participant
on

This looks seriously awesome. Can't wait to try it out.

Elijah Kerry
NI Director, Software Community
drjdpowell
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Is it not possible to show the Actor class names?   It is difficult to tell the difference between the various "Actor 6640xx".

PrimaryKey
NI Employee (retired)
on

You just have to provide the name as the Debug Alias when you launch the actor. That will be used in the diagram.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
AristosQueue (NI)
NI Employee (retired)
on

Powell: I think that shortfall might be on NI... I think we just use "Actor N" in all cases unless you give the actor a debug name. But many systems have actors that are unique per type... I can see where using the class name would've been a good idea.

PrimaryKey
NI Employee (retired)
on

Hey all, can you please tell me what kind of improvements would you like to see with this tool? I was thinking of building a pure LV version that could be integrated as a tool in to the menus. It wouldn't require internet connection and any python parsing. This however would require me to build a custom toolkit or two. Can you please let me know if you are interested in something like this? I dont want to waste time

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
justACS
Active Participant Active Participant
Active Participant
on

I'm interested.  I'd love to see the output integrated with the GOOP UML Toolkit, if you can translate the DETT output into a sequence diagram file.

justACS
Active Participant Active Participant
Active Participant
on

AristosQueue wrote:


                       

I can see where using the class name would've been a good idea.


                   

But possibly impractical.  The traces are pretty long as it is.  Since you'd still want the unique ID to handle instances where you have two of the same type, the total actor name <actor type>:<unique ID> could get pretty atrocious.

PrimaryKey
NI Employee (retired)
on

For now I have refined the parser a little bit. It is now removing the word Actor from the names, so be careful about that. Ive done it because i didnt like the prefix actor in front of everything in the diagram It's also parsing the types of messages a little better. The message no longer has to be a part of library to be parsed out. The new version is 1.1

How can this have 500+ downloads ?! I didn't know we had 500 customers using actors in LV

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
drjdpowell
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

niACS wrote:


Since you'd still want the unique ID to handle instances where you have two of the same type, the total actor name <actor type>:<unique ID> could get pretty atrocious.


                   

Subtract 6640000 from the Actor.vi clone number and you'll only need a couple of digits for the number, saving more characters for the name.

justACS
Active Participant Active Participant
Active Participant
on

drjdpowell wrote:


                       

Subtract 6640000 from the Actor.vi clone number and you'll only need a couple of digits for the number, saving more characters for the name.


                   

Fair point.  I'd need to confirm that we always got the same range of clone numbers, and I'd probably want to keep four digits, just because I hate dink think.

drjdpowell
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

Keep all the digits, just surpress the leading zeros.  I don't think the 6640000 number changes (it's some kind of hash of "Actor"), but one can determine it dynamically from the first clone.

C.Jacky@prones.de
Member
Member
on

Hi Piotr,

 

thank you for this helpful tool.

I just used it to debug/"re-engineer" my first AF-Project. Smiley Happy

I edited the script to handle time-delayed messages and added an additional case:

                elif 'created Time-Delayed Message' in msg:
                    creator, what, typeof = dsplit(msg, ' created ', ' for ')
                    if '.lvlib:' in typeof:
                        not_used, typeof, not_used = dsplit(typeof, '.lvlib:', '.lvclass')
                    else:
                        typeofarr = typeof.split('.lvclass')
                        typeof = typeofarr[0]  
                    text = 'create %s\n' % (leg(what))
                    text += '%s->%s:%s\n' % (leg(creator), leg(what), leg(typeof))

To automise the image creation I replaced planttext with plantUML and used hardcoded paths to avoid the filebrowser.

I'd like to use it in LabVIEW directly.

Let me know if the pure-LV solution is ready for testing Smiley Happy

kosist90
Active Participant
Active Participant
on

Great tool, Piotr!

  

Is it possible to add feature, that dialog window for paths selection will start not from the default location, but from the last used one? Just to store to some config file used path, and then set it next time as start path for trace file selection, and for storing of uml diagram text?

Also, are you going to implement it in pure LabVIEW, as some LabVIEW add-on toolkit? I guess it'll be very useful.

 

Thanks a lot,

 

Sincrerely, kosist90.

PrimaryKey
NI Employee (retired)
on

I dont think i will tinker anymore with this python implementation but I am very interested in writing a pure LV version of this tool. I'm still not sure how i would do it but i will keep you posted.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
kosist90
Active Participant
Active Participant
on

Actually, regarding my last post - the easiest way for me was to modify script, and add to functions fileopenbox, filesavebox default path; so even config file is needed...

Klopot
Member
Member
on

Hi Piotr,

 

Have you had chance to develop this tool completely at LV?
Is this tool working also with non-actor codes?

 

Regards,
Witold

Morefun
Member
Member
on

Hello,I follow your document.

But I got this , can you tell me why

C:\Users\10156>python "C:\Users\10156\Documents\DETT\AFParser.py" Traceback (most recent call last): File "C:\Users\10156\Documents\DETT\AFParser.py", line 37, in for line in af: UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 938: illegal multibyte sequence

Contributors