Skip to content

Commit 70d1dae

Browse files
committed
Update notebook to adapt to new API
1 parent e4d7242 commit 70d1dae

1 file changed

Lines changed: 34 additions & 16 deletions

File tree

notebook.ipynb

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 96,
5+
"execution_count": 1,
66
"metadata": {},
77
"outputs": [],
88
"source": [
99
"from edgeml import edgeml\n",
1010
"import time\n",
11-
"import random\n",
11+
"import math\n",
1212
"import pandas as pd\n",
1313
"import tsfresh"
1414
]
@@ -22,28 +22,46 @@
2222
},
2323
{
2424
"cell_type": "code",
25-
"execution_count": 97,
25+
"execution_count": 2,
2626
"metadata": {},
27-
"outputs": [],
27+
"outputs": [
28+
{
29+
"data": {
30+
"text/plain": [
31+
"True"
32+
]
33+
},
34+
"execution_count": 2,
35+
"metadata": {},
36+
"output_type": "execute_result"
37+
}
38+
],
2839
"source": [
29-
"localKey = \"RuW7CkG0keGCn9OH7yG40XY3nZz4Vfdl+gUgvpeiqxOP1eIwCwg90BjMrQVQV5fz3/zK1zBZ4uP+WFelZUmYTw==\" # Device API-key\n",
30-
"localUrl = \"http://localhost\" # Backend URL\n",
40+
"readKey = \"4c1137ca4a959601522c5d4367c3737d\" # Device API Read Access Key\n",
41+
"writeKey = \"e49f4833a04db7647d9e6c43b38d247f\" # Device API Write Access Key\n",
42+
"localUrl = \"http://localhost:3004\" # Backend URL\n",
3143
"datasetName = \"Example Dataset\" # Name of the dataset\n",
3244
"useDeviceTime = False # Change it to true if you want to use timestamps generated by the server \n",
3345
"startTime = time.time() # TODO isn't the use device time name confusing when its function is to allow use of the timestamps generated by \n",
3446
" # the \"SERVER\" and not the DEVICE?\n",
3547
"\n",
3648
"# create collector object to collect and upload data \n",
37-
"collector = edgeml.datasetCollector(localUrl,\n",
38-
" localKey,\n",
49+
"timeSeries = [\"Acc\", \"Mag\"]\n",
50+
"metaData = []\n",
51+
"collector = edgeml.DatasetCollector(localUrl,\n",
52+
" writeKey,\n",
3953
" datasetName,\n",
40-
" useDeviceTime)\n",
41-
"\n",
42-
"# upload randomly generated data to the project using the collector\n",
43-
"for i in range(50):\n",
44-
" currentTime = startTime + i * 10 \n",
45-
" collector.addDataPoint(\"Accelerometer\", random.randint(1,50)/10.0, currentTime) \n",
46-
" collector.addDataPoint(\"Magnetometer\", random.randint(1,50)/10.0, currentTime) \n",
54+
" useDeviceTime,\n",
55+
" timeSeries,\n",
56+
" metaData)\n",
57+
"timestamp = time.time() * 1000\n",
58+
"for i in range(400000):\n",
59+
" timestamp += 40\n",
60+
" x = i / 10000 # Adjust the divisor to control the frequency of the wave\n",
61+
" y_acc = math.sin(x) # Generate the y-coordinate for \"Acc\"\n",
62+
" y_mag = math.cos(x) # Generate the y-coordinate for \"Mag\"\n",
63+
" await collector.addDataPoint(timestamp, \"Acc\", y_acc) \n",
64+
" await collector.addDataPoint(timestamp, \"Mag\", y_mag) \n",
4765
"\n",
4866
"# signal data collection is complete\n",
4967
"collector.onComplete()\n"
@@ -6794,7 +6812,7 @@
67946812
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
67956813
},
67966814
"kernelspec": {
6797-
"display_name": "Python 3.8.10 64-bit",
6815+
"display_name": "Python 3 (ipykernel)",
67986816
"language": "python",
67996817
"name": "python3"
68006818
},

0 commit comments

Comments
 (0)