Skip to main content

Multi process collaboration

In the previous study, the process we wrote may contain several process blocks, and the more complex process may also contain multiple conditional judgments, but they are still just a process because they only have one "start" block. In this chapter, we will learn how to write multiple process for a Task (each process has its own "start" block), and complete this Task through collaboration among multiple process.

In Laiye Automation Platform, it supports not only the parallel running of multiple process (multiple process running at the same time), but also the serial running of multiple process (running one first, then another). The former is called" Auxiliary process ", The latter is called" Sub process ", Both have different uses. The following will be explained one by one.

Auxiliary process

When using "Laiye Automation Creator", you may notice that there is only one component called "Start of Main Process" on the process diagram, which is the starting point of the process. You can connect multiple process blocks to the back of "Start of Main Process" with arrows, and let these process blocks run in sequence, which constitutes a process. As shown in the figure below:

Schematic diagram of main flow

As the name implies, since there is a "main process", there will naturally be a "sub process". In Laiye Automation Platform, we name it "auxiliary process" instead of "sub process". The reason why it is so named is that its purpose is usually to help the main process complete some additional Task and play the role of "assistant". Examples will be given to explain how to assist. Let's first look at how to create an auxiliary process.

In the component panel on the left side of the process diagram, you can see a component called Auxiliary process Start, which can be dragged to the process diagram. The shape of this component is very similar to "start of main flow", but in addition to the difference in text, there is also a circle of dotted lines, as shown in the red box in the following figure:

Auxiliary process start

In a process diagram, there can be no or one or more "auxiliary process start" components. How many "auxiliary process start" components are created in the process diagram, and how many auxiliary process are generated when running. Of course, it is not enough to just create "Auxiliary process Start". You need to create several process blocks and connect them to the back of "Auxiliary process Start" with arrows, just like creating a primary process. As shown in the figure below, we have created a main process and an auxiliary process, which are connected to three process blocks respectively.

One main process and one auxiliary process

It is worth noting that there may be multiple process blocks in the process diagram. Each process block is either part of the main process or part of a certain auxiliary process, but it cannot be part of both the main process and auxiliary process, or part of multiple auxiliary process at the same time. Therefore, in the process diagram UI, once a process block is connected to the "primary process", you can no longer connect it to the "auxiliary process".

How does the auxiliary process work? When the process starts to run, the main process and all auxiliary process will start at the same time. At the same time, from the "Start of Main Process" and each "Start of Auxiliary process" component, run the contents of each process block according to the arrow direction. You can think of such a running process as a relay race in track and field. After the starting gun rings, there will be multiple groups of athletes running on multiple tracks at the same time. If they meet a teammate in the track, they will give the baton to the teammate, who will then run down.

Relay Race

Just as many groups of runners in the same race are on their own tracks, they will not conflict with each other. The variables used by the main process and the auxiliary process are also private and will not conflict. For example, in the main process, there is one named a Is a variable whose value is 1 , It is possible to have a variable with the same name in the auxiliary process, whose value is 2 .

When a process block in the main process finishes running, and no other process blocks are connected behind it, or the "End" component is connected, the main process will end. The auxiliary process is similar. If there is no subsequent process block or the "end" component is encountered, it will end. The difference between the two is that if the main process ends, each auxiliary process will be automatically notified, and they are required to also end. After the auxiliary process ends, the main process or other auxiliary process will not be affected.

Some readers may doubt that since the auxiliary process and the main process run simultaneously, and there is no limit on the number of auxiliary process. Then, if you create many auxiliary process and each auxiliary process does an independent Task, isn't it equivalent to running many software robot at the same time, allowing them to do more things in a fixed time? In fact, this is not the case. Laiye Automation Platform's auxiliary process are implemented using the multithreading mechanism of the operating system. Each auxiliary process is an independent thread. If readers are familiar with the principles of the computer system, they will know that an increase in the number of threads does not necessarily lead to an increase in work efficiency, or even an excessive number of threads will lead to a decline in efficiency. If the reader is not familiar with the basic principles of threads, it is OK to just remember that the number of auxiliary process should not be too many.

In fact, the original intention of Laiye Automation Platform's auxiliary process design mechanism is not to let us run multiple software robot at the same time to do different Task. Because Laiye Automation Platform often needs to simulate UI operations, if multiple process operate on the same set of UI, it is actually difficult to coordinate, so that they can do different operations in an orderly manner. Just like two people holding a mouse to operate the same computer, a slight carelessness will lead to conflict. For example, one person is typing in a text box, but another person clicks a button, causing the loss of input focus, and so on. The auxiliary process, as its name implies, is just the "assistant" of the main process, helping the main process do some chores.

The following examples can illustrate the general use of auxiliary process:

