November 2018
Intermediate to advanced
556 pages
14h 42m
English
From the example provided in the last section, it is very easy to implement an analytical function to check the signals and to apply a digital twin. The following function defines a simple excursion monitoring function and evaluates the value of data streaming:
const digitalTwin = {};digitalTwin['signal1'] = {upperLimit: 40, lowerLimit: 10};exports.helloPubSub = (event, callback) => { const pubsubMessage = event.data; const str = Buffer.from(pubsubMessage.data, 'base64').toString(); console.log(str); const data= str.split(','); console.log({ 'device': data[0], 'tag': data[1], 'value': data[2], 'ts': data[3], 'quality': data[4]});const deviceId=data[0];const tag=data[1];const value=data[2];const timestamp = data[3]; ...