A distributed real-time monitoring and control system for industrial equipment built with .NET 9, RabbitMQ, and Avalonia UI.
Equipment Control Center is a modern microservices-based system that enables real-time monitoring and control of multiple equipment types (CNC machines, 3D printers, etc.) through a dynamic desktop interface. Services automatically discover each other, and the UI dynamically generates controls based on equipment capabilities.
- 🔄 Automatic Service Discovery - Services announce themselves; UI discovers them automatically
- ⚡ Real-time Updates - Hybrid messaging with periodic heartbeats + immediate state change events
- 🎛️ Dynamic UI - Control panels generated dynamically based on service capabilities
- 🔌 Plug & Play - Add new equipment services without modifying the UI
- 📊 Observability - Built-in distributed tracing, metrics, and logging via .NET Aspire
- 🐰 Message Bus - RabbitMQ with MassTransit for reliable messaging
- 🎯 Type-Safe - Strongly-typed message contracts shared across services
┌─────────────────────────────────────────────────────────────┐
│ AppHost (.NET Aspire) │
│ Orchestrates all services, containers, and dependencies │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
┌───▼───┐ ┌─────▼─────┐ ┌─────▼─────┐
│Consul │ │ RabbitMQ │ │ Desktop │
│ │ │ │ │ UI │
└───────┘ └─────┬─────┘ └─────┬─────┘
│ │
┌─────────┴─────────┐ │
│ │ │
┌─────▼─────┐ ┌──────▼──────┐ │
│ CNC │ │ Printer │ │
│ Service │ │ Service │ │
└───────────┘ └─────────────┘ │
│ │ │
└───────────────────┴──────────┘
(Pub/Sub Messages)
- AppHost: .NET Aspire orchestrator managing all services and infrastructure
- Consul: Service registry with health checks
- RabbitMQ: Message broker with MassTransit for pub/sub messaging
- CNC Service: Example equipment service (3-axis CNC machine)
- Printer Service: Example equipment service (3D printer)
- Desktop UI: Cross-platform Avalonia application with dynamic control generation
- Shared: Common message contracts and models
- .NET 9.0 - Modern C# and latest framework features
- Avalonia 11.3.8 - Cross-platform UI framework (Windows, Linux, macOS, Web)
- MassTransit 8.3.4 - Distributed application framework for RabbitMQ
- RabbitMQ 4.0 - Message broker with management plugin
- Consul - Service discovery and distributed configuration
- .NET Aspire 9.0 - Cloud-ready stack for orchestration and observability
- CommunityToolkit.Mvvm - MVVM helpers for UI
- OpenTelemetry - Distributed tracing and metrics
- .NET 9.0 SDK
- Docker Desktop (for Consul and RabbitMQ containers)
- Windows, Linux, or macOS
The easiest way to run the entire system is using the AppHost:
cd src/EquipmentControlCenter.AppHost
dotnet runThis single command will:
- Start Consul container (http://localhost:8500)
- Start RabbitMQ container (http://localhost:15672)
- Launch CNC Service
- Launch 3D Printer Service
- Open Desktop UI window
- Open Aspire Dashboard in your browser
After starting the AppHost:
- Aspire Dashboard: http://localhost:15065 (check console for login URL with token)
- Desktop UI: Opens automatically as a native window
- Consul UI: http://localhost:8500
- RabbitMQ Management: http://localhost:15672 (username:
admin, password:admin)
If you prefer to run services individually:
# Terminal 1: Start AppHost (infrastructure only)
cd src/EquipmentControlCenter.AppHost
dotnet run
# Terminal 2: Start CNC Service
cd src/Services/EquipmentControlCenter.CncService
dotnet run
# Terminal 3: Start Printer Service
cd src/Services/EquipmentControlCenter.PrinterService
dotnet run
# Terminal 4: Start Desktop UI
cd src/EquipmentControlCenter.Desktop/EquipmentControlCenter.Desktop.Desktop
dotnet runEquipmentControlCenter/
├── src/
│ ├── EquipmentControlCenter.AppHost/ # Aspire orchestrator
│ ├── EquipmentControlCenter.Shared/ # Message contracts
│ │ └── Messages/ # Shared message types
│ ├── EquipmentControlCenter.ServiceDefaults/ # Common service configuration
│ ├── Services/
│ │ ├── EquipmentControlCenter.CncService/ # CNC machine service
│ │ └── EquipmentControlCenter.PrinterService/ # 3D printer service
│ ├── EquipmentControlCenter.Desktop/ # Avalonia UI (shared)
│ │ ├── EquipmentControlCenter.Desktop/ # Core UI logic
│ │ ├── EquipmentControlCenter.Desktop.Desktop/ # Desktop entry point
│ │ └── EquipmentControlCenter.Desktop.Browser/ # WebAssembly entry point
│ └── Infrastructure/
│ └── EquipmentControlCenter.ServiceDiscovery/ # Service discovery abstractions
└── tests/ # Unit and integration tests
1. Service starts → Publishes ServiceRegistered message
2. Desktop UI receives message → Adds service to list
3. Desktop UI displays service with all available controls
1. Service publishes ServiceHeartbeat with current state
2. Desktop UI receives → Updates health status, uptime, state
1. User clicks control in UI → Sends ControlCommand
2. Service receives command → Executes action
3. Service updates state → Publishes ServiceStateChanged
4. Desktop UI receives → Updates control values in real-time
-
Create a new service project:
cd src/Services dotnet new webapi -n EquipmentControlCenter.LaserService -
Add references:
- Reference
EquipmentControlCenter.Shared - Add MassTransit and MassTransit.RabbitMQ packages
- Reference
-
Copy the pattern from CncService or PrinterService:
ServiceStateManager- State trackingControlExecutor- Business logic for controlsControlDefinitionProvider- Define your controlsControlCommandConsumer- Handle UI commandsServiceRegistrationPublisher- Announce service on startupMonitoringService- Send heartbeats
-
Define your controls in
ControlDefinitionProvider:new ControlDefinition { ControlId = "laser-power", DisplayName = "Laser Power", Type = ControlType.Slider, Category = "Laser Control", Constraints = new ControlConstraints { MinValue = 0, MaxValue = 100, Step = 1 } }
-
Add to AppHost:
var laserService = builder.AddProject<Projects.EquipmentControlCenter_LaserService>("laser-service") .WaitFor(rabbitmq) .WithReference(rabbitmq);
-
Run - The service will automatically appear in the Desktop UI!
The system supports multiple control types:
| Type | Description | UI Component | Example |
|---|---|---|---|
Button |
Execute action | Button | Start Machine, Emergency Stop |
Toggle |
On/Off switch | ToggleSwitch | Coolant On/Off |
Slider |
Numeric range | Slider + Apply Button | Spindle Speed (0-5000) |
TextInput |
Text entry | TextBox + Submit | Program Name |
NumericInput |
Number entry | NumericUpDown | Custom value |
{
"ServiceConfig": {
"ServiceName": "my-service",
"ServiceId": "my-service-001",
"ServiceAddress": "localhost",
"ServicePort": 5003
}
}Services automatically get RabbitMQ connection strings from Aspire via GetConnectionString("rabbitmq").
For standalone mode, services fall back to localhost:5672 with guest/guest.
The Aspire Dashboard provides:
- Resources: See status of all services and containers
- Console Logs: Real-time logs from each service
- Structured Logs: Filterable structured logging
- Traces: Distributed tracing across service boundaries
- Metrics: Performance metrics and health checks
Enable message tracing:
docker exec $(docker ps -q -f name=rabbitmq) rabbitmq-plugins enable rabbitmq_tracingThen access via RabbitMQ Management UI → Admin → Tracing.
All message contracts are defined in EquipmentControlCenter.Shared/Messages/:
- ServiceRegistered - Service announces capabilities
- ServiceHeartbeat - Periodic health and state
- ServiceStateChanged - Immediate state change notification
- ServiceHealthReport - Detailed health information
- ControlDefinition - Control metadata and constraints
- ControlCommand - Command from UI to service (request)
- ControlCommandResponse - Result of command execution (response)
cd src
dotnet build EquipmentControlCenter.slnxcd tests
dotnet testcd src
dotnet clean
dotnet buildSymptom: No connection could be made because the target machine actively refused it (localhost:8500)
Solution: Make sure AppHost is running first. It starts the Consul container.
Symptom: Can't log into RabbitMQ Management UI
Solution: Use credentials admin/admin (configured in AppHost). Default guest/guest only works from localhost.
Symptoms: UI opens but service list is empty
Solutions:
- Check RabbitMQ is running:
docker ps | grep rabbitmq - Check service logs in Aspire Dashboard
- Verify services published ServiceRegistered message in RabbitMQ Management UI
Symptom: Address already in use
Solution: Stop existing containers and retry:
docker stop $(docker ps -q)- Multiple service instances (horizontal scaling)
- Historical data storage (time-series database)
- Real-time charting and visualization
- User authentication and authorization
- Role-based access control for controls
- Alert and notification system
- Service configuration UI
- Mobile app (iOS/Android via Avalonia)
- Web dashboard (WebAssembly)
- Integration with industrial protocols (OPC UA, Modbus)
[Your License Here]
Contributions are welcome! Please feel free to submit a Pull Request.
- Your Name - Initial work
- Built with .NET Aspire
- UI powered by Avalonia
- Messaging via MassTransit