OP10-CNC Rough Machining

5-Axis CNC Machine - Station 1
Modbus TCP

The first station in the production line performs rough machining operations on raw aluminum castings. This 5-axis CNC removes bulk material and creates the primary geometry of the brake caliper housing. Use Modbus TCP to read real-time machine state, production counters, sensor data, and fault information.

Connection: localhost:5020 Unit ID: 1 Update Rate: 50ms (20 Hz)

Business Purpose

Why Connect to This Simulator?

OEE Monitoring: Read production counters (good/bad parts) and machine states to calculate availability, performance, and quality metrics.

Predictive Maintenance: Monitor spindle load, vibration, and temperature sensors to detect wear patterns before failures occur.

Energy Management: Track power consumption per part for energy cost allocation and efficiency optimization.

Downtime Analysis: Capture fault codes and state transitions to build Pareto charts of downtime causes.

Station Specifications

Cycle Time
15 seconds
Load/Unload
3s / 3s
Process Time
9 seconds
Tools
Face Mill, Rough Bore

Modbus Register Map

All registers are holding registers (function code 03). Addresses follow Modbus convention (40001 = register 0).

AddressNameTypeDescription
40001Stateuint160=OFF, 1=IDLE, 2=RUNNING, 3=FAULTED, 4=BLOCKED, 5=STARVED
40002Stepuint160=IDLE, 1=LOADING, 2=PROCESSING, 3=UNLOADING
40005PartsProduceduint16Cumulative parts count
40006PartsGooduint16Good parts count
40007PartsBaduint16Bad parts (scrap + rework)
40008FaultActiveuint160=No fault, 1=Fault active
40009FaultCodeuint161001=Spindle Overload, 1002=Tool Break, 1003=Coolant Low
40010SpindleSpeeduint16RPM (0-12000)
40011SpindleLoaduint16Load % x10 (45.2% = 452)
40015Vibrationuint16mm/s x1000 (0.5 = 500)
40016Temperatureuint16Celsius x10 (35.2 = 352)
40022PowerKWuint16kW x100 (15.5 = 1550)
40110-11RunTimeuint32Accumulated run time (seconds)
40112-13DownTimeuint32Accumulated down time (seconds)

OP30-WASH Parts Washer

Aqueous Cleaning Station - Station 3
Modbus TCP

The parts washer uses high-pressure aqueous cleaning to remove machining chips, coolant residue, and contaminants from the brake caliper housing. Clean parts are essential for accurate leak testing at the next station. Monitor wash temperature, pressure, and filter status to ensure cleaning quality.

Connection: localhost:5021 Unit ID: 1 Update Rate: 50ms (20 Hz)

Business Purpose

Why Connect to This Simulator?

Quality Correlation: Monitor wash temperature and pressure to correlate cleaning parameters with downstream leak test results.

Maintenance Scheduling: Track filter pressure differential to schedule filter replacements before clogging causes downtime.

Process Optimization: Analyze cycle times and temperature profiles to optimize cleaning without affecting quality.

Environmental Compliance: Log water usage and chemical consumption for sustainability reporting.

Station Specifications

Cycle Time
12 seconds
Load/Unload
2s / 2s
Wash Time
8 seconds
Faults
Temp Low, Filter Clog

Modbus Register Map

AddressNameTypeDescription
40001Stateuint160=OFF, 1=IDLE, 2=RUNNING, 3=FAULTED, 4=BLOCKED, 5=STARVED
40002Stepuint160=IDLE, 1=LOADING, 2=WASHING, 3=UNLOADING
40005PartsProduceduint16Cumulative parts washed
40006PartsGooduint16Successfully cleaned parts
40007PartsBaduint16Parts requiring re-wash
40008FaultActiveuint160=No fault, 1=Fault active
40009FaultCodeuint163001=Temp Low, 3002=Filter Clogged
40013WashPressureuint16bar x10 (6.5 = 65)
40014WashTempuint16Celsius x10 (55.0 = 550)
40022PowerKWuint16kW x100

OP20-CNC Finish Machining

Precision CNC Machine - Station 2
OPC UA