In the business system of a telecom operator, it is necessary to constantly process the business requests sent by customers (such as modifying the mobile phone bill package, etc.). Processing each request requires a series of complex operations in the business system. Although complex, there are specific rules, so Laiye Automation Platform is particularly suitable for automated operations. As long as the operation is divided into multiple steps, each step can click a specific UI elements according to the rules. However, in this business system, the Notice dialog box may pop up repeatedly. The Notice dialog box is generated asynchronously, that is, it may pop up at any time during any operation without rules to follow. Once the dialog box pops up, you have to click the "Confirm" button in the dialog box to close the dialog box before continuing the operation.

As shown in the figure below, when we are filling in a form in the business system, an insignificant dialog box pops up. If it is operated by a person, it is easy to close the dialog box and continue. But if it is a software robot operation, it will become very troublesome. Because we cannot predict when the dialog box will pop up when we design the process, we have to check whether the dialog box pops up before operating each UI elements in the form. Otherwise, if the dialog box pops up when there is no detection in any step, the process will run incorrectly.

Example pop-up dialog box

If Laiye Automation Platform's auxiliary process is adopted, this problem will be solved easily. We only need to process the form in the main process as usual, without considering whether the dialog box pops up. In addition, create an auxiliary process to detect whether the dialog box pops up at any time. Once it pops up, close it immediately to avoid affecting the main process. This auxiliary process has only one process block, and its contents are roughly as shown in the following figure:

Detect and close the auxiliary process of the dialog box

In this way, the main process and the auxiliary process perform their respective duties, with clearer responsibilities and simpler process preparation. The auxiliary process is like "escort" the main process. When the main process ends, the auxiliary process will also end automatically.

Sub process

When we are developing a slightly more complex process, in order to improve efficiency and ensure that the process is completed as soon as possible, the common method is to divide the process into multiple steps, and different people will write different steps, and then assemble these steps together.

How can I do this with Laiye Automation Platform? If the readers have practical experience, they may use a process block to implement each step. Then use Laiye Automation Platform's Import function to import these process blocks into the same process diagram one by one.

This method is not impossible, but there are the following problems:

  • If the content of the process block is updated, you need to delete the old process block in the process diagram every time, and import the new process block again, which is very troublesome;
  • If a step is complex and it is not convenient to describe it with one process block, it must use multiple process blocks to make it clearer. This method is not supported;
  • We have defined a variable in the process diagram, which can be used in each process block. However, if two people lack coordination and do not know how to use this variable, it will cause conflicts such as data coverage (for example, we have defined a process diagram variable a , A process block sets its value to 1 , Another process block sets its value to 2 , If two process blocks are not written by the same person, the writer of the first process block does not know that the value has been modified, but still follows 1 If you handle it, problems will arise).

Laiye Automation Platform supports the sub process mechanism, which can avoid the previous problems and is more conducive to multi person collaboration. This mechanism is described in detail below.

Concept of sub process

For example, suppose we have a process, which includes one pre step, two business steps, and one post step. We hope that these two business steps can be written by others. Each business step is a "sub process", and each sub process can contain multiple process blocks and condition judgments. From our point of view, this process diagram is roughly the following state (we can call this top-level process "total process", which will continue to be called below):

General process

Among them, the "pre step" and "post step" process blocks are written by us, and the "sub process 1" and "sub process 2" steps are written by other colleagues. Careful readers may notice that "sub process 1" and "sub process 2" are not ordinary process blocks, because there is a vertical line on both sides of the icon, which is different from the icon of the process block. In fact, "Sub process 1" and "Sub process 2" are both a complete process diagram, which can also contain other process blocks. But from our perspective, we only regard the "sub process 1" and "sub process 2" written by these two colleagues as two separate components, and do not care about the details.

For example, "Sub process 1" may contain two process blocks, as shown below:

Schematic diagram of sub process 1

For "sub process 2", it may include a process block and a condition judgment, as shown below:

Schematic diagram of sub process 2

As the "general contractor", we don't care about the details of sub process 1 and sub process 2. As long as we write the pre and post steps, we can run this process after two colleagues finish sub process 1 and sub process 2 respectively. When we click the "Run" button, we will first run the pre step, and then run the process block contained in sub process 1. When we encounter the "End" block in sub process 1, we will not end the entire process, just jump out of sub process 1, and then run the next sub process 2 immediately. Similarly, when the "end" block in sub process 2 is encountered, it will not end, but will jump back to our process diagram, and then run the subsequent "post step". It will not really end until we encounter the "end" block in our process diagram.

In other words, the actual running path is:

Start ⇒ Pre steps ⇒ Sub process 1 - Step 1 ⇒ Sub process 1 - Step 2 ⇒ Sub process 2 - Step ⇒ Whether it is completed (in sub process 2, suppose the judgment condition here is "Yes") ⇒ Post step ⇒ End

