Usage

Establishing connection

First declare a web services FUB of type A3brWebService called A3brWebService_0. Then call the FUB cyclically until the ‘connected’ output goes TRUE: this means that the initial authentication with the server has succeeded, and that other blocks from the library can now be called using the ‘ident’ output from this block.

void _INIT ProgramInit(void)
{
	A3brWebService_0.enable = 1;
	strcpy(A3brWebService_0.parameters.hostname, "127.0.0.1");
	A3brWebService_0.parameters.port = 80;
	strcpy(A3brWebService_0.parameters.username, "Default User");
	strcpy(A3brWebService_0.parameters.password, "robotics");    
}

void _CYCLIC ProgramCyclic(void)
{
	A3brWebService(&A3brWebService_0);
	if(A3brWebService_0.connected){
		// Can now call other A3br blocks using A3brWebService_0.ident
	}
}

Reading IO

Declare a FUB of type A3brGetIO called A3brGetIO_0, and declare a STRING called IOPoint. This STRING must contain the path to the IO signal that needs to be read from the IRC. It will have the format “{network}/{unit}/{signal}”. Possible values for {network} are Local, EtherNetIP, etc. Possible values for {unit} are DRV_1, PANEL, DEVICE, etc. Possible values for {signal} depend entirely on how the individual IO signals are named on the IRC. This STRING should be of length A3BR_IO_STR_LEN.

Example code below will get the new value of “EtherNetIP/Device/doName” every time A3brGetIO_0.execute is set TRUE. The ‘done’ output will get set to TRUE once the read is successful, and the ‘value’ output will contain the read value.

void _INIT ProgramInit(void)
{
	strcpy(IOPoint, "EtherNetIP/Device/doName");
}

void _CYCLIC ProgramCyclic(void)
{
	A3brGetIO_0.ident = A3brWebService_0.ident;
	A3brGetIO_0.pSignal = &IOPoint;
	A3brGetIO(&A3brGetIO_0);
	A3brGetIO_0.execute = 0;

	if(A3brGetIO_0.done){
		// You can now use A3brGetIO_0.value. 
	}
}

Setting IO

Declare a FUB of type A3brSetIO called A3brSetIO_0, and declare a STRING called IOPoint. This STRING must contain the path to the IO signal that needs to be written to the IRC. It will have the format “{network}/{unit}/{signal}”. Possible values for {network} are Local, EtherNetIP, etc. Possible values for {unit} are DRV_1, PANEL, DEVICE, etc. Possible values for {signal} depend entirely on how the individual IO signals are named on the IRC. This STRING should be of length A3BR_IO_STR_LEN. Next, assign the desired write value to the ‘value’ input.

Example code below will set the value of “EtherNetIP/Device/doName” to A3brSetIO_0.value every time A3brSetIO_0.execute is set TRUE. The ‘done’ output will get set to TRUE once the write is successful.

void _INIT ProgramInit(void)
{
	strcpy(IOPoint, "EtherNetIP/Device/doName");
	A3brSetIO_0.value = 1;
}

void _CYCLIC ProgramCyclic(void)
{
	A3brSetIO_0.ident = A3brWebService_0.ident;
	A3brSetIO_0.pSignal = &IOPoint;
	A3brSetIO(&A3brSetIO_0);
	A3brSetIO_0.execute = 0;

	if(A3brSetIO_0.done){
		// The write operation has completed successfully. 
	}
}

IO Watch

Declare a FUB of type A3brIOWatch called A3brIOWatch_0. Declare an array of STRINGs each containing the path to an IRC IO signal (see A3brSetIO and A3brGetIO examples above for detailed STRING syntax). Declare an array of INTs where the values of the IO points will be mapped.

Example code below will connect two IO signals to the watch block. When the value is changed on the PLC, it will get updated on the IRC, and when the IRC value changes, it will get updated on the PLC.

void _INIT ProgramInit(void)
{
	strcpy(IOPoint[0], "EtherNetIP/Device/do1Name");
	strcpy(IOPoint[1], "EtherNetIP/Device/do2Name");
	A3brIOWatch_0.pSignals = ADR(IOPoint);
	A3brIOWatch_0.pValues = ADR(IOValue);
	A3brIOWatch_0.numSignals = 2;
	A3brIOWatch_0.maxCycleReads = 0;
	A3brIOWatch_0.refresh = T#1000ms;
	A3brIOWatch_0.enable = 1;
}

void _CYCLIC ProgramCyclic(void)
{
	A3brIOWatch_0.ident:= A3brWebService_0.ident;
	A3brIOWatch_0();
}

