Files
Vickey d2c897846c refactor(common): split ResponseEnum into SuccessCode/ErrorCode and align body code with HTTP status
Replace the mixed-purpose ResponseEnum with a ResponseCode interface implemented
by SuccessCode (OK/ADD/DELETE/UPDATE) and ErrorCode (NOT_FOUND/UNAUTHORIZED/
TOKEN_INVALID/IP_INVALID/FORBIDDEN/PASSWORD_*/VALIDATION/OUT_OF_RANGE/FAILURE),
each carrying its HTTP status so the envelope body code and transport status no
longer diverge.

- Introduce abstract BusinessException carrying an ErrorCode; all 23 business
  exceptions extend it and bind a fixed code. ExceptionConfig reads the carried
  code to set both body code and HTTP status (404->R404, 401->R401, 422->R422).
- Add GrpcRFactory (ok/fail/notFound) and remove the hand-written GrpcR builder
  boilerplate across 19 gRPC servers.
- Drop the dead @EnumValue index and ofIndex/ofCode/ofName lookups; OUT_OF_RANGE
  is now carried by OutRangeException.
- Update R factory methods to accept ResponseCode; migrate 90+ controllers,
  11 gRPC facades, OpenAPI specs and README to the split enums.

Also fix several pre-existing red tests surfaced by the full suite:
- OAuthMcpRuntimeServiceImplTest: setUp set @Value fields refactored into
  OAuthProperties; inject the properties object instead.
- DriverReadServiceImplTest: reset leaked ConnectionBackoff static state via a
  new clear() in @BeforeEach.
- modbus-rtu/tcp: make the static modbusFactory non-final so tests can swap it.
- ble: override no-arg health() to report OFFLINE before initialization.
- PlcS7/facade-local tests: expect the thrown exception / use the single-arg
  overload matching production behaviour.
- Remove a duplicate dc3-common-constant dependency in dc3-common-data/pom.xml.
2026-06-18 23:53:41 +08:00
..
2026-05-26 00:30:11 +08:00

DC3 Common Driver

Overview

dc3-common-driver is the shared driver dependency module of the IoT DC3 platform. It provides the driver SDK shared by all protocol drivers, including auto-registration with the Manager Center, metadata sync, RabbitMQ command handling, and scheduled data collection.

Module Information

  • Group ID: io.github.pnoker
  • Artifact ID: dc3-common-driver
  • Version: 2026.5.22

Key Components

Component Purpose
DriverInitRunner Registers the driver with Manager Center via gRPC on startup
DriverEnvironmentConfig Binds driver YAML config (name, attributes, point attributes)
gRPC Clients (PointClient, DeviceClient) Fetches point/device config from Manager Center
RabbitMQ Consumers Receives metadata update events and device commands
Scheduled Jobs Periodic read jobs triggering driver's data collection loop
DriverTopicConfig Configures driver-specific RabbitMQ queues/bindings

Driver Registration Flow

Driver startup
  → DriverInitRunner
    → gRPC: dc3-center-manager / DriverApi.driverRegister()
      ← Returns: driver ID, driver attributes, point attributes, device IDs
    → Subscribe to metadata queue: dc3.q.metadata.driver.{serviceName}
    → Subscribe to command queue: dc3.q.command.driver.{serviceName}

RabbitMQ Integration

Exchange Queue Purpose
dc3.e.metadata dc3.q.metadata.driver.{service} Receive config change events
dc3.e.command dc3.q.command.driver.{service} Receive READ/WRITE commands
dc3.e.value — Publish point values to data center

Build Instructions

mvn -s ../../.mvn/settings.xml clean package
  • All dc3-driver-* modules — Consume this SDK
  • dc3-api-driver — gRPC contracts consumed by this SDK
  • dc3-common-rabbitmq — RabbitMQ exchange configuration
  • dc3-common-constant — RabbitConstant routing key prefixes

License

Copyright 2016-present the IoT DC3 original author or authors.

Licensed under the GNU Affero General Public License v3.0 (AGPL 3.0)