TimeOut Property

Description

Sets or returns the Time To Live timeout period (in milliseconds) for the control to get a response from an Ethernet connection

VB 6.0

[ form ]. ABCTL TimeOut [ = timeout% ]

VC++

short ABCTL.GetTimeOut( void );

 

void ABCTL.SetTimeOut ( short size );

VB .NET

AxABCTL.TimeOut [ = timeout as System.Int16 ]

Remarks

This property determines how long the control will wait for a response from an Ethernet processor after the . Trigger command is invoked. 

If the .TimeOut period expires, the control will fire OnErrorEvent Event with a Winsock Error Code 10057.

NOTE: This property setting has changed from prior versions of ABCTL.OCX. In versions prior to Studio 5.2 the .TimeOut property was in seconds. When upgrading applications developer with older versions of ABCTL.OCX, you will need to increase the .TimeOut property, or Winsock error 10057 will occur

VB 6.0 Example

Sub Command1_Click()
  ABCTL1.TimeOut = 1000       ' * wait for a max of 1000 msecs
  ABCTL1.Host = "192.11.11.31"  ' * IP Address of PLC
  ABCTL1.Node = 2            ' * to PLC Node 2
  ABCTL1.Function = 0       ' * read PLC
  ABCTL1.FileAddr = "N7:0"  ' * starting at N7:0
  ABCTL1.Size = 10          ' * for 10 data points
  ABCTL1.Trigger             ' * tell control to get the data
End Sub

Sub ABCTL1_OnErrorEvent (nErrorCode as Integer)
     MsgBox "Ethernet PLC " & ABCTL1.Host & " Did not respond"
  End If
End Sub

VC Example

void MyCWndClass:: OnBtnClick()
{
  m_ABCTL1.SetTimeOut(1000); // set 1000 ms timeout
  m_ABCTL1.SetHost("192.11.11.31");    // IP Address
  m_ABCTL1.SetNode("5");          // to PLC Node 5
  m_ABCTL1.SetFunction(0)        // read PLC
  m_ABCTL1.SetFileAddr("N7:0");  // starting at N7:0
  m_ABCTL1.Size(10);              // for 10 data points
  m_ABCTL1.Trigger();             // tell control to get the data
}

void MyCWndClass :: ABCTL1OnErrorEvent( int nErrorCode )
{
  Cstring csMsg;
if (10057 == nErrorCode)
{
      csMsg.Format("Ethernet PLC %s Did not respond", m_ABCTL1.GetHost());
     AfxMessageBox(csMsg);
  }
}

VB .NET Example

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

AxABCTL1.Adapter = 0 ' * use adapter 0

AxABCTL1.Host = "192.168.1.31" ‘ * PLC IP Address

AxABCTL1.TimeOut = 1000 ‘ * 1000ms timeout

AxABCTL1.Function = 0 ' * read PLC

AxABCTL1.FileAddr = "N7:0" ' * starting at N7:0

AxABCTL1.CtlSize = 10 ' * for 10 data points

AxABCTL1.Trigger() ' * tell control to get the data

End Sub

 

Private Sub AxABCTL1_OnErrorEvent(ByVal sender As Object, ByVal e As AxABCTLLib._DABCTLEvents_OnErrorEventEvent) Handles AxABCTL1.OnErrorEvent

 

Dim nErrorCode As System.Int16

nErrorCode = AxABCTL1.ErrorCode

If nErrorCode = 10057 then

Text1.Text = "Ethernet PLC " & AxABCTL1.Host & " Timed Out"

End if

End Sub

Date Type

Integer (16-Bit)

Also See

Trigger Method OnErrorEvent Event