The finish machining station performs precision operations to achieve final dimensions and surface quality. This station is critical for bore tolerances and thread quality. OPC UA provides a rich, hierarchical data structure with strong typing and metadata for enterprise integration.

Endpoint: opc.tcp://localhost:4840 Security: None (Anonymous)

Business Purpose

Why Connect to This Simulator?

Precision Monitoring: Track bore diameter measurements and surface finish parameters for SPC analysis.

Tool Life Management: Monitor tool wear counters to optimize tool change intervals and reduce scrap from worn tools.

Traceability: Capture part serial numbers with timestamps for full genealogy tracking through the production line.

Enterprise Integration: OPC UA's standardized information model enables seamless connection to MES and ERP systems.

Station Specifications

Cycle Time
12 seconds
Load/Unload
2s / 2s
Process Time
8 seconds
Tools
Finish Bore, M10 Tap

OPC UA Node Structure

Nodes are organized under namespace index 1. Browse from ns=1;s=OP20-CNC

Node IDTypeDescription
ns=1;s=OP20-CNC.StateStringIDLE, RUNNING, FAULTED, BLOCKED, STARVED
ns=1;s=OP20-CNC.StepStringIDLE, LOADING, PROCESSING, UNLOADING
ns=1;s=OP20-CNC.CurrentPartStringSerial number of part being processed
ns=1;s=OP20-CNC.PartsProducedInt32Total parts completed
ns=1;s=OP20-CNC.PartsGoodInt32Good parts count
ns=1;s=OP20-CNC.PartsBadInt32Scrap + rework count
ns=1;s=OP20-CNC.SpindleSpeedFloatCurrent spindle RPM
ns=1;s=OP20-CNC.SpindleLoadFloatSpindle load percentage
ns=1;s=OP20-CNC.FeedRateFloatCurrent feed rate (mm/min)
ns=1;s=OP20-CNC.CoolantPressureFloatCoolant pressure (bar)
ns=1;s=OP20-CNC.CoolantTempFloatCoolant temperature (Celsius)
ns=1;s=OP20-CNC.VibrationFloatVibration level (mm/s)
ns=1;s=OP20-CNC.TemperatureFloatMachine temperature (Celsius)
ns=1;s=OP20-CNC.VoltageFloatSupply voltage (V)
ns=1;s=OP20-CNC.CurrentFloatCurrent draw (A)
ns=1;s=OP20-CNC.PowerFloatCurrent power consumption (kW)
ns=1;s=OP20-CNC.PowerFactorFloatPower factor
ns=1;s=OP20-CNC.EnergyKWHFloatCumulative energy (kWh)
ns=1;s=OP20-CNC.ToolIDStringCurrent tool identifier
ns=1;s=OP20-CNC.ToolNameStringCurrent tool name
ns=1;s=OP20-CNC.ToolLifeCountInt32Current tool usage count
ns=1;s=OP20-CNC.ToolLifeLimitInt32Tool life limit
ns=1;s=OP20-CNC.ToolLifeRemainingInt32Remaining tool life
ns=1;s=OP20-CNC.FaultActiveBooleanTrue if fault is active
ns=1;s=OP20-CNC.FaultCodeStringE2001=Bore OOS, E2002=Tap Break
ns=1;s=OP20-CNC.FaultNameStringFault description
ns=1;s=OP20-CNC.RunTimeSecFloatAccumulated run time
ns=1;s=OP20-CNC.DownTimeSecFloatAccumulated down time
ns=1;s=OP20-CNC.IdleTimeSecFloatAccumulated idle time

OP40-TEST Leak Test

Pressure Decay Test Station - Station 4
OPC UA

The final quality gate uses pressure decay testing to verify hydraulic integrity of the brake caliper. Parts are pressurized and held while monitoring for pressure drop. This station determines if parts pass to finished goods or are rejected. Critical for safety-related automotive components.

Endpoint: opc.tcp://localhost:4841 Security: None (Anonymous)

Business Purpose

Why Connect to This Simulator?

Quality Assurance: Every part's leak test result determines final pass/fail status - essential for quality KPIs.

