You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2026/05/28 07:29:35 UTC

(streampipes) 01/01: feat: Add segment index to alarm archive config

This is an automated email from the ASF dual-hosted git repository.

dominikriemer pushed a commit to branch enhance-wincc-alarm-archive-config
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 68ffc20488eb27c63c2fac01bce84cbe0caa2350
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Thu May 28 09:29:16 2026 +0200

    feat: Add segment index to alarm archive config
---
 .../FileWatcherConnectorsModuleExport.java         |   6 +-
 .../adapter/WinCCAlarmArchiveAdapter.java          |  73 +++++++-------
 .../WinCCAlarmArchiveAdapterMigrationV1.java       |  65 +++++++++++++
 .../documentation.md                               |   4 +-
 .../strings.en                                     |   2 +
 .../adapter/WinCCAlarmArchiveAdapterTest.java      | 108 +++++++++++++++++++++
 .../WinCCAlarmArchiveAdapterMigrationV1Test.java   |  44 +++++++++
 .../WinCCAlarmArchiveAdapterVersionedConfig.java   |  63 ++++++++++++
 8 files changed, 323 insertions(+), 42 deletions(-)

diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/FileWatcherConnectorsModuleExport.java b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/FileWatcherConnectorsModuleExport.java
index d87c1777d8..44511e8c63 100644
--- a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/FileWatcherConnectorsModuleExport.java
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/FileWatcherConnectorsModuleExport.java
@@ -23,8 +23,8 @@ import org.apache.streampipes.extensions.api.declarer.IExtensionModuleExport;
 import org.apache.streampipes.extensions.api.migration.IModelMigrator;
 import org.apache.streampipes.extensions.api.pe.IStreamPipesPipelineElement;
 import org.apache.streampipes.extensions.connectors.filewatcher.adapter.WinCCAlarmArchiveAdapter;
+import org.apache.streampipes.extensions.connectors.filewatcher.migration.WinCCAlarmArchiveAdapterMigrationV1;
 
-import java.util.Collections;
 import java.util.List;
 
 public class FileWatcherConnectorsModuleExport implements IExtensionModuleExport {
@@ -36,11 +36,11 @@ public class FileWatcherConnectorsModuleExport implements IExtensionModuleExport
 
   @Override
   public List<IStreamPipesPipelineElement<?>> pipelineElements() {
-    return Collections.emptyList();
+    return List.of();
   }
 
   @Override
   public List<IModelMigrator<?, ?>> migrators() {
-    return Collections.emptyList();
+    return List.of(new WinCCAlarmArchiveAdapterMigrationV1());
   }
 }
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapter.java b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapter.java
index 6a6547b262..b6510c021d 100644
--- a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapter.java
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapter.java
@@ -65,6 +65,7 @@ public class WinCCAlarmArchiveAdapter implements StreamPipesAdapter, IPullAdapte
   private static final String ARCHIVE_BASE_NAME = "archive-base-name";
   private static final String SEGMENTED_CIRCULAR_LOG_ENABLED = "segmented-circular-log-enabled";
   private static final String ARCHIVE_SEGMENT_COUNT = "archive-segment-count";
+  public static final String ARCHIVE_SEGMENT_START_INDEX = "archive-segment-start-index";
   private static final String POLL_INTERVAL_SECONDS = "poll-interval-seconds";
   private static final String INTER_EVENT_DELAY_MS = "inter-event-delay-ms";
   private static final String TIMEZONE_ID = "timezone-id";
