| Listing 5. Share: temperature sensor service. |
|
-- This Service returns a temperature value with 2 decimal digit precision
coTemperatureP2 = coroutine.create( function() local t while true do t = intT + math.random(-100, 100)/100 t = t - t%0.01 --P2 precision local tuple = {} table.insert(tuple, t) coroutine.yield(tuple) end end ) temperatureP2 = Service:new( "temperatureP2", "1.1.2", [[ return function() status, values = coroutine.resume(coTemperatureP2) end ]] , coTemperatureP2, function() return true --Pre-Conditions always satisfied end ) |