The BridgeModbusTcpImpl
does not work when
@Reference
private Cycle cycle;
is added. It seems the FSM is stucked in the WRITE
state
2024-04-01T09:30:40,819 [_cycle ] INFO [ker.internal.CycleTasksManager] State: WRITE -> WRITE (onExecuteWrite)
2024-04-01T09:30:41,816 [_cycle ] INFO [ker.internal.CycleTasksManager] State: WRITE unchanged (in onBeforeProcessImage) Delay [0] (time is invalid)
2024-04-01T09:30:41,818 [_cycle ] INFO [ebuglog.ControllerDebugLogImpl] [ctrlDebugLog0] _sum[State:Info] ess0[SoC:UNDEFINED|L:UNDEFINED|Allowed:UNDEFINED;UNDEFINED|On-Grid] modbus0[CycleDelay:0 ms|State:INFO: CycleTimeIsTooShort]
2024-04-01T09:30:41,819 [_cycle ] INFO [ker.internal.CycleTasksManager] State: WRITE -> WRITE (onExecuteWrite)
2024-04-01T09:30:42,815 [_cycle ] INFO [ker.internal.CycleTasksManager] State: WRITE unchanged (in onBeforeProcessImage) Delay [0] (time is invalid)
2024-04-01T09:30:42,818 [_cycle ] INFO [ebuglog.ControllerDebugLogImpl] [ctrlDebugLog0] _sum[State:Info] ess0[SoC:UNDEFINED|L:UNDEFINED|Allowed:UNDEFINED;UNDEFINED|On-Grid] modbus0[CycleDelay:0 ms|State:INFO: CycleTimeIsTooShort]
This problem was found during the implementation of high level modbus skip cycle function Modbus bridge skipcycle highlevel by cvabc · Pull Request #1 · girasolenergy/openems-fork · GitHub .
The core cycle time is needed to calculated how many cycles should be skipped
this.noSkipIdx = (int)Math.ceil(config.intervalBetweenAccesses() * 1.0 / cycle.getCycleTime());
The code can pass tests but cannot work on real hardware devices. After some try and error, it’s found that the import of even only 2 lines of code
@Reference
private Cycle cycle;
in the io/openems/edge/bridge/modbus/BridgeModbusTcpImpl.java
file in develop
branch would break the modbus bridge.
Normally this should be reported in github issues but issues is not enabled for OpenEMS GitHub - OpenEMS/openems: OpenEMS - Open Source Energy Management System .
Can you share more specific observation you have? Under certain circumstances underlying inversion of control mechanism might detect cyclic dependency and hold component from being activated. Other situation could be a deadlock. In case of a cyclic dependency appropriate log statement should be produced.
From what I understand you do not need access to cycle itself, but rather its time, am I right? If so, then you could try to obtain configured value by accessing ConfigurationAdmin
service and its methods.
Thank you for the reply!
I also think it could be a deadlock, but not sure where.
From what I understand you do not need access to cycle itself, but rather its time, am I right? If so, then you could try to obtain configured value by accessing ConfigurationAdmin service and its methods.
Yes, only the core cycle time value is needed and thank you for the suggestion I have turned to ConfigurationAdmin
and made the PR here
OpenEMS:develop
← girasolenergy:feat/modbus-bridge-skipcycle-highlevel
opened 07:35AM - 11 Apr 24 UTC
Related PR https://github.com/OpenEMS/openems/pull/2569
OpenEMS's core cycle … time is usually 1 second, but some modbus devices can be very slow. It's possible to lower the core cycle time but the whole system is slowed down.
The new configuable paraemter `intervalBetweenAccesses` can be configured to slow down the modbus bridge's access. Specifically, it defines the minimum time (in milliseconds) between 2 modbus accesses, which normally equals to the core cycle time (usually 1000ms).
`intervalBetweenAccesses` is aligned to and calculated from the core cycle time. It's set to be 0 by default and any value between 0 and core cycle time will not affect the original modbus bridge logic. The right amount of core cycles to be skipped will be calculated and applied when `intervalBetweenAccesses` is set to be longer than core cycle time.
Note that the real interval may be longer than configured due to the round off of core cycle time. For example, we set `intervalBetweenAccesses` to 1.5 seconds but core time is 1 second and in this case the final interval is 2 seconds.
1 Like