Defect Root Cause: Correlate leak failures with upstream machining parameters to identify process issues.

Compliance Documentation: Automotive safety regulations require traceable test records for every brake component.

Yield Analysis: Monitor first-pass yield trends to detect quality drift before it impacts production targets.

Station Specifications

Cycle Time
35 seconds
Load/Unload
7s / 7s
Test Time
21 seconds
Test Pressure
15 bar

OPC UA Node Structure

Nodes are organized under namespace index 1. Browse from ns=1;s=OP40-TEST. Test-specific sensors provide leak rate and pressure decay measurements.

Node IDTypeDescription
ns=1;s=OP40-TEST.StateStringMachine state
ns=1;s=OP40-TEST.StepStringIDLE, LOADING, PROCESSING, UNLOADING
ns=1;s=OP40-TEST.CurrentPartStringPart serial number under test
ns=1;s=OP40-TEST.PartsProducedInt32Total parts tested
ns=1;s=OP40-TEST.PartsGoodInt32Parts passed leak test
ns=1;s=OP40-TEST.PartsBadInt32Parts failed leak test
ns=1;s=OP40-TEST.TestPressureFloatCurrent test pressure (bar)
ns=1;s=OP40-TEST.LeakRateFloatMeasured leak rate (cc/min)
ns=1;s=OP40-TEST.PressureDecayFloatPressure drop during test (mbar)
ns=1;s=OP40-TEST.TemperatureFloatMachine temperature (Celsius)
ns=1;s=OP40-TEST.VoltageFloatSupply voltage (V)
ns=1;s=OP40-TEST.CurrentFloatCurrent draw (A)
ns=1;s=OP40-TEST.PowerFloatCurrent power consumption (kW)
ns=1;s=OP40-TEST.PowerFactorFloatPower factor
ns=1;s=OP40-TEST.EnergyKWHFloatCumulative energy (kWh)
ns=1;s=OP40-TEST.FaultActiveBooleanFault status
ns=1;s=OP40-TEST.FaultCodeStringE4001=Air Pressure Low, E4002=Seal Wear
ns=1;s=OP40-TEST.FaultNameStringFault description
ns=1;s=OP40-TEST.RunTimeSecFloatAccumulated run time
ns=1;s=OP40-TEST.DownTimeSecFloatAccumulated down time
ns=1;s=OP40-TEST.IdleTimeSecFloatAccumulated idle time

MES REST API

Manufacturing Execution System
REST API

The MES API provides production execution and shop floor control capabilities. Manage work orders, track production records with full part traceability, monitor quality measurements, record downtime events, and access real-time equipment status. All data is JSON-formatted for easy integration.

Base URL: http://localhost:8080/api/v1

Business Purpose

Why Connect to This Simulator?

Analytics Platform Integration: Structured JSON responses designed for BI tools and data warehouses.

OEE Calculation: Production counters, downtime events, and quality records provide all inputs for OEE metrics.

Part Traceability: Every part's complete production history including cycle times, measurements, and tool usage.

Master Data Sync: Equipment definitions, product routings, and reason codes for maintaining data consistency.

Available Endpoints

Master Data

GET /master/factory Factory and line definitions
GET /master/products Product definitions with routing
GET /master/equipment Equipment/station definitions
GET /master/downtime-reasons Downtime reason codes

Work Orders

GET /production/orders List all work orders
GET /production/orders/current Current active work order
POST /production/orders/:id/start Start a work order
POST /production/orders/:id/complete Complete a work order

Production Data

GET /production/records Part production history
GET /production/counters Raw production counters

Quality & Downtime

GET /quality/records Quality measurements
GET /downtime/events Downtime event history
GET /downtime/faults Fault events with codes

Real-Time Status

GET /realtime/equipment Current equipment states
GET /realtime/buffers Buffer levels
GET /energy/readings Energy consumption
Click "Try" to test an endpoint

ERP REST API

Enterprise Resource Planning
REST API

The ERP API provides business-level data for inventory management and stock movements. Use this API to simulate material replenishment, finished goods shipping, and inventory tracking operations that typically come from enterprise resource planning systems.

