Category Archives: Allgemein

Clojure connected to WinCC OA…

Because Clojure is a JVM language, oa4j can be used to connect to WinCC Open Architecture.

(def manager (new JManager))

(defn callback [values]
  (let [v (reduce #(+ %1 %2) (map #(.getValueObject %) values))];
    (dpSet :ExampleDP_Trend1. v)))

(defn -main [& args]
  (.init manager (into-array args))
  (.start manager)
  (dpSet {:ExampleDP_Arg1. 2.0 :ExampleDP_Arg2. 3.0})
  (println (clojure.string/join "," 
    (dpGet [:ExampleDP_Arg1. :ExampleDP_Arg2.])))
  (let [c (dpConnect [:ExampleDP_Arg1. :ExampleDP_Arg2.] callback)]
    (Thread/sleep 180000)
    (.disconnect c))
  (.stop manager))

Full example can be found here.

Matrix Multiplication in Clojure…

Clojure code for matrix multiplication (source: Rosetta Code) … short & smart…

(def mmul (fn [a b]
  (let [nested-for (fn [f x y] (map (fn [a] (map (fn [b] (f a b)) y)) x))
        transpose (fn [m] (apply map vector m))]
    (nested-for (fn [x y] (reduce + (map * x y))) a (transpose b)))))

(def ma [[1 2 3 4]
         [4 3 2 1]])

(def mb [[1]

(defn -main [& args]
  (println (mmul ma mb)))

Siemens IoT2000 and WinCC OA….

Got an IoT2040 from Siemens. It is Arduino compatible and runs on Yocto Linux. ETM managed to compile the SCADA System WinCC Open Architecture on it, additionally we used a MQTT server (mosquitto), Node-Red with MQTT, and a MQTT Driver for WinCC OA written in Java… runs well. Just connected a simple LED and a Button with Node-Red, those can now be controlled by WinCC OA. Because WinCC OA runs on it, it can be used to connect a wide range of different devices (a lot of drivers are available for WinCC OA).

Perfect as an Edge device to collect data from the field… Industrial IoT with Siemens!

Observing WinCC OA Logs with Elasticsearch and Logstash…

With Logstash we can collect the logs of WinCC OA systems and write it to Elasticsearch. Multiple WinCC OA system’s can be observed with a central log database…

With Kibana the logs can be easily discovered – I now see errors what i haven’t seen before in my system…

In parallel the log messages are written to Apache Kafka. With Apache Spark we can now observe the log streams and detect anomalies… a very simple observation could be to just simple count the amount of log messages per timeframe …


WinCC OA logstash configuration file: winccoa-logstash-conf