VL.WorkflowFoundation

Since there are many questions about a state machine automata in VL and the recent prototype patched in VL, I was looking into which options the C#/.NET world has to offer and found a crazy system that everyone seems to have on their windows pc already. Its’s called Windows Workflow Foundation and is usually used to model enterprise workflows that run on servers and connect to data bases.

Turns out they implemented some kind of visual programming environment and a state machine workflow and it is also a common scenario to host the workflow designer in an application. I’ve customized such a sample project to the needs of using the state machine and it works very good so far. Most time was spent on understanding the system and finalize the nodes, but it shows how software systems can be integrated and used in VL without much effort:

It comes with:

Workflow Designer

  • Workflow Designer - Rehosting in one Form with one tab per state machine
  • ToolboxControl - Selected for working with state machines
  • Workflow Execution - Retrieve real-time Execution Log (TrackData)
  • Workflow Management - Store to file / Run / Stop
  • Nested State Machines - Build state machine hierachies
  • IStateMachineControl - Interface to control a state machine by code

Custom Activities

  • Wait - Waits for a message with name of parent transition, must be placed in the “Trigger” of a transition
  • WaitFor - Waits for a given message, can be placed anywhere

VL Nodes

  • StateMachine - Instance as process node
  • SendMessage - Trigger state machine transitions and custom wait points
  • State - Get info from a selected state
  • ActiveStates - Get a spread of active states
  • EditorWindow - Show/hide the designer

Pros:

  • Fully working editor
  • Normal shortcuts like ctrl+s, undo/redo work
  • Many events like state enter, close, transition enter/close etc.
  • Can wait on each event for a custom message
  • Variables that can be used to further refine the logic
  • Developed and tested by microsoft engineers
  • Debugging via execution log
  • Restart while running with latest edit

Cons:

  • Windows only
  • Boring visual style
  • No direct jump to certain states, but would be possible with more coding
  • Realtime update possible, also would need more time

So now the question, does it run on other computers? Would be nice if you can give it a testing round. Donwload and unzip this file, open the file vvvv\Demo.v4p with vvvv beta38.1 and see what happens:

Beta:
VL.WorkflowFoundation.0.1.0.zip (3.5 MB)

Gamma:
VL.WorkflowFoundation_gamma.zip (773.9 KB)
Just place the content of the zip into your project folder and reference the VL.WorkflowFoundation.vl file in the document that uses the state machine. There is also a help patch included.

You should end up with this patch:

More info and source code:

4 Likes

seems to work fine here (b38.1x64 on a win10 system). i also added some states/messages and all that went fine (once you get used to the editor).

seems to be supercool and quite powerful with c# expressions etc.
really intereting stuff!

one thing that is missing imho is the possibility to interactively edit the machine (i.e. not save/reload the definition file on every change). not having that breaks the workflow we are used to in VVVV/VL a little.

yes, should probably write how to use it properly. if you press play it starts the edited machine again, no need for reload…

added a few pros and cons, thanks for testing @motzi!

always good to have alternatives,thanks tebjan

question, where was the urgent need for a VL automata editor discussed. wasn‘t aware of it. i was planing to rewrite/port automata ui for .net / VL for the standalone version anyway. just didn‘t see the urgency since nobody talked about it in the obvious channels.

It’s true that the discussion on riot have an exclusive character and that a lot of the insights found there never make it to the forum. These solutions are lost for the community and the aftermath.
I would also appreciate if the forum could keep it’s role as a growing compendium of community solutions.
Like the shout box, I think the riot chat should be visible on vvvv.org to logged-in users.

4 Likes

And regarding your question, we were looking for an automata node for vl

ok, riot then. i follow riot but sometimes its like 200 messages after a day. not the best format.

still don‘t understand why reinvent the wheel and don‘t talk to me. fair enough if one doesn‘t like the automata ui workflow but maybe we can contribute to something everybody likes to use instead of doing the same thing over and over again, solve the same problems.

you always need a state machine, some just don’t know it. :)

to understand why i picked this and invested time into it, here is a bit of story behind it:
since the old qfsm days, it is clear that you should start most of your projects with a state machine. it solves high-level application logic and is better to understand and design as doing the same in a vvvv/vl patch.

