Recent Changes - Search:

edit SideBar

GDPTestGenerator

(redirected from Notes.GDPTestGenerator)

The GDP is no longer supported by the Accessors Framework. This page exists as a historical reference.


$PTII/ptolemy/actor/lib/jjs/modules/gdp/demo/GDPTestGenerator/GDPTestGenerator.xml is a Ptolemy model that is deployed as a Swarmlet on terra.eecs.berkeley.edu that generates periodic test data.

The swarmlet appends to a GDP log named "edu.berkeley.eecs.testlog" a sequence of JSON data.

A new output is produced once per second and the values cycle through a specified range.

This is intended to be a test log that can be relied to be always producing data.

The JSON produced has the following properties:

  • pressure_pascals: ranges from 70,100 Pa (pressure at about 3000 m elevation) to 101,000 Pa (at sea level).
  • huminity_precent: ranges from 0 to 100.
  • temperature_celcius: ranges from 100 down to -10.
  • light_lux: ranges from 0 (no light) to 1000 (overcast day, very bright office).
  • battery_percent: ranges from 100 to 0.
  • sequence_number: starting from 0, the count of outputs from an execution of this test.
  • time: the time at which this output is produced.

Deploying on TerraSwarm

The $PTII/ptolemy/actor/lib/jjs/modules/gdp/demo/GDPTestGenerator/GDPTestGenerator.xml model has an AccessorSSHCodeGenerator that deploys the swarmlet to terra.eecs.berkeley.edu using the sbuser account.

To update the version running on terra, edit the AccessorSSHCodeGenerator attribute and change the remote host to sbuser@terra.eecs.berkeley.edu.

You will also need ssh access to sbuser on terra, see Access Control And Key Distribution. The password for the sbuser@terraswarm.org account on https://repo.eecs.berkeley.edu may be found on Terra in ~sbuser/.repopass.

Then run the model, the code should be redeployed to terra. You may need to do pm2 reload 0 to reload the swarmlet.

The swarmlet is restarted at boot time and periodically using pm2.

Attach:gdpSbuserPm2.png Δ

In addition, there is cronjob that restarts every 5 minutes. /home/sbuser/sbuser.cron says:

PATH=/usr/local/python/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin
#
# /home/sbuser/sbuser.cron
#
*/5 * * * *  csh -c '/home/sbuser/cg/node_modules/.bin/pm2 restart GDPTestGenerator.js' >& /home/sbuser/sbuser.cron.log

Log Rotation

We are using https://github.com/pm2-hive/pm2-logrotate pm2-logrotation:

pm2 install pm2-logrotate
pm2 set pm2-logrotate:rotateInterval '* * * /1 * *'

Testing

Subscription

There is a model at $PTII/ptolemy/actor/lib/jjs/modules/gdp/test/auto/GDPTerraLog.xml that tests out subscription.

gdp-reader

Here's how to test whether the edu.berkeley.eecs.testlog is active using gdp-reader

bash-3.2$ $PTII/vendors/gdp/gdp/apps/gdp-reader -s edu.berkeley.eecs.testlog
Reading GCL T2bu1EV7VRFDM3Ao5ybbtWS8uxPrCOyJngCv0JMcils
 >>> recno 1524164, len 178, ts 2017-07-28 13:35:49.508240000Z
