The Code Unit

 

The structure of the Code Unit is based on the simulation of electrical circuits

Where we have an interface formed of circuits, switches, branches & resistances.

 

 

Define The Resistance?

 

The Resistance is a group of instructions packed together

The Resistance is Replacement for Functions in Structure Programming.

The Resistance is Replacement for Methods in Object Oriented Programming.

The Resistance is Replacement for Events in Event-Driven Programming.

The Resistance lies in a branch (alone or beside other resistances)

  

   

 

Server Modes of operation

 

*      Server FireON run the Code Unit Circuits from the top to down or starting from the main circuit (if you selected a circuit as main circuit) to down (the last circuit in the code unit) then from the top (the first circuit in the code unit) to the main circuit (the selected one) and so on.

*      Call the main resistance of the code unit where the main resistance can be considered as the main function of the server.

 

With respect to the mode (Server FireON), if the Switch of the branch is closed (ON) then the resistances inside the branch will be invoked (Run), but if the switch is open (OFF) then the resistances inside the branch will not be invoked (Not Run)

 

Circuit Switch determines to invoke Circuit Branches or not while Branch Switch determines to invoke Branch Resistance or not.

 

The Branch is a switch + container for one or group of Resistances where Branch Switch determines to invoke Branch Resistances or not

 For Example:

*       Switch On      à Invoke Branch Resistances

*       Switch Off     à Ignore Branch Resistances

 

The Circuit is a Main switch + container for one or group of Branches where The Main Switch determines to invoke Branches or not.

For Example:

*       Main Switch On      à Invoke Branches

*       Main Switch Off     à Ignore Branches

 

With respect to the second mode (Main Resistance), the main resistance is invoked (RUN) at the start of the application without caring with the branch switch at all.

 

Resistance Polymorphism

 

  Because each circuit may have more than one branch, and each branch carry it's

  Own name, then we can have resistances with the same name but lies in different

  Branches for example

*       Resistance Start à inside the branch B1

*       Resistance Start à inside the branch B2

 

Branch Polymorphism

 

  Because the code unit may have more than one circuit, and each circuit carry it's

  Own name, then we can have multiple branches with the same name but lies in

  Different Circuits for example

*       Branch B1 à in Circuit C1

*       Branch B1 à in Circuit C2

 

 

 

 

Example – The Main Resistance of the server (mode of operation)

 

In this example, we will create new application by following the next steps

 

*      Create server file (*.SSF)

*      Create circuit

*      Create branch

*      Create resistance

*      Write resistance code (OR extract it from a goal)

*      Set operation mode of the server to be (call main resistance)

*      Determine server name & Eigen value

*      Build and Run the application

 

 

 

 

 

Simply we have

 

Server Name

Test

Server Type

Salve Server

Eigen Value

000

User Interface

Console

Operation Mode

Call Main Resistance

Main Resistance

Circuits\Main\Main\Main

 

 

         The code of Resistance: Circuits\Main\Main\Main

 

 

? " Hello world"        && Print message on screen (new line)

Inkey(3)                     && Wait three seconds

 

 

Instead of writing the code of the resistance, you can work without coding and you have two options

 

1-     You can create a goal then extract the code from it using the code extractor application then put the extracted code in the resistance code.

2-     You can create a goal and set it to override the resistance code automatically.

 

We are going to see example on the second solution (Goal override Resistance)

At first to create new goal, from (RPWI) popup, select (New Goal).

Determine the goal name and set it to override the main resistance

 

(RPWI) Popup – (New Goal) Item

 

 Create New Goal Override Resistance

 

The Goal Designer

 

Create Step (The First Step)

 

Final Steps Tree

 

 

Remove the resistance code (Don’t write resistance code)

 

The Final Application

 

Example – Server FireON (mode of operation)

 

Be sure to set the switch of the circuit to be ON

And the switch of the branch to be ON

 

 

[1] Select (Main) Circuit

[2] (Code) Popup – (Edit Circuit) Item

[3] Set main switch (ON)

[4] Select (Main) Branch

[5] (Code) Popup – (Edit Branch) Item

[6] Set branch switch (ON)

 

Then select (Server FireON) as the mode of operation of the server

Then build and run the application.

 

 

 

 

Now you know how to use the two modes of operations (Main Resistance) & (Server FireON) of the server and you know also how to create a goal override  a resistance and this knowledge is required to use the power of the code unit where you can

*      Call/Add/Remove resistance

*      Set Circuit/Branch switch ON/OFF

*      Use resistance as event by adding if statement before the code of the resistance

 

Domain (Code Unit)