@@ -82,49 +83,38 @@ public class WinCCAlarmArchiveAdapter implements StreamPipesAdapter, IPullAdapte
   @Override
   public IAdapterConfiguration declareConfig() {
     return AdapterConfigurationBuilder
-        .create(ID, 0, WinCCAlarmArchiveAdapter::new)
+        .create(ID, 1, WinCCAlarmArchiveAdapter::new)
         .withAssets(ExtensionAssetType.DOCUMENTATION, ExtensionAssetType.ICON)
         .withLocales(Locales.EN)
-        .requiredTextParameter(Labels.from(
-            DIRECTORY_PATH,
-            "Archive directory",
-            "Absolute path to the WinCC archive directory that contains the exported alarm CSV files."
+        .requiredTextParameter(Labels.withId(
+            DIRECTORY_PATH
         ))
-        .requiredTextParameter(Labels.from(
-            ARCHIVE_BASE_NAME,
-            "Archive base name",
-            "Base file name of the WinCC alarm archive, for example Meldungsarchiv."
+        .requiredTextParameter(Labels.withId(
+            ARCHIVE_BASE_NAME
         ))
         .requiredSingleValueSelection(
-            Labels.from(
-                SEGMENTED_CIRCULAR_LOG_ENABLED,
-                "Segmented circular log",
-                "Whether WinCC writes the alarm archive as a segmented circular log with rotating CSV segments."
+            Labels.withId(
+                SEGMENTED_CIRCULAR_LOG_ENABLED
             ),
             Options.from(
                 new Tuple2<>("Enabled", SEGMENTED_CIRCULAR_LOG_ON),
                 new Tuple2<>("Disabled", SEGMENTED_CIRCULAR_LOG_OFF)
             )
         )
-        .requiredIntegerParameter(Labels.from(
-            ARCHIVE_SEGMENT_COUNT,
-            "Segment count",
-            "Number of archive segments in segmented circular log mode. Ignored when the segmented circular log is disabled."
+        .requiredIntegerParameter(Labels.withId(
+            ARCHIVE_SEGMENT_COUNT
         ))
-        .requiredIntegerParameter(Labels.from(
-            POLL_INTERVAL_SECONDS,
-            "Polling interval (seconds)",
-            "How often the WinCC archive files should be scanned for new alarm entries."
+        .requiredIntegerParameter(Labels.withId(
+            ARCHIVE_SEGMENT_START_INDEX
+        ), 0)
+        .requiredIntegerParameter(Labels.withId(
+            POLL_INTERVAL_SECONDS
         ))
-        .requiredIntegerParameter(Labels.from(
-            INTER_EVENT_DELAY_MS,
-            "Inter-event delay (ms)",
-            "Delay between replayed alarm events in milliseconds. Use 0 to disable throttling."
+        .requiredIntegerParameter(Labels.withId(
+            INTER_EVENT_DELAY_MS
         ), 0)
-        .requiredTextParameter(Labels.from(
-            TIMEZONE_ID,
-            "Timezone",
-            "IANA timezone used when WinCC TimeString must be converted, for example Europe/Berlin."
+        .requiredTextParameter(Labels.withId(
+            TIMEZONE_ID
         ), ZoneId.systemDefault().getId())
         .buildConfiguration();
   }
@@ -214,16 +204,20 @@ public class WinCCAlarmArchiveAdapter implements StreamPipesAdapter, IPullAdapte
     var segmentedCircularLogMode =
         staticPropertyExtractor.selectedSingleValueInternalName(SEGMENTED_CIRCULAR_LOG_ENABLED, String.class);
     var segmentCount = staticPropertyExtractor.singleValueParameter(ARCHIVE_SEGMENT_COUNT, Integer.class);
+    var segmentStartIndex = staticPropertyExtractor.singleValueParameter(ARCHIVE_SEGMENT_START_INDEX, Integer.class);
     var interval = staticPropertyExtractor.singleValueParameter(POLL_INTERVAL_SECONDS, Integer.class);
     var interEventDelayMs = staticPropertyExtractor.singleValueParameter(INTER_EVENT_DELAY_MS, Integer.class);
     var timeZone = parseTimeZone(staticPropertyExtractor.singleValueParameter(TIMEZONE_ID, String.class));
     if (interEventDelayMs < 0) {
       throw new AdapterException("Inter-event delay must be greater than or equal to 0.");
     }
+    if (segmentStartIndex < 0) {
+      throw new AdapterException("Segment start index must be greater than or equal to 0.");
+    }
 
     Pattern filePattern = SEGMENTED_CIRCULAR_LOG_ON.equals(segmentedCircularLogMode)
-        ? buildSegmentPattern(baseName, segmentCount)
-        : buildSingleSegmentPattern(baseName);
+        ? buildSegmentPattern(baseName, segmentStartIndex, segmentCount)
+        : buildSingleSegmentPattern(baseName, segmentStartIndex);
 
     return new FileWatcherConfig(
         directory,
@@ -253,25 +247,28 @@ public class WinCCAlarmArchiveAdapter implements StreamPipesAdapter, IPullAdapte
     return trimmedBaseName;
   }
 
-  private Pattern buildSingleSegmentPattern(String baseName) {
-    return Pattern.compile(Pattern.quote(baseName) + "1\\.csv", Pattern.CASE_INSENSITIVE);
+  private Pattern buildSingleSegmentPattern(String baseName, int segmentStartIndex) {
+    return Pattern.compile(Pattern.quote(baseName) + segmentStartIndex + "\\.csv", Pattern.CASE_INSENSITIVE);
   }
 
-  private Pattern buildSegmentPattern(String baseName, int segmentCount) throws AdapterException {
+  private Pattern buildSegmentPattern(String baseName,
+                                      int segmentStartIndex,
+                                      int segmentCount) throws AdapterException {
     if (segmentCount < 1) {
       throw new AdapterException("Segment count must be at least 1 when the segmented circular log is enabled.");
     }
 
     return Pattern.compile(
-        Pattern.quote(baseName) + "(" + buildAllowedSegments(segmentCount) + ")\\.csv",
+        Pattern.quote(baseName) + "(" + buildAllowedSegments(segmentStartIndex, segmentCount) + ")\\.csv",
         Pattern.CASE_INSENSITIVE
     );
   }
 
-  private String buildAllowedSegments(int segmentCount) {
+  private String buildAllowedSegments(int segmentStartIndex, int segmentCount) {
     StringBuilder builder = new StringBuilder();
-    for (int i = 1; i <= segmentCount; i++) {
-      if (i > 1) {
+    int segmentEndExclusive = segmentStartIndex + segmentCount;
+    for (int i = segmentStartIndex; i < segmentEndExclusive; i++) {
+      if (i > segmentStartIndex) {
         builder.append("|");
       }
       builder.append(i);
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/WinCCAlarmArchiveAdapterMigrationV1.java b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/WinCCAlarmArchiveAdapterMigrationV1.java
new file mode 100644
index 0000000000..d44ed25e77
--- /dev/null
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/WinCCAlarmArchiveAdapterMigrationV1.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.extensions.connectors.filewatcher.migration;
+
+import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor;
+import org.apache.streampipes.extensions.api.migration.IAdapterMigrator;
+import org.apache.streampipes.extensions.connectors.filewatcher.adapter.WinCCAlarmArchiveAdapter;
+import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.model.extensions.svcdiscovery.SpServiceTagPrefix;
+import org.apache.streampipes.model.migration.MigrationResult;
+import org.apache.streampipes.model.migration.ModelMigratorConfig;
+import org.apache.streampipes.model.staticproperty.FreeTextStaticProperty;
+import org.apache.streampipes.sdk.StaticProperties;
+import org.apache.streampipes.sdk.helpers.Labels;
+
+public class WinCCAlarmArchiveAdapterMigrationV1 implements IAdapterMigrator {
+
+  @Override
+  public ModelMigratorConfig config() {
+    return new ModelMigratorConfig(
+        WinCCAlarmArchiveAdapter.ID,
+        SpServiceTagPrefix.ADAPTER,
+        0,
+        1
+    );
+  }
+
+  @Override
+  public MigrationResult<AdapterDescription> migrate(AdapterDescription element,
+                                                     IStaticPropertyExtractor extractor) throws RuntimeException {
+    element.getConfig().add(
+        4,
+        makeFreeTextStaticProperty()
+    );
+
+    return MigrationResult.success(element);
+  }
+
+  private FreeTextStaticProperty makeFreeTextStaticProperty() {
+    var sp = StaticProperties.integerFreeTextProperty(
+        Labels.withId(
+            WinCCAlarmArchiveAdapter.ARCHIVE_SEGMENT_START_INDEX
+        ),
+        0
+    );
+    sp.setValue("0");
+    return sp;
+  }
+}
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/documentation.md b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/documentation.md
index b84b5039bd..b83b548e03 100644
--- a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/documentation.md
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/documentation.md
@@ -29,13 +29,15 @@ Configuration is Siemens-specific:
 - archive base name
 - segmented circular log enabled or disabled
 - segment count in segmented circular log mode
+- segment start index
 - polling interval
 - optional delay between replayed events in milliseconds
 - timezone used when WinCC `TimeString` must be converted to Unix time
 
 The adapter assumes the WinCC alarm CSV layout with a header row and semicolon-separated columns.
 The configured base name should not include the segment number or file suffix. For example, use `Meldungsarchiv`
-to match `Meldungsarchiv1.csv` or `Meldungsarchiv1.csv` to `MeldungsarchivN.csv`.
+to match `Meldungsarchiv1.csv` or `Meldungsarchiv0.csv` to `MeldungsarchivN.csv`, depending on the configured
+segment start index.
 
 In segmented circular log mode the adapter treats reused file names as new generations by fingerprinting file content,
 so a segment like `Meldungsarchiv1.csv` can be consumed again after WinCC rotates the archive.
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/strings.en b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/strings.en
index 9f8866007a..116d327a73 100644
--- a/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/strings.en
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/main/resources/org.apache.streampipes.connectors.wincc.alarm.archive/strings.en
@@ -22,6 +22,8 @@ segmented-circular-log-enabled.title=Segmented circular log
 segmented-circular-log-enabled.description=Whether the WinCC alarm archive uses rotating file segments
 archive-segment-count.title=Segment count
 archive-segment-count.description=Number of archive segments in segmented circular log mode
+archive-segment-start-index.title=Segment start index
+archive-segment-start-index.description=First segment index used in the WinCC file names, for example 0 or 1
 poll-interval-seconds.title=Polling interval (seconds)
 poll-interval-seconds.description=Interval used to scan the alarm archive files for new entries
 inter-event-delay-ms.title=Inter-event delay (ms)
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapterTest.java b/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapterTest.java
new file mode 100644
index 0000000000..23fc0f5568
--- /dev/null
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/adapter/WinCCAlarmArchiveAdapterTest.java
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.extensions.connectors.filewatcher.adapter;
+
+import org.apache.streampipes.extensions.api.extractor.IAdapterParameterExtractor;
+import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor;
+import org.apache.streampipes.extensions.connectors.filewatcher.model.FileWatcherConfig;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.nio.file.Path;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class WinCCAlarmArchiveAdapterTest {
+
+  @TempDir
+  Path tempDir;
+
+  @Test
+  void shouldUseConfiguredStartIndexForSegmentedPattern() throws Exception {
+    var config = invokeToConfig("segmented-circular-log-on", 3, 0);
+
+    assertTrue(config.filePattern().matcher("Meldungsarchiv0.csv").matches());
+    assertTrue(config.filePattern().matcher("Meldungsarchiv2.csv").matches());
+    assertFalse(config.filePattern().matcher("Meldungsarchiv3.csv").matches());
+  }
+
+  @Test
+  void shouldUseConfiguredStartIndexForSingleFilePattern() throws Exception {
+    var config = invokeToConfig("segmented-circular-log-off", 3, 0);
+
+    assertTrue(config.filePattern().matcher("Meldungsarchiv0.csv").matches());
+    assertFalse(config.filePattern().matcher("Meldungsarchiv1.csv").matches());
+  }
+
+  private FileWatcherConfig invokeToConfig(String segmentedCircularLogMode,
+                                           int segmentCount,
+                                           int startIndex) throws Exception {
+    WinCCAlarmArchiveAdapter adapter = new WinCCAlarmArchiveAdapter();
+    Map<String, Object> values = Map.of(
+        "directory-path", tempDir.toString(),
+        "archive-base-name", "Meldungsarchiv",
+        "archive-segment-count", segmentCount,
+        "archive-segment-start-index", startIndex,
+        "poll-interval-seconds", 1,
+        "inter-event-delay-ms", 0,
+        "timezone-id", "UTC"
+    );
+
+    IStaticPropertyExtractor staticPropertyExtractor = (IStaticPropertyExtractor) Proxy.newProxyInstance(
+        IStaticPropertyExtractor.class.getClassLoader(),
+        new Class<?>[]{IStaticPropertyExtractor.class},
+        (proxy, method, args) -> {
+          if ("singleValueParameter".equals(method.getName())) {
+            return values.get(args[0]);
+          }
+          if ("selectedSingleValueInternalName".equals(method.getName())) {
+            return segmentedCircularLogMode;
+          }
+          throw new UnsupportedOperationException("Unexpected extractor method: " + method.getName());
+        }
+    );
+
+    IAdapterParameterExtractor extractor = (IAdapterParameterExtractor) Proxy.newProxyInstance(
+        IAdapterParameterExtractor.class.getClassLoader(),
+        new Class<?>[]{IAdapterParameterExtractor.class},
+        (proxy, method, args) -> {
+          if ("getStaticPropertyExtractor".equals(method.getName())) {
+            return staticPropertyExtractor;
+          }
+          if ("getAdapterDescription".equals(method.getName())) {
+            return null;
+          }
+          throw new UnsupportedOperationException("Unexpected adapter extractor method: " + method.getName());
+        }
+    );
+
+    Method toConfigMethod = WinCCAlarmArchiveAdapter.class.getDeclaredMethod(
+        "toConfig",
+        IAdapterParameterExtractor.class
+    );
+    toConfigMethod.setAccessible(true);
+
+    return (FileWatcherConfig) toConfigMethod.invoke(adapter, extractor);
+  }
+}
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/WinCCAlarmArchiveAdapterMigrationV1Test.java b/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/WinCCAlarmArchiveAdapterMigrationV1Test.java
new file mode 100644
index 0000000000..8544d9c3d7
--- /dev/null
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/WinCCAlarmArchiveAdapterMigrationV1Test.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.extensions.connectors.filewatcher.migration;
+
+import org.apache.streampipes.extensions.api.extractor.IStaticPropertyExtractor;
+import org.apache.streampipes.extensions.connectors.filewatcher.adapter.WinCCAlarmArchiveAdapter;
+import org.apache.streampipes.extensions.connectors.filewatcher.migration.config.WinCCAlarmArchiveAdapterVersionedConfig;
+import org.apache.streampipes.model.staticproperty.FreeTextStaticProperty;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class WinCCAlarmArchiveAdapterMigrationV1Test {
+
+  @Test
+  void shouldInsertSegmentStartIndexWithDefaultValue() {
+    var migration = new WinCCAlarmArchiveAdapterMigrationV1();
+    var adapterDescription = WinCCAlarmArchiveAdapterVersionedConfig.getWinCCAlarmArchiveAdapterDescriptionV0();
+
+    var migrated = migration.migrate(adapterDescription, (IStaticPropertyExtractor) null).element();
+
+    assertEquals(8, migrated.getConfig().size());
+    var startIndexProperty = (FreeTextStaticProperty) migrated.getConfig().get(4);
+    assertEquals(WinCCAlarmArchiveAdapter.ARCHIVE_SEGMENT_START_INDEX, startIndexProperty.getInternalName());
+    assertEquals("1", startIndexProperty.getValue());
+  }
+}
diff --git a/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/config/WinCCAlarmArchiveAdapterVersionedConfig.java b/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/config/WinCCAlarmArchiveAdapterVersionedConfig.java
new file mode 100644
index 0000000000..31fda484a8
--- /dev/null
+++ b/streampipes-extensions/streampipes-connectors-filewatcher/src/test/java/org/apache/streampipes/extensions/connectors/filewatcher/migration/config/WinCCAlarmArchiveAdapterVersionedConfig.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.extensions.connectors.filewatcher.migration.config;
+
+import org.apache.streampipes.extensions.connectors.filewatcher.adapter.WinCCAlarmArchiveAdapter;
+import org.apache.streampipes.model.connect.adapter.AdapterDescription;
+import org.apache.streampipes.model.extensions.ExtensionAssetType;
+import org.apache.streampipes.sdk.builder.adapter.AdapterConfigurationBuilder;
+import org.apache.streampipes.sdk.helpers.Labels;
+import org.apache.streampipes.sdk.helpers.Locales;
+import org.apache.streampipes.sdk.helpers.Options;
+import org.apache.streampipes.sdk.helpers.Tuple2;
+
+public class WinCCAlarmArchiveAdapterVersionedConfig {
+
+  private static final String DIRECTORY_PATH = "directory-path";
+  private static final String ARCHIVE_BASE_NAME = "archive-base-name";
+  private static final String SEGMENTED_CIRCULAR_LOG_ENABLED = "segmented-circular-log-enabled";
+  private static final String ARCHIVE_SEGMENT_COUNT = "archive-segment-count";
+  private static final String POLL_INTERVAL_SECONDS = "poll-interval-seconds";
+  private static final String INTER_EVENT_DELAY_MS = "inter-event-delay-ms";
+  private static final String TIMEZONE_ID = "timezone-id";
+  private static final String SEGMENTED_CIRCULAR_LOG_ON = "segmented-circular-log-on";
+  private static final String SEGMENTED_CIRCULAR_LOG_OFF = "segmented-circular-log-off";
+
+  public static AdapterDescription getWinCCAlarmArchiveAdapterDescriptionV0() {
+    return AdapterConfigurationBuilder
+        .create(WinCCAlarmArchiveAdapter.ID, 0, WinCCAlarmArchiveAdapter::new)
+        .withAssets(ExtensionAssetType.DOCUMENTATION, ExtensionAssetType.ICON)
+        .withLocales(Locales.EN)
+        .requiredTextParameter(Labels.withId(DIRECTORY_PATH))
+        .requiredTextParameter(Labels.withId(ARCHIVE_BASE_NAME))
+        .requiredSingleValueSelection(
+            Labels.withId(SEGMENTED_CIRCULAR_LOG_ENABLED),
+            Options.from(
+                new Tuple2<>("Enabled", SEGMENTED_CIRCULAR_LOG_ON),
+                new Tuple2<>("Disabled", SEGMENTED_CIRCULAR_LOG_OFF)
+            )
+        )
+        .requiredIntegerParameter(Labels.withId(ARCHIVE_SEGMENT_COUNT))
+        .requiredIntegerParameter(Labels.withId(POLL_INTERVAL_SECONDS))
+        .requiredIntegerParameter(Labels.withId(INTER_EVENT_DELAY_MS), 0)
+        .requiredTextParameter(Labels.withId(TIMEZONE_ID), "UTC")
+        .buildConfiguration()
+        .getAdapterDescription();
+  }
+}