graph/test/test.py

53 lines
908 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():
2024-05-17 14:24:47 +00:00
start = 0
while True:
x = np.linspace(start, start+0.5, 100)
y = np.sin(x)
start += 0.5
2024-05-16 23:43:31 +00:00
2024-05-17 14:24:47 +00:00
data = {
"chart": 0,
"series": "R1",
"points": [ {"x": i[0], "y":i[1]} for i in zip(x,y) ]
}
2024-05-16 23:43:31 +00:00
2024-05-17 14:24:47 +00:00
r = requests.post("http://0.0.0.0:8080/add", json=data, headers={"Connection":"close"})
sleep(0.25)
2024-05-16 23:43:31 +00:00
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()
2024-05-17 14:24:47 +00:00
#star()
2024-05-15 20:52:13 +00:00
if __name__ == "__main__":
2024-05-16 23:43:31 +00:00
main()