|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": 96, |
| 5 | + "execution_count": 1, |
6 | 6 | "metadata": {}, |
7 | 7 | "outputs": [], |
8 | 8 | "source": [ |
9 | 9 | "from edgeml import edgeml\n", |
10 | 10 | "import time\n", |
11 | | - "import random\n", |
| 11 | + "import math\n", |
12 | 12 | "import pandas as pd\n", |
13 | 13 | "import tsfresh" |
14 | 14 | ] |
|
22 | 22 | }, |
23 | 23 | { |
24 | 24 | "cell_type": "code", |
25 | | - "execution_count": 97, |
| 25 | + "execution_count": 2, |
26 | 26 | "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 | + ], |
28 | 39 | "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", |
31 | 43 | "datasetName = \"Example Dataset\" # Name of the dataset\n", |
32 | 44 | "useDeviceTime = False # Change it to true if you want to use timestamps generated by the server \n", |
33 | 45 | "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", |
34 | 46 | " # the \"SERVER\" and not the DEVICE?\n", |
35 | 47 | "\n", |
36 | 48 | "# 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", |
39 | 53 | " 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", |
47 | 65 | "\n", |
48 | 66 | "# signal data collection is complete\n", |
49 | 67 | "collector.onComplete()\n" |
|
6794 | 6812 | "hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1" |
6795 | 6813 | }, |
6796 | 6814 | "kernelspec": { |
6797 | | - "display_name": "Python 3.8.10 64-bit", |
| 6815 | + "display_name": "Python 3 (ipykernel)", |
6798 | 6816 | "language": "python", |
6799 | 6817 | "name": "python3" |
6800 | 6818 | }, |
|
0 commit comments