What if a process is not based on queue items but is based on a sequence of bulk operations?
You can think every bulk operation as fake queue item and manage them from control room.
But maybe you want to apply some logic, for example, let's assume your process id made of 4 subprocesses (A, B, C, D), if something go wrong with A you don't want to execute C, no problem on B and D.
Yeah, maybe too simple as an example, but use you imagination... believe me, you don't want to know anything about the process that, in the real world, lives on this solution (Alberto Cannas became mad on this).
So think about a process that doesn't rely on queue and where you want to play with subprocesses that can be seen as transactions.
We could store the data in a DB, but what if we cannot use a DB... we can use a JSON file as a DB, in order to have a flexible DB that helps us.
For example, in the process we are dealing with, we use a JSON file that is generated everyday, and the process state is represented by data in a collection.
I will show you a little process that simply export data only at 10.00/12.00/14.00/16.00 using JSON to make all clear. This is what BP object Utility - JSON wrote when using Collection to JSON action.
{"Log 10":false, "Log 12":false, "Log 14":false, "Log 16":false}
So you can read the informations you store in your information in a JSON file, implement your logic, and write again only when needed.
You should take care about 2 things:
- The subprocess that works on file must be encapsulated in enviroment lock. This will be helpful in a multi-robot environment;
- Pay attention to what you write in the JSON, when you use JSON to Collection action, the objects write the collection as an array, so you have to remove brackets at beginning and at the end of the JSON (thank Manuel Mascia for the trick)
Yeah... tips'n'tricks |
Now you can push this solution beyond this example.
That's all folks.
0 commenti:
Post a Comment
Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).