OPCUA Fusion is a comprehensive Django-based web application designed to connect to, monitor, and interact with multiple OPC UA servers. It provides a real-time dashboard for each connected server, logs historical data to Google Firebase, enables complex process scheduling across machines, and offers tools for data visualization and download.
- π Multi-Server Connectivity: Connect to multiple OPC UA servers simultaneously from a central hub.
- π Real-time Dashboard: For each connection, a dedicated dashboard provides:
- A hierarchical tree view of the server's address space.
- Detailed node information (ID, class, description, data type).
- Live monitoring of variable values, updated every 500ms.
- βοΈ Method Execution: Call methods on the OPC UA server directly from the web interface, with support for input arguments.
- βοΈ Cloud Data Logging: All connection events, node structures, real-time variable data, and method calls are logged to Google Firebase Firestore, creating a historical data record.
- π Process Scheduling & Aggregation:
- Design and execute complex process chains involving method calls on different machines in a specific sequence.
- Use the output of one process step as an input for a subsequent step.
- π¨ Data Visualization: Generate 2D plots of historical data stored in Firestore by selecting variables for the X and Y axes and specifying a time range.
- πΎ Data Export: Download historical variable data as a CSV file for a given time period.
- π§ 3D Machine Visualization: The main hub displays an interactive 3D model (using Three.js) for each connected machine type (CNC, Cobot, Conveyor).
- π Backend: Django 5.0, Python 3.x
- π€ OPC UA Communication:
freeopcua/opcualibrary - ποΈ Database:
- Primary Data Store: Google Firebase Firestore
- Django Backend: SQLite (default)
- π₯οΈ Frontend: HTML, CSS, JavaScript (Vanilla)
- β‘ Asynchronous Tasks:
asyncio,ThreadPoolExecutor, andthreadingfor non-blocking data collection and process execution. - π§ 3D Rendering: Three.js
- πΌ Data Handling & Plotting: Pandas, Matplotlib
- Python 3.10+
pippackage manager- An active OPC UA Server for testing.
- A Firebase project enabled.
Follow these steps to set up and run the project locally.
This project relies on Google Firebase to store all operational data.
-
Create a Firebase Project:
- Go to the Firebase Console.
- Click "Add project" and follow the on-screen instructions.
-
Generate a Service Account Key:
- In your Firebase project, go to Project Settings (click the gear icon βοΈ next to "Project Overview").
- Navigate to the Service accounts tab.
- Click Generate new private key. A JSON file will be downloaded.
- Rename this file to
serviceAccountKey.json. - Place this file in the root directory of the Django project (the same folder that contains
manage.py).
-
Set up Firestore Database:
- In the Firebase Console, go to Build > Firestore Database.
- Click Create database.
- Start in Test mode for initial setup. This allows open read/write access.
β οΈ Security Note: For production, you must configure Security Rules to protect your data.- Choose a location for your database.
-
Set up Firebase Storage:
- The application uses a storage bucket name in the configuration.
- In the Firebase Console, go to Build > Storage.
- Click Get started and follow the setup wizard (you can use the default security rules for now).
- Once created, you will see your storage bucket URL at the top (e.g.,
gs://my-project.appspot.com). - Open
opcua_client/views.pyand find this line:firebase_admin.initialize_app( cred, {"storageBucket": "opcuafusion.appspot.com"}, # <-- CHANGE THIS )
- Replace
"opcuafusion.appspot.com"with your actual bucket name (without thegs://prefix).
-
Clone the Repository:
git clone <your-repository-url> cd opcua_fusion
-
Create and Activate a Virtual Environment:
# For Windows python -m venv venv .\venv\Scripts\activate # For macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt
-
Apply Database Migrations: (This sets up the local SQLite database for Django's internal use)
python manage.py migrate
-
Run the Development Server:
python manage.py runserver
The application will now be running at http://127.0.0.1:8000/.
- Open your browser to
http://127.0.0.1:8000/. - In the form, enter:
- Endpoint: The URL of your OPC UA server.
- Namespace URI: The namespace identifier for your server's objects.
- Machine: Select a machine type (CNC, Cobot, etc.).
- Click Connect. A new browser tab will open with the dashboard for that machine.
- The main hub page will now show a 3D model of the connected machine. You can interact with the model and connect to more machines.
The new tab is the command center for a single machine.
- Address Space: Browse the server's nodes. Click
βΆto expand. Click a node name to see its details. - Display Panel: Shows details of the last-clicked node and the results of method calls.
- Variables Real Time: A live feed of all variable values from the server, refreshing automatically.
- Methods: Lists all callable methods. Provide inputs and click Run to execute.
- Disconnect: Click the "Disconnect" button or close the tab to end the session.
On the machine dashboard, you will find two buttons:
- Generate Graph: Opens a new tab to plot historical data from Firestore.
- Download Data: Opens a new tab to download historical variable data as a CSV file.
Automate tasks across multiple connected machines.
- From the main hub, click Schedule the Machines.
- A new window opens. Enter the number of steps in your process.
- Define the Chain: For each step, select a machine and the method to call.
- Provide Inputs: For each step, provide static values or use the output from a previous step as input.
- Schedule and Execute: Start the process and monitor the live log. An Emergency Stop button is available.
- Test Environment: The OPCUA Fusion application can be tested using a set of sample OPC UA servers and virtual hardware simulations available at: opcua_fusion_test_servers_and_hardware.
- Customer-Facing Application: A complementary customer-facing cloud application that works with the data logged by OPCUA Fusion is available here: opcua_fusion_cloud.
π Connecting OPCUA Test Server Cobot and Conveyor Hardware Directly via Ethernet (Network Bridge)
To connect the Raspberry Pi-based hardware directly to the laptop running this application without an external router, you can create a network bridge. This allows the laptop to share its Wi-Fi connection with devices connected via its Ethernet port.
(Internet) --- Wi-Fi ---> [ Laptop (Running OPCUA Fusion) ] --- Ethernet ---> [ Switch ] --- Ethernet ---> [ Pi 1: Conveyor (192.168.1.2) ]
|
--- Ethernet ---> [ Pi 2: Cobot (192.168.1.3) ]
Your laptop must have a static IP address on the same network as the hardware. We will use the 192.168.1.x subnet.
On Windows:
- Open Network Connections: Press
Win + R, typencpa.cpl, and press Enter. - Set Static IP on Ethernet Port:
- Right-click your Ethernet adapter and select Properties.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
- Select "Use the following IP address".
- Enter the following:
- IP address:
192.168.1.1 - Subnet mask:
255.255.255.0
- IP address:
- Leave the "Default gateway" and "DNS server" fields blank. Click OK.
- Share Wi-Fi Connection:
- Right-click your Wi-Fi adapter and select Properties.
- Go to the Sharing tab.
- Check the box "Allow other network users to connect through this computer's Internet connection".
- From the "Home networking connection" dropdown, select your Ethernet adapter.
- Click OK.
On macOS:
- Open System Settings > Network.
- Set Static IP on Ethernet Port:
- Select your Ethernet adapter (or USB-to-Ethernet adapter).
- Click Details... > TCP/IP.
- Set "Configure IPv4" to Manually.
- Enter the following:
- IP Address:
192.168.1.1 - Subnet Mask:
255.255.255.0
- IP Address:
- Leave the "Router" field blank. Click OK.
- Share Wi-Fi Connection:
- Go to System Settings > General > Sharing.
- Turn on Internet Sharing.
- Click the info icon (
i) next to it. - Set "Share your connection from:" to Wi-Fi.
- Set "To computers using:" to your Ethernet adapter.
- Click Done.
- Connect an Ethernet cable from your laptop's Ethernet port to a network switch.
- Connect both Raspberry Pis (Cobot and Conveyor) to the same switch using Ethernet cables.
- Open a terminal or Command Prompt on your laptop and test the connection using
ping:# Test connection to the Conveyor Pi ping 192.168.1.2 # Test connection to the Cobot Pi ping 192.168.1.3
- If you receive replies, the network is configured correctly. You can now run the OPCUA Fusion application and connect to the hardware using their endpoints:
- Conveyor:
opc.tcp://192.168.1.2:4840/conveyor - Cobot:
opc.tcp://192.168.1.3:4840/cobot_arm
- Conveyor:
