codemorphis.com Forum Index codemorphis.com
Software development: pure and simple.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Programming Tip #7: Data Flow

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum
View previous topic :: View next topic  
Author Message
CodeMorphis



Joined: 02 Dec 2003
Posts: 252

PostPosted: Thu Apr 01, 2004 8:13 pm    Post subject: Programming Tip #7: Data Flow Reply with quote

Programming Tip #7: Data Flow

In this article, we take an in-depth look at how data flows in a Synopsis program. This article is supplemental information to the documentation in the Synopsis Help module.

There are essentially three different situations that we shall examine for data flow:

  1. Data flow involving process components.
  2. Data flow involving data components.
  3. Data flow involving the Nesting component.


1. Data flow involving process components

Suppose that we have the following program:



In this program, the Set Variable component simply takes the input value from its data port 0 and passes it through its output data port 0. Since output data port 0 of the Set Variable component is connected to the input data port 0 of the Console Print, the Console Print component will receive data from the Set Variable component. The Console Print component then just prints this data to the console output area of the Synopsis interface.

NOTE: Input ports are always located at the top of Synopsis components while output ports are always located at the bottom.

Both the Set Variable and the Console Print components are process components. This is indicated by the presence of the red process ports on the components. A process component can receive data through its input data ports (the blue ports), perform some service on the data and then can pass data through its output data ports. The order in which process components are executed is determined by the sequence of process connections, defined by the red lines. Process control always starts at the Start component and then follows the red process connections.

So the things that a process component will perform are in the following order:

  1. Take the data currently stored in its input data ports.
  2. Perform the required service. The nature of this service depends on the type of component.
  3. Pass any required data through its output data ports.


In our program, when the Set Variable is executed it takes whatever data that it has in its input data port 0 and then performs its service, which simply entails passing that data through its output data port 0.

When data is passed through the output data port interface, the data arrives to all connected input data ports. In our program above, after the Set Variable has finished executing, its output data will arrive at the input data port 0 of the Console Print component. The Console Print component is subsequently executed and it takes the data in its input data port 0 and prints it to the console output area. It then sends a carbon copy of what it outputed to its output data port 0. Since this output data port is not connected to anything, no data is transmitted, however, if you view the output data port (by double clicking on it), you will see the output data there.

Key Idea for Process Components: For a process component, data is acted upon when the process component receives program control. After the component finishes its job, it can pass data through its output data ports and this data is transmitted to whatever components in the program that may require the data.


2. Data flow involving the data components

Now consider the following program:



Here we have slightly modified our program with the introduction of a Variable component. The Variable component is a data component, not a process component. This is indicated by the absence of any red process ports.

We have connected the output data port 0 of the Set Variable component to the input data port 0 of the Variable component. We have also connected the output data port 0 of the Variable component to the input data port 0 of the Console Print component. When the Set Variable component has finished its work, it will pass its data to the Variable component. The Variable component, however, will immediately pass data from its input data port to its output data port.

Key Idea for Data Components: As a data component has no process ports, it immediately transmits data from its input data interface to its output data interface and from there, to any other connected components.

The Variable component is useful since it is capable of "remembering" data and can be used to store and retrieve data that can be immediately transmitted to other program components, without the need for acquisition of program control.

In our example program, when the Set Variable pushes data through its output interface, the data will immediately be passed through the Variable component and on to the input interface of the connected Console Print component. The Console Print component then receives program control and outputs the data to the console output area.


3. Data flow involving the Nesting component

In the program example below, we have modified the first example by nesting the Console Print component. Please refer to the Synopsis Help module for a treatment on nesting.



If we descend into the Nesting component we can see the nested Console Print component and the interior and exterior interfaces of the Nesting component:



Note that the black rectangle divides each port into an exterior interface and an interior interface. The exterior interface is that to which other components can connect while the interior interface is that to which nested components can interface to receive data and process control from the outside.

Note that at nesting level 0 (the level at which the Start component resides), the Set Variable's output process and data ports are connected to the Nesting component's exterior interface.

When we are at nesting level 1 (inside the Nesting component, as depicted in the diagram above), we see that the Console Print component's input process and data ports are connected to the Nesting component's interior interface.

Now, the Nesting component is a process component and behaves as we have described process components in section 1. However, because of the interior interface, it merits discussing what exactly goes on when a Nesting component receives data and process control.

After the Set Variable component transmits its data to the input data port on the Nesting component, the Nesting component is executed. Here is the order in which things happen inside the Nesting component:


  1. Data currently stored in the Nesting component's input data ports are transmitted to all components connected to the interior input data interface.
  2. Process control is passed to the component inside the Nesting component that is connected to the interior input process interface.
  3. Process control and data propagation is handled according to previous rules for the components inside the Nesting component.
  4. When process control arrives at the interior output process interface of the Nesting component, data is propagated through the Nesting component's output data interface. Then process control leaves the Nesting component and the component that is connected to the Nesting component's exterior process interface is executed.


Thus, in our example, the Set Variable component passes its data to the Nesting component's input data port 0. Then the Nesting component is executed. This causes the data currently stored in the Nesting component's input data port 0 to be transmitted to the nested Console Print component. Next, the Console Print component is executed. The Console Print component sends its output data to the Nesting component's output data port. After this, the Nesting component is again executed. This time, the Nesting component transmits the data currently stored in its output data interface to any components connected on the outside (in this case, none). Finally, the Nesting component passes process control to the outside (in our example, there is no process component connected to the output process port of the Nesting component, so the program will terminate normally).
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    codemorphis.com Forum Index -> Visual Programming Forum All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group