Home | Products | Services | Support | Download | Order | Corporate | Site Map

Up
Get Started
Applications
Utilities

Utility Programs for SansGUI

The following utility programs require the SansGUI Run-Time Environment.  You can use the SansGUI Demonstration Edition which contains the run-time environment without file saving capability.  If you would like to save your work, you need to purchase the low-cost SansGUI Run-Time Environment.  The programs listed here are not included in the SansGUI software distribution.  You need to download them separately.  We take an open source approach in dealing with these utility programs.  You are encouraged to look into the source and customize the capability as you like.  See the license terms in the documentation of each program for more details.

  • Calc - Visual Calculator for SansGUI: demonstrates how to program basic mathematical calculations in visual forms -- calculation flow diagrams.  Using this utility, SansGUI users can draw mathematical equations with visual expressions, perform calculations, and plot data curves.  Some application examples are shown.

  • MIDIplay - MIDI Player for SansGUI: demonstrates how to implement an external process simulator to work in concert with an in-process simulator and chart data dynamically.  In this example, the external process simulator is a MIDI player that sends MIDI streams to the Windows multimedia facility for music playing while the in-process simulator fetches the MIDI event data and communicates with SansGUI for dynamic data display and charting.

  • Unit - Unit Conversion for SansGUI: converts numerical values from one measuring unit to another.  Based on IEEE/ASTM SI-10 1997 Standard, this program covers most of the SI units and many other non-SI units.  It includes many advanced features not available in other unit conversion programs.


Calc -- Visual Calculator for SansGUI

  • Description

    Visual Calculator for SansGUI is a programmable calculator that acts on mathematical equations expressed in visual forms.  This calculator has some basic arithmetic operators and functions implemented in component classes.  It differs from regular calculators or spreadsheet programs in that the mathematical expressions are drawn as visual diagrams.  With this, the relationship of operators and operands can be visualized.

  • Demonstration

    Click on a picture to obtain its full size screen shot.

This simple example shows the graphical expression of

D = (A + B + C) / sqrt(A + B + C)

The calculated result is shown in the bottom pane.

This example finds the roots of quadratic equations aX2 + bX + c = 0 by calculating:

(-b ± sqrt(b2 - 4ac)) / 2a

This example demonstrates the cubic equation

Y = aX3 + bX2 + cX + d

The model has a loop to guide the simulation through a range of X values with a specified step size.

The input values of a, b, c, d, and the initial X value can be entered through a Grid View in the right pane.  The simulation results are displayed in the Result View in the bottom pane.  In this example, we made X start from -5 with a step size of 0.1.  The simulation ran 100 cycles (steps).
Both X and Y values are logged and plotted.  We can see that there are three roots of X (when Y = 0) in this curve.  The coordinates in the upper left corner indicates where the mouse pointer is located, using the chart's coordinate system.
A Sine Wave Generator with a damping factor was created to show a little bit more elaborated programming in the model building block.  We simply sent the generated output to a variable and then plotted its values.  The angle can be entered and viewed in a unit specified by the user (degree in this case).
A damping factor of 0.5 was entered to generate a damped sine wave, as shown in the picture.
This figure shows the new dynamic charting feature in SansGUI version 1.1.  All existing SansGUI simulators have this capability.  No extra programming is needed to take advantage of the dynamic display.
  • Details

    The Visual Calculator implements addition, subtraction, multiplication, division, and negation operators in generic (no class attribute) component classes.  They simply take values from the input links and send the resulting value to the output links.  Negation operator takes only one input link while others take multiple input links.  In most cases, Port 1 is used to connect input links and Port 2 is for output links.  In the division operator, however, we have to differentiate the dividend from divisors; therefore, a special Port 0 is defined for the unique dividend and Port 1 are reserved for possibly multiple divisors.  We use SansGUI's Port Definition facility to specify these rules.  A similar rule applies to the subtraction operator.

    A SquareRoot function is implemented similar to the negation operator, which takes only one input value.  A SineGen class is created for pumping out damped sine wave data.  Finally, a variable component allows the user to store values, used mostly as sources or sinks in calculating flow diagrams.

  • Code

    The implementation of this example can be found in the evaluation functions of eight classes: Base.Add, Base.Subtract, Base.Multiply, Base.Divide, Base.Negate, Base.SquareRoot, Base.SineGen, and Base.Variable.  The Base.Variable class also contains an Initialization function to deposit its initial value to the input link so that the value will not be wiped out at the beginning of the evaluation cycle.  Click on the following links to see all the necessary code for this project.  The C/C++ and Fortran implementations are independent; only one of them is required.

  • Download

    Download Visual Calculator for SansGUI.  You need the SansGUI Run-Time Environment to run this utility program.  A free SansGUI Demonstration Edition is available in the same download area.

  • Credit

    This example is developed by the SansGUI Development Team at ProtoDesign, Inc.


