deltaFSD

  
sidebar

Some customization notes

What is in the source files?

  • deletion.c:  handles deletion of functions and various graphical elements
  • engine.c:  function instantiation and the core exeution engine
  • f????.c:  the various components of the specific functions
  • fileops.c:  read/write data files
  • fmisc.c:  utilities for functions - menus, definition, instantiation
  • function.c:  function definition
  • gutils.c:  graphical utilities
  • main.c:  overall program start-up and initialization

How do I add my own functions?

Adding a new function involves two elements: definition and registration.

Most of this takes place in functions.c.

Definition

Look at the implementation of the basic mathematical functions provided - for example multiply:

void Multiply (funs f) { Out(0) = In(0) * In(1); }

All of the data related to this Multiply function (in particular the inputs and outputs) is based on the parmater f.

In(0), In(1), Out(0) are macros which use the pointer f to access the correct elements of the data structures.

The function itself is a straightforward C function with no special rules or limitations.

It can be as simple or as complex as you require.

Registration

This is needed to:

  1. Create the data structures required.
  2. Set up the menu entry - in particular the menu section and the text to be used.
  3. Define the function entry point.
  4. Define any initialization or special handling needed for this type of function.
  5. Define the numbers of inputs and outputs the function will have.

Each function initialize an array element in functions[]:

{ "/Math functions/Multiply", "Multiply", Multiply, NULL, 2, 1 }

The elements of this structure are:

  1. The text of the menu entry for the function
  2. The name of the function - the text displayed (and used in the data file)
  3. the function itself (as defined above)
  4. A pointer to a structure for "special" functions
  5. The number of inputs
  6. the number of outputs

What are these mysterious "special" functions?

If not NULL the fourth parameter needs to be a pointer to a data structure which contains:

  1. A function called when this type of function is created (registered)
  2. A function called when creating an instance of the function from the user interface (ie when the menu item is selected).
  3. A function called when creating an instance of the function from a file entry.
  4. A function called when writing an instance of the function to a file entry.
  5. A function called when the user right clicks the box hot spot.
  6. A function called an instance of the funtion is destroyed.
  7. Some explanatory text to go into the creation dialog box

For straightforward functions (like Mulitply) all of the actions are handled by standard, default, versions of these.

 

What does the engine realy look like?

void process_func (funs f)
{// process a single function - execute it and propogate the changes through each of its output variables
varo curo;
    // execute the function
    (*f->funct->func) (f);
    // then work through each of its outputs to force consequential changes
    for (curo = f->frstout; curo != 0; curo = curo->nexto)
        process_var (curo);
}

void process_var (varo curo)
{// process a single variable - update it and then execute each of the function in list of dependencies
funp curf;
    if (curo->ivarb->current_value == curo->ivarb->next_value) /* no change - nothing to do */ return;
    curo->ivarb->current_value = curo->ivarb->next_value; /* update the value */
    // then work through each of its dependant functions to force recalculation
    for (curf = curo->ivarb->frstf; curf != 0; curf = curf->next)
        process_func (curf->depfun);
}

It couldn't be much simpler!

 

Some of the key internal relationships

Boxes and lines

The hierarchy of boxes

Functions and variables

 
  
 

    More information on the:

    and for the originators of deltaFSD:

 

deltaFSD is now a Sourceforge project

 
  At 06:06:45 06/24/17© Copyright DeDf 2003 - 2010Base: progman
File: progman.txt
Side: gifs/deltafsdside.gif