ooPIC Logo

ooPIC Programmer's Guide

 Chapter 8 - Virtual Circuits

Back to top of pageWhat is a Virtual Circuit?
 A Virtual Circuit is a set of objects that interact with each other in the background.

A Virtual Circuit can be comprised of any number of any kind of Objects so long as at least one Processing Object is included. Each individual part of the Virtual Circuit can be manipulated or evaluated by the program providing total computerized control of the entire circuit.

Back to top of pageHow are Virtual Circuits made?
 Virtual Circuits are created by programmatically linking together a set of Objects in the same methodology as one would physically link together a set of electronic components to assemble an electronic circuit. The application's program can assemble, disassemble, or reconfigure the structure of a Virtual Circuit at any time during the execution of the program.

The Objects that are used to link together the Virtual Circuits retrieve their input values and store their output values in the properties of other Objects. These Objects are referred to as Processing Objects. These Objects encapsulate various mathematical, logical and other data manipulation functions. When they are linked to other Objects, their encapsulated function is performed on the "Linked" Objects. The Link that specifies what Objects are used, is done with a special Object Property called a Pointer.

In order for a Processing type Object to have value for its operation, its pointer properties must be linked.

Back to top of pageLinking Objects
 To programmatically link together the Objects of a Virtual Circuit, The Link method is used in conjunction with the Objects and properties that are to be connected. This method creates a link between a two Objects. Once a link is created, the linking Object will use the linked property's value.

While other methods are used to instruct Objects to perform operations, the Link method is used to instruct a Pointer to point to another Object's property. The syntax for the Link method is as follows;

baseobject.pointerproperty.Link(linkobject.propertytolink)

The Link method is only available on properties that are designated as a Pointer.

Back to top of pagePointer Properties
 A Pointer is an Object's Property that tells that Object where to find information in another Object. It does not store the information itself, instead each time the information is needed, the Pointer is used to identify where to retrieve the information from or store the information to.  

The Object's property that a Pointer is linked to can be changed at any time during the execution of the applications program.

All of the predefined ooPIC objects use two types of Pointers.

  1. A Pointer to an oValue Object.  Typically the target Object's Default property is an oValue property or has an oValue property in its default path.  These type of pointers are referred to as an oValue Pointer (example: oBus has oValue pointers.  One for its input and one for its output.)
  2. A Pointer to an oLogic Object.  Often, the target Object will have a number of oLogic properties.  These type of pointers are referred to as an oLogic Pointer. (example: oGate has oLogic Pointers).

When Linking Pointer Properties to Objects properties, the Pointer's type and the Object property's type must always match.

Back to top of pageoValue Pointers
 An oValue Pointer is used to link a Processing Object to the oValue Property of another Object which is usually the default property. When linking a Pointer of this type, The argument that is expected inside a set of parentheses after the link method is the Target Object's Name plus a period and the Target Object's oValue Property or just the Target Object's Name.

Note that Default Property of an Object is the property that will be used if none is specified when referring to that Object. To find out which Object's properties are Default Properties, refer to the Object's Technical Information where each property's Data-Type is specified

The following example shows the oValue Pointers of the oMath Object being linked to the default properties of two other Objects.

Visual Basic & BASIC syntax C & Java Syntax
Dim a As New oMath
Dim b As New oByte
Dim c As New oDIO8

Sub Main()
  a.Input1.Link(b.Value)
  a.Input2.Link(c.State)
End Sub
oMath a = New oMath;
oByte b = New oByte;
oDIO8 c = New oDIO8;

Void Main(Void){
  a.Input1.Link(b.Value);
  a.Input2.Link(c.State);
}

Some objects have a the oValue Object as a default property.  These objects can be pointed to by the oValue pointer as well. The following table lists various objects that have the oValue Object as the default property and therefore can be pointed to with an oValue pointer.  It should also be noted that any object that has the oValue Object anywhere in its default property search path can be pointed to by the oValue pointer as well.  for example: oDCmotor.Speed.oValue
 ObjectDescriptionA1A2B1B2C1
oValueAn Object used for virtual circuits.xxxxx
oBitManages a 1-bit value with a range of 0 to 1.xxxxx
oNibManages a 4-bit value with a range of 0 to 15.xxxxx
oNibXManages a 4-bit signed value with a range of -8 to +7.x
oByteManages a 8-bit value with a range of 0 to 255.xxxxx
oCharManages a 8-bit signed value with a range of -128 to -127.xxx
oWordManages a 16-bit value with a range of 0 to 65,535.xxxxx
oIntManages a 16-bit signed value with a range of -32,768 to +32,767.xxx
oBuffer(1-32)32 Objects that Manage various sized data-buffer/string variable.xxxxx
oDistanceManages a URCP Distance value.xxx
oHeadingManages a URCP Heading value.xxx
oPowerManages a URCP Power value.xxx

Back to top of pageoLogic Pointers
 A oLogic pointer is used to link a Processing Object to a oLogic Property of another Object.  When linking a Pointer of this type, The argument that is expected inside a set of parentheses after the link method is the Target Object's Name plus a period and the desired Target Object's oLogic Property.  

A oLogic Property is a property that consists of 1-bit. To find out which Object's properties are oLogic Properties, refer to the Object's Technical Information where each property's Data-Type is specified. 

The following example shows the oLogic pointers of the oGate Object being linked to the oLogic properties of two other Objects.

Visual Basic & BASIC syntax C & Java Syntax
Dim a As New oGate
Dim b As New oByte
Dim c As New oDIO1

Sub Main()
  a.Input1.Link(b.NonZero)
  a.Output.Link(c.State)
End Sub
oGate a = New oGate;
oByte b = New oByte;
oDIO1 c = New oDIO1;

Void Main(Void){
  a.Input1.Link(b.NonZero);
  a.Output.Link(c.State);
}

Some objects have a the oLogic Object as a default property.  These objects can be pointed to by the oLogic pointer as well.  The following table lists various objects that have the oLogic Object as the default property and therefore can be pointed to with an oLogic pointer.
 ObjectDescriptionA1A2B1B2C1
oLogicA Boolean Object used for virtual circuits.xxxxx
oOperateA switch that selects one of 2 options considered to be On and Off.xxxxx
oSelect0To1LA switch that selects one of 2 options and can be pointed to by a Virtual Circuit.xxxxx
oBitManages a 1-bit value with a range of 0 to 1.

Note: The oBit Object's default property is an oValue Object, not an oLogic value.  But to maintain backwards compatibility, if a oLogic pointer is used to point to the oBit Object or the oBit Object's Value property, the compiler will automatically redirect the pointer automatically to the Data property and no error will occur.

xxxxx


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.