@@ -76,25 +76,30 @@ public BridgeModbusTcpImpl() {
7676 }
7777
7878 @ Activate
79- private void activate (ComponentContext context , ConfigTcp config ) throws IOException {
79+ private void activate (ComponentContext context , ConfigTcp config ) throws UnknownHostException {
8080 super .activate (context , config .id (), config .alias (), config .enabled (), config .logVerbosity (),
8181 config .invalidateElementsAfterReadErrors ());
8282 this .applyConfig (config );
8383 }
8484
8585 @ Modified
86- private void modified (ComponentContext context , ConfigTcp config ) throws IOException {
86+ private void modified (ComponentContext context , ConfigTcp config ) throws UnknownHostException {
8787 super .modified (context , config .id (), config .alias (), config .enabled (), config .logVerbosity (),
8888 config .invalidateElementsAfterReadErrors ());
8989 this .applyConfig (config );
9090 this .closeModbusConnection ();
9191 }
9292
93- private void applyConfig (ConfigTcp config ) throws IOException {
93+ private void applyConfig (ConfigTcp config ) {
9494 this .setIpAddress (InetAddressUtils .parseOrNull (config .ip ()));
9595 this .port = config .port ();
96- this .coreCycleTime = (int ) (Integer ) this .cm .getConfiguration ("Core.Cycle" ).getProperties ().get ("cycleTime" );
97- this .noSkipIdx = (int )Math .ceil (config .intervalBetweenAccesses () * 1.0 / this .coreCycleTime );
96+ try {
97+ // the default cycleTime is not persisted and won't be returned, only modified cycleTime will!
98+ this .coreCycleTime = (int ) (Integer ) this .cm .getConfiguration ("Core.Cycle" ).getProperties ().get ("cycleTime" );
99+ } catch (Exception e ) {
100+ this .coreCycleTime = 1000 ;
101+ }
102+ this .noSkipIdx = (int )Math .ceil (config .intervalBetweenAccesses () * 1.0 / this .coreCycleTime );
98103 this .noSkipIdx = Math .max (this .noSkipIdx , 1 );
99104 this .logCycle ("applyConfig: cycleTime=" + this .coreCycleTime
100105 + ", interval=" + config .intervalBetweenAccesses ()
0 commit comments