Skip to main content

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.

ItemValue
opc_typeFOCAS
Implementation classplantpulse.driver.protocol.focas.FOCASDriver
Library(none — stub)
Target controllersFanuc 0i / 30i / 31i / 32i / 35i, Power Mate, FS18i, etc.
Communication mediumEthernet (TCP, default port 8193) — HSSB optical cards are separate
readstub (returns "")
writestub
Current status: stub driver

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.

DependencyDescriptionDeployment impact
Fwlib32.dll (Windows)32-bit DLL — Fanuc license requiredRequires an x86 JVM or IPC separation
libfwlib32.so (Linux)x86-64 / ARM builds — separate per licenseOS / glibc version matching
HSSB card driverPCI card for optical communication — 1:1 with the controllerLinux kernel module required
License keyRegistration as a member company entitled to use FwLibRedistribution not permitted
JNI bindingJava <-> C memory model / threadingA 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).

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 usePage
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 usePage
OPCUAOPC-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

SituationRecommendation
OEM (Mazak SmartBox / DMG MORI Celos / Okuma) already runs an MTConnect AgentMTConnect → HTTP
Newer Fanuc 30i, OPC UA option can be addedFanuc OPC UA → OPCUA
Older Fanuc 0i, SI holds a licenseKEPServerEX Fanuc Suite → OPCUA
Own FwLib license / custom data requiredfocas-grpc sidecar → HTTP
Only a simple availability (0/1) metric neededController digital output → Modbus/Ethernet IO module

Considerations for a future native implementation

OptionDependenciesDifficulty
Embed FwLib JNI directlyRequires x86 / x64 / ARM builds, plus a licenseVery high
Separate plantpulse-edge-driver-focas.jar (motorsensor.jar pattern)Library loaded by reflectionHigh
Sidecar + gRPCFwLib lives only in the sidecar; PlantPulse is an HTTP/gRPC clientMedium
Reverse-engineered wire protocol (3rd-party)Risk of violating the Fanuc licenseNot recommended
Conclusion

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": []
}'