Commit Graph
424 Commits
Author SHA1 Message Date
Vickey 47760888bd feat: unify DeviceStatusEnum and DriverStatusEnum into EntityStatusEnum
- Replace two duplicate enums with single EntityStatusEnum (same index/code)
- Rename DB columns: state_flag→entity_state_flag, state_ext→entity_state_ext
- Add stateDescription field to DeviceStateDTO/DriverStateDTO for diagnostics
- Add description field to DeviceHealthState/DriverHealthState
- UPSERT SQL now writes stateDescription into entity_state_ext on heartbeat
- Remove EntityStateStatus interface (no longer needed with single enum)
- Update MQ layer, heartbeat services, status queries, gRPC, and all tests
2026-05-22 22:35:02 +08:00
pnoker 436b3b01bb feat: refine device and driver health state handling 2026-05-22 18:29:24 +08:00
pnoker 0471bd904e feat: add device health timeout state handling 2026-05-22 16:44:58 +08:00
pnoker 9007cbc22c style: apply consistent code formatting across all modules and docs 2026-05-22 00:24:22 +08:00
Vickey db14585cb8 refactor: replace manual constructors with @RequiredArgsConstructor
Replace hand-written all-assignment constructors with Lombok
@RequiredArgsConstructor across controllers, services, config classes,
event listeners, and tool classes. No behavioral change.
2026-05-21 23:18:08 +08:00
pnoker 91eef8cbcf refactor(drivers,tests): switch to constructor injection via @RequiredArgsConstructor
Last batch of the cross-module refactor away from @Resource field
injection.