00000000 7b 22 64 65 76 69 63 65 22 3a 22 54 45 53 54 22
         {  "  d  e  v  i  c  e  "  :  "  T  E  S  T  "
00000010 2c 22 70 72 65 73 73 75 72 65 5f 70 61 73 63 61
         ,  "  p  r  e  s  s  u  r  e  _  p  a  s  c  a
00000020 6c 73 22 3a 37 33 34 30 30 2c 22 68 75 6d 69 64
         l  s  "
 :  7  3  4  0  0  ,  "  h  u  m  i  d
00000030 69 74 79 5f 70 65 72 63 65 6e 74 22 3a 38 2c 22
         i  t  y  _  p  e  r  c  e  n  t  "
 :  8  ,  "
00000040 74 65 6d 70 65 72 61 74 75 72 65 5f 63 65 6c 63
         t  e  m  p  e  r  a  t  u  r  e  _  c  e  l  c
00000050 69 75 73 22 3a 39 32 2c 22 6c 69 67 68 74 5f 6c
         i  u  s  "
 :  9  2  ,  "  l  i  g  h  t  _  l
00000060 75 78 22 3a 38 30 2c 22 62 61 74 74 65 72 79 5f
         u  x  "
 :  8  0  ,  "  b  a  t  t  e  r  y  _
00000070 70 65 72 63 65 6e 74 22 3a 39 32 2c 22 73 65 71
         p  e  r  c  e  n  t  "
 :  9  2  ,  "  s  e  q
00000080 75 65 6e 63 65 5f 6e 75 6d 62 65 72 22 3a 38 2c
         u  e  n  c  e  _  n  u  m  b  e  r  "
 :  8  ,
00000090 22 74 69 6d 65 22 3a 22 32 30 31 37 2d 30 37 2d
         "  t  i  m  e  "  :  "  2  0  1  7  -  0  7  -
000000a0 32 38 54 31 33 3a 33 34 3a 32 39 2e 33 33 31 5a
         2  8  T  1  3  :  3  4  :  2  9  .  3  3  1  Z
000000b0 22 7d
         "
 }
 >>> recno 1524165, len 178, ts 2017-07-28 13:35:50.508682000Z
00000000 7b 22 64 65 76 69 63 65 22 3a 22 54 45 53 54 22
         {  "  d  e  v  i  c  e  "  :  "  T  E  S  T  "
00000010 2c 22 70 72 65 73 73 75 72 65 5f 70 61 73 63 61
         ,  "  p  r  e  s  s  u  r  e  _  p  a  s  c  a
00000020 6c 73 22 3a 37 33 37 30 30 2c 22 68 75 6d 69 64
         l  s  "
 :  7  3  7  0  0  ,  "  h  u  m  i  d
00000030 69 74 79 5f 70 65 72 63 65 6e 74 22 3a 39 2c 22
         i  t  y  _  p  e  r  c  e  n  t  "
 :  9  ,  "
00000040 74 65 6d 70 65 72 61 74 75 72 65 5f 63 65 6c 63
         t  e  m  p  e  r  a  t  u  r  e  _  c  e  l  c
00000050 69 75 73 22 3a 39 31 2c 22 6c 69 67 68 74 5f 6c
         i  u  s  "
 :  9  1  ,  "  l  i  g  h  t  _  l
00000060 75 78 22 3a 39 30 2c 22 62 61 74 74 65 72 79 5f
         u  x  "
 :  9  0  ,  "  b  a  t  t  e  r  y  _
00000070 70 65 72 63 65 6e 74 22 3a 39 31 2c 22 73 65 71
         p  e  r  c  e  n  t  "
 :  9  1  ,  "  s  e  q
00000080 75 65 6e 63 65 5f 6e 75 6d 62 65 72 22 3a 39 2c
         u  e  n  c  e  _  n  u  m  b  e  r  "
 :  9  ,
00000090 22 74 69 6d 65 22 3a 22 32 30 31 37 2d 30 37 2d
         "  t  i  m  e  "  :  "  2  0  1  7  -  0  7  -
000000a0 32 38 54 31 33 3a 33 34 3a 33 30 2e 33 33 32 5a
         2  8  T  1  3  :  3  4  :  3  0  .  3  3  2  Z
000000b0 22 7d
         "
 }

WebSockets

Terra is also running GDPToWebSocket.js, which should set up a WebSocket on terra that publishes the data.

To run the model locally:

$PTII/bin/capecode $PTII/ptolemy/actor/lib/jjs/modules/gdp/demo/GDPToWebSocket/*.xml

Run GDPToWebSocket.xml first, then TestGDPToWebSocket.xml

TestGDPToWebSocket.xml should connect to the WebSocket created by GDPToWebSocket.xml and produce data.

Edit - History - Print - Recent Changes - Search
Page last modified on January 02, 2018, at 03:07 AM