Table of Contents

Developing a Driver

This document explains how to develop a driver for x4Trace.

Drivers are responsible for direct communication with devices, such as:

  • PLCs
  • Cameras
  • Sensors
  • Custom or proprietary hardware

Line modules use drivers to control devices and define operational behavior.


Driver and Line Module Responsibilities

  • Drivers

    • Communicate directly with hardware devices
    • Handle protocols and low-level communication
    • Expose device functionality to x4Trace
  • Line Modules

    • Use drivers to control devices
    • Define production logic and behavior
    • Coordinate multiple drivers during an operation

Drivers are reusable components that can be shared across multiple line modules.


Development Environment

To develop a driver, you need:

  • Visual Studio
  • Development language:
    • C#
    • VB.NET

Drivers can be written in either language.


Samples and Reference Code

Sample drivers are included with the x4Trace Server installation: x4Trace.Server.Drivers

To explore how drivers are implemented, open the following solution: x4Trace.Server.UserPlugins.sln

When creating a new driver, the recommended approach is to:

  1. Copy an existing driver
  2. Rename the copied code
  3. Modify it for your specific device

Required Assemblies

Your driver project must reference the following DLL: Ix4Trace.Server.Engine.dll

This assembly provides the base interfaces and infrastructure required by x4Trace.


Creating a Driver

To implement a driver:

  1. Create a new class library project.
  2. Reference Ix4Trace.Server.Engine.dll.
  3. Create a class that inherits from:

This interface defines the contract between the driver and x4Trace.


Building and Deployment

After implementing the driver:

  1. Build the project.
  2. Copy the generated DLL and all required dependencies to:
    • The x4Trace Server directory
    • The Drivers folder of the x4Trace Server

Restart the x4Trace Server if required.


Important Notes

  • Do not modify an existing driver that is currently used by a running server.
  • Modifying an active driver can cause the server to malfunction.

If you need a new driver:

  • Create a new driver based on an existing one
  • Rename it
  • Deploy it as a separate driver

This ensures stability and avoids breaking existing integrations.


Summary

Developing a driver allows you to:

  • Integrate custom hardware
  • Extend device communication capabilities
  • Reuse drivers across multiple line modules

Drivers are low-level building blocks and should be developed carefully, using existing drivers as reference implementations.