InstrumentMock.Core 0.2.0

dotnet add package InstrumentMock.Core --version 0.2.0
                    
NuGet\Install-Package InstrumentMock.Core -Version 0.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="InstrumentMock.Core" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="InstrumentMock.Core" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="InstrumentMock.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add InstrumentMock.Core --version 0.2.0
                    
#r "nuget: InstrumentMock.Core, 0.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package InstrumentMock.Core@0.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=InstrumentMock.Core&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=InstrumentMock.Core&version=0.2.0
                    
Install as a Cake Tool

InstrumentMock

Lightweight SCPI and Modbus TCP device simulator for integration testing.

Spin up a realistic instrument mock in one line of C# code.
No Docker. No admin rights. No hardware required. Runs on any Windows CI agent.


Quick Start

// Load device model from YAML and start SCPI server on port 5025
await using var device = MockDevice.FromYaml("devices/generic_psu.yaml", port: 5025);
await device.StartAsync();

// Your test code connects via TCP to localhost:5025
// Any VISA-compatible client works: pyvisa, python-ivi, NI-VISA, ...

await device.StopAsync();

In a test (xUnit example)

[Fact]
public async Task PowerSupply_SetsVoltage()
{
    await using var device = MockDevice.FromYaml("generic_psu.yaml", port: 5025);
    await device.StartAsync();

    // Connect your real driver under test to localhost:5025
    var psu = new MyPsuDriver("localhost", 5025);
    await psu.SetVoltageAsync(12.5);

    Assert.Equal("12.5", device.StateMachine.GetState("voltage_set"));
}

Device Model (YAML)

Each device is described by a simple YAML file:

id: my_psu
name: My Power Supply
manufacturer: Keysight
model: E36312A
firmware: A.01.07
serial: MY12345678

initial_state:
  voltage_set: "0.0"
  current_set: "1.0"
  output_enabled: "0"

commands:
  - pattern: "VOLT {value}"
    description: "Set output voltage"
    min: 0.0
    max: 32.0
    set_state:
      voltage_set: "{value}"

  - pattern: "VOLT?"
    response: "{voltage_set}"

  - pattern: "OUTP {state}"
    set_state:
      output_enabled: "{state}"

  - pattern: "OUTP?"
    response: "{output_enabled}"

  - pattern: "MEAS:VOLT?"
    response: "{voltage_set}"

Built-in IEEE 488.2 commands (always available)

Command Response
*IDN? Manufacturer,Model,Serial,Firmware
*RST Resets all state to initial values
*CLS Clears status (no response)
*OPC? 1
*STB? 0
*ESR? 0
SYST:ERR? +0,"No error"

Architecture

DeviceModel (YAML)
      │
      ▼
DeviceStateMachine   ←── stateful, thread-safe
      │
      ▼
ScpiServer (TCP :5025)
      │
      ▼
Your test code / driver under test

Modbus TCP

await using var device = MockModbusDevice.FromYaml("devices/relay_board.yaml", port: 502);
await device.StartAsync();

// Inject a measured value from the "sensor" side
device.Registers.SetInput(0, 2450); // e.g. 24.50 V (10mV resolution)

// Assert what the client wrote
var setpoint = device.Registers.GetHolding(0);

Supported function codes: FC01–FC06, FC0F, FC10 (coils, discrete inputs, holding/input registers).


Roadmap

  • SCPI/TCP support
  • Modbus/TCP support (relay boards, EA PSUs)
  • Fault injection API (response delay, error queue, drop/override)
  • KI-based YAML generation from instrument manuals (paid service)
  • Device library (verified YAML files for common instruments)
  • Serial port (RS232) transport

License

MIT – Core library is free and open source forever.
Premium device models available at [instrumentmock (coming soon) (coming soon)

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.0 96 5/4/2026