InPlace Version v0.16.0 delivers the following milestones in the project Practical Tools to Build the Context Web as supported by NLnet:
lru-cache
supports properties that reflect the number of stored items, it was not a priori clear how we should incorporate such changing properties in the Perspectives model. We do have properties on roles, but these can only be changed by users. This provides the clue to how we have fitted them in: we can image that the end user reads such a sensor
himself and enters the value as some property's value. All we have to do is to make that action automatic - and since Perspectives has automatic actions, this fits the concepts we already had. But this has to be repeated periodically - so we have extended our language with time facets that allow us to express that an automatic action has to be performed a number of times, with a time interval between each recurrence, or indefinetely. We've also added a waiting period before things start, and an end moment that shuts down the repeating action. Also, repeating actions are confined to a particular state. As soon as the state ends, the actions are no more carried out.Taken from model:System
, the fragment that models a context Caches
. State StartReading
has an automatic action defined with timing facets (the line illustrates the possibilities rather than being a useful monitoring service):
case Caches
aspect sys:ContextWithScreenState
state ContextOnScreen = extern >> IsOnScreen
on entry
do for Manager
StartReading = true for Cache
on exit
do for Manager
StartReading = false for Cache
state NoCaches = not exists Cache
on entry
do for Manager
letA
contextcache <- create role Cache
rolecache <- create role Cache
domeincache <- create role Cache
in
Name = "contextcache" for contextcache
Name = "rolecache" for rolecache
Name = "domaincache" for domeincache
external
aspect sys:ContextWithScreenState$External
user Manager = sys:Me
perspective on Cache
defaults
thing Cache (relational)
property Name (String)
property StartReading (Boolean)
property Size (Number)
property NrOfTicks (Number)
state InitTicks = not exists NrOfTicks
on entry
do for Manager
NrOfTicks = 0
state StartReading = StartReading
on entry
do for Manager after 10 Seconds until 20 Seconds every 5 Seconds maximally 4 times
NrOfTicks = NrOfTicks + 1
Size = callExternal sensor:ReadSensor ( Name, "size" ) returns Number
A trimmed down version of that model, sampling cache sizes every 2 seconds shows on screen as follows:
Explanation. We see two overlapping Chrome windows, each showing an InPlace screen (both are connected to the same PDR) displaying a single context. The top window (right) shows the 'Simple Chat' application, currently displaying the list of available chats. By clicking the + button, a new Chat (a context instance with several roles) is created (without a title). The underlying window (left) shows part of the Caches window, displaying a table with a row for each cache. The columns show the cache name and the cache size in terms of items. As we add Chat instances, the number of contexts and roles increases. Explanation of the way the screen is refreshed: every two seconds, each cache's size is recomputed and recorded in perspectives, in a separate transaction. Each time, the entire screen is recomputed in the PDR and is sent to the InPlace client. This currently causes a noticeable update on screen.
IsOnScreen
to the external role of a context. The GUI application InPlace sets that property to true as soon as the end user opens the context on screen, and sets it to false as soon as it is closed. Thus, this screen state is reflected in Perspectives state.None.