In the First steps exemple, we have seen that bob was stuck in its initial location because no connexion was available for him. We also have seen that the monitor was a convenient way to inspect the resources managed by the different bags of the system. We are going to demonstrate here that it is also possible to use this same monitor to manage resources (insert or remove).
Below is reminded the state of our application once the rules are enacted upon the initial given resources.
| Customer| Destination| Connection| Travel| |---|---|---|---| | ('bob','B')| ('bob','D')| ('A','B')| ('A','D','alice')| | ('denis','D')|| ('A','D')| ('C','D','charles')| | ('alice','D')|| ('C','D')| ('A','D','denis')| | ('charles','D')|||
bob cannot reach destination D because there is no resource ('B','D') in the Connection bag.
The purpose of this lesson is to demonstrate how we can use the monitor to introduce one.
With the application running, use your web browser to navigate to the monitor interface of the Connection bag.
If you used the provided configuration, you may use the following URL :
In the following, we will focus on the right-hand side of the screen, where the content of the bag is displayed.
By default the monitor is set to inspect mode (or in browse mode). This means that it is settled to ease navigation within the available resources contained in the bag.
You can apply some filtering by acting on the selection mask (first line, just below the resources column/field headers). By default, each filter token is set to *''*. This means that no filtering is applied to the field. Here, as we have 2 fields, the default "no selection" mask is set to *('','').
Defining restriction criteria in the mask will apply the related filter to all the available resources of the bag. As a consequence, only the resources matching the specified filter will be retrieved and displayed in the monitor interface.
For example, if you want to retrieve all the resources containing the D value in the arrival field, you should select D instead of ** in the corresponding dropdown list (just below the header label), then click on the *[mask] button on the left. The resource table is then updated and 2 resources are displayed : ('A', 'D') et ('C', 'D').
To get back to the global table, without applying any filter, simply select ** values in all the restriction criteria (each drop down list) and click again on the *[mask] button.
All this filtering process is quite powerful for retrieving specific resources in large bags,.... but it does not help us getting bob' to his *D destination !
To make bob travel, we need to add the missing ('B', 'D') Connection resource.
For that, first toggle the monitor in Edit mode by clicking on the Edit icon, on the top left-hand corner of the resource table.
In Edit mode the resource table is adapted to enable the possibility to interact with the content of the bag by inserting or consuming resources through put() and get() operations.
In this Edit mode, a new row appears under the filter mask line. This line constitutes a form in which you can enter field values to insert a new resource by performing a put() operation. This is detailed further in this section.
You may also notice that an icon is added in the first column of the table, in front of each displayed resource. This icon may be enabled or disabled depending on the aspects associated with the bag: when the bag is ReadOnly, then the icon is disabled. By clicking on the enabled icon, you perform the get() operation on the Connection bag, corresponding to the resource depicted in the same table row.
Note : Depending on the source code you used to test the current lesson, you may experiment either one or the other of these behaviors. In our case, the Connection bag was designed with the ReadOnly aspect (as reminded in the above picture with ro added in the Bag type top label). As a consequence, the icon is disabled and no noticeable modification can be witnessed while clicking on it. On the other hand, if you did not set the ReadOnly aspect on the Connection bag but adapted the rules to perform read operations instead of get ones, then clicking on enabled icons should consume the corresponding resource.
Let us go back to our problem: we want to get bob from his B location to its D destination.
From the Connection bag table in Edit mode, simply enter B in the departure field and D in the arrival field, then click on the insertion button. This will execute what is associated to the put() operation at bag level. Most of the time, and in particular here, this will insert the resource ('B','D').
You may switch back to Inspect mode by clicking on the magnifier icon.
Now, all the required connections are defined in our system. As a consequence, the rule waiting for the (B, D) resource is triggered and bob is led to his intended destination. You can inspect the Travel bag to convince you.
| Customer| Destination| Connection| Travel| |---|---|---|---|---| | ('bob','D')|| ('A','B')| ('A','D','alice')| | ('denis','D')|| ('A','D')| ('C','D','charles')| |('alice','D')|| ('C','D')| ('B','D','bob')| | ('charles','D')|| ('B','D')| ('A','D','denis')|
As a conclusion, we have seen that it is possible to perform put() and get() operations from the monitor interface, even while the application is running. This interface introduces a very convenient way to perform live debugging and testing of applications.
The Monitor gives you access to several tools (detailed in LINC Tools: