Here are some script examples:

**Script1**

*This script takes two physical sensors and calculates two virtual sensors out of that with frequency at one per second.*

V1[t] = abs(S1[t]-S2[t])

V2[t] = (sqrt(800 + S1[t])) + 10

**Script2**

*This script counts the total value produced by adding the Carton counter value (Sensor S2) of the previous measurement (t-1) up to and including the current time (t), without evaluating the value of the Power sensor. This will be calculated every second. In the calculation of the second sensor, conditional counter, the value of the Power sensor S1 will be evaluated, whether it is equal to '1'. If it is, the total value produced by adding the Carton counter value (Sensor S2) of the previous measurement (t-1) up to and including current time (t). This will be calculated every second as well.*

V1[t] = sum(S2[t-1,t])

V2[t] = sumif(S2[t-1,t], S1[t] == 1)

**Script 3:**

*This script counts the total value produced by adding up the input quantity (Sensor S1) of the previous measurement (t-1) up to and including current time (t). This will be calculated every second. The second calculation based on this outcome is calculating the sum over the Second quantity (Sensor V1) every 10 seconds. The time interval of the calculation is based on the frequency of the virtual sensor(s) which are the output of a script.*

V1[t] = sum(S1[t-1,t])

V2[t] = sum(V1[t-1,t])

**Script 4**:

*This script calculates the average temperature as a virtual sensor, based on two physical temperature sensors in the machine. Both physical temperature sensors are measuring at a frequency of 1 second. The average temperature based on that is also calculated with the same frequency of 1 per second.*

AverageTemperature[t] = (Temperature1[t] + Temperature2[t]) / 2

**Script 5:**

*This script calculates the production speed of the machine per minute as a virtual sensor, based on a physical cumulative counter sensor. Also calculates a virtual sensor for the threshold of the speed per minute, based on a physical sensor which indicates the type of product being produced. There is an extra calculation for the speed per minute to prevent the value dropping below 0 when the physical cumulative counter is reset by the machine operator, for example. All sensors are set at a frequency of 1 second.*

Cartonslastminute[t] = Cartoncounter[t] - Cartoncounter[t-60]

if(Milkpercarton[t] == 2)

{

CartonThreshold[t] = 350

}

else

{

CartonThreshold[t] = 290

}

if(Cartonslastminute[t] < 2)

{

Cartonslastminute[t] = 0

}

## Comments