graph/test/test.py

49 lines
873 B
Python
Raw Normal View History

2024-05-15 20:52:13 +00:00
#!/bin/env python3
import requests
from math import sin
from time import sleep
2024-05-16 23:43:31 +00:00
import numpy as np
import json
2024-05-15 20:52:13 +00:00
2024-05-16 23:43:31 +00:00
def sine():
2024-05-15 20:52:13 +00:00
x = 0.0
while True:
requests.get(f"http://localhost:8080/add?chart=0&series=R1&x={x}&y={sin(x)}")
x += 0.01
sleep(0.01)
2024-05-16 23:43:31 +00:00
def sine_array():
x = np.linspace(0, 2*np.pi, 1)
y = np.sin(x)
data = {
"chart": 0,
"series": "R1",
"points": [ {"x": i[0], "y":i[1]} for i in zip(x,y) ]
}
r = requests.post("http://0.0.0.0:8080/add", json=data, headers={"Connection":"close"})
print(r.request.body, len(r.request.body))
def star():
points = [
(2,2),
(3,0),
(0,1),
(4,1),
(1,0),
(2,2)
]
for point in points:
requests.get(f"http://localhost:8080/add?chart=0&series=R1&x={point[0]}&y={point[1]}")
def main():
#sine()
sine_array()
#star()
2024-05-15 20:52:13 +00:00
if __name__ == "__main__":
2024-05-16 23:43:31 +00:00
main()