TcAdsClient.InvokeRpcMethod Method (ITcAdsSymbol, Int32, .Object.)
Invokes the specified RPC Method
Namespace: TwinCAT.Ads
Assembly: TwinCAT.Ads (in TwinCAT.Ads.dll)
Version: 4.3.0.0
Syntax
C#
public Object InvokeRpcMethod(
ITcAdsSymbol symbol,
int methodId,
Object[] parameters
)
VB
Public Function InvokeRpcMethod (
symbol As ITcAdsSymbol,
methodId As Integer,
parameters As Object()
) As Object
Parameters
symbol |
Type: TwinCAT.Ads.ITcAdsSymbol |
methodId |
Type: System.Int32 |
parameters |
Type: .System.Object. |
Return Value
Type: Object
System.Object.
Examples
The following sample shows how to call (Remote Procedures / Methods) within the PLC.
Dynamic Tree Mode
namespace Sample
{
using System;
using System.Diagnostics;
using TwinCAT.Ads;
using TwinCAT.TypeSystem;
class RpcCallV1Program
{
/// <summary>
/// Defines the entry point of the application.
/// </summary>
/// <param name="args">The arguments.</param>
static void Main(string[] args)
{
//Parse the AmsAddress from command-line arguments
AmsAddress address = ArgParser.Parse(args);
// Create the ADS Client
using (TcAdsClient client = new TcAdsClient())
{
// Establish Connection
client.Connect(address);
// Call a Method that has the following signature (within MAIN Program)
/* {attribute 'TcRpcEnable'}
METHOD PUBLIC M_Add : INT
VAR_INPUT
i1 : INT := 0;
i2 : INT := 0;
END_VAR
*/
short result = (short)client.InvokeRpcMethod("MAIN", "M_Add", new object[] {(short)1, (short)4});
// Call a Method that has no parameter and returns VOID
client.InvokeRpcMethod("MAIN", "M_Method1", new object[] {});
}
}
}
}