Reading RAPID data symbols

Declare a FUB of type A3brGetSymbol called A3brGetSymbol_0, and declare a STRING called SymbolName. This STRING must contain the path to the data symbol that needs to be read from the IRC. The path can be found in the “Source” column of the RAPID watch window for a given data symbol. It will have the format “RAPID/{task}/{module}/{symbol}”. {task} should contain the name of the RAPID task (i.e. T_ROB1). {module} should contain the name of the RAPID program module or system module where the symbol is declared. {symbol} will contain the name of the symbol. This STRING should be of length A3BR_SYMBOL_STR_LEN. In addition to the STRING, declare a local variable called LocalTestVar with the same data type as the RAPID symbol (either a STRING or an INT).

Example code below will get the new value of “RAPID/T_ROB1/TestModule/TestInteger” every time A3brGetSymbol_0.execute is set TRUE. The ‘done’ output will get set to TRUE once the read is successful.

void _INIT ProgramInit(void)
{
	strcpy(SymbolName, "RAPID/T_ROB1/TestModule/TestInteger");
	A3brGetSymbol_0.pValue = &LocalTestVar;
	A3brGetSymbol_0.szValue = sizeof(LocalTestVar);
	A3brGetSymbol_0.typeValue = A3BR_VAR_TYPE_INT;
}

void _CYCLIC ProgramCyclic(void)
{
	A3brGetSymbol_0.ident = A3brWebService_0.ident;
	A3brGetSymbol_0.pSignal = &SymbolName;
	A3brGetSymbol(&A3brGetSymbol_0);
	A3brGetSymbol_0.execute = 0;

	if(A3brGetSymbol_0.done){
		// You can now use LocalTestVar. 
	}
}

Setting RAPID data symbols

Declare a FUB of type A3brSetSymbol called A3brSetSymbol_0, and declare a STRING called SymbolName. This STRING must contain the path to the data symbol that needs to be written to the IRC. The path can be found in the “Source” column of the RAPID watch window for a given data symbol. It will have the format “RAPID/{task}/{module}/{symbol}”. {task} should contain the name of the RAPID task (i.e. T_ROB1). {module} should contain the name of the RAPID program module or system module where the symbol is declared. {symbol} will contain the name of the symbol. This STRING should be of length A3BR_SYMBOL_STR_LEN. In addition to the STRING, declare a local variable called LocalTestVar with the same data type as the RAPID symbol (either a STRING or an INT).

Example code below will set a new value for “RAPID/T_ROB1/TestModule/TestInteger” every time A3brSetSymbol_0.execute is set TRUE. The ‘done’ output will get set to TRUE once the write is successful.

void _INIT ProgramInit(void)
{
	strcpy(SymbolName, "RAPID/T_ROB1/TestModule/TestInteger");
	A3brSetSymbol_0.pValue = &LocalTestVar;
	A3brSetSymbol_0.szValue = sizeof(LocalTestVar);
	A3brSetSymbol_0.typeValue = A3BR_VAR_TYPE_INT;

	LocalTestVar = 17;
}

void _CYCLIC ProgramCyclic(void)
{
	A3brSetSymbol_0.ident = A3brWebService_0.ident;
	A3brSetSymbol_0.pSignal = &SymbolName;
	A3brSetSymbol(&A3brSetSymbol_0);
	A3brSetSymbol_0.execute = 0;

	if(A3brSetSymbol_0.done){
		// The RAPID symbol on the IRC now has the updated value. 
	}
}

Reading the state of the IRC

Declare a FUB of type A3brGetState called A3brGetState_0.

Example code below retrieves the current state information every time execute is set to TRUE.

void _INIT ProgramInit(void)
{

}

void _CYCLIC ProgramCyclic(void)
{
	A3brGetState_0.ident = A3brWebService_0.ident;
	A3brGetState(&A3brGetState_0);
	A3brGetState_0.execute = 0;

	if(A3brGetState_0.done){
		// State information is now available on output of FUB.
	}
}

Controlling the state of the IRC

Declare a FUB of type A3brControl called A3brControl_0.

Example code below sets the controller state to “power on”.

void _INIT ProgramInit(void)
{

}

void _CYCLIC ProgramCyclic(void)
{
	A3brControl_0.ident = A3brWebService_0.ident;
	A3brControl_0.power = 1;
	A3brControl(&A3brControl_0);

	if(A3brControl_0.done){
		// Commanded operation has succeeded. 
	}
}