Skip to main content

ProtoTwin Connect Client

This package provides a simple client that can be used to interface with ProtoTwin Connect.

Basic Example

# STEP 1: Import the ProtoTwin client
import prototwin
import asyncio
import os
import math

# STEP 2: Define your signal addresses (obtain these from your ProtoTwin model)
simulation_time_address = 0
motor_target_velocity_address = 3

async def main():
    # STEP 3: Start ProtoTwin Connect, load and initialize the model
    path = os.path.join(os.path.dirname(__file__), "example.ptm")
    client = await prototwin.start()
    await client.load(path)
    await client.initialize()

    # STEP 4: Create the simulation loop
    while True:
        t = client.get(simulation_time_address) # Read signal values
        client.set(motor_target_velocity_address, math.sin(t)) # Write signal values
        await client.step() # Step the simulation forward in time

asyncio.run(main()) # Run the simulation loop

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prototwin-0.2.3.tar.gz (5.1 kB view details)

Uploaded Source

File details

Details for the file prototwin-0.2.3.tar.gz.

File metadata

  • Download URL: prototwin-0.2.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for prototwin-0.2.3.tar.gz
Algorithm Hash digest
SHA256 9526a2a9af73b0c4925d91eb97df77120482b245dd314b65554b06c9a91be2a5
MD5 fe8c43b7d10576383b5c59fca9aac51d
BLAKE2b-256 326224e62b53a8293d67bc1dcdb99f5e7dbff3ae1b7a92a8697d111f2b51576b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.3 This release

1 file

0.2.2

1 file

0.2.1

1 file

0.2.0

1 file

0.1.15

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page