diff --git a/APSERa Codes/ACI Webapp/cryotel_f.py b/APSERa Codes/ACI Webapp/cryotel_f.py
index c44a1d4..e27aea3 100644
--- a/APSERa Codes/ACI Webapp/cryotel_f.py
+++ b/APSERa Codes/ACI Webapp/cryotel_f.py
@@ -8,6 +8,59 @@
import time
import json
+import tkinter as tk
+from tkinter import simpledialog
+
+def get_usb_paths():
+ # Create the main Tkinter window
+ root = tk.Tk()
+ root.withdraw() # Hide the root window
+
+ # Create a custom dialog for multiple inputs
+ def submit():
+ global cryo_usb, lakeshore_usb, power_usb, iia_usb
+ cryo_usb = cryo_entry.get()
+ lakeshore_usb = lakeshore_entry.get()
+ power_usb = power_entry.get()
+ iia_usb = iia_entry.get()
+ dialog.destroy() # Close the dialog box
+
+ dialog = tk.Toplevel()
+ dialog.title("Enter USB Paths")
+
+ # Labels and entry fields
+ tk.Label(dialog, text="Cryo USB:").grid(row=0, column=0, padx=10, pady=5, sticky="e")
+ cryo_entry = tk.Entry(dialog, width=30)
+ cryo_entry.insert(0, "/dev/ttyUSB1")
+ cryo_entry.grid(row=0, column=1, padx=10, pady=5)
+
+ tk.Label(dialog, text="Lakeshore USB:").grid(row=1, column=0, padx=10, pady=5, sticky="e")
+ lakeshore_entry = tk.Entry(dialog, width=30)
+ lakeshore_entry.insert(0, "/dev/ttyUSB2")
+ lakeshore_entry.grid(row=1, column=1, padx=10, pady=5)
+
+ tk.Label(dialog, text="Power USB:").grid(row=2, column=0, padx=10, pady=5, sticky="e")
+ power_entry = tk.Entry(dialog, width=30)
+ power_entry.insert(0, "/dev/ttyUSB5")
+ power_entry.grid(row=2, column=1, padx=10, pady=5)
+
+ tk.Label(dialog, text="IIA USB:").grid(row=3, column=0, padx=10, pady=5, sticky="e")
+ iia_entry = tk.Entry(dialog, width=30)
+ iia_entry.insert(0, "/dev/ttyUSB3")
+ iia_entry.grid(row=3, column=1, padx=10, pady=5)
+
+ # Submit button
+ tk.Button(dialog, text="Submit", command=submit).grid(row=4, column=0, columnspan=2, pady=10)
+
+ dialog.wait_window() # Wait until the dialog box is closed
+
+ return cryo_usb, lakeshore_usb, power_usb, iia_usb
+
+# Get user inputs
+cryo_usb, lakeshore_usb, power_usb, iia_usb = get_usb_paths()
+
+
+
app = Flask(__name__)
#===========================================================================================
@@ -22,7 +75,7 @@
# Functions for serial connection of cryo controller
def initialize_serial_connection():
global ser_connection_fail, ser
- port = "/dev/ttyUSB1" # or "COM3" for Windows
+ port = cryo_usb # or "COM3" for Windows
baudrate = 9600
try:
@@ -254,7 +307,7 @@ def initialize_serial_lakeshore(port, baudrate):
# Setup serial connection
def setup_serial_lakeshore():
global ser_lakeshore
- port = "/dev/ttyUSB2" # Replace this with actual port input
+ port = lakeshore_usb # Replace this with actual port input
baudrate = 9600 # Replace this with actual baudrate input
ser_lakeshore = initialize_serial_lakeshore(port, baudrate)
return ser_lakeshore
@@ -336,17 +389,6 @@ def plot_temperatures():
terminator_power = '\r\n'
read_timeout_power = 2
-# Power Supply Functions
-def initialize_serial_power():
- try:
- serial_power = serial.Serial(port='/dev/ttyUSB6', baudrate=9600, timeout=read_timeout_power)
- status = remote_on_power()
-
- return serial_power
-
- except Exception as e:
- print(f"Failed to initialize serial port: {e}")
- return None
def read_response_power(serial_port, timeout_period, terminator_power):
start_time = time.time()
@@ -501,7 +543,7 @@ def get_data_iia():
# Initialize the serial connection
try:
- ser_iia = serial.Serial('/dev/ttyUSB3', 9600, timeout=1)
+ ser_iia = serial.Serial(iia_usb, 9600, timeout=1)
except Exception as e:
print(f"Error opening serial port: {e}")
exit()
@@ -511,7 +553,7 @@ def get_data_iia():
try:
- ser_power = serial.Serial(port='/dev/ttyUSB6', baudrate=9600, timeout=read_timeout_power)
+ ser_power = serial.Serial(port=power_usb, baudrate=9600, timeout=read_timeout_power)
remote_on_power()
except Exception as e:
print(f"Error opening serial port: {e}")
@@ -522,4 +564,4 @@ def get_data_iia():
initialize_serial_connection()
-app.run(debug=False, host='172.16.101.78', port=5002)
\ No newline at end of file
+app.run(debug=False, host='172.16.101.78', port=5001)
diff --git a/APSERa Codes/ACI Webapp/templates/index.html b/APSERa Codes/ACI Webapp/templates/index.html
index 05270e0..459816d 100644
--- a/APSERa Codes/ACI Webapp/templates/index.html
+++ b/APSERa Codes/ACI Webapp/templates/index.html
@@ -274,6 +274,12 @@
AccZ: --
+
+
@@ -346,10 +352,22 @@
Lakeshore Monitor
let outVoltageData = [];
let outCurrentData = [];
+ let accXData = [];
+ let accYData = [];
+ let accZData = [];
let timeData = [];
+
+ let accXValues = [];
+ let accYValues = [];
+ let accZValues = [];
+ let timeSeries = [];
let timeCounter = 0; // Initialize a counter for time tracking
+
+ // To track the current time in seconds
+ let currentTime = 0;
+
function formatTime(seconds) {
const date = new Date(0);
date.setSeconds(seconds);
@@ -644,12 +662,7 @@ Lakeshore Monitor
// Call this function to initialize the dummy plot
function plotDummy() {
- const trace = {
- x: Array.from({ length: 60 }, (_, i) => i + 1),
- y: Array.from({ length: 60 }, () => Math.random() * 100), // Dummy data
- mode: 'lines',
- name: 'Dummy Data',
- };
+
const layout = {
title: 'Dummy Plot',
@@ -711,6 +724,8 @@ Lakeshore Monitor
Plotly.newPlot('outCurrentPlot', [trace], layout);
}
+
+
function setVoltage() {
const voltage = prompt("Enter the voltage value:");
if (voltage !== null) {
@@ -757,35 +772,154 @@ Lakeshore Monitor
}
}
- async function fetchData_iia() {
- const response = await fetch('/get_data_iia');
- const data = await response.json();
- document.getElementById('temperature').innerText = data.temperature[data.temperature.length - 1] + ' °C';
- document.getElementById('humidity').innerText = data.humidity[data.humidity.length - 1] + ' %';
- document.getElementById('accx').innerText = data.accx[data.accx.length - 1];
- document.getElementById('accy').innerText = data.accy[data.accy.length - 1];
- document.getElementById('accz').innerText = data.accz[data.accz.length - 1];
+ function initPlots() {
+
+ const layout = {
+ title: '',
+ xaxis: {
+ title: 'Time (seconds)',
+ showticklabels: true,
+ ticks: 'outside'
+ },
+ yaxis: { title: 'Acceleration (m/s²)' },
+ plot_bgcolor: '#121212',
+ paper_bgcolor: '#121212',
+ font: { color: '#ffffff' },
+ };
+
+ Plotly.newPlot('accXPlot', [], layout);
+ Plotly.newPlot('accYPlot', [], layout);
+ Plotly.newPlot('accZPlot', [], layout);
+ }
+
+ // Function to fetch real acceleration data from an API or sensor
+ async function fetchAccelerationData() {
+ try {
+ const response = await fetch('/get_data_iia'); // Your actual API endpoint here
+ const data = await response.json();
+
+ // Fetch the latest acceleration values for each axis
+ const accX = data.accx[data.accx.length - 1];
+ const accY = data.accy[data.accy.length - 1];
+ const accZ = data.accz[data.accz.length - 1];
+
+ // Increment the time by 1 second
+ timeCounter++;
+
+ // Add the new data points to the arrays
+ timeSeries.push(timeCounter);
+ accXValues.push(accX);
+ accYValues.push(accY);
+ accZValues.push(accZ);
+
+ // Limit data to the last 60 seconds
+ if (timeSeries.length > 60) {
+ timeSeries.shift();
+ accXValues.shift();
+ accYValues.shift();
+ accZValues.shift();
+ }
+
+ // Update the plots
+ plotAccX();
+ plotAccY();
+ plotAccZ();
+
+ } catch (error) {
+ console.error('Error fetching acceleration data:', error);
+ }
}
-
-
+ function plotAccX() {
+ const trace = {
+ x: timeSeries,
+ y: accXValues,
+ mode: 'lines',
+ name: 'Acceleration X',
+ };
- setInterval(fetchData_iia, 1000);
+ const layout = {
+ title: 'Acceleration X (m/s²)',
+ xaxis: {
+ title: 'Time (seconds)',
+ showticklabels: false, // Hides the tick labels
+ ticks: '' // Hides the ticks
+ },
+ yaxis: { title: 'Acceleration (m/s²)' },
+ plot_bgcolor: '#121212',
+ paper_bgcolor: '#121212',
+ font: { color: '#ffffff' },
+ };
+
+ Plotly.newPlot('accXPlot', [trace], layout);
+ }
+
+ function plotAccY() {
+ const trace = {
+ x: timeSeries,
+ y: accYValues,
+ mode: 'lines',
+ name: 'Acceleration Y',
+ };
+
+ const layout = {
+ title: 'Acceleration Y (m/s²)',
+ xaxis: {
+ title: 'Time (seconds)',
+ showticklabels: false, // Hides the tick labels
+ ticks: '' // Hides the ticks
+ },
+ yaxis: { title: 'Acceleration (m/s²)' },
+ plot_bgcolor: '#121212',
+ paper_bgcolor: '#121212',
+ font: { color: '#ffffff' },
+ };
+
+ Plotly.newPlot('accYPlot', [trace], layout);
+ }
+
+ function plotAccZ() {
+ const trace = {
+ x: timeSeries,
+ y: accZValues,
+ mode: 'lines',
+ name: 'Acceleration Z',
+ };
+
+ const layout = {
+ title: 'Acceleration Z (m/s²)',
+ xaxis: {
+ title: 'Time (seconds)',
+ showticklabels: false, // Hides the tick labels
+ ticks: '' // Hides the ticks
+ },
+ yaxis: { title: 'Acceleration (m/s²)' },
+ plot_bgcolor: '#121212',
+ paper_bgcolor: '#121212',
+ font: { color: '#ffffff' },
+ };
+
+ Plotly.newPlot('accZPlot', [trace], layout);
+ }
+
+ // Initialize plots on page load
+ initPlots();
// Update the voltage and current values every second
- setInterval(updateVoltageCurrent, 1000);
-
+ setInterval(updateVoltageCurrent, 2000);
// Other intervals remain the same
setInterval(updateTemperatures, 2000); // Update every 2 seconds
setInterval(updateLakeshoreTemperatures, 1000); // Update every 1 second
initPlot();
setInterval(fetchCurrentTemperature, 8000); // Update temperature every 8 seconds
-
-
+ plotAccX();
+ plotAccY();
+ plotAccZ();
// Initial plot setup
- plotDummy();
// Update every second
- setInterval(updateVoltageCurrent, 1000);
+ setInterval(updateVoltageCurrent, 2000);
+ setInterval(fetchAccelerationData, 1000); // Fetch data every 1000ms (1 second)
+