Home 

     Systems Engineering 
     Subsea Control Systems 
     Software Development 
     Products and Applications 
     Tech Info 
     Contacts & Key Personnel 
      OPC Simulation Server

     Introduction 
    The Process IT Development OPC Simulation Server is a tool for simulation and testing of OPC client applications.

    The OPC Simulation Server allows the user to define an OPC tag database using a comma separated (CSV) file, and to simulate a process by changing tag values.

    The Simulation Server provides two ways of simulating data:

    • Scripting
    • Random values
    The user can set the quality of a tag to Bad via the Bad check boxes, or can change the simulation mode for each OPC tag with the Sim combo boxes.

    An overall master switch for the simulation is turned on or off using the Simulate dropdown from the Options menu.

     

     Configuration 
    The OPC Simulation Server is configured using an INI file and a CSV file.

    The OpcSim.INI file is the main configuration file, a sample of which is shown below:

    [OPC Simulation Server]
    LicenseKey=Demo
    ActiveConfig = 2
    
    [Config 1]
    Database=TpnServer.csv
    Simulate=True
    Scripts=0
    
    [Config 2]
    Database=Loopsim.csv
    Simulate=True
    Scripts=1
    Script1=Scripts\LoopSim.vbs
    Main1=LoopSim
    
    [Config 3]
    Database=ZCalc.csv
    Simulate=True
    Scripts=0
    
    [Config 4]
    Database=WellTest.csv
    Simulate=True
    Scripts=1
    Script1=Scripts\WellTest.vbs
    ScriptExecInterval1 = 5
    Main1=WellTest
    
    

    License Key
    The license key for the OPC server is a string in the configuration INI file, and is based on the machine name. Anything other than a valid string (for example LicenseKey=Demo) is treated as a demo license. The simulation will time out after 30 minutes for a demo license, although the OPC server itself will still allow manual entry of tag data.

    ActiveConfig
    The OPC server allows more than one simulation configuration to be specified in the INI file, although only one of these configurations will be used. This is the ActiveConfig.

    [Config N]
    The Config sections specify a number of different parameters:

    Database
    The tags to load are listed in a CSV file, which is specified using a directive such as:

      Database=ZCalc.csv
    

    A typical CSV file is shown below:

       

    Simulate
    This is the overall simulation On/Off switch that can be used to enable or disable simulation for all data items.

    The simulation switch can be set on from the main menu of the OPC Sim Server.

    Scripts
    This directive specifies the number of scripts for a simulation, e.g. Scripts=1. If the simulation does not use scripts, set Scripts=0 or omit the directive.

    ScriptX (X=1,2,3...)
    For each script, this directive specifies the name of the file containing the VB Script. For example:

    Script1=Scripts\LoopSim.vbs
    Script2=Scripts\PlantSim.vbs
    

    MainX (X=1,2,3...)
    For each script, this gives the entry point (or Main) subroutine for the file.

    ScriptExecIntervalX (X=1,2,3...)
    For each script, this specifies the execution interval in seconds. The default is 1 second.

     

     Operation 
    The operation of the OPC Simulation Server is relatively straightforward.

     Startup 
    At startup, the OPC tags are assigned the values in the Initial PV column of the database CSV file.

     Simulation 
    The current version (1.1) of the OPC Simulation Server provides two forms of simulation:

    • Scripting
      VB Script can be used to read and write values in the OPC server. This allows the user to customise the simulation to their requirements.
    • Random Values
      The value of the tag is varied between the maximum and minimum values specified in the database CSV file.
    The demo version supports a maximum of 30 simulated tags, and the simulation features time out after 30 minutes. The OPC Simulation Server can be licensed for a nominal fee - see below.

    The OPC values can be set manually by simply typing in a new value. Individual items may be given a Bad status by ticking the Bad checkbox.

     OPC Writes 
    The default is that the tags in the OPC server are read-only. To permit an OPC client to write to a tag in the OPC server, make an entry in the EnableWrite column of the database CSV file.

    Note that this requirement to enable writes only applies to the OPC interface - it is always possible to manually enter a value into the OPC server.

     

     Scripting 
    Through the use of VB Script, the OPC Simulation server allows the user to simulate a process in a simple yet powerful manner.

    The script can reference the OPC Server tag database, through the following properties of the Sim object:

    • TagVal(strTag)
      This gets or sets the value of a tag using the OPC tag name, for example:
      Sim.TagVal("23FC0020.PV") = 0.5 * Sim.TagVal("23FC0020.OP") + 10
      
    • AliasVal(strInstance, strAlias) This get/set property allows each OPC tag to be referenced using an instance and alias. The instance and alias names are specified in the OPC tag definition CSV file. This approach makes it easy to write generic subroutines for simulating process components such as a PID loop or a motor.
      For example, the following sample code could be used in a subroutine, where strLoop, the name of the instance, has been passed as an argument to the subroutine.
      rError = 0.01*(Sim.AliasVal(strLoop,"SP") - Sim.AliasVal(strLoop,"PV"))
      
    • IAliasVal(strInstance, strAlias, nIndex) This is similar to AliasVal, but in addition it allows the OPC tags to be indexed. The index is specified in the OPC tag definition CSV file. For example, the following script updates an array of tags referenced as "NN". This fragment of code would typically form part of a subroutine, where strArray would be an argument to the subroutine.
      for i = 1 to 10
         Sim.IAliasVal(strArray,"NN",i) = i*i
      next
      
    Here is an example of a simulation script in VB Script that uses the TagVal and AliasVal tag access routines:
    Option Explicit
    
    '--------------
    Sub LoopSim()
    '--------------
    
    ' Calling a subroutine, and using an Alias
    ' ----------------------------------------
    Sim.TagVal("23FC0020.PV") = 0.6*Sim.TagVal("23FC0020.PV") + 0.4*(Sim.TagVal("23FC0020.OP")) + Sim.Rand
    
    call PID("Loop 1")
    
    End Sub
    
    
    '---------------
    Sub PID(strLoop)
    '---------------
    
    	' A very crude PID controller
    	' In fact it is really just using a bit of integral action
    	dim rError
    	rError = 0.01*(Sim.AliasVal(strLoop,"SP") - Sim.AliasVal(strLoop,"PV"))
    
    	dim rOpCalc, K
    	K = Sim.AliasVal(strLoop,"K")
    	rOpCalc = Sim.AliasVal(strLoop,"OP") + Csng(K*rError)
    
    	if rOpCalc > 100 then
    		rOpCalc = 100
    	elseif rOpCalc < 0 then
    		rOpCalc = 0
    	end if
    	
    	Sim.AliasVal(strLoop,"OP") = rOpCalc
    
    End Sub
    
    

     

     Download 
    The OPC Simulation Server is available as a Microsoft Installer package: Download.

     

     Purchase a License 
    A license for the OPC Simulation server can be purchased below using PayPal. Enter the name of the PC to be licensed on the PayPal site, or alternatively send it to the following email address:
    Email:

     
    30 Tags $ 20  
    50 Tags $ 30  
    100 Tags $ 60  
    200 Tags $ 100  
    500 Tags $ 200  
    1000 Tags $ 300  

     Norwegian Customers Only  Includes 25% Norwegian MVA
    30 Tags NOK 150  
    50 Tags NOK 225  
    100 Tags NOK 420  
    200 Tags NOK 750  
    500 Tags NOK 1500  
    1000 Tags NOK 2250