It is worth noting that the variables of the total process, sub process 1 and sub process 2 are isolated from each other. That is, if a variable is defined in both the total process and sub process a , whether a Whether it is a process diagram variable or a process block variable, they have their own values in the overall process or sub process, and will not affect each other. In this way, when we write a process or sub process, even if it is completed by different people, we do not have to worry about the conflict caused by the fact that everyone accidentally gives the same name to the variable.

It is actually very easy to create such a process containing sub process. The following describes its operation methods.

Create Sub process

With Laiye Automation Platform, you can first create a sub process (including its process block), and then reference the sub process in the overall process. You can also create a sub process and reference it in the process of writing the overall process. In addition, other sub processes can also be created in the sub process. The creation order is not limited. As shown in the figure below, the total process includes three sub process, some of which include other sub process (it can be called "sub process"). Then you can first create sub process one by one, then create sub process, and finally create the overall process; You can also create a total process first, then create sub process one by one, and then create sub process one by one in each sub process.

Schematic diagram of multi-level sub process

Let's consider the simplest case: reference a sub process in a total process. After mastering this operation, you can draw inferences from one instance by considering multi-level sub process.

Suppose that we are currently writing the overall process and need to reference a sub process. In the component panel on the left, you can see an icon as shown in the figure. The text below it indicates that "sub process" can be introduced with this component. As shown below:

"Sub process" component icon

Drag this component into the process diagram, and the Laiye Automation Creator will immediately pop up a dialog box asking whether we want to reference the existing sub process or create a sub process and reference it, as shown below. If a sub process has been created before, it is obvious that you should select Open to select an existing sub process; Otherwise, you can select "Create blank ⇒ process" or "Create from template ⇒ Enterprise Process Template" to create a sub process.

Create or open sub process

It is worth noting that in the Laiye Automation Creator, a Windows folder will be used to place a process, and all the files contained in the process are under this folder. Therefore, if you select an existing sub process, the Laiye Automation Creator will immediately pop up a "Select Folder" dialog box, which means to determine the folder under which the imported sub process is located. If you are creating a new sub process, specify the path of the process in the "Location" column and click "Create". Whether you select an existing sub process or create a sub process, A "sub process" icon is added to the process diagram. In the process of running the process along the arrow, whenever this icon is encountered, the sub process will start to run until the sub process finishes running, and then return to this process diagram.

After adding a sub process to the process diagram, the Laiye Automation Creator does not copy all the contents of the sub process into our process diagram, but instead uses the "reference" method to record only the path information of the sub process. That is to say, after creating a sub process, if the sub process is modified again, we do not need to do any additional action. When running again, the sub process is already the modified content.

You may notice that after adding a sub process to the process diagram, there will also be a button displayed as paper and pen on the box representing the sub process (as shown in the red circle in the following figure). After clicking this button, the Laiye Automation Creator will automatically open the process diagram of the sub process, giving us the opportunity to modify the sub process.

Buttons for modifying sub process

Some readers may worry that there are sub process and sub process. If there are too many levels of nesting, "there is no limit to the number of children and grandchildren", will they forget the hierarchical structure of sub process. Don't worry, Laiye Automation Creator will help you remember clearly. Whether you are editing a process diagram or a process block, there is a tab named "process" on the left (you can drag it to another location, but the default location is on the left). When you switch to this tab, a tree structure is displayed, from the total process to the sub process, to the process block in each sub process. This tab has two main functions:

  1. Display the structure of the whole process, and indicate the position of the process diagram or process block currently being edited in the whole process in bold font;

  2. Double click any process diagram or process block to start editing immediately. It is convenient for you to quickly jump between different sub processes.

Role of the process tab

Since the total process and sub process use different Windows folders to save them, we can put the files needed during the process running (such as the image files used in the "Find Image" command) in their own folders, without interfering with each other. According to what we have learned before, use it in any process block of the overall process @res"" , What you get is the total process in the folder res folder. In the sub process, you will get the res folder.

When we have written the total process and sub process in the Laiye Automation Creator and want to use them in the "Laiye Automation Worker", we need to use the enterprise version of the Laiye Automation Creator and package the process into an independent, Extension .bot File. When packaging, although the total process and sub process are placed in different folders, the Laiye Automation Creator will automatically traverse the required sub process and the folder where the sub process in the sub process ("sub process") is located, and package their contents All to the same folder .bot In the document. That is to say, when packaging, you don't need to care where the total process and sub process are placed, nor do you need to worry about the conflict between the files they use in operation. Everything is handled automatically.

Input and output of sub process

