Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // tags:TAGS
  2. var tags = new Array();
  3.  
  4. var tag = {};
  5. if (me.CurrentHumidity < me.VMHumidityLowLimit) {
  6.     tag.vocabulary = "VendingMachineEventTags";
  7.     tag.vocabulartTerm = "Humidity Low";
  8.     tags.push(tag);
  9.     me.VMHumidityLow = true;
  10. } else {
  11.     me.VMHumiditytLow = false;
  12. }
  13. if (me.CurrentHumidity > me.VMHumidityHighLimit) {
  14.     tag.vocabulary = "VendingMachineEventTags";
  15.     tag.vocabulartTerm = "Humidity High";
  16.     tags.push(tag);
  17.     me.VMHumidityHigh = true;
  18. } else {
  19.     me.VMHumidityHigh = false;
  20. }
  21. if (me.CurrentTemperature < me.VMTemperatureLowLimit) {
  22.     tag.vocabulary = "VendingMachineEventTags";
  23.     tag.vocabulartTerm = "Temperature Low";
  24.     tags.push(tag);
  25.     me.VMTemperatureLow = true;
  26. } else {
  27.     me.VMTemperatureLow = false;
  28. }
  29. if (me.CurrentTemperature > me.VMTemperatureHighLimit) {
  30.     tag.vocabulary = "VendingMachineEventTags";
  31.     tag.vocabulartTerm = "Temperature High";
  32.     tags.push(tag);
  33.     me.VMTemperatureHigh = true;
  34. } else {
  35.     me.VMTemperatureHigh = false;
  36. }
  37.  
  38. // timestamp:DATETIME
  39. var timestamp = new Date();
  40.  
  41. // values:INFOTABLE(Datashape: VendingMachineProcessData)
  42. var values = Things["VendingMachineProcessValuesStream"].CreateValues();
  43.  
  44. values.VMTemperature = me.CurrentTemperature; //NUMBER
  45. values.VMHumidity = me.CurrentHumidity; //NUMBER
  46.  
  47. // location:LOCATION
  48. var location = new Object();
  49. location.latitude = 0;
  50. location.longitude = 0;
  51. location.elevation = 0;
  52. location.units ="WGS84";
  53.  
  54. var params = {
  55.     tags : tags,
  56.     timestamp : timestamp,
  57.     source : me.name,
  58.     values : values,
  59.     location : me.Location
  60. };
  61.  
  62. // AddStreamEntry(tags:TAGS, timestamp:DATETIME, source:STRING("me.name"), values:INFOTABLE(VendingMachineProcessData), location:LOCATION):NOTHING
  63. Things["VendingMachineProcessValuesStream"].AddStreamEntry(params);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement