# Standard pim services

This chapter covers the pim facilities available in the standard personal information management module. The basic operations are related to time management.

All standard pim objects are located in the `afnix-pim` module. This module must be loaded prior any operation. Multiple calls to the module initialization routine are harmless. The interpreter method `module` loads a specific module by name. When the module has been loaded, the object are available in the `afnix:pim` nameset.

interp:library "afnix-pim"

## General concepts

The `afnix-pim` provides the support for manipulating information management data. Information data are generally personal information that are used to manage time and constraints. The concepts of agenda and appointer fall into this category.

### Slot

The concept of slot is central in the pim module. A slot is a combination of time and duration. A slot is allocated by an appointer to indicate the next available slot. For an agenda, the concept of slot can be derived to describe an appointment.

### Appointer

An appointer is a slot generator. The appointer can be designed to respond automatically with respect to a certain number of rules. Common rules found in an appointer are closed days like week-end and time allocation period.

### Assistant

An assistant is a combination of pim object like appointers. An assistant can be used for example, to manage several appointers.

## Appointer operations

The `Appointer` class is designed to allocate slots with respect to a certain duration or from a certain time with a duration. The appointer operates with rules which describe the operating calendar and daily schedule. such rules are designed to mimic real-life situations like week-end blocked days or Christmas vacation day.

### Slot allocation

A slot is allocated with the `get-slot` method. This method is common to the `Appointer` and `Assistant` classes.

# allocate a 1 hour slot const slot (appt:get-slot 3600)

In the example above, a 1 hour slot is allocated at the current appointer time. Note that the time and duration are always given in seconds. If the slot needs to be allocated starting at a certain time, the 2 arguments form can be used.

# allocate a 1 hour slot starting at 2AM const slot (appt:get-slot 7200 3600)

In the presence of an `Assistant` object the `get-slot` is the same but selects the appropriate appointer with the help of an internal index which rotated after each call. This method permits an equal distribution for all appointers within an assistant.

### Appointer rules

There are basically, two types of appointer's rules. The first type of rule is used for blocking a day as a whole. The second type of rule is designed to describe valid periods of allocation time. The first type of rules is called the and rules since all rules must be valid in order to allocate a slot at the requested time. The second type is a called the or rules since only one rule needs to be valid in order to allocate a slot.

# create a reference appointer const appt (afnix:pim:Appointer) # add a saturday and sunday blocked day rule appt:set-blocked-day 6 appt:set-blocked-day 0 # set the special days appt:set-special-day 1 1 appt:set-special-day 12 25

The example above defines an appointer object. The first 2 rules defines Saturday and Sunday as blocked days. The other 2 rules, defines Jan 1st and Dec 25th as special days. No slot can be allocated in a blocked or special day.

# set a valid block time between 8AM to 12AM and 2PM to 6PM const ambt (* 3600 8) const amet (* 3600 12) const pmbt (* 3600 14) const pmet (* 3600 18) appt:set-valid-block-time ambt amet appt:set-valid-block-time pmbt pmet

the above example defines two valid periods for allocating time. The first period runs from 8AM to 12AM and the second one runs from 2PM to 6PM. Note that the time is also expressed in second. The time arguments are always rounded to the maximum number of seconds per day.

## Assistant operations

An assistant object is build by adding object to it. In general, a reference object is created, and several of them are added to the assistant by cloning the reference object.

### Assistant integration

Once an assistant object has been created, the object can be added by cloning.

# create an assistant const name "Mr Smith" const info "The super assistant" const asst (afnix:pim:Assistant name info)

# create a reference appointer const appt (afnix:pim:Appointer)

# add 2 appointers by cloning asst:add-appointer (appt:clone) asst:add-appointer (appt:clone)

In the case of an `Appointer` object, the appointer is cloned with all its rules attached to it. This method is particularly useful when an assistant needs to be setup for several person that shares the same calendar.