Base URL: http://localhost:8081/api/v1

Business Purpose

Why Connect to This Simulator?

Inventory Visibility: Real-time stock levels for raw materials, WIP, and finished goods.

Material Flow: Track stock movements from receiving through production to shipping.

Automation Control: Configure automatic material replenishment and shipping rules.

Available Endpoints

Inventory

GET /inventory All inventory levels
GET /inventory/raw Raw material stock
GET /inventory/finished Finished goods stock
POST /inventory/receive Receive raw materials {"quantity": 50}
POST /inventory/ship Ship finished goods {"quantity": 25}

Automation & Movements

GET /movements Stock movement history
GET /automation Automation status & config
PUT /automation/mode Switch mode {"mode": "automatic"}
Click "Try" to test an endpoint

MQTT Event Broker

Pub/Sub Event Streaming
MQTT

An embedded MQTT broker that publishes real-time factory events. Subscribe to topics to receive station state changes, cycle events, faults, work order updates, quality data, and periodic status updates. Connect any MQTT client (mosquitto_sub, MQTT Explorer, Node-RED) to stream events.

Connection
mqtt://localhost:1883

Topic Structure

All topics use the format factory/LINE-BC-01/... where LINE-BC-01 is the production line ID.

To receive all events, subscribe to: factory/LINE-BC-01/#

Event Stream Topics

Aggregated event streams - subscribe to these for all events of a type

Topic Event Type Description
factory/LINE-BC-01/events/state_change STATION_STATE_CHANGE All station state transitions
factory/LINE-BC-01/events/cycle CYCLE_START, CYCLE_COMPLETE All cycle events from all stations
factory/LINE-BC-01/events/production PART_COMPLETED Parts finished (GOOD/SCRAP/REWORK)
factory/LINE-BC-01/events/faults FAULT_TRIGGERED, FAULT_CLEARED All fault events from all stations
factory/LINE-BC-01/events/work_orders WORK_ORDER_STARTED, WORK_ORDER_COMPLETED Work order lifecycle events

Equipment Topics (per station)

Station-specific events. Stations: OP10-CNC, OP20-CNC, OP30-WASH, OP40-TEST

Topic Event Type Description
factory/LINE-BC-01/equipment/{station}/state STATION_STATE_CHANGE State change (IDLE, RUNNING, FAULTED, etc.)
factory/LINE-BC-01/equipment/{station}/cycle/start CYCLE_START Part started processing at station
factory/LINE-BC-01/equipment/{station}/cycle/complete CYCLE_COMPLETE Part finished with measurements & process data
factory/LINE-BC-01/equipment/{station}/fault FAULT_TRIGGERED Fault occurred at station
factory/LINE-BC-01/equipment/{station}/fault/cleared FAULT_CLEARED Fault resolved at station

Parts & Work Orders Topics

Topic Event Type Description
factory/LINE-BC-01/parts/completed PART_COMPLETED Part finished all operations
factory/LINE-BC-01/work_orders/started WORK_ORDER_STARTED Work order started production
factory/LINE-BC-01/work_orders/completed WORK_ORDER_COMPLETED Work order finished

Quality & Alerts Topics

Topic Event Type Description
factory/LINE-BC-01/quality/defects DEFECT_DETECTED Quality defect with root cause
factory/LINE-BC-01/alerts/fault FAULT_TRIGGERED Critical fault alerts
factory/LINE-BC-01/simulation/profile PROFILE_CHANGE Simulation profile changed

Periodic Status Topics (every 5 seconds)

Topic Event Type Description
factory/LINE-BC-01/status/production LINE_STATUS Production line summary (counts, PPH)
factory/LINE-BC-01/status/equipment/{station} EQUIPMENT_STATUS Station state, counters, energy, faults
factory/LINE-BC-01/status/buffers/{buffer} BUFFER_STATUS Buffer level and capacity
factory/LINE-BC-01/status/work_order WORK_ORDER_STATUS Current work order progress