MIDIplay -- MIDI Player for SansGUI

  • Description

    MIDI Player for SansGUI has been created to demonstrate a couple of new SansGUI version 1.1 features, which 1) allow an external process simulator to work in concert with an in-process simulator, and 2) allow the users to chart data dynamically.  In this example, the external process simulator is a console-based Musical Instrument Digital Interface, or MIDI, player that feeds MIDI streams into the Windows multimedia facility and displays MIDI events in the console.  While processing the MIDI events, it also writes the MIDI channel numbers and data to a shared memory area (as two integers) for the in-process simulator to read.  Acting as a monitor, the in-process simulator distributes the data to the corresponding channel components (parts), based on the user selected channel numbers associated with these components.  The data in the channel components are then plotted using the dynamic charting feature in SansGUI without any extra programming effort from the simulation developer's side.

  • Demonstration

    Click on a picture to obtain its full size screen shot.

The path of the MIDI file to be played, a unique shared memory name, and sampling intervals are entered via a MIDI reference object.  The parts, Channel-0 and Channel-1 are created to fetch the MIDI event data according to their channel numbers.  More parts can be created when there are more channels.
The MIDI Player is a console-based program that is invoked via the Run External button in the Run toolbar.  A command window is opened to show the output from the player.  The player also writes MIDI event data to a shared memory area.
While the MIDI Player is running with the music playing in the background, the In-Process simulator is invoked to fetch the MIDI event data and distribute the data to the channels.  The data are displayed in the bottom pane and charted dynamically.
The architecture of the MIDI Player.  Invoked by a command script, the External Process simulator (.EXE) reads in a Model File to know where the MIDI file is located.  It sends the MIDI data stream to the Windows multimedia facility and writes MIDI event data to a shared memory area for the In-Process simulator (.DLL) to communicate with SansGUI.
The intrinsic attributes in the external process simulation control class (XProc).  A simulation developer creates a subclass out of the XProc intrinsic class to inherit all the attributes from it.  New attributes can be added to the subclass when needed.
The intrinsic attributes in the in-process simulation control class (Cycle).  A simulation developer creates a subclass out of the Cycle intrinsic class and extend the attribute list, when needed.  In MIDI Player, the control parameters are defined in a reference class, to be shared by both In-Process and External Process simulators.
  • Details

    Communication between the external MIDI player and the in-process monitor is asynchronous, meaning that the former keeps pumping out data (a producer) while the latter reads the data (a consumer) with a user-definable interval without the knowledge of the former.  You can implement synchronous inter-process communication if the nature of your application requires it.

    Although this demonstration program plays MIDI music, please be reminded that the external process simulator can be any console-based program, an application with its own GUI, a control process, or a simulated process of a real machine, written in any programming language or development environment.  It may even be a remote process running across the wire.

  • Code

    As the above architectural diagram shows, the implementation of this example is split into two modules: an external process simulator and an in-process simulator.

  • Download

    Download MIDI Player for SansGUI.  You need the SansGUI Run-Time Environment to run this utility program.  A free SansGUI Demonstration Edition is available in the same download area.

  • Credit

    This example is developed by the SansGUI Development Team at ProtoDesign, Inc.  The MIDI playing mechanism uses a CMIDI class originally developed by Jörg König.  We thank him for giving us the permission to use and distribute his MIDI.h and MIDI.cpp files.


