OPC-UA Virtual Device

Actualizado: 2025-10-16

OPC-UA Virtual Device Manual

This document describes the virtual devices and sensors simulated by the Virtual OPC-UA Plant server.

1. PIDControl

Simulates a PID temperature control loop.

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

2. Sensor_Motion

Simulates a motion detector.

  • Sensor_Motion_Detected: Boolean value indicating motion detected (read-only)

3. Sensor_Door

Simulates a door open/close sensor.

  • Sensor_Door_IsOpen: Boolean value indicating if the door is open (read-write)

4. Sensor_Humidity

Simulates an environmental humidity sensor.

  • Sensor_Humidity_Value: Humidity level in % (read-only)

5. Sensor_Proximity

Simulates a proximity sensor.

  • Sensor_Proximity_Distance: Distance to object in cm (read-only)

6. Sensor_Light

Simulates a light level sensor.

  • Sensor_Light_Lux: Light level in lux (read-only)

7. Sensor_Gas

Simulates a gas leakage detector.

  • Sensor_Gas_Concentration: Gas concentration in ppm (read-only)

8. Sensor_Vibration

Simulates a vibration sensor.

  • Sensor_Vibration_Level: Vibration intensity (read-only)

9. Sensor_Smoke

Simulates a smoke detector.

  • Sensor_Smoke_Detected: Boolean value indicating presence of smoke (read-only)

10. Sensor_Battery

Simulates a battery status monitor.

  • Sensor_Battery_Level: Battery level in % (read-only)

11. Sensor_Network

Simulates network signal strength.

  • Sensor_Network_Strength: Signal strength from 0 to 100 (read-only)

12. System_PowerStatus

Indicates if the system is powered.

  • System_PowerStatus_IsPowered: Boolean value indicating power status (read-only)

Note: Writable variables are intended for use with commands such as OPC_WRITE or OPC_SUBSCRIPTION.

Ejemplo

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:"Entidad"}
Graphic {NAME:Text2,Type:TEXT,X:424,Y:124,Text:"qqqqqq"}
Graphic {NAME:Text3,Type:TEXT,X:425,Y:514,Text:"write"}
Graphic {NAME:Text4,Type:TEXT,X:115,Y:398,Text:"door"}

initial nAgente,0
START 500

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

PROCEDURE PRE_RUN
;	timeout agente.main,0

    OPC_SUBSCRIPTION { NAME: opc1
    	, VARIABLE: "PIDControl_CurrentTemperature"
        , TRIGGER: on_suscription 
        }
    OPC_SUBSCRIPTION { NAME: opc1
    	, VARIABLE: "Sensor_Door_IsOpen"
        , TRIGGER: puerta_abierta 
        }
	TERMINATE_VE
ENDPROCEDURE 1

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

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

;move {name:Text1,TEXT:"Entidad Resultado X$(variables)"}
OPC_READ {name:opc1, savevalue:temperatura  }
;OPC_READ {name:opc1, async:1,trigger:on_results }

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

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


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

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


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