James Setters

Continuous Casting Control – Web Edition

Project:

CC Control Code (Web Edition)

Description:

  • Python Flask web app for controlling and logging a continuous casting process via serial (G-code).
  • Features real-time temperature plotting and a state-machine for process automation.
  • Auto-installs required Python packages at runtime for easy setup.
  • Visualizes results with interactive 3D Plotly charts and Chart.js graphs.

How to Use:

  1. Connect your hardware (set correct COM port in the code).
  2. Run python CC\ Control\ Code\ (Web\ Edition).py.
  3. Use your browser to control, monitor, and export results.
  4. See the repo for detailed setup instructions and full source code.

Key Features:

  • Live temperature and process graphing
  • Interactive plotting of experiment results
  • Automated G-code control and manual override
  • Web-based data entry and result export
#!/usr/bin/env python3
"""
CC Control Code (Web Edition) – Fixed version
Ensures required packages are installed at runtime and removes duplicate or incorrect imports.
"""
import sys
import subprocess

def ensure(pkg_name, module_name=None):
    try:
        __import__(module_name or pkg_name)
    except ModuleNotFoundError:
        print(f"'{pkg_name}' not found – installing via pip...")
        subprocess.check_call([sys.executable, "-m", "pip", "install", pkg_name])

for pkg, mod in [
    ("flask", None),
    ("pandas", None),
    ("plotly", None),
    ("pyserial", "serial"),
]:
    ensure(pkg, mod)

from flask import Flask, request, render_template_string, jsonify, redirect, url_for
import pandas as pd
import plotly.graph_objects as go
import plotly.offline as pyo
import serial
import os, time, datetime, re, csv, threading, webbrowser, random

app = Flask(__name__)

# ... (Code continues! See repo for full version)
          
Try It: Graphing Calculator
Example: sin(x), x**2, cos(2*x)+1, exp(-x/5)*sin(x), tan(x), x**3 - 3*x