Crappy
  • What is Crappy ?
    • Overview
    • Key features of Crappy
    • Is Crappy for me ?
  • Installation
    • Requirements
    • 1. Check your Python version
    • 2. Deploy a virtual environment (optional)
    • 3. Install Crappy
    • 4. Check your install
  • Tutorials
    • Getting started : writing scripts in Crappy
      • 0. General concepts
        • 0.a. Blocks
        • 0.b. Links
        • 0.c. Labels
      • 1. Understanding Crappy’s syntax
      • 2. The most used Blocks
        • 2.a. The Generator Block and its Paths
        • 2.b. The Camera Block
        • 2.c. The Grapher Block
        • 2.d. The Recorder Block
        • 2.e. The IOBlock Block
        • 2.f. The Machine Block
      • 3. Properly stopping a script
    • Towards more complexity
      • 1. Using feedback loops
      • 2. Using Modifiers
      • 3. Advanced Generator condition
      • 4. Dealing with streams
      • 5. Writing scripts efficiently
        • 5.a. Use variables
        • 5.b. Use loops
        • 5.c. Use other packages
      • 6. Using Crappy objects outside of a Crappy test
      • 7. Advanced control over the runtime
        • 7.a. Alternative startup methods
        • 7.b. Arguments to the startup method
    • Creating and using custom objects in Crappy
      • 1. Custom Modifiers
      • 2. Custom Actuators
      • 3. Custom InOuts
        • 3.a. Regular mode
        • 3.b. Streamer mode
      • 4. Custom Cameras
      • 5. Custom Blocks
        • 5.a. Methods of the Block
        • 5.b. Useful attributes of the Block
        • 5.c. Sending data to other Blocks
        • 5.d. Receiving data from other Blocks
    • More about custom objects in Crappy
      • 1. Custom Generator Paths
      • 2. More about custom InOuts
      • 3. More about custom Actuators
      • 4. More about custom Cameras
        • 4.a. Pre-defined settings
        • 4.b. Reload slider and choice settings
        • 4.c. Manage the metadata of the images
      • 5. Custom Camera Blocks
        • 5.a. The CameraProcess class
        • 5.b. Writing the custom Camera Block
        • 5.c. Sending an overlay to the Displayer
        • 5.d. Final runnable example
      • 6. Sharing custom objects and Blocks
  • Current functionalities
    • Functionalities (Blocks)
      • Data display
      • Data recording
      • Data processing
      • Real-time image correlation
      • Video-extensometry
      • Signal generation
      • Hardware control
      • Test management
      • Others
    • Supported hardware (Cameras, InOuts, Actuators)
      • Supported Cameras
      • Supported Actuators
      • Supported Sensors and outputs
        • Acquisition boards
        • Sensors
        • Multi-device drivers
        • Outputs
        • Enhanced Actuators
      • LaMcube-specific hardware
    • On-the-fly data modification (Modifiers)
  • API
    • Actuators
      • Regular Actuators
        • Adafruit DC Motor Hat
        • Fake DC Motor
        • Fake Stepper Motor
        • JVL Mac140
        • Kollmorgen ServoStar 300
        • Newport TRA6PPD
        • Oriental ARD-K
        • Phidget Stepper4A
        • Pololu Tic
        • Schneider MDrive 23
      • FT232H Actuators
        • Adafruit DC Motor Hat FT232H
      • Parent Actuator
        • Actuator
        • Meta Actuator
    • Blocks
      • Regular Blocks
        • Auto Drive
        • Button
        • Camera Block
        • Canvas
        • Client Server
        • Dashboard
        • DIS Correl
        • DIC VE
        • Fake Machine
        • Generator
        • GPU Correl
        • GPU VE
        • Grapher
        • HDF Recorder
        • IOBlock
        • Link Reader
        • Machine
        • Mean Block
        • Multiplexer
        • Pause Block
        • PID
        • Recorder
        • Sink
        • Stop Block
        • Stop Button
        • Synchronizer
        • UController
        • Video Extenso
      • Generator Paths
        • Conditional
        • Constant
        • Custom
        • Cyclic
        • Cyclic Ramp
        • Integrator
        • Ramp
        • Sine
        • Parent Path
      • Camera Processes
        • Camera Process
        • DIC VE Process
        • DIS Correl Process
        • Displayer Process
        • GPU Correl Process
        • GPU VE Process
        • Recorder Process
        • Video Extenso Process
      • Parent Block
        • Block
        • Meta Block
    • Cameras
      • Regular Cameras
        • Camera GStreamer
        • Camera OpenCV
        • Fake Camera
        • File Reader
        • Raspberry Pi Camera
        • Raspberry Pi Camera 2
        • Seek Thermal Pro
        • Webcam
        • Xi API
      • CameraLink Cameras
        • Basler Ironman Camera Link
        • JAI GO-5000C-PMCL
        • JAI GO-5000C-PMCL 8 bits
      • Parent Camera
        • Camera
        • Meta Camera
        • Camera Settings
    • Modifiers
      • Regular Modifiers
        • Demux
        • Differentiate
        • DownSampler
        • Integrate
        • Mean
        • Median
        • Moving Average
        • Moving Median
        • Offset
        • Trig on change
        • Trig on value
      • Parent Modifier
        • Modifier
        • Meta Modifier
    • In / Out
      • Regular In/Outs
        • ADS1115
        • Agilent 34420A
        • Comedi
        • DAQmx
        • Fake Inout
        • GPIO PWM
        • GPIO Switch
        • Kollmorgen AKD PDMM
        • Labjack T7
        • Labjack T7 Streamer
        • Labjack UE9
        • MCP9600
        • MPRLS
        • NAU7802
        • NI DAQmx
        • OpSens HandySens
        • Phidget Wheatstone Bridge
        • PiJuice
        • Sim868
        • Spectrum M2I 4711
        • Waveshare AD/DA
        • Waveshare High Precision
      • FT232H In/Outs
        • ADS1115 FT232H
        • GPIO Switch FT232H
        • MCP9600 FT232H
        • MPRLS FT232H
        • NAU7802 FT232H
        • Waveshare AD/DA FT232H
      • Parent In/Out
        • InOut
        • Meta InOut
    • Links
      • Link
        • Link
    • Tools
      • Microcontroller templates
        • Arduino Template
        • MicroPython Template
      • Bindings
        • Comedi Bind
        • Py Spectrum
      • Camera Configurators
        • Camera Configurator
        • Camera Configurator with Boxes
        • DIS Correl Configurator
        • DIS VE Configurator
        • Video Extenso Configurator
        • Configurator Tools
      • Data
      • FT232H Tools
        • FT232H
        • FT232H Server
        • I2C Message
        • USB Server
      • Image Processing Tools
        • DIS Correl Tool
        • DIS VE Tool
        • Fields Tools
        • GPU Correl Tool
        • GPU Kernels
        • Video Extenso Tool
        • Video Extenso Tracker
    • Exceptions & missing Python modules
      • CameraPrepareError
      • CameraRuntimeError
      • CrappyFail
      • DefinitionError
      • GeneratorStop
      • LinkDataError
      • LostSpotError
      • PrepareError
      • ReaderStop
      • StartTimeout
      • T0NotSetError
      • OptionalModule
        • OptionalModule.__init__()
        • OptionalModule.__getattr__()
        • OptionalModule.__call__()
    • Aliases
      • Link Method
        • link()
      • Open Online Documentation
        • docs()
      • Classes aliases
      • Methods aliases
        • crappy.prepare()
        • crappy.renice()
        • crappy.launch()
        • crappy.start()
        • crappy.stop()
        • crappy.reset()
    • LaMcube
      • Bi Spectral
        • BiSpectral
      • Biaxe
        • Biaxe
      • Biotens
        • Biotens
  • Developers information
    • Contributing to Crappy
    • Technical description of Crappy
      • Blocks and Links
        • Regular Blocks and Links
        • Camera-related Blocks
      • Actuators, Cameras, InOuts
      • Modifier objects
      • C++ extension modules
      • Other objects
        • Generator Paths objects
        • CameraConfig window
        • CameraSetting objects
        • Image processing
        • FT232H feature
    • Detailed runtime sequence of Crappy
      • In the main Process
        • The __init__ phase
        • The prepare phase
        • The renice phase
        • The launch phase
        • The cleanup phase
      • In the children Processes
  • Citing Crappy
  • Troubleshooting