Production code:
- dc3-driver/* (8 driver modules): listening-virtual (4 files: Netty
  handlers + driver custom impl), virtual, mqtt (2), coap (2),
  modbus-tcp, plcs7, opc-da, opc-ua. Fields become private final;
  jakarta.annotation.Resource imports are removed.
- NettyTcpServer/NettyUdpServer pass null to NettyTcpServerHandler /
  NettyUdpServerHandler when adding the manually-created handler to the
  Netty pipeline. Those handler instances are pure stubs that delegate
  to the Spring-managed instance via the existing static self-reference,
  so a null collaborator field on the stub is functionally equivalent to
  the prior no-op default-constructor instance.

Test adaptations:
- 26 tests across dc3-common-mqtt, dc3-common-data, dc3-common-auth,
  dc3-common-manager, dc3-common-facade-{local-manager,local-auth,
  local-data}, and dc3-driver/* swap the no-args + reflection setup for
  a direct constructor call that passes the Lombok-generated parameter
  list. Reflection setters and the `injectField` helper are removed
  where they only existed for refactor-affected fields; reflection
  helpers that touch unrelated state (static factories, private cache
  maps used as test seams) are kept.
- 3 dc3-common-driver tests (DeviceCommandReceiverTest,
  MetadataReceiverTest, DriverRegisterServiceImplTest) get the same
  treatment. MetadataReceiverTest also gains a DriverClient mock to
  match the now-five-arg constructor.
- VirtualDriverCustomServiceImplTest and SessionServiceImplTest drop
  their reflection-only @BeforeEach blocks: with final fields, Mockito
  @InjectMocks now uses constructor injection automatically and matches
  collaborators by type.
- PointServiceImplTest gains a missing DriverService @Mock so that
  Mockito constructor injection can populate every parameter.
2026-05-21 14:57:13 +08:00
pnoker 89282a71c6 refactor(runtime): encapsulate mutable static state 2026-05-19 01:42:48 +08:00
Vickey 14faabedc7 style: apply consistent formatting across GitHub workflows, docs and common modules 2026-05-19 00:15:07 +08:00
pnoker 3fa286f423 refactor: rename static final fields to UPPER_SNAKE_CASE
Six public/private static final fields used camelCase, in violation
of the standard Java naming convention for class-level constants:

  MqttScheduleJob.messageLock         -> MESSAGE_LOCK
  MqttScheduleJob.messageCount        -> MESSAGE_COUNT
  MqttScheduleJob.messageSpeed        -> MESSAGE_SPEED
  MqttScheduleJob.mqttMessages        -> MQTT_MESSAGES
  NettyTcpServer.deviceChannelMap     -> DEVICE_CHANNEL_MAP
  RepositoryStrategyFactory.repositoryServiceMap -> REPOSITORY_SERVICE_MAP

The receiveBatch() method parameter mqttMessages is intentionally
kept as camelCase; only the static field is renamed.
2026-05-18 17:54:29 +08:00
pnoker 7f5da1a0f8 chore: bump version to 2026.5.18 across all modules 2026-05-18 00:24:22 +08:00
pnoker ba187405b4 feat(driver): add CoAP driver module scaffold
Register dc3-driver-coap in the driver aggregator POM and add initial
project structure with source and target directories.
2026-05-17 22:16:51 +08:00
pnoker 994ccba991 docs: update READMEs and project documentation
Refresh module READMEs, AGENTS.md, CONTRIBUTING.md, and dc3/doc/
guides to reflect the unified Dockerfile, consolidated compose stacks,
and updated build instructions.
2026-05-17 19:03:21 +08:00
pnoker 105c63603e build: consolidate per-service Dockerfiles into unified multi-target build
Replace 14 individual Dockerfiles with a single unified Dockerfile at
the repo root using multi-stage BuildKit targets. Maven build runs
inside the builder stage so no host JDK is required.
2026-05-17 19:02:03 +08:00
pnoker 996518186a build: bump version to 2026.5.17
Update parent version and dc3.version from 2026.5.5 to 2026.5.17
across all Maven modules.
2026-05-17 19:01:44 +08:00
pnoker 7c853ac8bc chore: correct @since tag to project inception date
Update @since from 2022.1.0 to 2016.10.1 and @version from 2026.5.5
to 2026.5.17 across all Java source files to reflect the actual
project start date.
2026-05-17 19:01:28 +08:00
pnoker 019daf62ce feat: do someting test and code review 2026-05-16 00:56:04 +08:00
pnoker db683533b2 refactor(common): preserve exception causes 2026-05-15 17:27:04 +08:00
pnoker a0e774cca8 fix(driver): preserve protocol exception causes in modbus/opc drivers
Modbus TCP, OPC DA, and OPC UA all wrapped low-level protocol errors
with constructors that only carried e.getMessage() and dropped the
cause — so the connection / read / write traces ended at the SDK
boundary and operators saw the symptom (a misleading top-level message
without the protocol stack). Switch every connection / read / write
catch site to the placeholder-aware exception constructors so the
driver name, device id, host/port/slave/offset context, and the
underlying Throwable all survive on the cause chain. This pairs with
the SDK-side change that stopped catch-all-wrapping write failures
inside DriverWriteServiceImpl — the receiver now sees the actual
protocol exception type with full stack rather than a generic
ServiceException.
2026-05-15 17:15:27 +08:00
pnoker cb457c37cf refactor(driver): rename RValue/WValue and add CalculatedPointValue
Driver SPI used the cryptic RValue/WValue names for read/write payload
envelopes. Rename them to ReadPointValue/WritePointValue so the public
contract reads naturally, add a sibling CalculatedPointValue for values
that need their derived/scaled form to flow alongside the raw sample,
and pull the value-type conversion utility into a dedicated
support/TypedValueConverter helper instead of leaving it inline.

DriverCustomService.read/write signatures and the seven driver
implementations (modbus-tcp, mqtt, opc-da, opc-ua, plcs7, virtual,
listening-virtual) move to the new types in lockstep so every consumer
of the SDK keeps compiling. Tests are renamed and resequenced to match,
and the driver authoring guide reflects the new identifiers.
2026-05-15 16:10:18 +08:00
pnoker 74e16bfb30 style: format dc3-common, dc3-driver and dc3-e2e test code 2026-05-15 00:28:35 +08:00
Vickey 9ce05b8384 test(driver): cover plcs7 driver custom service and point variable mapping
PlcS7DriverCustomServiceImplTest (12 tests):
  - schedule sends ONLINE / is silent under empty device set
  - device update / delete events invalidate the cached connector wrapper
  - device add and point events do NOT touch the connection map
  - read with primed connector dispenses through serializer and stringifies result
  - read swallows serializer failures and returns null (per existing contract)
  - write with primed connector stores integer through serializer and returns true
  - write returns false when serializer.store throws downstream
  - PlcS7PointVariable maps every supported S7 type code (bool/byte/int/dint/word/dword/real/date/time/datetime) and falls back to STRING for unknown codes
  - initial is idempotent

The private static MyS7Connector wrapper and connectMap are populated via
reflection so that read/write paths can run without invoking the static
S7ConnectorFactory chain (which depends on a real PLC endpoint).
2026-05-14 10:59:19 +08:00
Vickey 108cb3957a test(driver): cover opc-ua and opc-da driver custom services
OpcUaDriverCustomServiceImplTest (9 tests):
  - initial allocates an empty connection map and is idempotent
  - schedule sends ONLINE for every attached device with 25s TTL
  - schedule is silent when no devices are registered
  - device update / delete events invalidate the cached OpcUaClient
  - device add and point events do NOT touch the connection map
  - factory failure (UaException) surfaces as ConnectorException, cache stays empty
  - connector is cached across subsequent invocations (factory called once per device)

OpcDaDriverCustomServiceImplTest (17 tests):
  - initial allocates an empty connection map
  - schedule sends ONLINE / is silent under empty device set
  - device update / delete events invalidate the cached Server
  - device add and point events do NOT touch the connection map
  - getItem reuses existing group when found, adds a new group otherwise
  - readItem dispatches by JIVariant.VT_I2/I4/I8/R4/R8/BOOL/BSTR with correct conversion
  - readItem falls back to toString() for unknown variant types

Static OpcUaClient.create(...) is mocked via Mockito.mockStatic for the OPC UA
connector tests. OPC DA's vendored DCOM stack uses concrete-class mocking only;
no real DCOM endpoint is required.
2026-05-14 10:59:19 +08:00
Vickey b0eeb86ce5 test(driver): cover mqtt driver custom service and receive pipeline
MqttDriverCustomServiceImplTest (7 tests):
  - initial is no-op and does not touch collaborators
  - schedule sends ONLINE for every attached device with 25s TTL
  - device and point metadata events are observed without side effects
  - read returns null because mqtt is passive
  - write publishes with configured commandQos when present
  - write falls back to default-QoS overload when commandQos is missing
  - write falls back to default-QoS overload when commandQos has wrong type

MqttReceiveServiceImplTest (3 tests):
  - single receive parses payload, stamps createTime and forwards via sender
  - batch receive forwards point values in order with createTime stamped
  - single receive tolerates null header (logs null topic/qos and proceeds)
2026-05-14 10:59:19 +08:00
Vickey f5fc53cd8e test(driver): cover modbus tcp driver custom service with mocked master
ModbusTcpDriverCustomServiceImplTest (16 tests):
  - schedule sends ONLINE for every attached device with 25s TTL
  - device update / delete events invalidate the cached ModbusMaster
  - point events do not touch the per-device connection cache
  - first read creates and inits the connection, subsequent reads reuse it
  - connection init failure surfaces as ConnectorException with original cause
  - read dispatches by function code 1=coil, 2=input status, 3=holding, 4=input register
  - read with unsupported function code returns "0" without contacting master
  - read transport / error response failures surface as ReadPointException
  - write coil returns true when response is not an exception, false otherwise
  - write coil transport failure surfaces as WritePointException
  - write holding register succeeds when setValue does not throw
  - write holding register transport failure surfaces as WritePointException
  - write with unsupported function code returns false and skips master entirely

Static ModbusFactory field is swapped via reflection per test and restored after.
2026-05-14 10:59:19 +08:00
Vickey 22bd526819 test(driver): cover virtual and listening-virtual driver custom services
VirtualDriverCustomServiceImplTest (9 tests):
  - initial is no-op and does not touch collaborators
  - schedule sends ONLINE for every attached device with 25s TTL
  - schedule is silent when no devices are registered
  - device and point metadata events are observed without side effects
  - read returns constant string for STRING points
  - read returns parseable boolean for BOOLEAN points
  - read returns numeric value in [0, 100) for other point types
  - write returns false unconditionally

ListeningVirtualDriverCustomServiceImplTest (7 tests):
  - initial dispatches both TCP and UDP listeners through the thread pool
  - schedule sends ONLINE for every attached device with 25s TTL
  - device and point metadata events are observed without side effects
  - read returns null because the listener is passive
  - write flushes value through the channel when device channel is registered
  - write is a no-op (returns true) when no channel is mapped for the device

16 GREEN.
2026-05-14 10:59:19 +08:00
pnoker 252c55b83d refactor(driver): rename DriverCustomServiceImpl to protocol-specific class names
Rename the generic DriverCustomServiceImpl in each driver module to a
protocol-specific name (e.g., ModbusTcpDriverCustomServiceImpl) so
that static analysis tools can scan every driver module without
filtering duplicate fully-qualified class names. Update
DRIVER-AUTHORING.md to reflect the new convention.
2026-05-10 11:25:55 +08:00
Vickey 00692d125b refactor(driver): replace System.out with logger and improve structured logging
- Replace System.out.println/print with slf4j logger calls in S7/PLC
  driver (Nodave, S7BaseConnection, PDU, PLCinterface, S7Connection)
- Add structured log messages with protocol, deviceId, and operation
  context to modbus-tcp, mqtt, opc-ua, opc-da, and virtual drivers
- Add null checks and guard clauses in Netty message handlers
- Add keystore lifecycle logging in OPC-UA KeyLoader
2026-05-10 10:48:08 +08:00
Vickey 03052e4da9 style(java): expand wildcard imports to explicit imports 2026-05-10 00:07:32 +08:00
pnoker f586f0cd1c docs: align markdown tables and wrap long lines 2026-05-09 23:50:58 +08:00
pnoker 88614fd79a style(java): expand wildcard imports to explicit imports 2026-05-09 23:50:48 +08:00
pnoker bfb9d19999 refactor(i18n): standardize user-facing text in english 2026-05-09 20:59:51 +08:00
pnoker 50c18422d3 refactor(config): standardize dc3 property prefixes 2026-05-09 20:45:22 +08:00
pnoker 0ca9639aea fix(modbus-tcp): restore abstract keyword on 18 vendored modbus4j classes
A prior docs-simplification commit (4a17fcd7f) merged two adjacent class
Javadoc blocks and inadvertently dropped the leading 'abstract' modifier
that lived between them, leaving 18 abstract-by-design classes declared
as concrete. The compiler then rejected each one with "is not abstract
and does not override abstract method ...".

Restoring 'abstract' on BaseLocator, ModbusMaster/SlaveSet, ModbusMessage
and its Request/Response subclasses, BaseMessageParser/RequestHandler,
SerialMaster/Message/Slave, IpMessage, AsciiMessage, ProgressiveTask,
and ModbusValue makes dc3-driver-modbus-tcp compile again.
2026-05-09 12:56:57 +08:00
pnoker 1c9cc2cda6 docs(common-public): simplify verbose class-level Javadocs to concise one-liners
Remove redundant <p> paragraphs that restate the class name.
Keep @author/@version/@since tags consistent across all classes.
2026-05-08 00:51:12 +08:00
pnoker e47299a327 chore: remove format and format-check targets from Makefile 2026-05-07 23:55:32 +08:00
pnoker db456d61fe style: apply spring-javaformat 0.0.47 and fix checkstyle violations
- Apply Spring Java Format to all 1087 Java source files
- Fix star imports (java.lang.annotation, org.quartz, java.util.concurrent, etc.)
- Fix missing trailing newlines across codebase
- Fix redundant public modifiers on interface methods
- Fix multiple variable declarations
- Fix if-statements missing braces in JsonUtil, RegexUtil, RequestUtil
2026-05-07 16:53:16 +08:00
pnoker 95c40b2387 chore: bump version to 2026.5.5
Roll every pom, per-module README, Spring banner, and @version /
@since javadoc tag from 2026.4.30 to the new 2026.5.5 release line.
2026-05-05 00:56:09 +08:00
Vickey 200beeaa71 chore: update version to 2026.4.30 in multiple files 2026-04-30 16:06:30 +08:00
Vickey cd268bdc30 refactor: remove explicit Netty dependency from listening-virtual and add field comments
- Remove netty-all and netty-resolver-dns-native-macos from listening-virtual
  pom.xml (already provided transitively via grpc-netty)
- Add field comments to NettyTcpServerHandler, NettyUdpServerHandler, and
  PlcS7PointVariable
2026-04-30 01:37:07 +08:00
pnoker f6bd1daf80 docs: fix incorrect comments and improve Javadoc in S7 PLC API classes
- Fix all 16 shifted enum constant comments in DaveArea.java
- Fix getSizeInBits() Javadoc that incorrectly said "bytes"
- Rewrite content-free Javadoc in S7Serializable, S7Serializer, S7Type
- Improve class/method Javadoc in S7Connector, S7Variable, SiemensPLCS
- Add missing Javadoc in S7ConnectorFactory, S7SerializerFactory
2026-04-30 01:31:38 +08:00
pnoker f2e531bf56 style: remove dangling Javadoc and clean up driver service comments
Remove dangling Javadoc comments between annotations and fields across
all driver modules. Strip redundant inline block comments from method
bodies that duplicate method-level Javadoc. Improve class-level Javadoc
and simplify verbose private method documentation. Convert traditional
switch to enhanced switch expression in Modbus TCP driver.
2026-04-30 01:29:31 +08:00
pnoker a38ec90601 feat: add gRPC client configuration and exception handling for ResponseStatusException 2026-04-29 19:02:37 +08:00
pnoker 1a52a12b23 fix: downgrade JRE version in Dockerfile from 25 to 21 2026-04-29 16:25:23 +08:00
pnoker c5a9feeeb9 feat: add .env file for Docker Compose configuration and update usage instructions 2026-04-29 10:27:57 +08:00
pnoker e87cff607e fix: correct JAVA_OPS syntax and update Maven command in Dockerfile 2026-04-19 14:07:19 +08:00
pnoker ea17c86387 chore: update version to 2026.4.19 across all modules and adjust branch settings in codeql.yml 2026-04-19 13:45:21 +08:00
pnoker e57793ec5f chore: bump version to 2026.4.18.3 and optimize pom.xml dependencies
- Bump all module versions from 2025.11.1 to 2026.4.18.3
- Remove orphaned dc3-common-influx dependency and property from root pom.xml
- Standardize dependency comment style in dc3-common/pom.xml
- Merge gRPC dependency groups into single section in dc3-common-api
- Restructure Spring Integration MQTT and Eclipse Paho groups in dc3-common-mqtt
- Fix incorrect comment 'DC3 Common Exception' to 'DC3 Common Related' in dc3-common-postgres
- Add missing blank line before </dependencies> in dc3-common-driver
- Remove stray blank line in root pom.xml dependencyManagement
2026-04-18 01:05:30 +08:00
Vickey 01078a784d refactor: replace NioEventLoopGroup with MultiThreadIoEventLoopGroup to utilize NioIoHandler factory in UDP and TCP Netty servers 2026-02-11 11:58:48 +08:00
Vickey 0adff1532b refactor: replace deprecated EnvironmentPostProcessor imports and update JsonMapper references 2026-02-11 11:56:52 +08:00
Vickey 275efde952 feat: add detailed JavaDoc comments to driver implementations and entry points 2026-01-07 20:03:06 +08:00