Stations: OP10-CNC, OP20-CNC, OP30-WASH, OP40-TEST
Buffers: buffer-raw, buffer-1, buffer-2, buffer-3, buffer-finished

Example Payloads

CYCLE_COMPLETE Event

{
  "event_type": "CYCLE_COMPLETE",
  "station_id": "OP10-CNC",
  "part_serial": "SN-000042",
  "cycle_time_sec": 52.3,
  "result": "GOOD",
  "tool_used": "T1-FACE-MILL",
  "tool_life_at": 245,
  "energy_kwh": 0.42,
  "measurements": [...],
  "process_data": {
    "spindle_speed_rpm": 3500,
    "spindle_load_percent": 45.2,
    "feed_rate_mm": 250
  },
  "timestamp": "2024-01-15T10:30:52Z"
}

FAULT_TRIGGERED Event

{
  "event_type": "FAULT_TRIGGERED",
  "station_id": "OP10-CNC",
  "fault_id": "FLT-12345",
  "fault_code": "E1001",
  "fault_name": "Spindle Overload",
  "description": "Spindle motor current exceeded threshold",
  "severity": "major",
  "start_time": "2024-01-15T10:25:30Z",
  "timestamp": "2024-01-15T10:25:30Z"
}

LINE_STATUS Event (Periodic)

{
  "event_type": "LINE_STATUS",
  "total_produced": 1250,
  "good_count": 1220,
  "scrap_count": 20,
  "rework_count": 10,
  "parts_per_hour": 42.5,
  "timestamp": "2024-01-15T10:35:00Z"
}

EQUIPMENT_STATUS Event (Periodic)

{
  "event_type": "EQUIPMENT_STATUS",
  "station_id": "OP10-CNC",
  "state": "RUNNING",
  "step": "PROCESSING",
  "current_part": "SN-000042",
  "parts_produced": 125,
  "parts_good": 120,
  "parts_bad": 5,
  "run_time_sec": 3600.5,
  "down_time_sec": 120.0,
  "idle_time_sec": 280.3,
  "fault_active": false,
  "power_kw": 8.5,
  "energy_kwh": 42.3,
  "timestamp": "2024-01-15T10:35:00Z"
}

BUFFER_STATUS Event (Periodic)

{
  "event_type": "BUFFER_STATUS",
  "buffer_id": "buffer-raw",
  "name": "Raw Material Buffer",
  "current_level": 85,
  "capacity": 100,
  "timestamp": "2024-01-15T10:35:00Z"
}

WORK_ORDER_STATUS Event (Periodic)

{
  "event_type": "WORK_ORDER_STATUS",
  "order_id": "WO-2024-001",
  "product_id": "BC-2024-A",
  "target_qty": 100,
  "produced_qty": 85,
  "good_qty": 82,
  "scrap_qty": 2,
  "rework_qty": 1,
  "status": "in_progress",
  "timestamp": "2024-01-15T10:35:00Z"
}

Quick Start

Test the MQTT broker with any MQTT client:

Using mosquitto_sub

# Subscribe to all factory events
mosquitto_sub -h localhost -p 1883 -t "factory/LINE-BC-01/#" -v

# Subscribe to fault events only
mosquitto_sub -h localhost -p 1883 -t "factory/LINE-BC-01/events/faults" -v

# Subscribe to specific station
mosquitto_sub -h localhost -p 1883 -t "factory/LINE-BC-01/equipment/OP10-CNC/#" -v

Using Node.js

const mqtt = require('mqtt');
const client = mqtt.connect('mqtt://localhost:1883');

client.on('connect', () => {
  client.subscribe('factory/LINE-BC-01/#');
});

client.on('message', (topic, message) => {
  const event = JSON.parse(message.toString());
  console.log(topic, event);
});

PostgreSQL Factory Database

Embedded Relational Database
PostgreSQL

An embedded PostgreSQL database containing factory master data. Query employee information, shift schedules, equipment records, maintenance schedules, suppliers, materials, and product specifications. Connect any PostgreSQL client (psql, DBeaver, pgAdmin) to explore the data.

Connection
postgres://factory:factory123@localhost:5432/factory