Crappy
  • API
  • Links
  • Edit on GitHub
Previous Next

Links

Link

class crappy.links.Link(*args, **kwargs)[source]

This class is used for transferring information between two instances of Block.

The created Link is unidirectional, from the input Block to the output Block. Under the hood, a Link is basically a multiprocessing.Pipe with extra features.

Note

It is possible to add one or multiple Modifier to modify the transferred value. The Modifiers should be callables taking a dict as argument and returning a dict. They can be functions, or preferably children of Modifier.

Added in version 1.4.0.

__init__(input_block, output_block, modifiers: list[Callable[[dict[str, Any]], dict[str, Any]]] | None = None, name: str | None = None) → None[source]

Sets the instance attributes.

Parameters:
  • input_block – The Block sending data through the Link.

  • output_block – The Block receiving data through the Link.

  • modifiers – A list containing callables. If several objects given, they will be called in the given order. Refer to Modifier for more information.

  • name – Name of the Link, to differentiate it from the others when debugging. If no specific name is given, the Links are numbered in the order in which they are instantiated in the script.

Changed in version 1.5.9: renamed condition argument to conditions

Changed in version 1.5.9: renamed modifier argument to modifiers

Removed in version 2.0.0: conditions, timeout and action arguments

log(log_level: int, msg: str) → None[source]

Method for recording log messages from the Link.

Parameters:
  • log_level – An int indicating the logging level of the message.

  • msg – The message to log, as a str.

Added in version 2.0.0.

poll() → bool[source]

Returns True if there’s data available for reading.

Added in version 2.0.0.

send(value: dict[str, Any]) → None[source]

Sends a value from the upstream Block to the downstream Block.

Before sending, applies the given Modifiers and makes sure there’s room in the Pipe for sending the data (Linux only).

recv() → dict[str, Any][source]

Reads a single value from the Link and returns it.

The read value is the oldest available in the Link, see recv_last() for reading the newest available value.

If no data is available in the Link, returns an empty dict.

Returns:

A dict whose keys are the labels being sent, and for each key a single value (usually a float or a str).

Removed in version 2.0.0: blocking argument

recv_last() → dict[str, Any][source]

Reads all the available values in the Link, and returns the newest one.

If no data is available in the Link, returns an empty dict. All the data that is not returned is permanently dropped.

Returns:

A dict whose keys are the labels being sent, and for each key a single value (usually a float or a str).

Removed in version 2.0.0: blocking argument

recv_chunk() → dict[str, list[Any]][source]

Reads all the available values in the Link, and returns them all.

Returns:

A dict whose keys are the labels being sent, and for each key a list of the received values. The first item in the list is the oldest one available in the Link, the last item is the newest available.

Removed in version 1.5.9: length argument

Added in version 1.5.9: blocking argument

Removed in version 2.0.0: blocking argument

Previous Next

© Copyright 2024, LaMcube and contributors. Last updated on Nov 26, 2024.

Built with Sphinx using a theme provided by Read the Docs.