deleted unused and no longer needed scripts
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
import threading
|
||||
import queue
|
||||
import paho.mqtt.client as mqtt
|
||||
import time
|
||||
|
||||
# Global variable to store received message
|
||||
received_data = None
|
||||
|
||||
def __on_connect(client, userdata, flags, rc):
|
||||
print("Connected with result code " + str(rc))
|
||||
client.subscribe("test/topic") # Change this to your topic
|
||||
|
||||
def __on_message(client, userdata, msg):
|
||||
global received_data
|
||||
received_data = msg.payload.decode()
|
||||
#TODO: Write data to pickle and in queue
|
||||
print(f"Message received on {msg.topic}: {received_data}")
|
||||
|
||||
def __mqtt_thread():
|
||||
client = mqtt.Client()
|
||||
client.on_connect = __on_connect
|
||||
client.on_message = __on_message
|
||||
|
||||
client.connect("broker.hivemq.com", 1883, 60) # Replace with your broker address and port
|
||||
client.loop_forever()
|
||||
|
||||
def start_mqtt_in_thread():
|
||||
thread = threading.Thread(target=__mqtt_thread, daemon=True)
|
||||
thread.start()
|
||||
|
||||
# Example usage
|
||||
if __name__ == "__main__":
|
||||
start_mqtt_in_thread()
|
||||
|
||||
# Simulate main thread work
|
||||
while True:
|
||||
if received_data:
|
||||
print(f"Main thread sees data: {received_data}")
|
||||
received_data = None # Reset after handling
|
||||
time.sleep(1)
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
from time import sleep
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
import pyads
|
||||
|
||||
|
||||
def check_path(path_str):
|
||||
try:
|
||||
path = Path(path_str)
|
||||
if not path.exists():
|
||||
raise FileNotFoundError(f"Path does not exist: {path_str}")
|
||||
print(f"Path exists: {path_str}")
|
||||
except FileNotFoundError as e:
|
||||
print(f"Error: {e}")
|
||||
config_path = r"C:\Users\berti_r\Python_Projects\StagePerformaceDocu\Config\config.json"
|
||||
check_path(config_path)
|
||||
|
||||
|
||||
|
||||
library_path = r"C:\Users\berti_r\Python_Projects\templates\motion_libs"
|
||||
check_path(library_path)
|
||||
sys.path.append(library_path)
|
||||
measurement_mov_path = r"C:\Users\berti_r\Python_Projects\StagePerformaceDocu\Config\measurement.json"
|
||||
check_path(measurement_mov_path)
|
||||
|
||||
|
||||
import motionFunctionsLib as mfl
|
||||
import time
|
||||
|
||||
|
||||
plc = mfl.plc('5.67.222.118.1.1', 852)
|
||||
|
||||
plc.connect()
|
||||
axis1 = mfl.axis(plc, 1)
|
||||
axis4 = mfl.axis(plc, 4)
|
||||
|
||||
print(axis4.getCoupledGear1())
|
||||
axis1.setAcceleration(10000.0)
|
||||
axis1.setDeceleration(10000.0)
|
||||
axis1.setVelocity(3)
|
||||
|
||||
|
||||
axis4.setAcceleration(10000.0)
|
||||
axis4.setDeceleration(10000.0)
|
||||
axis4.setVelocity(3)
|
||||
|
||||
|
||||
|
||||
axis1.enableAxis()
|
||||
axis4.enableAxis()
|
||||
sleep(1)
|
||||
print("coupling: ",axis4.getCoupledGear1())
|
||||
for i in range(3):
|
||||
axis4.moveRelative(0.5)
|
||||
axis1.moveRelative(0.5)
|
||||
sleep(5)
|
||||
axis4.moveRelative(-0.5)
|
||||
axis1.moveRelative(-0.5)
|
||||
sleep(5)
|
||||
|
||||
|
||||
|
||||
|
||||
axis1.disableAxis()
|
||||
axis4.disableAxis()
|
||||
@@ -1,36 +0,0 @@
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
FIFO_BUFFER_SIZE = 30
|
||||
|
||||
|
||||
def write_to_fifo_file(filepath, x, y, timestamp):
|
||||
"""
|
||||
Appends (x, y, time) to a .dat file, keeping only the most recent FIFO_BUFFER_SIZE entries.
|
||||
|
||||
Parameters:
|
||||
- filepath: Path to the .dat file.
|
||||
- x: X position (float)
|
||||
- y: Y position (float)
|
||||
- timestamp: Unix time (float or int)
|
||||
"""
|
||||
new_entry = np.array([[x, y, timestamp]])
|
||||
|
||||
# Load existing data
|
||||
if os.path.exists(filepath):
|
||||
try:
|
||||
data = np.loadtxt(filepath)
|
||||
if data.ndim == 1 and data.size == 3:
|
||||
data = data.reshape(1, 3)
|
||||
except Exception:
|
||||
data = np.empty((0, 3))
|
||||
else:
|
||||
data = np.empty((0, 3))
|
||||
|
||||
# Append and trim oldest if needed
|
||||
data = np.vstack((data, new_entry))
|
||||
if len(data) > FIFO_BUFFER_SIZE:
|
||||
data = data[-FIFO_BUFFER_SIZE:]
|
||||
|
||||
# Save updated buffer
|
||||
np.savetxt(filepath, data, fmt="%.6f %.6f %.6f")
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB |
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user