UniCon.WebServer provides a comprehensive RESTful API layer based on ASP.NET Core Minimal APIs. It serves as a universal protocol conversion and configuration bridge between southbound industrial devices and northbound IT systems.
- Driver Lifecycle Management: Enables dynamic addition, query, and deletion of driver instances for various industrial protocols (S7, Modbus, OPC UA, MQTT, OPC UA PubSub) via APIs without requiring a service restart.
- Universal Data Read/Write: Shields underlying protocol differences by providing strongly-typed read and write operations on any device tag address using a unified HTTP format.
- Subscription & Real-Time Caching: Maintains southbound driver data subscriptions in memory and stores the latest timestamps and data quality in cache for high-speed polling by northbound clients.
- Object-Device Mapping (ODM): Automatically generates tag mapping tables using entity class attributes, and supports bulk reading from devices to auto-populate entities, as well as reflecting bulk writing of entity properties to devices.
- Task Scheduling Management: Enables dynamic runtime creation, querying, updating, and deletion (CRUD) of scheduled tasks.
| Method | Route | Description |
|---|
GET | /api/drivers | Get status list of all registered drivers |
GET | /api/drivers/{id} | Query details of a single driver |
POST | /api/drivers | Dynamically register and spin up a new driver (with Watchdog self-healing) |
DELETE | /api/drivers/{id} | Stop, unregister, and destroy the specified driver |
| Method | Route | Description |
|---|
GET | /api/drivers/{id}/read?address=&type= | Strongly-typed real-time read of a single tag |
POST | /api/drivers/{id}/write | Strongly-typed real-time write of a single tag |
POST | /api/drivers/{id}/subscribe | Dynamically register tag subscription (cache the latest value) |
POST | /api/drivers/{id}/unsubscribe | Unsubscribe from the specified tag |
GET | /api/drivers/{id}/subscriptions | Get cached data for all subscribed tags of this driver |
GET | /api/drivers/{id}/subscriptions/{*address} | Get real-time cached value of a single subscription |
| Method | Route | Description |
|---|
GET | /api/odm/schema | Scan entity classes using reflection to generate physical tag mapping schemas |
GET | /api/odm/data | Spin up drivers on demand and batch-read entities to automatically populate and return them |
POST | /api/odm/data | Receive entity JSON and reflectively batch-write properties to physical devices |
| Method | Route | Description |
|---|
GET | /api/jobs/executing-count | Get the number of currently executing tasks |
GET | /api/jobs | Get a list of all scheduled tasks |
GET | /api/jobs/{id} | Query detailed information of a single task |
POST | /api/jobs | Dynamically create and schedule a new task |
PUT | /api/jobs/{id} | Update the Cron expression and parameters of a scheduled task |
DELETE | /api/jobs/{id} | Unregister and completely delete the specified task |
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddUniCon(); // Inject driver registry, connection manager, cache, and ODM engine
builder.Services.AddUniConJobs(); // Inject task scheduling system
var app = builder.Build();
// Automatically discover and register all drivers decorated with [UniconDriver]
var driverRegistry = app.Services.GetRequiredService<IDriverRegistry>();
driverRegistry.DiscoverAndRegisterDrivers();
// Start the task scheduler
var jobScheduler = app.Services.GetRequiredService<JobScheduler>();
await jobScheduler.StartAsync();
app.Run();