Fanuc FOCAS (CNC) Driver
Overview
FOCAS = Fanuc Open CNC API Specification. It is the de facto standard API for reading spindle load / axis position / part programs / alarms / OEE metrics from Fanuc CNC (Computer Numerical Control) controllers. Machine tool OEMs such as Mazak, DMG MORI, and Doosan expose the same interface whenever they adopt Fanuc as the controller.
| Item | Value |
|---|---|
opc_type | FOCAS |
| Implementation class | plantpulse.driver.protocol.focas.FOCASDriver |
| Library | (none — stub) |
| Target controllers | Fanuc 0i / 30i / 31i / 32i / 35i, Power Mate, FS18i, etc. |
| Communication medium | Ethernet (TCP, default port 8193) — HSSB optical cards are separate |
| read | stub (returns "") |
| write | stub |
Only a stub of FOCAS exists. To communicate with an actual Fanuc controller, use one of the
bridge patterns described in Alternative operating methods below.
There is no plan to embed the native FwLib inside the single PlantPulse code base jar.
Why a native implementation is difficult
The FOCAS wire protocol is proprietary. Fanuc does not publish the wire specification and instead distributes a C library called FwLib (Focas Library) to licensed subscribers. In other words, speaking FOCAS directly from the Java side requires one of the following.
| Dependency | Description | Deployment impact |
|---|---|---|
Fwlib32.dll (Windows) | 32-bit DLL — Fanuc license required | Requires an x86 JVM or IPC separation |
libfwlib32.so (Linux) | x86-64 / ARM builds — separate per license | OS / glibc version matching |
| HSSB card driver | PCI card for optical communication — 1:1 with the controller | Linux kernel module required |
| License key | Registration as a member company entitled to use FwLib | Redistribution not permitted |
| JNI binding | Java <-> C memory model / threading | A failed call can crash the JVM |
As with ROS 2 / DALI / IO-Link, embedding a native library is cost > benefit under the PlantPulse Edge policy of single-jar deployment + support for a wide range of OS / ARCH combinations. Furthermore, license policy means FwLib is not a component PlantPulse can freely redistribute.
Alternative operating methods
Fortunately, Fanuc and third parties already provide standard bridges. PlantPulse only needs to consume the bridge's output interface (HTTP / OPC UA).
Option 1. MTConnect Adapter / Agent (recommended)
Most modern machine tools / Fanuc CNCs adopt MTConnect (ANSI/MTC1.4) as their primary integration path. Fanuc provides its own FOCAS-MTConnect Adapter free of charge, and OEMs (Okuma, DMG MORI, Mazak SmartBox) follow the same standard.
| PlantPulse driver to use | Page |
|---|---|
HTTP (REST polling; XML parsing handled in the formula / ingest pipeline) | HTTP |
Option 2. OPC UA (Fanuc CNC OPC UA option or KEPServer)
Newer Fanuc controllers expose an OPC UA Server as an add-on option. Older controllers are converted using a commercial gateway such as Kepware KEPServerEX Fanuc Suite or Matrikon FOCAS OPC Server.
| PlantPulse driver to use | Page |
|---|---|
OPCUA | OPC-UA |
Option 3. Direct FwLib JNI (sidecar)
Sites that hold an FwLib license can run their own JNI module as a separate jar (motorsensor.jar pattern) or
as a sidecar process (e.g. focas-grpc-server), with PlantPulse polling its output.
Even in this case the main PlantPulse jar is unchanged, and the FOCAS driver can remain a stub.
Which option to choose
| Situation | Recommendation |
|---|---|
| OEM (Mazak SmartBox / DMG MORI Celos / Okuma) already runs an MTConnect Agent | MTConnect → HTTP |
| Newer Fanuc 30i, OPC UA option can be added | Fanuc OPC UA → OPCUA |
| Older Fanuc 0i, SI holds a license | KEPServerEX Fanuc Suite → OPCUA |
| Own FwLib license / custom data required | focas-grpc sidecar → HTTP |
| Only a simple availability (0/1) metric needed | Controller digital output → Modbus/Ethernet IO module |
Considerations for a future native implementation
| Option | Dependencies | Difficulty |
|---|---|---|
| Embed FwLib JNI directly | Requires x86 / x64 / ARM builds, plus a license | Very high |
Separate plantpulse-edge-driver-focas.jar (motorsensor.jar pattern) | Library loaded by reflection | High |
| Sidecar + gRPC | FwLib lives only in the sidecar; PlantPulse is an HTTP/gRPC client | Medium |
| Reverse-engineered wire protocol (3rd-party) | Risk of violating the Fanuc license | Not recommended |
The official integration path recommended by PlantPulse Edge is MTConnect (HTTP driver). OEMs already supply an MTConnect Adapter, and it sidesteps all license / deployment / OS compatibility issues. If the Fanuc OPC UA option is available, connecting directly with the OPCUA driver is the cleanest route.
stub registration (test only)
curl -X POST http://<edge-host>/api/v1/opc \
-H "Content-Type: application/json" \
-d '{
"opc_id": "OPC_FOCAS_STUB",
"opc_type": "FOCAS",
"opc_name": "FANUC FOCAS stub",
"opc_agent_ip": "192.168.0.0",
"opc_agent_port": "8193",
"site_id": "SITE_00001",
"auto_collect": false,
"timecycle": 5000,
"tag_list": []
}'