Samples
TX100062 Version: 1.2
1bytefor"PlcVarBool",2bytesfor"PlcVarInt"and81bytesfor"PlcVarString"=84bytes
try
{
TcWebService.Read(szAmsNetId,iPort,iIndexGroup,0,84,outabDataBuffer);
//Convertsthefirstbyteofthebuffertobool
boolbVarBool=BitConverter.ToBoolean(abDataBuffer,0);
//Convertsthesecondandthirdbyteofthebuffertoint
intiVarInt=BitConverter.ToInt16(abDataBuffer,1);
//Convertstheotherbytesofthebuffertostring
stringszVarString=encoder.GetString(abDataBuffer,3,81);

//Writesvaluesintothetext-boxes
txtBool.Text=bVarBool.ToString();
txtInt.Text=iVarInt.ToString();
txtString.Text=szVarString;
}
catch(SoapExceptionex)
{
MessageBox.Show(ex.Message);
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}

privatevoidWrite()
{
try
{
//byte-arraysforthevariables
byte[]abDataBool=newbyte[1];
byte[]abDataInt=newbyte[2];
byte[]abDataString=newbyte[81];
//Getsvaluesforthetext-boxes
boolbValueBool=Convert.ToBoolean(txtBool.Text);
intiValueInt=Convert.ToInt16(txtInt.Text);
stringszValueString=txtString.Text;
//Convertingvariablestobyte-arrays
abDataBool=BitConverter.GetBytes(bValueBool);
abDataInt=BitConverter.GetBytes((Int16)iValueInt);

encoder.GetBytes(szValueString,//Source
0,//Positionofthef
irstcharactertoconvert
encoder.GetByteCount(szValueString),//Getsthelengthofth
esource
abDataString,//Byte-
arraytosavetheconversionto
0);//Firstbyteinthe
arraytosavetheconversionto
//WritingvaluestoPLC
TcWebService.Write(szAmsNetId,iPort,iIndexGroup,0,abDataBool);
TcWebService.Write(szAmsNetId,iPort,iIndexGroup,1,abDataInt);
TcWebService.Write(szAmsNetId,iPort,iIndexGroup,3,abDataString);
}
catch(SoapExceptionex)
{
MessageBox.Show(ex.Message);
}
catch(Exceptionex)
{
MessageBox.Show(ex.Message);
}
}
#endregion