When we introduce a sub process into the overall process, their variables are isolated from each other according to the above. Even if variables with the same name are defined, each has its own value, which will not conflict. Although the problem of conflict is avoided, if the overall process and sub process need to cooperate, it is inevitable to transfer data between the overall process and sub process. For example, a colleague is responsible for writing a sub process, which is used to query the location of my mobile phone number according to my mobile phone number. Then, in the process of collaboration with this colleague, there are at least three demand to meet:

  • Colleagues responsible for writing sub process can easily use their own mobile phone numbers to test the effectiveness of sub process;
  • When we use the sub process, we can easily send the mobile phone number to be queried to the sub process;
  • After the sub process finds out where the mobile phone number belongs, it can easily send the results back to us.

In the Laiye Automation Creator, open any process diagram, and there will be a tab on the right, called Variable. Click this tab to see that there are three types of variables in the pop-up panel. The first type is called "process diagram", that is, "process diagram variable" is defined here; The second type is called "process input", which means that "process input variable" is defined here, and the Laiye Automation Creator will usually automatically create a new one named g_input Process input variables; The third type is called "process output", which means that "process output variable" is defined here. Similarly, the Laiye Automation Creator will automatically create a new one named g_output The process output variable of.

As we learned earlier, the "process diagram variable" defined here can be shared in each process block in the process diagram. In fact, "process input variable" and "process output variable" are also special process diagram variables, which can also be shared in each process block. Of course, they have further uses.

  • For "process input variable", when this process diagram is used as a child process, this variable can receive the value from the upper level process (referred to as "parent process");
  • For "process output variable", when this process diagram is used as a child process, this variable can transfer the value to the parent process;
  • The process Diagram Variable can only be used in the process diagram and its process block, and is not visible to the parent process;
  • For the overall process, its "process input variable" and "process output variable" can also be used as the input and output of the Task when the "Laiye Automation Commander" is used to create Task. In addition, there is no other difference with "process diagram variable".

Define process Diagram Variables

Except for the automatically defined "process input variable" g_input And "process Output Variables" g_output In addition, you can click the "plus" icon below to add variables, or click the "trash can" icon on the right to delete these variables.

Careful readers may also find that "process Diagram Variable" and "process Output Variable" are not defined in the "Type" column, but in the "process Input Variable" column. In fact, the variables in Laiye Automation Platform are of dynamic type, that is, a variable may first be a string, and then become an array, numerical value and other types. Therefore, what type of data is stored in "process diagram variables" and "process output variables" is known only when the process is running, and cannot be estimated in advance. For the "process input variable", Laiye Automation Platform does not force Limit its data type. The "type" filled in this column only tells its parent process or Laiye Automation Commander that when it needs to enter, proposal What type of value is entered.

For the above example of querying the location of a mobile phone number, it is obvious that we need to define two variables in the sub process (as shown in the figure):

  • One is "process input variable", which is used to obtain the mobile phone number to query from the parent process. Since Laiye Automation Platform can name the variable name in Chinese, you might as well name it as Phone_Number . Set its type as string, and you can also set an initial value for it, such as "13074835678" ;
  • The other is "process output variable", which is used to transfer the location of the found mobile phone number to the parent process. You might as well name it Ascription .

Variables in Sub process

In this way, for the colleague who wrote this sub process, you only need to read Phone_Number The value of this variable can get the mobile phone number to be queried. In addition, when the process is not accessed as a sub process in the process writing and unit testing stages, the value of this variable is the initial value we set for debugging. After the location information is found, you only need to place it Ascription Variable, waiting to be used by the parent process.

When we write the general process (which is also the parent process of the sub process above), similarly, we only need to define a "process diagram variable" to receive the home information returned by the sub process. The variable name can be positioned as Ascription_Result . We can also set an initial value for it, such as "BeiJing" . In this way, before the sub process is connected, you can also use this initial value to test and debug the subsequent steps. See the figure below.

Variables in the total process (parent process)

Finally, suppose that the sub process and the overall process have been written and the integration test has started. Just follow the described steps to introduce the sub process into the overall process, and select the block representing the sub process in the process diagram. Note that there is a property page named "attribute" on the right. Open this property page. In the panel, in addition to displaying the name of the sub process and other information, all "process input variables" and "process output variables" defined in the sub process will also be displayed.

Basic Information panel of sub process and its Settings method

The Settings shown above means that before the sub process runs, the string "13912341234" (Note: the above figure is input in Normal Mode, so double quotation marks representing strings are not required. If it is in Expert Mode, quotation marks are required.) As the mobile phone number to be queried, it is passed to the sub process Phone_Number This "process Input Variable"; After the sub process runs, the sub process Ascription The value of this "process output variable" is put into the Ascription_Result Variable. The Laiye Automation Creator uses the arrow marked with the left and right directions to indicate the direction of data transmission. Pay attention to this arrow and its direction, which will help you understand how data is transferred between the overall process and the sub process.