Spaxiom-DSL
███████╗██████╗ █████╗ ██╗ ██╗██╗ ██████╗ ███╗ ███╗
██╔════╝██╔══██╗██╔══██╗╚██╗██╔╝██║██╔═══██╗████╗ ████║
███████╗██████╔╝███████║ ╚███╔╝ ██║██║ ██║██╔████╔██║
╚════██║██╔═══╝ ██╔══██║ ██╔██╗ ██║██║ ██║██║╚██╔╝██║
███████║██║ ██║ ██║██╔╝ ██╗██║╚██████╔╝██║ ╚═╝ ██║
╚══════╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝
An embedded domain-specific language for spatial sensor fusion, temporal reasoning, and real-time event detection.
╔═══════════╗ ╔═══════════╗
║ SENSORS ║ ║ DETECTION ║
║ ●━━━━━━━━━║═══════════════════║━━━━━━━━━● ║
║ ●━━━━━━━━━║═══════════════════║━━━━━━━━━● ║
╚═══════════╝ ╚═══════════╝
│ ▲
▼ │
╔═══════════╗ ╔═══════════╗ ╔═══════════╗
║ ║ ║ ║ ║ ║
║ SPATIAL ║════>║ TEMPORAL ║════>║ EVENTS ║
║ ║ ║ ║ ║ ║
╚═══════════╝ ╚═══════════╝ ╚═══════════╝
What is Spaxiom?
Spaxiom is a powerful Domain-Specific Language (DSL) designed for building intelligent systems that work with:
- Spatial Data: Zones, sensors, and physical spaces
- Temporal Logic: Time-based conditions and historical analysis
- Event Processing: Triggering actions based on complex conditions
- Entity Management: Tracking and querying objects in your system
- Physical Units: Working with measurements in a type-safe manner
With Spaxiom, you can easily define complex conditions that span across space and time, and connect them to real-world events.
Key Features
- 🏠 Spatial Zones: Define and work with 2D spatial regions
- ⚡ Sensors: Interface with various sensor types and data streams
- ⏱️ Temporal Logic: Create conditions that must be true for specific durations
- 🔄 Event Callbacks: Register event handlers triggered by complex conditions
- 👥 Entity Tracking: Maintain collections of entities with flexible attributes
- 📏 Physical Units: Work with measurements and conversions seamlessly
- 🧩 Logical Operators: Combine conditions using intuitive &, |, and ~ operators
- 📄 YAML Configuration: Define sensors and system setup through YAML files
Installation
pip install spaxiom
Quick Examples
Spatial & Temporal Logic
from spaxiom import Sensor, Zone, Condition, on, within
# Define a zone and sensor
office_zone = Zone(0, 0, 10, 10)
motion_sensor = Sensor("motion1", "motion", (5, 5, 0))
# Create condition based on sensor data
motion_detected = Condition(lambda: motion_sensor.read() > 0.5)
# Make it temporal - must be true for 5 seconds
sustained_motion = within(5.0, motion_detected)
# Register an event handler
@on(sustained_motion)
def alert_sustained_motion():
print("Motion has been detected for 5 seconds!")
Entity Management
from spaxiom import EntitySet, Entity, exists, on, Condition
# Create a collection of entities
persons = EntitySet("Persons")
# Add entities with attributes
persons.add(Entity(attrs={"type": "person", "confidence": 0.9}))
# Create condition based on entity existence
person_detected = exists(persons, lambda p: p.attrs.get("confidence", 0) > 0.8)
# Register an event handler
@on(person_detected)
def alert_person():
print("Person detected with high confidence!")
Physical Units
from spaxiom import Quantity
# Create measurements with units
distance = Quantity(10, "m")
time = Quantity(2, "s")
# Automatic unit conversion
speed = distance / time # 5 m/s
# Convert to different units
speed_kph = speed.to("km/hour") # 18 km/h
YAML Configuration
from spaxiom import load_sensors_from_yaml, on, Condition, within
# Load sensors from YAML configuration file
sensors = load_sensors_from_yaml("sensors_config.yaml")
# Access sensors by name from the registry
from spaxiom import SensorRegistry
registry = SensorRegistry()
motion_sensor = registry.get("motion_sensor1")
# Create condition based on sensor from config
motion_detected = Condition(lambda: motion_sensor.read() > 0.5)
# Register event handler
@on(motion_detected)
def alert_motion():
print("Motion detected!")
Example YAML configuration:
sensors:
- name: motion_sensor1
type: gpio_digital
pin: 17
location: [0, 0, 0]
pull_up: true
- name: temperature_sensor1
type: random
location: [1, 2, 0]
hz: 5.0
Documentation
Online Documentation
The full documentation is available online at: https://joescanlin.github.io/spaxiom-dsl/
Local Documentation
For local development, you can build and view the documentation using MkDocs:
# Install MkDocs and required extensions
pip install mkdocs-material pymdown-extensions
# Serve the documentation locally
mkdocs serve
# Build the documentation
mkdocs build
The documentation source files are located in the docs/ directory. Some key sections:
Documentation Updates
The documentation is automatically deployed to GitHub Pages when changes are pushed to the main branch.
Changes to files in the docs/ directory or to mkdocs.yml will trigger a new build and deployment.
License
MIT
Metadata
Release files for spaxiom 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spaxiom-0.1.0.tar.gz | 64.4 kB | Without provenance | Details for spaxiom-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spaxiom-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for spaxiom-0.1.0-py3-none-any.whl |
Total release size: 148.1 kB
Release files / spaxiom-0.1.0.tar.gz
| Download URL | spaxiom-0.1.0.tar.gz |
|---|---|
| Size | 64.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f291d6a3fb3307502e2bbc4c75671ea123830422c751735df15f10c339531253
|
|
BLAKE2b-256 checksum How to use checksums |
27a6eb66aea3a0ceb6da093931ee38ff6f35665c38192a68b449e1158f07de11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / spaxiom-0.1.0-py3-none-any.whl
| Download URL | spaxiom-0.1.0-py3-none-any.whl |
|---|---|
| Size | 83.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f12359067b5077e8eb507e9245c6675c655f994b312992e45df6bddcd9050eca
|
|
BLAKE2b-256 checksum How to use checksums |
ec47c95b50969f0533a1aca869d6bef10f0e651e15d939fc231f7119ce0fe35f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for spaxiom 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.