Evaluate the AutomationView desktop suite free for 30 days. No credit card required. Claim trial key →
arrow_back Back to Articles

Inside AutomationView: Leveraging the Python SDK for Automated Regression Testing of SFC Logic

calendar_month
person Carvalho Raphael

Inside AutomationView: Leveraging the Python SDK for Automated Regression Testing of SFC Logic

AutomationView
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
flowchart LR
    A["Git Commit"]:::bgBlue --> B["CI Pipeline"]:::bgGreen
    B --> C["AutomationView SDK"]:::bgBlue
    C --> D["SFC Execution"]:::bgRed
    D --> E["Test Report"]:::bgGreen

    classDef bgBlue fill:#2563eb,color:#ffffff,stroke-width:0px
    classDef bgGreen fill:#16a34a,color:#ffffff,stroke-width:0px
    classDef bgRed fill:#dc2626,color:#ffffff,stroke-width:0px
AutomationView Icon AutomationView

Automated regression testing is common in standard software engineering, but it remains notoriously difficult to implement in the industrial automation world. Engineers often test PLC code manually during the commissioning phase, discovering logic conflicts only when physical hardware is at risk. By leveraging the AutomationView Python SDK, control engineers can run automated regression testing on their Sequential Function Charts (SFC) long before deploying to the factory floor.

Key Takeaways

  • Manual PLC testing scales poorly as sequence complexity increases.
  • The AutomationView Python SDK allows headless execution of SFCs.
  • Integrating PLC regression tests into a CI/CD pipeline prevents logic regressions during collaborative development.

The Paradox of PLC Regression Testing

In traditional development, testing a function block means providing inputs and verifying outputs. SFC logic, however, relies heavily on state and time. A sequence step might wait for a cylinder limit switch to actuate within a 5-second window. Testing this manually requires an engineer to sit at a desk, toggle bits in a watch table, and observe the transitions. This process is time-consuming and almost never repeatable across multiple iterations.

When multiple engineers work on a single sequence using Git integration, one logic change can easily break another branch’s functionality. Without an automated way to verify that existing states and transitions still operate correctly, teams face massive bottlenecks during factory acceptance testing.

Architecting Automated Tests with the Python SDK

AutomationView addresses this by exposing its core simulation engine through a Python API. Instead of manually clicking through the UI to trigger transitions, engineers write Python scripts that load the SFC model, simulate physical inputs, advance the clock, and assert expected outputs.

flowchart TD
    start_test["Start Python Script"]:::bgBlue --> load_model["Load SFC Model via SDK"]:::bgBlue
    load_model --> simulate_inputs["Inject Hardware Variables"]:::bgGreen
    simulate_inputs --> run_cycle["Execute PLC Cycle"]:::bgRed
    run_cycle --> assert_outputs["Assert Expected State"]:::bgGreen
    assert_outputs --> test_pass["Pass/Fail Report"]:::bgBlue

    classDef bgBlue fill:#2563eb,color:#ffffff,stroke-width:0px
    classDef bgGreen fill:#16a34a,color:#ffffff,stroke-width:0px
    classDef bgRed fill:#dc2626,color:#ffffff,stroke-width:0px

Simulating Hardware-in-the-Loop

True automated testing requires simulating the physical plant. The Python SDK allows you to create virtual models of valves, motors, and sensors. For example, when the SFC sets a valve command to true, the Python script catches this output, waits for a defined virtual time delay, and then sets the corresponding limit switch input to true. This closes the loop without requiring real hardware.

This method exposes timing-related bugs that standard Boolean logic checks would miss. If a transition is programmed to fail if the limit switch does not actuate within 3 seconds, the Python script can intentionally delay the sensor feedback to ensure the SFC correctly triggers the timeout alarm.

Comparing Testing Methods

The transition from manual testing to automated regression testing requires an upfront investment in scripting, but the long-term benefits are substantial.

Testing Method Speed Repeatability Hardware Dependency
Manual Watch Table Slow Low High (Needs physical PLC or manual toggling)
HMI Simulation Medium Low Medium (Requires UI interaction)
AutomationView Python SDK Very Fast High (100%) None (Fully simulated)

Continuous Integration for PLC Code

Once you have a suite of Python tests verifying your SFC logic, the next logical step is integrating them into a Continuous Integration pipeline. Tools like GitLab CI or GitHub Actions can execute these Python scripts every time an engineer pushes a commit to the repository. If a recent change breaks an existing machine sequence, the pipeline fails, preventing the faulty logic from ever reaching the production environment.