Unit -- Unit Conversion for SansGUI

  • Description

    Unit Conversion for SansGUI is a powerful utility program that converts numerical values from one measuring unit to another.  Based on IEEE/ASTM SI-10 1997 Standard, this program covers most of the SI units and many other non-SI units.  Advanced features unique to Unit Conversion for SansGUI are:

    • Extensibility: Users can extend unit tables to include any desired measuring units not defined in the distribution.  In addition to built-in unit tables, there are five user definable unit tables for creating new dimensions of measurement.  Dynamic unit conversion tables, such as international currency exchange rates, can also be implemented easily.

    • Versatility: Users can covert a single value, an array (vector) of Values to five different units to be displayed in a table, or a whole resizable matrix of data in one operation.

    • Programmability: Users can populate the data array (vector) or matrix programmatically using Microsoft Visual C++ or Compaq Visual Fortran.  Programming examples in both languages are included.

  • Demonstration

    Click on a picture to obtain its full size screen shot.

The units are organized into nine categories, including those defined in the tables of IEEE/ASTM SI-10 1997 Standard.
Inside each unit category, the user can choose to convert a single value, an array (vector) of values, or a multi-dimensional (up to 3D) matrix of values.
An array (vector) of data has been converted to five different user selectable units in a table.  The Check Data button is used to copy the data from the Data column to the rest of the columns.  In addition to entering the data manually, the Load Data button can be programmed to populate the data array.
Each unit dimension is implemented as a unit object that contains a user extensible conversion table.
The unit conversion table in a unit object can be extended by the user to include the units not defined in the distribution.
  • Details

    Unit Conversion for SansGUI is a very small "simulator" program that is installed and run within the SansGUI Modeling and Simulation Environment.  Although very small in its implementation, this utility program fully exploits the unit conversion facility and features built into the SansGUI Run-Time Environment.  Because Unit Conversion for SansGUI is designed to handle single value, vector, and matrix unit conversion in one operation, we created Collection, Table, Matrix classes for all the unit dimensions in addition to the unit objects in its Schema Definition.

    • Collection Reference Classes: implement single value unit conversion for all the unit dimensions in a single unit category; therefore, each unit category occupies one class derived from class Collection.

    • Table Reference Classes: implement 1-dimensional array (vector) unit conversion.  Each subclass represents on unit dimension and has 6 non-intrinsic attributes, one for each data column.  The first column is of in/out scope to allow users to enter the values.  The other 5 columns are output only.  The values are copied from the first column when the user clicks on the Check Data button.

    • Matrix Reference Classes: implement matrix unit conversion.  Each subclass represents one unit dimension and has exactly one attribute that uses the units in the unit dimension.

    • Component Classes: implement switchboards for all unit categories.  In each component class, a set of object references are created to let user select and jump to the appropriate reference class easily.

  • Code

    The only code needed is to copy the data vector from the user data column to the other five target columns in class Table.Vector.<UnitDimension>.  Because the copy operations of all the <UnitDimension>s are the same, we created the intermediate class Vector to implement the common copying function.  All the <UnitDimension> classes simply call the function in the base class.

  • Download

    Download Unit Conversion for SansGUI.  You need the SansGUI Run-Time Environment to run this utility program.  A free SansGUI Demonstration Edition is available in the same download area.

  • Credit

    This utility program is developed by the SansGUI Development Team at ProtoDesign, Inc.

                                        Main Product Page

 
Home | Products | Services | Support | Download | Order | Corporate | Site Map

If you have any comments or questions regarding this web site, please contact  webmaster@protodesign-inc.com.

Copyright © 2000-2010 ProtoDesign, Inc.  All rights reserved.

Last Updated: Sunday, November 07, 2010