From 1f92b43879e67af6e03ce9842f3c27ac0978c6c7 Mon Sep 17 00:00:00 2001 From: Toolf Date: Fri, 2 Feb 2024 22:51:54 +0200 Subject: [PATCH] add: agent template --- agent/.gitignore | 2 + agent/Dockerfile | 12 + agent/docker/docker-compose.yaml | 33 + agent/docker/mosquitto/config/mosquitto.conf | 11 + agent/requirements.txt | 3 + agent/src/config.py | 17 + agent/src/data/accelerometer.csv | 1422 ++++++++++++++++++ agent/src/data/gps.csv | 126 ++ agent/src/domain/accelerometer.py | 8 + agent/src/domain/aggregated_data.py | 12 + agent/src/domain/gps.py | 7 + agent/src/file_datasource.py | 21 + agent/src/main.py | 53 + agent/src/schema/accelerometer_schema.py | 7 + agent/src/schema/aggregated_data_schema.py | 9 + agent/src/schema/gps_schema.py | 6 + 16 files changed, 1749 insertions(+) create mode 100644 agent/.gitignore create mode 100644 agent/Dockerfile create mode 100644 agent/docker/docker-compose.yaml create mode 100644 agent/docker/mosquitto/config/mosquitto.conf create mode 100644 agent/requirements.txt create mode 100644 agent/src/config.py create mode 100644 agent/src/data/accelerometer.csv create mode 100644 agent/src/data/gps.csv create mode 100644 agent/src/domain/accelerometer.py create mode 100644 agent/src/domain/aggregated_data.py create mode 100644 agent/src/domain/gps.py create mode 100644 agent/src/file_datasource.py create mode 100644 agent/src/main.py create mode 100644 agent/src/schema/accelerometer_schema.py create mode 100644 agent/src/schema/aggregated_data_schema.py create mode 100644 agent/src/schema/gps_schema.py diff --git a/agent/.gitignore b/agent/.gitignore new file mode 100644 index 0000000..d75edea --- /dev/null +++ b/agent/.gitignore @@ -0,0 +1,2 @@ +venv +__pycache__ \ No newline at end of file diff --git a/agent/Dockerfile b/agent/Dockerfile new file mode 100644 index 0000000..77f8852 --- /dev/null +++ b/agent/Dockerfile @@ -0,0 +1,12 @@ +# set base image (host OS) +FROM python:latest +# set the working directory in the container +WORKDIR /usr/agent +# copy the dependencies file to the working directory +COPY requirements.txt . +# install dependencies +RUN pip install -r requirements.txt +# copy the content of the local src directory to the working directory +COPY src/ . +# command to run on container start +CMD ["python", "main.py"] \ No newline at end of file diff --git a/agent/docker/docker-compose.yaml b/agent/docker/docker-compose.yaml new file mode 100644 index 0000000..3c8b1c4 --- /dev/null +++ b/agent/docker/docker-compose.yaml @@ -0,0 +1,33 @@ +version: "3.9" +name: "road_vision" +services: + mqtt: + image: eclipse-mosquitto + container_name: mqtt + volumes: + - ./mosquitto:/mosquitto + - ./mosquitto/data:/mosquitto/data + - ./mosquitto/log:/mosquitto/log + ports: + - 1883:1883 + - 9001:9001 + networks: + mqtt_network: + + + fake_agent: + container_name: agent + build: ../ + depends_on: + - mqtt + environment: + MQTT_BROKER_HOST: "mqtt" + MQTT_BROKER_PORT: 1883 + MQTT_TOPIC: "agent_data_topic" + DELAY: 0.1 + networks: + mqtt_network: + + +networks: + mqtt_network: diff --git a/agent/docker/mosquitto/config/mosquitto.conf b/agent/docker/mosquitto/config/mosquitto.conf new file mode 100644 index 0000000..0394e8c --- /dev/null +++ b/agent/docker/mosquitto/config/mosquitto.conf @@ -0,0 +1,11 @@ +persistence true +persistence_location /mosquitto/data/ +listener 1883 +## Authentication ## +allow_anonymous true +# allow_anonymous false +# password_file /mosquitto/config/password.txt +## Log ## +log_dest file /mosquitto/log/mosquitto.log +log_dest stdout +# listener 1883 \ No newline at end of file diff --git a/agent/requirements.txt b/agent/requirements.txt new file mode 100644 index 0000000..ddaf109 --- /dev/null +++ b/agent/requirements.txt @@ -0,0 +1,3 @@ +marshmallow==3.20.2 +packaging==23.2 +paho-mqtt==1.6.1 diff --git a/agent/src/config.py b/agent/src/config.py new file mode 100644 index 0000000..c7576ed --- /dev/null +++ b/agent/src/config.py @@ -0,0 +1,17 @@ +import os + + +def try_parse(type, value: str): + try: + return type(value) + except Exception: + return None + + +# MQTT config +MQTT_BROKER_HOST = os.environ.get("MQTT_BROKER_HOST") or "mqtt" +MQTT_BROKER_PORT = try_parse(int, os.environ.get("MQTT_BROKER_PORT")) or 1883 +MQTT_TOPIC = os.environ.get("MQTT_TOPIC") or "agent" + +# Delay for sending data to mqtt in seconds +DELAY = try_parse(float, os.environ.get("DELAY")) or 1 diff --git a/agent/src/data/accelerometer.csv b/agent/src/data/accelerometer.csv new file mode 100644 index 0000000..2d608d4 --- /dev/null +++ b/agent/src/data/accelerometer.csv @@ -0,0 +1,1422 @@ +x,y,z +-17,4,16516 +-58,114,16546 +379,31,16535 +-112,-318,16533 +277,91,16516 +-113,90,16526 +284,-303,16549 +-51,77,16533 +-46,40,16537 +286,15,16544 +-98,28,16533 +-48,56,16541 +262,23,16551 +-42,17,16545 +-28,51,16552 +-10,4,16525 +258,29,16546 +-56,15,16533 +-51,13,16753 +267,23,16565 +-55,51,16757 +-22,3,16537 +-74,25,16553 +374,34,16546 +123,60,16531 +298,50,16549 +334,-303,16536 +-97,75,16523 +274,90,16516 +-67,-273,16523 +270,75,16554 +-77,77,16549 +272,-267,16539 +-7,-269,16519 +-87,111,16546 +282,-266,16520 +-64,-281,16535 +261,50,16535 +-38,64,16544 +273,5,16756 +-48,20,16546 +-50,71,16528 +268,28,16562 +-12,37,16555 +-98,28,16534 +-14,37,16544 +279,9,16528 +-75,54,16542 +-1034,-1533,16817 +666,-263,16973 +568,12,18266 +1806,-520,17278 +4535,101,16589 +5894,333,15617 +11137,1956,15682 +13044,1115,12182 +11668,265,7520 +13236,-1220,2689 +16250,-972,5117 +15666,-2060,3254 +16383,-1699,3800 +16119,-1210,4098 +15008,-1829,2326 +16260,-1742,2469 +16270,-1467,2904 +16331,-2310,2769 +16910,-2167,4185 +15456,-2025,2523 +17725,-1564,6162 +13802,-1084,5516 +17243,1243,13860 +8887,-271,5629 +9450,1802,13389 +7073,1026,15146 +5302,526,16329 +2010,-716,15028 +3865,-1312,16090 +1165,-1005,15953 +1652,-393,17442 +174,-27,17487 +253,-304,16649 +-851,274,16021 +-406,9,15554 +-914,-129,16553 +177,-1285,17261 +560,-2866,16538 +884,-3898,18714 +1483,-5590,17936 +-306,-6890,14141 +3733,-8762,15404 +-460,-10276,10497 +5369,-12711,9552 +3403,-14151,6603 +3368,-14521,5689 +3503,-14968,5826 +2827,-14806,5520 +3550,-15638,5487 +3134,-15707,5440 +3186,-14561,7307 +1695,-14992,6498 +2660,-14017,6858 +1667,-14160,8449 +1862,-12017,10153 +1442,-11929,11796 +23,-10126,12085 +1691,-8080,13632 +595,-7466,14585 +1838,-6726,15214 +1647,-2861,18619 +1559,-4236,15996 +1427,-1841,17123 +387,-977,16780 +1110,-389,16309 +209,-344,17229 +1139,-389,16615 +1011,-543,16644 +1910,-564,16862 +847,-851,15784 +627,-586,16880 +-3173,-1004,16084 +-3746,-1574,16042 +-5734,-821,15582 +-13448,-2097,11609 +-13414,-1457,5600 +-13950,-2114,9398 +-14334,-2388,7021 +-15635,-2337,4874 +-14774,-1722,4552 +-16666,-1740,3251 +-15960,-1648,3578 +-15869,-1181,3227 +-15925,-1818,2572 +-16800,-1286,2795 +-16526,-1601,2831 +-16446,-1633,3376 +-16028,-1039,4834 +-18048,-841,4844 +-10600,-2986,10337 +-8500,-4088,12509 +-6470,-2843,15269 +-4359,-2279,17713 +-800,-3048,15572 +2453,-2623,16304 +3269,-1723,14261 +2462,-991,15013 +2726,-489,17504 +2197,-1370,16379 +3572,-1389,17700 +2888,-1449,16794 +3337,-1710,16845 +1913,-345,17813 +4268,-630,16075 +-1100,4202,17507 +1051,4120,14478 +931,6020,12738 +-2098,9546,14325 +-1544,9778,13936 +-3166,10762,15665 +-1584,9627,12646 +309,10969,14125 +-189,10303,11658 +28,10654,13359 +-510,10222,11190 +-801,11552,11927 +-1217,11535,11096 +-146,11633,10968 +80,11765,11191 +-144,11699,11382 +273,11612,11247 +-65,10924,10737 +-720,10720,10649 +-242,11163,13552 +-313,9275,13540 +-544,7518,12563 +-2828,6747,14063 +618,6324,16557 +-1972,3795,13716 +-686,3201,15680 +820,2425,18500 +-1560,-65,17038 +-1418,194,19072 +-999,-813,17771 +-1544,-2809,14798 +1358,-3406,16684 +5709,-3681,18002 +591,-980,17857 +-14149,1535,15843 +16212,-5540,16165 +978,-1138,18277 +-10607,1332,15994 +15352,-5760,15163 +-16141,4002,20784 +16391,-7805,12295 +-12659,2476,17871 +3654,-2747,21809 +-510,-3882,10029 +-1485,1140,19381 +-782,-211,18704 +-625,-1403,14613 +2009,-1427,14914 +167,223,19993 +8710,-1987,17690 +-2006,-3287,14279 +-14283,534,16222 +-6746,-51,19045 +23694,-9733,15459 +-1860,-209,19946 +-16185,-726,12993 +4209,-405,19428 +17134,-4287,17408 +-15701,488,17821 +-4573,2032,17689 +26301,-9145,14377 +-13964,2084,21354 +-1682,581,15312 +8896,-2854,16042 +290,-870,17967 +-3692,532,15834 +2506,-755,17014 +2141,-454,18295 +-310,422,17751 +1193,-164,15009 +2570,34,15529 +1066,-420,15238 +-713,334,24556 +-713,757,19024 +1514,-1988,719 +-49,-2073,18455 +811,-2332,31846 +-2470,-390,13972 +-1210,-3450,494 +4138,-1874,27609 +350,-1097,23056 +-1983,-3888,-2684 +6865,2482,32504 +1556,-1426,20957 +-3705,-1674,1368 +4641,1914,30027 +2227,-599,26477 +-2025,-374,539 +2669,86,23420 +55,-245,25554 +-1747,-390,3980 +92,-2426,9933 +5293,2391,32504 +-1371,-214,13591 +-3323,-3240,-1800 +1311,500,24355 +3223,936,32504 +-3640,-2133,1 +-712,-1488,14276 +6104,2732,32504 +-1370,-2391,10869 +-3351,-554,6582 +6962,1421,31930 +-11,-231,16710 +-3842,297,4572 +6977,1821,32262 +-3170,-2160,6574 +363,72,16027 +2204,559,22016 +-1063,-138,12826 +-414,376,15058 +532,1206,19598 +-137,-149,14974 +525,263,17273 +-302,-1485,18248 +1909,-1326,16022 +1054,5933,14803 +-2587,7468,15059 +-3147,-968,19938 +2160,-11160,16265 +4177,-3891,15543 +-4483,7906,18065 +-3995,6602,21773 +536,-10703,13153 +4644,-6507,16362 +1287,5759,14240 +-4997,10320,19188 +-3367,-3394,15645 +2774,-10005,17446 +4149,-415,15010 +-5315,10827,17106 +-4636,-121,17179 +4918,-11963,17359 +5623,-3850,16396 +-3648,10276,17572 +-5312,5797,15773 +110,-10859,16329 +5270,-9881,17997 +2556,3147,15624 +-8299,12544,17197 +-1434,2871,16718 +-313,-5474,16398 +1721,-10312,17237 +3989,-2852,15564 +-4017,8410,14862 +-2946,8690,17936 +-1769,963,18547 +611,-8813,17079 +3889,-8794,15249 +-920,3027,15301 +-5529,8063,17306 +-2664,954,17686 +222,-2299,19041 +820,-3775,13755 +-1167,-1040,16052 +-3946,1376,17653 +-2653,-559,15069 +-2540,73,16759 +-2490,-157,16785 +-3010,-638,15838 +-2864,-287,16002 +-3353,-575,17610 +-3343,-1598,17007 +-2802,-1479,16538 +-2540,-1901,15789 +-1826,-1141,16194 +-3011,-1886,15886 +-4156,-798,17647 +-1576,-1072,16556 +-1954,-890,16455 +-589,-817,15971 +-233,-1644,14560 +-3191,522,17341 +-1794,-178,16565 +-543,-136,16763 +-2500,544,17342 +-13,-413,16784 +-1096,-55,17025 +-792,-250,16567 +-141,-156,16036 +1105,-630,17277 +960,-866,16809 +1477,-710,17172 +1408,-685,16547 +2308,-824,16550 +2198,-947,16237 +2938,-905,15797 +3654,-992,16412 +3756,-1153,15763 +5214,-1264,16064 +5525,-1598,15751 +5876,-1233,15726 +6324,-1304,15378 +6636,-1395,15377 +7705,-1056,14849 +7927,-1297,14026 +8840,-1076,14395 +9802,-795,14044 +9886,-763,13380 +9961,-888,12911 +10126,-350,12902 +10934,-372,13114 +11506,-364,11912 +11893,-290,11465 +12524,-30,11605 +12547,46,10429 +13034,-302,9379 +13221,146,9876 +13602,177,9267 +15166,384,8703 +13696,628,8210 +15071,612,7639 +15472,514,6446 +15704,8,4739 +15365,346,4072 +16069,177,3869 +16519,338,2745 +16290,-36,2523 +16986,552,2564 +16723,60,1051 +16411,290,433 +16387,283,149 +15979,-35,-587 +16967,-88,-167 +16074,190,-3 +16514,28,161 +17025,357,1412 +16948,-9,1145 +16186,-123,895 +16654,627,2437 +16617,250,2873 +15580,572,2853 +16055,826,3953 +15890,-45,3416 +15579,135,3851 +16160,582,4786 +16563,-69,4957 +15403,571,6206 +15427,269,6360 +14277,245,6958 +14119,335,7418 +14477,-544,8236 +14381,-326,9040 +13489,-492,8662 +15106,-829,10100 +13149,-169,10722 +13521,-643,11121 +12351,-199,11159 +11683,-838,11556 +11035,-412,12187 +12371,-744,12629 +9203,-212,13527 +9353,-828,14183 +8103,-469,13764 +7461,-454,14301 +6919,-600,14970 +5574,-204,15618 +5380,0,15604 +5175,-528,16142 +4136,75,16114 +4195,-154,16451 +3129,-43,16957 +1658,-599,15629 +472,146,16851 +724,-188,16323 +-372,-100,17506 +-2400,831,16547 +-2987,548,16172 +-4846,617,16042 +-5357,205,15402 +-5789,152,15649 +-7346,241,15267 +-8825,595,13958 +-10020,54,13332 +-10383,-120,12570 +-11312,-513,12453 +-12057,-136,11775 +-12764,-472,10939 +-13065,-478,10374 +-13197,-838,10459 +-14401,-473,9284 +-13914,-451,8443 +-14405,-1378,7145 +-15023,-831,7950 +-14790,-1406,6013 +-15565,-1303,4692 +-15832,-834,6698 +-16186,-969,4606 +-15800,-1799,3011 +-16284,-1324,2602 +-17000,-1230,1430 +-15694,-1452,473 +-16883,-1195,890 +-16901,-2069,883 +-16028,-2367,-232 +-16558,-2135,-178 +-15283,-2689,-677 +-17740,-1637,-2583 +-16038,-1781,-1882 +-16678,-2084,-2779 +-16450,-1624,-2005 +-16318,-2105,-4117 +-15711,-1638,-3371 +-15506,-1611,-3931 +-16569,-1653,-3967 +-16235,-1616,-4131 +-15829,-2152,-3541 +-17007,-1187,-3371 +-15598,-2176,-3777 +-15890,-1436,-2372 +-16096,-1435,-3048 +-16375,-1408,-2018 +-16737,-1559,-2575 +-16187,-1596,-2405 +-16364,-2074,1044 +-16332,-1509,1629 +-16839,-1591,479 +-16992,-1352,1969 +-15819,-1202,1856 +-16210,-1388,3239 +-16388,-1604,2802 +-15829,-1158,4563 +-15543,-1103,4295 +-15111,-1659,6740 +-16079,-673,6805 +-14222,-1441,7032 +-15407,-1159,7896 +-13249,-1261,9315 +-13376,-1098,8863 +-14165,-934,10261 +-13697,-948,9911 +-11483,-1275,10643 +-11748,-1353,11782 +-10726,-1408,12904 +-11288,-1180,12882 +-11337,-1305,14242 +-8170,-1298,13299 +-8784,-992,13343 +-8596,-670,14462 +-7984,-533,15265 +-5615,-684,14308 +-5708,-406,16190 +-5123,-440,16765 +-3826,-661,15690 +-4423,285,17197 +-2377,-410,15496 +-1452,-103,16907 +-1379,-185,16130 +-540,47,16632 +-806,-174,15765 +1564,370,18332 +184,164,16038 +588,562,16181 +25,263,15258 +658,334,17214 +317,989,16932 +-196,1575,16359 +-259,1775,17488 +514,1750,16624 +-774,2439,16103 +7,2802,16439 +-768,3379,15815 +-479,3639,16532 +-811,3755,16103 +-1254,4217,15738 +-1195,4314,16043 +-1579,5195,16073 +-1858,5646,15461 +-1788,6080,15533 +-2632,6825,15638 +-2272,6969,14972 +-2633,6874,14814 +-2648,7638,15153 +-2799,7996,14348 +-2238,8210,13372 +-2205,9301,14662 +-2757,9096,13569 +-3751,10194,14203 +-2837,9229,11970 +-3132,9804,12644 +-3120,10615,12234 +-3221,11564,12639 +-3036,11070,10793 +-2865,11860,11799 +-2995,11821,10492 +-2944,12415,10637 +-3215,12716,10238 +-2995,12879,9572 +-3373,13228,9856 +-3606,13165,9007 +-2960,13110,10268 +-3720,13633,9289 +-3033,12681,8444 +-3649,13318,7989 +-3108,13284,7658 +-3562,13841,8055 +-4104,14085,8073 +-3217,13786,8014 +-3784,14132,7885 +-2820,12967,7356 +-3308,13860,8062 +-3954,14150,8661 +-3852,13000,7823 +-3702,12915,8975 +-3047,12914,9150 +-2694,13069,9126 +-3315,13247,9855 +-3590,12685,8185 +-3300,12382,8053 +-2749,13250,9628 +-3046,13431,9706 +-3260,12576,9100 +-3186,12232,9770 +-4560,11794,10455 +-2468,10628,11772 +-3387,10793,12849 +-2664,9666,12797 +-2481,9098,13337 +-2448,8651,13095 +-2769,7900,13805 +-1887,7438,14990 +-2372,6499,14305 +-2125,6484,16002 +-2148,5618,15765 +-2210,4881,15448 +-1714,4030,16348 +-2130,2729,15353 +-2469,2837,16317 +-1943,925,17241 +-3450,425,17563 +-1961,-1513,16782 +-2398,-2645,16590 +-1336,-4477,15967 +-2074,-3892,17765 +-2992,-5564,14748 +-1080,-7171,15736 +-2035,-7542,15060 +-1887,-7841,13957 +-904,-10674,11324 +-1731,-11021,12101 +-1585,-12192,11811 +-1369,-13317,10348 +-1932,-12534,11327 +-769,-13665,10000 +-1055,-14411,8280 +-406,-14073,8392 +555,-14641,8141 +-804,-14220,6896 +138,-14640,6956 +784,-15011,6193 +1765,-15855,4949 +557,-15491,5564 +1643,-15004,5489 +1873,-15082,4540 +3102,-15837,3322 +2451,-15314,2979 +2096,-15089,3262 +2253,-16001,3622 +2582,-16385,2988 +2428,-16420,2717 +2459,-16275,2993 +2465,-14717,2175 +1673,-16660,2618 +2172,-15971,2799 +2318,-15980,2938 +1982,-15931,2875 +2418,-16184,3589 +2357,-15925,3285 +2410,-15893,3902 +2318,-15248,2453 +1069,-16125,3300 +1879,-15891,4219 +2317,-16145,4892 +563,-15720,6386 +1078,-15474,5277 +1257,-14533,6062 +620,-14432,7447 +108,-13953,8283 +894,-14126,8953 +454,-12957,10656 +-179,-12594,10471 +-55,-12185,10681 +507,-12300,11375 +226,-11759,11174 +-172,-10976,12414 +-246,-10918,12614 +-454,-10277,13828 +-1133,-9993,14581 +-756,-8302,13732 +-684,-7963,13816 +120,-6368,15579 +-1212,-5586,16147 +-83,-4307,16885 +-1059,-3456,15784 +-809,-2232,16301 +-627,-1362,16252 +-399,-162,16658 +-1674,1756,18719 +-381,704,15986 +-1659,3352,16708 +-2572,3619,15717 +-1322,3119,14259 +-1716,4161,15856 +-4246,6760,18538 +-1461,3799,15454 +-2258,4613,14923 +-2575,4376,15205 +-1192,3054,15748 +-1908,3043,16419 +-1926,2955,17043 +-2598,3473,18052 +-1866,1726,16706 +-799,760,15932 +-1114,789,16134 +-1814,1083,17158 +-986,-281,17026 +-576,-1254,16038 +-876,-1301,16825 +-815,-1586,17202 +-214,-1435,16895 +-255,-2169,16713 +-613,-2160,16929 +101,-2048,16349 +-238,-2113,16730 +-102,-1922,16382 +-328,-2041,16176 +-8,-1938,16602 +-374,-2001,16188 +-333,-2290,16484 +-293,-2145,17043 +-452,-2336,16684 +-292,-2393,16127 +-126,-1996,16380 +1162,-3223,16341 +-700,-1672,17353 +98,-1960,16797 +157,-2115,16823 +328,-2330,15514 +152,-2156,16396 +698,-2257,16039 +152,-1981,16371 +333,-1920,17361 +412,-1867,16625 +625,-946,16132 +189,-394,16345 +433,-653,16213 +1061,-239,16781 +902,-430,16786 +770,-131,17166 +212,-22,16913 +385,-255,16293 +-101,-359,15702 +415,-166,17076 +1106,-493,17358 +-10,-591,16690 +187,-298,16744 +1056,-378,16974 +724,-226,16587 +879,-208,16726 +834,-287,16674 +1296,-796,16703 +-56,110,16621 +-86,49,16520 +354,-259,16732 +-55,26,16535 +-37,29,16542 +-35,31,16764 +-4,28,16751 +-8,41,16748 +-14,82,16759 +-67,38,16759 +-59,43,16533 +-49,83,16540 +263,4,16557 +-314,-1078,16692 +367,-22,16541 +-458,-594,16757 +53,-305,16534 +67,-305,16551 +-75,26,16558 +-77,-297,16551 +123,-277,16543 +-97,21,16529 +-85,24,16527 +-119,-258,16528 +-108,-270,16551 +-66,-264,16545 +-80,18,16525 +-71,11,16526 +-640,-149,16589 +214,76,16766 +-281,-324,16526 +251,91,16550 +75,80,16555 +-91,-337,16579 +277,-268,16542 +119,95,16566 +64,-295,16542 +-43,-319,16542 +-45,-80,16546 +86,-277,16542 +-89,-370,16548 +-73,-99,16558 +-57,15,16578 +-88,-348,16584 +-28,25,16542 +-100,57,16553 +-271,-336,16550 +-31,-292,16611 +-99,-268,16555 +360,-126,16760 +-315,-273,16567 +-100,-318,16577 +127,-275,16583 +338,-99,16568 +-275,-316,16560 +-61,-344,16564 +-74,98,16531 +-54,103,16562 +-102,-366,16555 +-120,-295,16577 +-24,127,16530 +-106,-307,16544 +102,-376,16725 +394,952,16918 +-4,-328,17003 +46,-361,16584 +-113,25,16573 +-47,39,16550 +-110,-308,16527 +1311,-8,16670 +385,310,16812 +1317,-436,16787 +859,208,16721 +2030,167,16793 +3011,-86,16374 +4699,-606,16206 +5371,-192,15861 +5686,467,16656 +7959,-326,15865 +10005,-463,11758 +10352,1065,12280 +11791,-344,12436 +11266,185,12098 +11238,144,12505 +10937,176,12397 +10961,406,12392 +11170,624,12216 +11175,486,11956 +11237,432,12277 +11682,315,12084 +10959,878,12768 +11531,801,12115 +11163,973,12584 +11222,1044,11962 +11412,828,12081 +11432,841,12312 +11519,470,12095 +11473,811,12085 +11507,476,11730 +11788,438,11767 +11394,770,12327 +11396,790,12288 +11808,536,12092 +11481,411,12045 +11440,390,12054 +11167,437,11955 +10972,631,12519 +10468,758,12837 +9929,1059,13022 +9574,1019,14064 +9945,513,13099 +9735,625,13495 +9762,203,13486 +9345,196,13733 +9796,-12,13529 +9325,629,14096 +9363,146,13462 +9170,334,14078 +9547,-15,13750 +9338,152,13742 +9183,290,13735 +9136,325,14120 +9526,299,13875 +9638,50,13041 +9336,200,14205 +9588,-22,13941 +9151,215,13705 +9169,310,13940 +9269,361,14119 +9050,-39,13722 +7560,971,15123 +8241,390,14320 +7765,862,14784 +8033,529,14548 +7317,792,14822 +7386,638,14735 +7495,416,15212 +7482,569,14814 +7215,788,15024 +7064,639,15196 +7181,872,15022 +7215,781,15224 +7040,462,15205 +7437,599,14820 +7055,630,15055 +7064,597,14990 +7079,522,15231 +7048,582,15212 +7200,460,15162 +7234,412,14991 +7200,638,15220 +6810,483,15235 +7194,533,15150 +7253,239,15206 +6911,551,15376 +6819,634,15052 +6950,423,15405 +7012,589,15380 +6801,639,14986 +6580,412,15098 +6565,532,15475 +6125,544,15620 +6005,141,15631 +5302,363,15909 +4844,-98,15936 +4458,-488,16460 +3014,80,16394 +1265,-226,16476 +610,-445,17974 +1025,430,16587 +857,-570,16549 +-483,-104,16563 +178,772,16972 +92,-274,16519 +99,-236,16699 +-27,122,16570 +52,-132,16611 +-28,27,16547 +-35,60,16515 +-3,31,16553 +-43,32,16572 +-13,54,16523 +-20,28,16568 +-1,84,16572 +-19,21,16567 +-22,0,16520 +-63,59,16545 +-17,8,16564 +132,-114,16561 +-2370,-4619,17417 +-146,-216,16675 +360,263,16909 +236,-897,16750 +-65,-2029,16991 +-787,-3312,16116 +-515,-3863,16951 +-439,-3296,16088 +302,-4446,16202 +122,-4497,15562 +-246,-4951,15675 +364,-4732,16255 +-289,-5038,16152 +-521,-5249,15728 +-66,-5746,15624 +-171,-5587,15908 +-105,-5766,15960 +142,-6488,15327 +377,-6784,15042 +277,-6728,15060 +332,-7272,15395 +764,-7702,14808 +269,-7730,14873 +550,-7606,14696 +2053,-9037,15002 +1398,-8686,12752 +-2067,-7024,14668 +304,-8112,16191 +3704,-10146,11717 +-1058,-7072,14025 +3214,-9893,14971 +-736,-7434,13091 +4239,-9727,14138 +-3584,-5783,15383 +3997,-9461,15745 +456,-8264,10257 +-845,-7028,20529 +2262,-10052,10248 +-1980,-5412,18028 +4340,-11133,10830 +-3915,-4773,16954 +3861,-9395,16438 +1333,-7791,10271 +-67,-6781,19891 +1121,-8887,10249 +-1674,-5071,18603 +2740,-10322,9704 +-2706,-5240,18675 +3734,-10093,11540 +-1496,-5780,15316 +1531,-8468,16443 +-902,-6848,13505 +2534,-8069,14759 +-1650,-6952,13491 +1050,-6622,18704 +1084,-8085,10941 +-419,-5727,18787 +367,-8405,12189 +695,-6371,17655 +110,-8570,10381 +-2464,-4250,21220 +970,-8334,11217 +1311,-6690,15229 +120,-7425,15123 +-2630,-5043,17453 +3536,-9297,12203 +-4606,-3829,20066 +4227,-9811,13673 +-337,-6222,12897 +1023,-7402,16423 +-463,-6914,13535 +-2088,-5715,18700 +3714,-9331,9917 +-2176,-5449,16932 +342,-7939,17281 +2410,-8471,12246 +-2159,-5997,18498 +1331,-8600,12093 +-572,-6143,17301 +2278,-9294,11374 +-3098,-4606,18987 +3170,-9798,13370 +-974,-5961,15416 +993,-7990,16483 +-448,-7140,12663 +1384,-7362,18004 +-1757,-6425,12152 +1503,-7996,18158 +-122,-7639,12705 +712,-6894,16819 +-277,-7767,13201 +428,-6557,17526 +937,-8529,10863 +-2844,-4838,18703 +2025,-9147,12464 +-2013,-5484,15241 +173,-7759,17441 +-470,-6660,12414 +-580,-5814,16043 +-1217,-6606,16807 +1096,-6518,13635 +-1088,-5903,16216 +-1143,-5219,15932 +-405,-4942,15878 +-1351,-4625,15700 +-783,-3304,17311 +433,-3752,15191 +-903,-2623,16680 +-142,-1845,16828 +-422,-924,16463 +-368,-1092,16753 +1551,2587,16170 +396,310,16427 +-192,-177,16120 +-50,13,16536 +-106,9,16517 +819,-306,17491 +505,-1662,15687 +1310,-1192,17187 +-2757,2276,20794 +2135,-2657,12673 +-2769,311,16730 +4399,-3371,15711 +-4739,2872,17867 +6943,-3630,15043 +-2064,-398,14940 +-1867,2103,22510 +5021,-3449,11536 +-3034,1282,18167 +1907,-1169,19675 +-313,-1753,13022 +-751,2228,23151 +3090,-3249,12044 +-2396,1196,19154 +3476,-2480,15718 +-253,-1328,15167 +-916,990,20700 +2488,-2441,13222 +-1888,382,18366 +207,-612,17488 +1034,-1236,14611 +634,-1022,16473 +24,-923,17634 +588,-758,16956 +-494,-621,16758 +834,-1552,16534 +-793,-862,17003 +-1012,-1139,15947 +578,-382,16782 +1081,-1652,16521 +-122,-956,16296 +-178,-414,16254 +1955,1182,14706 +-446,66,16904 +-116,6,16764 +149,98,16358 +175,83,16752 +-98,6,16537 +120,-275,16570 +1431,417,18030 +-941,-381,16800 +309,-208,16617 +26,-754,16679 +-127,-355,16594 +-335,282,16120 +299,125,16580 +-115,-278,16555 +116,-279,16563 +-1018,-854,16522 +274,-67,16607 +-201,-558,16591 +-86,3,16542 +1525,1327,16950 +-995,-1961,16662 +45,-373,16614 +-296,-196,16569 +-43,55,16552 +82,0,16521 +84,-352,16593 +108,-305,16533 +-32,36,16551 +-113,18,16528 +-117,-260,16560 +68,-347,16545 +-67,-297,16560 +119,63,16550 +-73,75,16551 +-78,-378,16570 +14,-333,16589 +-61,123,16569 +121,-292,16978 +156,-100,16567 +-465,-283,16753 +344,623,17503 +40,-45,16808 +3469,612,17929 +2616,-1551,19164 +-1284,-1417,15931 +255,-2280,17708 +-950,-2100,14975 +-3264,-1239,15659 +-7110,-1597,16562 +-7102,-2824,13536 +-8640,-675,14188 +-11023,-1070,11823 +-12186,-1504,9048 +-17821,-1135,4529 +-13530,-1950,2945 +-16622,-1531,1053 +-14622,-1513,-3960 +-15453,-2017,-6476 +-15994,-3222,-8420 +-14103,-2899,-11698 +-14065,-3756,-10544 +-9813,-4185,-11194 +-11655,-3097,-11496 +-12279,-3999,-12568 +-9906,-2910,-12995 +-9256,-3250,-13632 +-10198,-2262,-12583 +-9833,-2229,-14080 +-8683,-1727,-14359 +-6732,-1180,-15049 +-6299,-906,-14596 +-7490,-1548,-14331 +-6077,-940,-14155 +-3416,866,-15838 +-3404,855,-16138 +-3987,491,-15103 +-5594,1285,-14997 +-3794,-150,-16581 +-3623,-105,-16744 +-2322,-155,-16030 +-1382,-542,-15800 +-2120,-1026,-16537 +-1610,-974,-16720 +-2046,-669,-17994 +-1056,-776,-15460 +-1468,-491,-16174 +-1467,-1343,-17211 +96,-839,-16330 +-923,-187,-15956 +-1507,11,-16893 +-806,-220,-16453 +-1266,79,-16721 +-890,-916,-16950 +-16,-494,-16562 +-433,-369,-16595 +-349,-254,-17785 +-1794,-262,-16155 +-1834,-145,-16268 +-975,-586,-17161 +-275,-164,-16624 +-1444,-15,-15089 +-2936,-179,-16293 +-1331,-473,-16935 +-1015,-443,-16749 +-752,-771,-16943 +-1945,-356,-16821 +-1631,-547,-15592 +-902,-620,-16548 +-1714,-408,-16539 +-1556,-946,-16477 +-935,-607,-17172 +-1195,-565,-15894 +-1949,-183,-17748 +-1660,-878,-15399 +-1137,-395,-16942 +-1966,-376,-15813 +-1466,-505,-17987 +-807,-491,-16706 +-1528,-254,-16013 +-1299,-487,-17081 +-1398,-478,-16180 +-1679,-413,-15749 +-1562,-597,-16271 +-729,-501,-16436 +-1188,-462,-17277 +-1967,-543,-16684 +-503,-477,-16525 +-1929,-878,-16837 +-1460,-410,-16420 +-724,-259,-16031 +-2340,-189,-15740 +-2219,-196,-16859 +-256,-419,-16482 +-2373,-434,-16315 +-2367,-553,-16993 +-1342,-157,-17070 +-1276,-569,-15643 +-2920,-175,-16467 +-1853,27,-16940 +-1273,-417,-15909 +-1782,-196,-15841 +-1253,192,-17957 +-1972,-327,-15473 +-1720,-665,-16555 +-614,-596,-18201 +-734,-426,-16034 +-3335,-441,-15910 +-1007,-174,-17550 +-401,-255,-14756 +-2891,-170,-17274 +-1519,281,-17473 +-468,6,-15016 +-2861,-607,-15784 +-1944,126,-17379 +-1102,-20,-15441 +-2905,-429,-16023 +-2378,-147,-17235 +38,198,-16543 +-3454,-170,-14972 +-3289,-282,-17551 +402,-270,-16046 +-2322,-174,-15264 +-3295,103,-17467 +-105,95,-16203 +-2263,-429,-16175 +-3035,285,-17978 +88,-50,-16190 +-2759,-149,-15831 +-2268,60,-17288 +-1591,328,-16275 +-1731,-312,-16709 +-3403,107,-16460 +-844,-169,-16180 +-2599,-533,-17223 +-1175,-329,-16320 +-2372,-176,-16824 +-2067,-272,-17211 +-1516,-46,-16063 +-2106,85,-16320 +-2262,82,-16968 +-1373,-307,-15782 +-2634,-302,-16937 +-1897,-276,-16300 +-1989,106,-16088 +-2040,79,-16333 +-2244,321,-16459 +-1668,-175,-16154 +-1814,125,-17279 +-1759,171,-16281 +-2904,147,-16459 +-1694,25,-16382 +-2322,77,-16297 +-1533,-37,-16012 +-2358,-65,-15754 +-2615,-30,-16377 +-1765,-99,-16450 +-2491,28,-15784 +-2362,-318,-16123 +-3501,-424,-16836 +-2715,-827,-16223 +-3839,-431,-15833 +-4083,-1135,-16593 +-3242,-801,-15494 +-4307,-505,-15537 +-4496,-931,-16294 +-4812,-1324,-16059 +-5135,-432,-15945 +-5869,-206,-15259 +-6671,-1185,-15631 +-6280,-1090,-15071 +-6823,-243,-14729 +-7269,-702,-14702 +-8249,-834,-14845 +-8345,-522,-13953 +-8796,-45,-14236 +-9605,-1165,-12492 +-10742,-1219,-11132 +-13379,-2294,-10922 +-13696,-2052,-9606 +-13787,-2033,-9595 +-13694,-1232,-8306 +-14205,-1642,-8510 +-16793,-1432,-2819 +-17270,-2808,-2702 +-16396,-2543,-519 +-17469,-2159,917 +-15265,-1688,3457 +-16270,-1469,3924 +-14562,-1500,4374 +-11552,-1242,10294 +-17171,-728,11282 +-12418,-1873,11792 +-11172,-2724,12067 +-10338,-3168,10927 +-10366,-1093,12007 +-8881,-802,12595 +-6839,-972,15930 +-6270,-1253,16681 +-5082,-152,16574 +-1621,-1848,16921 +-902,-1767,15499 +1266,-1173,18089 +4086,-2116,15963 +5944,-1684,16306 +9776,-3239,12474 +11815,-2436,11268 +11522,-3038,8615 +14084,-3738,6984 +12709,-4237,3976 +14165,-4182,5968 +14370,-4789,4705 +15190,-5211,6448 +13994,-4370,7446 +15617,-4919,8025 +12727,-3554,8192 +13912,-2984,7739 +12672,-3483,8153 +12899,-3130,11218 +11352,-3225,12372 +9560,-3365,13466 +6638,-2965,12146 +7094,-2209,16830 +4705,-3665,12651 +5091,-2698,16594 +2362,-2416,15538 +1497,-1409,16405 +222,-182,18281 +-331,-602,16678 +-384,299,17379 +335,-319,16536 +-274,310,16225 +701,170,16581 +455,-995,16179 +-225,-132,16271 +-323,-343,16994 +420,-522,16359 +353,-454,16751 +517,-441,16424 +59,631,16380 +-195,39,16760 +-88,-281,16354 +457,5,16577 +-17,282,16907 +59,-333,16627 +-80,27,16578 +-75,25,16554 +-61,5,16565 +-58,-271,16556 +-41,11,16533 +-53,58,16592 +-30,52,16530 +-84,-330,16574 +-45,-304,16551 +257,-111,16547 +120,125,16554 +321,-136,16525 +-33,121,16562 +122,110,16764 +364,-340,16545 +-121,-257,16571 +-73,-78,16550 +261,-315,16533 +-28,-260,16564 +123,-110,16753 +268,1,16565 +258,-337,16577 +-84,79,16567 +-69,101,16557 +-4,-309,16549 +-59,18,16555 +-119,-124,16569 +-16,38,16517 +-14,-270,16529 +-91,69,16553 +296,5,16569 +263,18,16587 +124,41,16541 +288,62,16555 +299,30,16574 +-66,63,16572 +-31,31,16541 +-44,44,16554 +-61,46,16577 +-52,57,16540 +287,64,16559 +-105,71,16562 +-26,11,16570 +-93,11,16545 +307,75,16531 +-64,23,16536 +-30,17,16567 +-28,23,16557 +-15,41,16574 +-36,49,16540 +-37,23,16566 +-7,44,16540 +257,66,16557 +-39,37,16562 +258,22,16566 +-42,23,16552 +-15,80,16542 +-4,24,16557 +281,68,16517 +-95,22,16561 +-17,92,16569 +264,9,16550 +-48,39,16551 +-48,49,16524 +306,27,16567 +258,29,16546 +-70,97,16526 +-34,-291,16568 +-47,104,16548 +-16,61,16560 +-45,22,16512 +-15,-274,16581 +-35,83,16550 +-47,56,16574 +346,-321,16589 +-125,84,16536 +-66,53,16570 +301,-273,16583 +-100,73,16544 +-47,61,16562 +-22,6,16548 +-16,37,16555 diff --git a/agent/src/data/gps.csv b/agent/src/data/gps.csv new file mode 100644 index 0000000..43141ca --- /dev/null +++ b/agent/src/data/gps.csv @@ -0,0 +1,126 @@ +longitude,latitude +50.450386085935094,30.524547100067142 +50.45050063818424,30.52432932092009 +50.45061519043338,30.524111541773035 +50.450729742682526,30.52389376262598 +50.45084429493167,30.523675983478928 +50.450958847180814,30.523458204331874 +50.45107339942996,30.52324042518482 +50.4511879516791,30.523022646037766 +50.45130250392825,30.522804866890713 +50.45141705617739,30.52258708774366 +50.45158184958234,30.52247389776916 +50.451757508676074,30.522413170763514 +50.45193316776981,30.522352443757867 +50.452108826863544,30.52229171675222 +50.45228448595728,30.522230989746575 +50.45246014505101,30.52217026274093 +50.45263580414475,30.522109535735282 +50.45281146323848,30.522048808729636 +50.45298712233222,30.52198808172399 +50.45316278142595,30.521927354718343 +50.45333844051969,30.521866627712697 +50.4535017075372,30.521748100680377 +50.45366497455471,30.521629573648056 +50.453828241572225,30.521511046615736 +50.45399150858974,30.521392519583415 +50.45415477560725,30.521273992551095 +50.45431804262476,30.521155465518774 +50.454481309642276,30.521036938486453 +50.45464457665979,30.520918411454133 +50.4548078436773,30.520799884421812 +50.454971110694814,30.520681357389492 +50.455093555427055,30.520474423051503 +50.4552160001593,30.520267488713515 +50.45523090797679,30.51998595727611 +50.455245815794285,30.519704425838704 +50.45526072361178,30.5194228944013 +50.455275631429274,30.519141362963893 +50.45529053924677,30.518859831526488 +50.45530544706426,30.518578300089082 +50.455320354881756,30.518296768651677 +50.45533526269925,30.51801523721427 +50.455350170516745,30.517733705776866 +50.45536507833424,30.51745217433946 +50.45535571063255,30.517170053920086 +50.45518133729636,30.517100783785818 +50.455006963960166,30.51703151365155 +50.45483259062397,30.51696224351728 +50.45465821728778,30.516892973383012 +50.454483843951586,30.516823703248743 +50.45430947061539,30.516754433114475 +50.4541350972792,30.516685162980206 +50.45397769437711,30.51682186381075 +50.45382029147502,30.516958564641296 +50.45366288857293,30.51709526547184 +50.45348323217105,30.517081686354636 +50.45336278271238,30.51687189126274 +50.45324233325371,30.51666209617084 +50.45312188379504,30.516452301078942 +50.45297828058652,30.516282205294928 +50.452804445806855,30.516209678584172 +50.45263061102719,30.516137151873416 +50.45245677624752,30.51606462516266 +50.45228294146786,30.515992098451903 +50.45210910668819,30.515919571741147 +50.451935271908525,30.51584704503039 +50.45176143712886,30.515774518319635 +50.45158760234919,30.51570199160888 +50.45141376756953,30.515629464898122 +50.45123993278986,30.515556938187366 +50.451066098010195,30.51548441147661 +50.45089226323053,30.515411884765854 +50.45071842845086,30.515339358055098 +50.4505445936712,30.51526683134434 +50.45037075889153,30.515194304633585 +50.450196924111864,30.51512177792283 +50.4500230893322,30.515049251212073 +50.44984925455253,30.514976724501317 +50.449675419772866,30.51490419779056 +50.4495015849932,30.514831671079804 +50.449327750213534,30.514759144369048 +50.44915391543387,30.514686617658292 +50.4489800806542,30.514614090947536 +50.44893464360986,30.51488739159867 +50.44888920656552,30.515160692249804 +50.448843769521176,30.515433992900938 +50.448798332476834,30.515707293552072 +50.44875289543249,30.515980594203207 +50.44870745838815,30.51625389485434 +50.44866202134381,30.516527195505475 +50.448616584299465,30.51680049615661 +50.44857114725512,30.517073796807743 +50.44852571021078,30.517347097458877 +50.44848027316644,30.51762039811001 +50.4484348361221,30.517893698761146 +50.448389399077755,30.51816699941228 +50.44834396203341,30.518440300063414 +50.44829852498907,30.51871360071455 +50.44825308794473,30.518986901365682 +50.448207650900386,30.519260202016817 +50.448162213856044,30.51953350266795 +50.4481167768117,30.519806803319085 +50.44807133976736,30.52008010397022 +50.44802590272302,30.520353404621353 +50.447980465678675,30.520626705272488 +50.44793502863433,30.52090000592362 +50.44788959158999,30.521173306574756 +50.44784415454565,30.52144660722589 +50.44779871750131,30.521719907877024 +50.447753280456965,30.52199320852816 +50.4479216063945,30.52209274810735 +50.44808993233204,30.522192287686543 +50.448258258269576,30.522291827265736 +50.44842658420711,30.52239136684493 +50.44859491014465,30.52249090642412 +50.448763236082186,30.522590446003314 +50.44893156201972,30.522689985582506 +50.44907610254229,30.52285809923405 +50.44922064306486,30.523026212885593 +50.44936518358743,30.523194326537137 +50.44950972411,30.52336244018868 +50.44965426463257,30.523530553840224 +50.44979880515514,30.523698667491768 +50.44994334567771,30.52386678114331 +50.450069433207545,30.52406822530458 +50.450204300386,30.52425511880424 diff --git a/agent/src/domain/accelerometer.py b/agent/src/domain/accelerometer.py new file mode 100644 index 0000000..44c9ed7 --- /dev/null +++ b/agent/src/domain/accelerometer.py @@ -0,0 +1,8 @@ +from dataclasses import dataclass + + +@dataclass +class Accelerometer: + x: int + y: int + z: int diff --git a/agent/src/domain/aggregated_data.py b/agent/src/domain/aggregated_data.py new file mode 100644 index 0000000..d05a183 --- /dev/null +++ b/agent/src/domain/aggregated_data.py @@ -0,0 +1,12 @@ +from dataclasses import dataclass + +from datetime import datetime +from domain.accelerometer import Accelerometer +from domain.gps import Gps + + +@dataclass +class AggregatedData: + accelerometer: Accelerometer + gps: Gps + time: datetime diff --git a/agent/src/domain/gps.py b/agent/src/domain/gps.py new file mode 100644 index 0000000..eadfab8 --- /dev/null +++ b/agent/src/domain/gps.py @@ -0,0 +1,7 @@ +from dataclasses import dataclass + + +@dataclass +class Gps: + longitude: float + latitude: float diff --git a/agent/src/file_datasource.py b/agent/src/file_datasource.py new file mode 100644 index 0000000..b2194f8 --- /dev/null +++ b/agent/src/file_datasource.py @@ -0,0 +1,21 @@ +from csv import reader +from datetime import datetime +from domain.aggregated_data import AggregatedData + + +class FileDatasource: + def __init__( + self, + accelerometer_filename: str, + gps_filename: str, + ) -> None: + pass + + def read(self) -> AggregatedData: + """Метод повертає дані отримані з датчиків""" + + def startReading(self, *args, **kwargs): + """Метод повинен викликатись перед початком читання даних""" + + def stopReading(self, *args, **kwargs): + """Метод повинен викликатись для закінчення читання даних""" diff --git a/agent/src/main.py b/agent/src/main.py new file mode 100644 index 0000000..52351bd --- /dev/null +++ b/agent/src/main.py @@ -0,0 +1,53 @@ +from paho.mqtt import client as mqtt_client +import json +import time +from schema.aggregated_data_schema import AggregatedDataSchema +from file_datasource import FileDatasource +import config + + +def connect_mqtt(broker, port): + """Create MQTT client""" + print(f"CONNECT TO {broker}:{port}") + + def on_connect(client, userdata, flags, rc): + if rc == 0: + print(f"Connected to MQTT Broker ({broker}:{port})!") + else: + print("Failed to connect {broker}:{port}, return code %d\n", rc) + exit(rc) # Stop execution + + client = mqtt_client.Client() + client.on_connect = on_connect + client.connect(broker, port) + client.loop_start() + return client + + +def publish(client, topic, datasource, delay): + datasource.startReading() + while True: + time.sleep(delay) + data = datasource.read() + msg = AggregatedDataSchema().dumps(data) + result = client.publish(topic, msg) + # result: [0, 1] + status = result[0] + if status == 0: + pass + # print(f"Send `{msg}` to topic `{topic}`") + else: + print(f"Failed to send message to topic {topic}") + + +def run(): + # Prepare mqtt client + client = connect_mqtt(config.MQTT_BROKER_HOST, config.MQTT_BROKER_PORT) + # Prepare datasource + datasource = FileDatasource("data/data.csv", "data/gps_data.csv") + # Infinity publish data + publish(client, config.MQTT_TOPIC, datasource, config.DELAY) + + +if __name__ == "__main__": + run() diff --git a/agent/src/schema/accelerometer_schema.py b/agent/src/schema/accelerometer_schema.py new file mode 100644 index 0000000..8dcc76b --- /dev/null +++ b/agent/src/schema/accelerometer_schema.py @@ -0,0 +1,7 @@ +from marshmallow import Schema, fields + + +class AccelerometerSchema(Schema): + x = fields.Int() + y = fields.Int() + z = fields.Int() diff --git a/agent/src/schema/aggregated_data_schema.py b/agent/src/schema/aggregated_data_schema.py new file mode 100644 index 0000000..eca4069 --- /dev/null +++ b/agent/src/schema/aggregated_data_schema.py @@ -0,0 +1,9 @@ +from marshmallow import Schema, fields +from schema.accelerometer_schema import AccelerometerSchema +from schema.gps_schema import GpsSchema + + +class AggregatedDataSchema(Schema): + accelerometer = fields.Nested(AccelerometerSchema) + gps = fields.Nested(GpsSchema) + time = fields.DateTime("iso") diff --git a/agent/src/schema/gps_schema.py b/agent/src/schema/gps_schema.py new file mode 100644 index 0000000..a720009 --- /dev/null +++ b/agent/src/schema/gps_schema.py @@ -0,0 +1,6 @@ +from marshmallow import Schema, fields + + +class GpsSchema(Schema): + longitude = fields.Number() + latitude = fields.Number()