Skip to content

Commit

Permalink
datetime.datetime.utcnow()
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamBenes3 committed Dec 1, 2023
1 parent 4457930 commit 2df374a
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 20 deletions.
4 changes: 2 additions & 2 deletions CDP.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
app = FastAPI()
router = APIRouter()

#express_base_url = "http://localhost:4000"
express_base_url = "https://fik.crreat.eu"
express_base_url = "http://localhost:4000"
#express_base_url = "https://fik.crreat.eu"

car_dict = {}

Expand Down
5 changes: 2 additions & 3 deletions LDP.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

topic = '#'
balloons_dict = {}
#express_base_url = "http://localhost:4000"
express_base_url = "https://fik.crreat.eu"
express_base_url = "http://localhost:4000"
#express_base_url = "https://fik.crreat.eu"


def heartbeat_loop():
Expand Down Expand Up @@ -74,7 +74,6 @@ def on_message(client, userdata, message):
longitude,
altitude + 1000
)
time.sleep(10)
except json.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
try:
Expand Down
Binary file modified __pycache__/CDP.cpython-311.pyc
Binary file not shown.
210 changes: 210 additions & 0 deletions data/ALLDATA.json
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,216 @@
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 09:59:11.560442"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:20:44.133456"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:20:44.206615"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:20:44.230646"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:20:50.988906"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:20:50.999404"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:20:51.009825"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:20:57.564997"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:20:57.578542"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:20:57.592307"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:21:04.743176"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:21:04.761129"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:21:04.792345"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:21:11.674539"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:21:11.687398"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:21:11.709589"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:21:18.583936"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:21:18.596222"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:21:18.602990"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:21:25.573039"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:21:25.579319"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:21:25.584951"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 10:21:32.154757"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 10:21:32.165938"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 10:21:32.186419"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 09:21:54.198845"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 09:21:54.214604"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 09:21:54.221554"
},
{
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 09:22:01.032993"
},
{
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 09:22:01.046950"
},
{
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 09:22:01.057367"
}
]
}
2 changes: 1 addition & 1 deletion data/car1_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": "2023-12-01 09:59:11.531726"
"tmp": "2023-12-01 09:22:01.032993"
}
2 changes: 1 addition & 1 deletion data/car1_hb.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"car_heartbeat_value": "2023-12-01 09:59:16.573293",
"car_heartbeat_value": "2023-12-01 09:22:06.072089",
"car_id": "car1",
"latitude": 50.073,
"longitude": 14.418,
Expand Down
2 changes: 1 addition & 1 deletion data/car2_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": "2023-12-01 09:59:11.543593"
"tmp": "2023-12-01 09:22:01.046950"
}
2 changes: 1 addition & 1 deletion data/car2_hb.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"car_heartbeat_value": "2023-12-01 09:59:09.994743",
"car_heartbeat_value": "2023-12-01 09:22:06.640647",
"car_id": "car2",
"latitude": 50.073,
"longitude": 14.418,
Expand Down
2 changes: 1 addition & 1 deletion data/car3_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 09:59:11.560442"
"tmp": "2023-12-01 09:22:01.057367"
}
2 changes: 1 addition & 1 deletion data/car3_hb.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"car_heartbeat_value": "2023-12-01 09:59:10.712288",
"car_heartbeat_value": "2023-12-01 09:22:07.258920",
"car_id": "car3",
"latitude": 50.073,
"longitude": 14.418,
Expand Down
2 changes: 1 addition & 1 deletion data/car_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": "2023-12-01 09:59:11.560442"
"tmp": "2023-12-01 10:21:32.186419"
}
2 changes: 1 addition & 1 deletion data/cdp_hb.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"cdp_heartbeat_value": "2023-12-01 09:59:16.366896"
"cdp_heartbeat_value": "2023-12-01 09:22:19.847018"
}
2 changes: 1 addition & 1 deletion data/ldp_hb.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"ldp_heartbeat_value": "2023-11-30 17:10:43.360383"
"ldp_heartbeat_value": "2023-12-01 09:22:23.728235"
}
12 changes: 6 additions & 6 deletions fastapi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def send_heartbeat():
url = "http://localhost:8000/post/car/hb"

# Heartbeat data
heartbeat_data = {"car_heartbeat_value": str(datetime.datetime.now()), "car_id": "car1", "latitude": 50.073, "longitude": 14.418, "altitude": 400}
heartbeat_data = {"car_heartbeat_value": str(datetime.datetime.utcnow()), "car_id": "car1", "latitude": 50.073, "longitude": 14.418, "altitude": 400}

# Send POST request to the FastAPI app
response = requests.post(url, json=heartbeat_data)
Expand All @@ -16,7 +16,7 @@ def send_heartbeat():
url = "http://localhost:8000/post/car/hb"

# Heartbeat data
heartbeat_data = {"car_heartbeat_value": str(datetime.datetime.now()), "car_id": "car2", "latitude": 50.073, "longitude": 14.418, "altitude": 400}
heartbeat_data = {"car_heartbeat_value": str(datetime.datetime.utcnow()), "car_id": "car2", "latitude": 50.073, "longitude": 14.418, "altitude": 400}

# Send POST request to the FastAPI app
response = requests.post(url, json=heartbeat_data)
Expand All @@ -25,7 +25,7 @@ def send_heartbeat():
url = "http://localhost:8000/post/car/hb"

# Heartbeat data
heartbeat_data = {"car_heartbeat_value": str(datetime.datetime.now()), "car_id": "car3", "latitude": 50.073, "longitude": 14.418, "altitude": 400}
heartbeat_data = {"car_heartbeat_value": str(datetime.datetime.utcnow()), "car_id": "car3", "latitude": 50.073, "longitude": 14.418, "altitude": 400}

# Send POST request to the FastAPI app
response = requests.post(url, json=heartbeat_data)
Expand All @@ -45,7 +45,7 @@ def send_data():
"latitude": 50.073,
"longitude": 14.618,
"altitude": 400,
"tmp": str(datetime.datetime.now())
"tmp": str(datetime.datetime.utcnow())
}

# Send POST request to the FastAPI app
Expand All @@ -56,7 +56,7 @@ def send_data():
"latitude": 50.073,
"longitude": 14.818,
"altitude": 400,
"tmp": str(datetime.datetime.now())
"tmp": str(datetime.datetime.utcnow())
}

# Send POST request to the FastAPI app
Expand All @@ -67,7 +67,7 @@ def send_data():
"latitude": 50.073,
"longitude": 14.418,
"altitude": 400,
"tmp": str(datetime.datetime.now())
"tmp": str(datetime.datetime.utcnow())
}

# Send POST request to the FastAPI app
Expand Down

0 comments on commit 2df374a

Please sign in to comment.