Software Engineering with PSF

Example Architecture Specification

As example we have an application consisting of two tools. Tool1 can either send a 'message' to Tool2 and then waits for an acknowledgement from Tool2, or it can send a 'quit' after which the application will shutdown.

data module Data
begin
    exports
    begin
        functions
            message : -> DATA
            ack : -> DATA
            quit : -> DATA

            c1 : -> ID
            c2 : -> ID
    end
    imports
        ArchitectureTypes
end Data
We first specify a module for the data and id's we use.

process module ApplicationSystem
begin
    exports
    begin
        processes
            ApplicationSystem
    end
    imports
        Data,
        ArchitecturePrimitives
    atoms
        send-message
        stop
    processes
        Component1
        Component2
    definitions
        Component1 =
                send-message .
                snd(c1 >> c2, message) .
                rec(c2 >> c1, ack) .
                Component1
            +   stop .
                snd-quit
        Component2 = 
            rec(c1 >> c2, message) .
            snd(c2 >> c1, ack) .
            Component2
        ApplicationSystem =
	    Component1 || Component2
end ApplicationSystem
We then specify the system of our application.

The snd-quit in the process definition for Component1 communicates with the architecture environment followed by a disrupt to end all processes.

process module Application
begin
    imports
        Architecture {
            System bound by [
                System -> ApplicationSystem
            ] to ApplicationSystem
            renamed by [
                Architecture -> Application
            ]
        }
end Application
Next, we put the system in the architecture environment by means of binding the main process to the System parameter of the environment.