This approach transforms PLC programming from a solitary, hardware-dependent task into a modern, collaborative software engineering discipline.

Common Challenges and FAQ

How do you handle real-time constraints in a simulated environment?

The AutomationView simulation engine can decouple its internal clock from real-world time. This allows the Python script to advance time in fixed increments, ensuring deterministic execution regardless of the host machine’s processing speed.

Can this replace physical factory acceptance testing?

No. Automated regression testing verifies the logical intent of the code. Physical testing is still required to account for unpredictable variables like sensor noise, mechanical friction, and wiring errors.

Start modernizing your sequence development today. Visit the AutomationView Store to explore licenses, templates, and training materials designed to accelerate your engineering workflow.

Share this article

Stay Updated with AutomationView

Get the latest articles and news delivered directly to your inbox.

Log in to Subscribe

You must be registered and logged in to manage subscriptions.

Recommended for you

Inside AutomationView: Implementing GEMMA for Master State Coordination in PLC Sequences

AutomationView
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
flowchart LR
    A[GEMMA PC] -->|State Coordination| B[AutomationView]
    B -->|SFC Logic| C[PLC Hardware]
    B -->|Python Sim| D[Digital Twin]
    style A fill:#0d47a1,stroke:#1e88e5,stroke-width:2px,color:#fff
    style B fill:#1b5e20,stroke:#4caf50,stroke-width:2px,color:#fff
    style C fill:#424242,stroke:#757575,stroke-width:2px,color:#fff
    style D fill:#4a148c,stroke:#9c27b0,stroke-width:2px,color:#fff
AutomationView Icon AutomationView
calendar_month

Inside AutomationView: Implementing GEMMA for Master State Coordination in PLC Sequences

Key Takeaways: The GEMMA framework provides a standardized visual approach to managing machine states beyond normal production (stops, faults, preparations). Integrating GEMMA directly into your AutomationView GEMMA implementation bridges the gap between high-level operational modes and low-level Sequential Function Charts (SFC). By decoupling the master state logic from the physical actuators, engineers achieve significantly more […]

Read Article arrow_forward

Inside AutomationView Fault Injection: A Technical Guide to Validating PLC Edge Cases

AutomationView
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
flowchart LR
    A["PLC Sequence"]:::blue -->|Inject Fault| B["AutomationView Simulator"]:::green
    B -->|Analyze Response| C["Error Handling Logic"]:::red
    classDef blue fill:#2563eb,stroke:#1d4ed8,stroke-width:2px,color:#ffffff
    classDef green fill:#16a34a,stroke:#15803d,stroke-width:2px,color:#ffffff
    classDef red fill:#dc2626,stroke:#b91c1c,stroke-width:2px,color:#ffffff
AutomationView Icon AutomationView
calendar_month

Inside AutomationView Fault Injection: A Technical Guide to Validating PLC Edge Cases

In industrial control systems, a single unchecked edge case can result in catastrophic mechanical failure or prolonged downtime. Validating that a Programmable Logic Controller (PLC) responds correctly to sensor failures, communication drops, and unexpected logic states is notoriously difficult in live production environments. AutomationView Fault Injection allows control engineers to deliberately introduce errors within a […]

Read Article arrow_forward

How to Build Automated Unit Tests for PLC Sequences in AutomationView

AutomationView
%%{init: {'theme':'dark', 'themeVariables': { 'background': '#001c38' }}}%%
---
title: AutomationView Unit Testing Architecture
---
flowchart TD
    classDef test fill:#3b82f6,stroke:#2563eb,color:#ffffff
    classDef sfc fill:#10b981,stroke:#059669,color:#ffffff
    classDef report fill:#f59e0b,stroke:#d97706,color:#ffffff
    A["Python Test Runner (PyTest)"]:::test --> B["Mock I/O Variables"]:::test
    B --> C["Execute SFC Step/Transition"]:::sfc
    C --> D{"Assert Outputs == Expected"}
    D -- Pass --> E["Generate Coverage Report"]:::report
    D -- Fail --> F["Flag Error & Halt CI/CD"]:::report
AutomationView Icon AutomationView
calendar_month

How to Build Automated Unit Tests for PLC Sequences in AutomationView

In modern software engineering, pushing code to production without running automated unit tests is considered professional malpractice. Yet, in the industrial automation world, engineers routinely download thousands of lines of ladder logic into critical infrastructure relying solely on manual simulation and blind faith. AutomationView changes this paradigm entirely by introducing a native Python-based unit testing […]

Read Article arrow_forward