Connection Details

Parameter Value
Host localhost
Port 5432
Database factory
Username factory
Password factory123

Database Schema

The factory database contains 15 tables organized into logical groups:

Organization & Personnel

Table Description Key Columns
departments Factory departments id, name, code, manager_id
employees Employee records id, employee_id, first_name, last_name, email, department_id, role, hire_date
shifts Shift definitions id, name, start_time, end_time, days_of_week
shift_assignments Employee shift assignments id, employee_id, shift_id, start_date, end_date
skills Skills catalog id, name, category, description
employee_skills Employee certifications employee_id, skill_id, proficiency_level, certified_date

Equipment & Maintenance

Table Description Key Columns
equipment Factory equipment/machines id, equipment_id, name, type, manufacturer, model, serial_number, station_id
maintenance_schedules Planned maintenance id, equipment_id, maintenance_type, frequency_days, last_performed, next_due
maintenance_records Maintenance history id, equipment_id, maintenance_type, performed_by, performed_at, notes, parts_replaced

Supply Chain

Table Description Key Columns
suppliers Material suppliers id, name, code, contact_name, email, phone, address, rating
materials Raw materials inventory id, material_id, name, category, unit, supplier_id, lead_time_days, min_stock
customers Customer records id, name, code, contact_name, email, phone, address

Products & Quality

Table Description Key Columns
products Product catalog id, product_id, name, description, customer_id, cycle_time_sec, weight_kg
bom_items Bill of materials id, product_id, material_id, quantity, unit
quality_specs Quality specifications id, product_id, parameter, min_value, max_value, unit, station_id

Sample Queries

List All Employees with Department

SELECT e.employee_id, e.first_name, e.last_name, e.role, d.name as department
FROM employees e
JOIN departments d ON e.department_id = d.id
ORDER BY d.name, e.last_name;

Current Shift Assignments

SELECT e.first_name, e.last_name, s.name as shift,
       s.start_time, s.end_time, sa.start_date
FROM shift_assignments sa
JOIN employees e ON sa.employee_id = e.id
JOIN shifts s ON sa.shift_id = s.id
WHERE sa.end_date IS NULL
ORDER BY s.name;

Equipment Maintenance Due

SELECT eq.equipment_id, eq.name, ms.maintenance_type,
       ms.next_due, ms.frequency_days
FROM maintenance_schedules ms
JOIN equipment eq ON ms.equipment_id = eq.id
WHERE ms.next_due <= CURRENT_DATE + INTERVAL '7 days'
ORDER BY ms.next_due;

Employee Skills Matrix

SELECT e.first_name, e.last_name, sk.name as skill,
       es.proficiency_level, es.certified_date
FROM employee_skills es
JOIN employees e ON es.employee_id = e.id
JOIN skills sk ON es.skill_id = sk.id
ORDER BY e.last_name, sk.category;

Product Bill of Materials

SELECT p.product_id, p.name as product, m.name as material,
       b.quantity, b.unit, s.name as supplier
FROM bom_items b
JOIN products p ON b.product_id = p.id
JOIN materials m ON b.material_id = m.id
JOIN suppliers s ON m.supplier_id = s.id
ORDER BY p.name, m.name;

Quick Start

Connect to the database using any PostgreSQL client:

Using psql

# Connect to the factory database
psql -h localhost -p 5432 -U factory -d factory

# List all tables
\dt

# Describe a table
\d employees

# Run a query
SELECT * FROM employees LIMIT 5;

Using Python

import psycopg2

conn = psycopg2.connect(
    host="localhost",
    port=5432,
    database="factory",
    user="factory",
    password="factory123"
)

cur = conn.cursor()
cur.execute("SELECT * FROM employees")
for row in cur.fetchall():
    print(row)

conn.close()

Using Node.js

const { Pool } = require('pg');

const pool = new Pool({
  host: 'localhost',
  port: 5432,
  database: 'factory',
  user: 'factory',
  password: 'factory123'
});

pool.query('SELECT * FROM employees', (err, res) => {
  console.log(res.rows);
  pool.end();
});