victor.pl
FREN
← All projects

Frame 016 · systemsC

Pulse

Factory simulator in C: factories, PLCs and sensors wired together through handlers, to reproduce how an industrial plant works.

View the repository on GitLab (opens in a new tab)

README.md

Pulse is a factory simulator developed in C.

logo_pulse

The project aims to reproduce, in a simple and modular way, the behavior of an industrial installation composed of:

  • 🏭 Factories (factory)
  • 🤖 Automates (automate)
  • 📡 Sensors (sensor)
  • 🔗 Linked lists for managing the different components
  • ⚙️ Handlers for defining component behavior

The idea is to be able to build a virtual factory, add multiple automates to it, and associate sensors with each automate. These sensors can generate or update values that the automates can then use.


Architecture

Pulse currently relies on a hierarchical architecture:

                    ┌───────────────┐
                    │    Factory    │
                    │   (factory)   │
                    └───────┬───────┘
                            │
                  ┌─────────┴─────────┐
                  │                   │
           ┌──────▼──────┐     ┌──────▼──────┐
           │  Automate   │     │  Automate   │
           │  (automate) │     │  (automate) │
           └──────┬──────┘     └──────┬──────┘
                  │                   │
             ┌────┴────┐         ┌────┴────┐
             │ Sensors │         │ Sensors │
             └─────────┘         └─────────┘

Each level has its own processing cycle.


Simulation Loop

The long-term goal of Pulse is to simulate the continuous operation of a factory.

A simulation cycle could conceptually look like this:

┌──────────────────────┐
│      Factory         │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│      Automate        │
└──────────┬───────────┘
           │
           ▼
┌──────────────────────┐
│       Sensors        │
└──────────┬───────────┘
           │
           ▼
    Sensor handlers
           │
           ▼
    Value updates
           │
           ▼
    Automate handler
           │
           ▼
    Decision / Action

This makes it possible to simulate behaviors such as:

Temperature > 80°C
        │
        ▼
     Automate
        │
        ▼
    Trigger an
       action

The handler system allows components to remain generic while letting the application define their behavior.


List Management

Pulse includes its own linked list implementation in linkedList.

typedef struct linkedList
{
    void *elmnt;
    size_t elmnt_size;
    linkedList_t *next;
} linkedList_t;

It is used to store the different components:

Factory
  └── linkedList
       ├── Automate
       ├── Automate
       └── Automate

Automate
  └── linkedList
       ├── Sensor
       ├── Sensor
       └── Sensor

Compilation

The project currently uses GCC and a simple Makefile.

Requirements

  • GCC
  • Make
  • A Unix/Linux or compatible environment

Build

everything is contain in the src/ directory

cd src/
make && ./pulse

Conceptual Example

An installation could, for example, be organized like this:

Factory: Chemical Plant
│
├── Automate: Temperature Controller
│   ├── Sensor: Reactor Temperature
│   └── Sensor: Reactor Pressure
│
├── Automate: Water Controller
│   ├── Sensor: Water Level
│   └── Sensor: Water Temperature
│
└── Automate: Security
    ├── Sensor: Door
    └── Sensor: Emergency Stop

Goals

Pulse is still under development. The goal is to progressively turn the project into a small industrial simulation engine.

Current Features

  • Sensor management
  • Automate management
  • Factory management
  • Component identifiers
  • Handler system
  • Generic linked list
  • Simulation state management
  • Makefile-based compilation

Roadmap

  • Complete simulation loop
  • Time / tick system
  • Sensor value generation
  • Measurement history
  • Actuator management
  • Communication between automates
  • Event system
  • Alarms and thresholds
  • Logging
  • Factory configuration
  • User interface / dashboard
  • Failure simulation
  • Statistics and metrics
  • Unit tests
  • API documentation

Project Philosophy

Pulse aims to remain simple, modular, and extensible.

The core principle is to delegate behavior to components through callbacks:

             Pulse
               │
       ┌───────┴───────┐
       │               │
    Factory         Configuration
       │
    Automates
       │
    Sensors
       │
    Handlers

Data structures represent the hardware, while handlers represent their behavior.

This separation should make it possible to create different simulations without modifying the core engine.


Technologies

  • C
  • GCC
  • Make
  • Custom data structures
  • Callbacks / function pointers

License

This project is under IMT license.