Virtual OPC-UA Device Reference

Updated: 2025-10-16

OPC-UA Virtual Device Manual

This document describes the virtual devices and sensors simulated by the Virtual OPC-UA Plant server. This server is ideal for testing logic before deploying to real industrial PLCs.

1. PIDControl

Simulates a PID temperature control loop. Useful for testing OPC_WRITE by changing setpoints.

  • PIDControl_CurrentTemperature: Current temperature (read-only)
  • PIDControl_Setpoint: Target temperature (read-write)
  • PIDControl_PIDOutput: PID output signal (read-only)

2. Sensor_Door & Motion

Simulates physical access sensors.

  • Sensor_Motion_Detected: Boolean indicating motion (read-only)
  • Sensor_Door_IsOpen: Boolean indicating if the door is open (read-write)

3. Environmental & Proximity Sensors

A collection of read-only sensors for monitoring conditions.

  • Sensor_Humidity_Value: Humidity level in %
  • Sensor_Proximity_Distance: Distance to object in cm
  • Sensor_Light_Lux: Light level in lux
  • Sensor_Gas_Concentration: Gas concentration in ppm
  • Sensor_Vibration_Level: Vibration intensity
  • Sensor_Smoke_Detected: Boolean presence of smoke

4. System Status

  • Sensor_Battery_Level: Battery level in %
  • Sensor_Network_Strength: Signal strength (0-100)
  • System_PowerStatus_IsPowered: Boolean power status

Note: Writable variables are intended for use with commands such as OPC_WRITE. Changes in these variables may trigger logic updates in the virtual plant simulation.

Example

SYSTEM {TYPE:PRE_RUN,TRIGGER:PRE_RUN}

OPC {NAME:opc1,X:100,Y:121,visible:1, TYPE:REAL,
    CLIENT:"opc.tcp://192.168.1.10:4840"}

POSITION {NAME:POS1,X:251,Y:335}
POSITION {NAME:POS2,X:469,Y:341}

Graphic {NAME:Text1,Type:TEXT,X:425,Y:314,Text:"Entity"}
Graphic {NAME:Text2,Type:TEXT,X:424,Y:124,Text:"Data"}
Graphic {NAME:Text3,Type:TEXT,X:425,Y:514,Text:"Write Status"}
Graphic {NAME:Text4,Type:TEXT,X:115,Y:398,Text:"Door Sensor"}

initial nAgente,0
START 500

;*****************************************************

PROCEDURE PRE_RUN
    OPC_SUBSCRIPTION { NAME: opc1
        , VARIABLE: "PIDControl_CurrentTemperature"
        , TRIGGER: on_subscription 
        }
    OPC_SUBSCRIPTION { NAME: opc1
        , VARIABLE: "Sensor_Door_IsOpen"
        , TRIGGER: door_opened 
        }
	TERMINATE_VE
ENDPROCEDURE 1

;*****************************************************
GENERATE 0,0,0,0 {NAME:GEN1,X:43,Y:300}

if (D$N==1)
    ASSIGN values, { PIDCONTROL_SETPOINT: 10 }
    OPC_WRITE { NAME: opc1, VALUES: V$values ,async:1,trigger:on_write}
endif

OPC_READ {name:opc1, savevalue:temperature  }

move {name:Text1,TEXT:"READ Result: X$(temperature.Sensor_Proximity_DistanceInCm)"}
	
ADVANCE 20,0 {TO:pos1}
	
ENDGENERATE 1

procedure on_subscription
    move {name:Text2,TEXT:"Subscription AC1$:\n P$PARAM_A \N P$PARAM_B P$PARAM_C"}
    TERMINATE_VE
endprocedure

procedure on_write
    move {name:Text3,TEXT:"Write AC1$:\n P$PARAM_A \N P$PARAM_B P$PARAM_C"}
	TERMINATE_VE
endprocedure

procedure door_opened
    move {name:Text4,TEXT:"DOOR AC1$ ; P$PARAM_A"}
    if (P$(PARAM_A.value)==1)
    	NEW GEN1
    endif
	TERMINATE_VE
endprocedure