Internal
Much of this information is internal documentation. Care has not been made to make links work and make the documentation conprehensible for outsiders.

The implementation of CpnTools is now an ongoing project for nearly 3 years at least. There have been quite a few programmers involved during that time, and becouse of this the code is not organized and structure as one would like. Furthermore was the code first used as a prototype and rapidly programmed to have substantial application to show, the code design could therefore be characterized ad-hoc in many places. The code has furtunatly run through some refactoring, but there are still some parts, which need redesign.

  • - General Structure —

I will first introduce how the tool works on near code basis to better get the understanding how things are put together. When you create or load a net, the checker thread will be started. The checker thread is responsible for checker the net upon any semantic change (this is actually a coded event), and send the net to the simulator, which runs as seperat process. (To learn more about the simulator ask Lisa) As the name implies is the checker thread a thread which run simultaneously as the main thread and several (hmm) other gui/event related threads. Currently there are no mechanism to prevent mutual exclusion from mutual data structures. It seems are there are no conflicts when using the tool except for some minor, which have been fixed without the use of semaphores.

The checker thread restarts every time there has been a change in the semantic structure of the net. (e.g. a call to semanticChanged)

When a net is created (either a new or loaded), we both store the dynamic and the static part of the net. The static part of the net, is what you usually see, e.g. the places, transitions and arc. The dynamic part has more to do with how the net is simulated. For each place and transition there is their corresponding instance object: PlaceInstance and TransitionInstance. If you know a little about cp-nets, then you will also know about instances.

Operations on nets are performed when the user uses an instrument. An instrument is usually kept in the “hand”, meaning that the instrument is active and occupies a mouse/cursor. Instruments can have figurs, which correspond to the mouse cursor.

When an instrument is applied a command is usually responsible for performing the action, the user requested. A command sometimes uses a clipping to perform the work.

A marking menu is a shortcut for applying an instrument.

The code is generally (sometimes less) divide into the following parts:

  • The static and the dynamic structure of the net, e.g. places, transition,… and also placeInstance and transitionInstance. These patterns along with common parent patterns, some graphical patterns (guidelines and aux figures), all inscriptions and tags together with a lot of other code is placed in /cpnet/cpnet.bet
  • All instruments are kept in the directory /cpntools/instruments/. Clippings and commands are also kept here.
  • /cpntools/cpnworkspace.bet is a direct subpattern of the workspace in the framework. This pattern contains a lot intialization stuff, and also the prototypes for various page elements. Here are also some event handlers regarding application specific stuff.
  • /cpntools/cpntools.bet is the main file. Here is likewise a lot of initialization code, and a lot of graphic related stuff.
  • /cpntools/menues/ contains the marking menus.
  • **/cpntools/wseelements/ contains workspace elements such as the Statusbubble and the CpnBinder.