<< Prev        Next >>

ID : 6651

Standard Use

Process Flow

Providers are used in accordance with the flow shown in the diagram below.

Generate a provider object at the Connection step (A).

At the Operation step (B), the generated object properties and methods are used to access an external device, with repeated access possible until disconnection.

Perform the Disconnection step (C) after operation is complete. The generated object is deleted at this step.

The following section describes how to use providers with PacScript.

The following example describes how to acquire RC7M controller variables and specify settings using the NetwoRC provider.

Connection (A) with PacScript

Connect using the following procedure.

1. Prepare Variables to Retain the Object.

In order to perform operation using a provider, an object used for connection to each device and an object for executing provider functions are generated.

Refer to the respective provider user's manuals for details of the types of objects that exist and the types of functions that are executed.

In this example, a CaoController object required to connect to the RC7M controller and a CaoVariable object used to access variables are necessary.

The following example shows a code in PacScript.

	Dim g_ctrl as Object' CaoController object
	Dim g_val as Object	' CaoVariable object

2. Generate an Object for Connection to the Provider.

Set the provider name and parameter to generate the CaoController object. With the NetwoRC provider, specify the IP address of the controller to which the connection is to be established with an option character string.

The following example shows a code in PacScript.

	g_ctrl = cao.AddController("RC", "CaoProv.DENSO.NetwoRC",
			 "", "conn=eth:10.6.235.60")

In this example, the cao.AddController parameters are as follows, and the setting values will differ depending on the provider. Refer to the user's manual for each provider for details.

Parameter Meaning Value in This Example
Parameter 1 Controller name This is the name given for administrative purposes by the program creator.
Parameter 2 Provider name Describes the predetermined name for each provider. The provider name in this example is NetwoRC.
Parameter 3 Provider execution machine name This parameter is not used in this example.
Parameter 4 Option character string This differs for each provider. In this example, the communication format (Ethernet) and IP address have been specified.

3. Generate an Object for Operation.

Generate the CaoVariable object for the variables for which a connection is to be established. With the NetwoRC provider, generate the CaoVariable with the CaoController object method.

The following example shows the code used to generate a P type 10th variable object.

	g_val =  g_ctrl.AddVariable("P10", "")
Parameter Meaning Value in This Example
Parameter 1 Variable specification Specifies the variable name and number.
Parameter 2 Option character string This parameter is not used in this example.

Operation (B) with PacScript

Perform operation using the generated operation object properties and methods.

The example given in this section is used to describe how to acquire variable values and specify settings using the generated CaoVariable object.

The connected variable values can be acquired by referring to the CaoVariable object Value properties. Variable values can be set by entering them in the Value properties. A code example is given below.

	Dim vntPotision as Variant
	vntPotision = g_val.Value ' value acquisition
	g_val.Value = Array(50, 50, 50, 0, 0, 0, -1) ' value setting

Disconnection (C) with PacScript

Delete the generated object using the reverse of the procedure used for generation.

A code example is given below.

	g_ctrl.Variables.Remove g_val.Index
	g_val = Nothing
	cao.Controllers.Remove g_ctrl.Index
	g_ctrl = Nothing

Other Examples

The example given in this section is used to describe how to acquire RC7M controller variable values and specify settings using the NetwoRC provider, however, several other examples can be referenced by accessing the links below.

Format sample 1 In this example, the NetwoRC provider is used to start a PAC program.
Format sample 2 In this example, the NetwoRC provider is used to operate a robot.

Passing Objects to Other Programs

Prepare an argument for an object variable in the called side, then set the object variable name to the argument in the caller side.

'!TITLE "Pro01"
#include "Pro02.pcs"

Sub Main
	Dim Ctrl as Object
	Ctrl = cao.AddController("DS" "caoProv.DataStore", "", "")
	Call Pro02(Ctrl)

End Sub
'!TITLE "Pro02"
Sub Main(Byref Ctrl as Object)

	Dim Value as Object
	Value = Ctrl.AddVariable("@Version")

	PrintDBG Value

End Sub

ID : 6651

<< Prev        Next >>