since the early days of vl we are talking about ways of integrating a state machine into the vl workflow and i was looking now and then into other tools like ventuz, unity etc. to see what they have come up with. one day i watched this video a bit and saw the concept of state machine hierarchies and all the events like enter, leave etc., which made total sense and i wanted to have that for the future vl state machine workflow.

as said in the original post, i was looking into it recently again and saw this funny workflow thing which exactly has all those features (and much more) and is tested since years. pulling it out of everyone’s pc and making a glue for vl looked easy enough to try it. and it was literally just 3 evenings of coding. compare that to developing a whole system from scratch, it would take weeks and would need testing. this is available now!

it was not trying to re-inventing it, just gluing it to vl until there is something better/more appealing. till then this is a working solution with minimal effort, problem solved for now -> more time for other things. so it was a quite pragmatic decision and i certainly don’t want to proclaim this as the final solution, just good enough for now.

since the interface to vl is very slim, you could implement the same interface @u7angel. then it can be replaced later and the same nodes would still work, just with another ui/editor. so please go ahead whenever you have time. would love to see a better looking state machine in the near future.

@tonfilm
this is absolutely understandable and great you worked on that. my criticism was about communication channels. i‘m really interested in a discussion like that and i‘m an avid reader of the forum and riot. but still this question slipped through.

there are just too many ways for discussions i guess.

anyway, back to the topic and something i like to add. are you planing to introduce some interface for VL to add additional editors to the UI. so rather placing a editor node somewhere in the patch, with view/close bangs but integrating better in VL aka dropdown menu, dockable window etc.

when we talk about something like workflow foundation, it would be nice to have something like that.

its not easy to catch up in the chat sometimes and not all topics get a forums thread to discuss in more detail. but i agree that embedding it into the website would be good for everyone.

yes, we have that as high priority on our list. and the big challenge is to find a windowing framework that works cross platform. currently we are using windows forms (windows, menu and context menu) which needs to get replaced. then we need to figure out how the integration and user extensions should work. since there isn’t the perfect solution right now, we are waiting for the winner of the the ui framework wars in 2019 on .net core 3.0. let’s see.

image
btw. the EditorWindow node is only there for convenience (e.g. close on startup of finished project), you don’t need to put it somewhere. if you place a StateMachine node in the patch it opens the editor automatically, just like renderers. you can also place a StateMachine in a loop and dynamically create 100 of them.

i‘m following the UI frameworks development for the last 5 years. looks like there will never be the „eierlegende wollmichsau“ for UI programming. i doubt 2019 will change that impression.

xaml is definetely interesting hence uno sounds cool. question is, does it make sense to wait for some wonders or choose a pragmatic windows solution to move forward.

1 Like

yes, definitely worth waiting a bit, .net core 3.0 will change the landscape. i’d say the pragmatic windows solution is what we have right now with Forms.

my bets are on uwp

once microsoft manages to slip uwp into the windows chromium, we’ll know for sure

one thing that makes this very hard to use is lack of visual feedback regarding the automata state in editor window. Makes it very clumsy to work with.

the UI is the default from WorkflowFoundation, I think it was not designed to work at runtime. however, there are two places to get insights:

  • the log window gives you real-time feedback when something changes:
    image

  • the ActiveStates node will give you all current states in the patch:
    image

@tonfilm, btw. is there anything planned in gamma to have a simple way to open an UI window for a node. just like in beta. right click on automata node reveals automata UI ?

2 Likes

@u7angel there is a general system in the VL API that gives you the selected node on selection changed. with that, you can patch such a system. however, it doesn’t differentiate between left or right-click.

you can see that in action here:

thanks tebjan, this looks interesting.

but a strategy for gamma user interface extensions would be of value. if i recall right, we were talking about this at the vvvv summer camp…including the whole automata/timeline discussion. beta had a straight forward way of handling such things which is still missing in gamma/VL.

when we think about something like that, being able to have multiple windows and the ability to tab them, touches this topic.

This is pretty good. I’m not sure how ‘if’ conditions work when I have more than one transition from a state but this is a handy system. But maybe with one caveat:

.Net 5 (core)

1 Like