VB.Net and SAIA Web server

All recent Saia PCD controllers have a Web server. To access a web server need Saia Web-Connect software installed on your PC. Communications with web SAIA server possible via Ethernet, USB and serial simple S-bus (RS 485) networks. IP addresses for Ethernet communications should also be set with Saia Web-Connect software.

CGI of the Web server. Exchanging data with SAIA WEB server is done  through CGI (Common Gateway Interface) functions. In the Web server there are already 4 CGIs (executable) implemented. Read and write functions to some data and can also read data that have been predefined with order functions.

CGI functions:

- readval.exe
Read value function is used to read a single PCD media.The syntax is: Pref + readVal.exe?TAG
- writeval.exe.
Write value function is used to write a single PCD media. The syntax is: Pref + writeval.exe?TAG+xxx.
- ordervalues.exe.
Order values function is used when access to  more than one PCD media is needed in the same time.The syntax is: Pref + OrderValues.exe?listname+dummy+ssss+TAG1+TAG2+ TAG3+T….
- readfile.exe.
Read file function is used to read the media values that have been predefined in the list with the “ordervalue” function. The function will return the list of the tags with their value. The syntax is: Pref + ReadFile.exe?listname.

VB.NET application can use the following scenario to exchange data with web server. Start application. Writing orders to the WEB server with data needed for run-time functions. With timer reading this data from server and update user interface of the application.

Connection function to WEB server:

Function URLLoad(ByVal URL As String, _
          ByRef Response As String) As Integer

  ' Voorwerpen voor web-toegang definiëren
  Dim wReq As WebRequest
  Dim wResp As WebResponse

    wReq = WebRequest.Create(URL) ' Toegang tot de site

    wReq.Proxy = WebProxy.GetDefaultProxy
    wReq.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials

    wResp = wReq.GetResponse() ' Antwoord Extractie (Stream)
  Catch ex As Exception
    ' Error Handling
    pdNetCom_ErrorMessage = ex.Message
    pdNetCom_ErrorString = ex.ToString
    Return -1
  End Try

  'Stream objecten voor het bepalen van de behandeling
  Dim sr As New StreamReader(wResp.GetResponseStream(), Encoding.ASCII)
  Dim strSource As New StringBuilder("")
  Dim strTemp As String = ""

  'Stream lezen en op te slaan in string
  strTemp = sr.ReadLine()
  While Not (strTemp Is Nothing)
    strSource.Append((strTemp + ControlChars.Cr + ControlChars.Lf))
    strTemp = sr.ReadLine()
  End While
  Response = strSource.ToString

  'Objecten vrijgegeven en retourcode set
  Return 0

End Function

Example to use “ordervalues.exe” function of the WEB server. This function write order “room2” for reading 18 registers R100 – R117.


Dim ConString As String = ""
  Public Sub SetOrderR()
  Dim FileN As String = "OrderValues.exe?room2+dummy+1000"
  Dim W1 As String ="+PDP,,R100,d+PDP,,R101,d+PDP,,R102,d+PDP,,R103,d"
  Dim W2 As String ="+PDP,,R104,d+PDP,,R105,d+PDP,,R106,d+PDP,,R107,d"
  Dim W3 As String ="+PDP,,R108,d+PDP,,R109,d+PDP,,R110,d+PDP,,R111,d"
  Dim W4 As String ="+PDP,,R112,d+PDP,,R113,d+PDP,,R114,d+PDP,,R115,d"
  Dim W5 As String = "+PDP,,R116,d+PDP,,R117,d"

  If PLC_Connection.URLLoad(ConString & FileN & W1 & W2 & W3 & W4 & W4 & W5, Response) <> 0 Then
    ToolStripStatusLabel3.Text =
  End If
End Sub

Example to use “readfile.exe” function of the WEB server. This function read file “room2” with 18 registers R100 – R117.

If PLC_Connection.URLLoad(ConString & "ReadFile.exe?room2", waardes) = 0 Then
  'Label1.Text = waardes
  Dim resA As String() = waardes.Split(delimiters)
  Me.L100.Text = CStr(Val(resA(1) / 10.0)) & " C°"
  'Temperature Reaction tank
  Me.L101.Text = CStr(Val(resA(3) / 10.0)) & " C°"
  'Temperature H2O2 tank
  Me.L102.Text = CStr(Val(resA(5) / 10.0)) & " C°"
  'Temperature FA tank

    'ToolStripStatusLabel1.Text = PLC_Connection.dNetCom_
    ToolStripStatusLabel1.Text = "RunTime error"
    Timer1.Enabled = False
  End If

Source of the example:


Note: For data you have empty directory “C:\SkidData\” create on the PC.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: