 |
ooPIC Programmer's Guide
Chapter 8 - Virtual Circuits
|
|
|
|
What 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. |
How 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. |
Linking 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. |
Pointer 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.
- 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.)
- 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. |
oValue 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
| | Object | Description | A1 | A2 | B1 | B2 | C1 |
 | oValue | An Object used for virtual circuits. | x | x | x | x | x |
 | oBit | Manages a 1-bit value with a range of 0 to 1. | x | x | x | x | x |
 | oNib | Manages a 4-bit value with a range of 0 to 15. | x | x | x | x | x |
 | oNibX | Manages a 4-bit signed value with a range of -8 to +7. | x |
 | oByte | Manages a 8-bit value with a range of 0 to 255. | x | x | x | x | x |
 | oChar | Manages a 8-bit signed value with a range of -128 to -127. | x | x | x |
 | oWord | Manages a 16-bit value with a range of 0 to 65,535. | x | x | x | x | x |
 | oInt | Manages a 16-bit signed value with a range of -32,768 to +32,767. | x | x | x |
 | oBuffer(1-32) | 32 Objects that Manage various sized data-buffer/string variable. | x | x | x | x | x |
 | oDistance | Manages a URCP Distance value. | x | x | x |
 | oHeading | Manages a URCP Heading value. | x | x | x |
 | oPower | Manages a URCP Power value. | x | x | x |
|
oLogic 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.
|
|