OEE-simulators Introduction
Tags: iot, cumulocity, microservices, json
Published: 2023-04-26 14:11:55

---
title: OEE-simulators Introduction
published: true
date: 2023-04-18 16:24:39 UTC
tags: IoT, Cumulocity, microservices, json
canonical_url: https://tech.forums.softwareag.com/t/oee-simulators-introduction/277727
---

 

## Introduction OEE-simulators microservice

[![image](https://global.discourse-cdn.com/techcommunity/optimized/3X/b/e/be806138f6c14ec63b903178a54674a20de8de9e_2_690x364.png)](https://global.discourse-cdn.com/techcommunity/original/3X/b/e/be806138f6c14ec63b903178a54674a20de8de9e.png "image")

The Cumulocity IoT OEE application is a powerful tool for measuring the efficiency, effectiveness, and performance of production processes. By breaking down processes into the three components of Availability, Performance, and Quality, the OEE application allows users to identify and measure problems and provides a standard method of benchmarking progress to optimize production processes.  
To make it even easier for users to get started with the OEE application, the **[OEE-simulators](https://github.com/SoftwareAG/oee-simulators)** microservice provides a [collection of simulators](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/simulators.md) that can be used to automatically create preconfigured devices and start sending data of events and measurements to the OEE application. These simulators are designed to simulate commonly seen machine types, making it easier to calculate OEE based on configuration profiles that can be set up in the OEE app. The OEE-simulators are a powerful tool that can help users to save time and resources and get started with the Cumulocity IoT OEE app quickly and easily.

The OEE-simulators microservice has notable features that make it attractive and worth giving a try:

1. Configuration in JSON, which eliminates the need to write code.
2. Automatic creation of simulators and oee-profiles and data transmission between them.
3. Identification of simulators and oee- profiles through a configurable `externalId`.
4. Option to disable devices, preventing them from sending any events or measurements.
5. Written in Python, allowing for easy modification and further development.
6. Simulators that operate based on their assigned shift and random status probabilities.

## Description OEE-Simulators

**OEE-simulators** offers two [main](https://github.com/SoftwareAG/oee-simulators/tree/main/simulators/main) features:

- The **[oee-simulators microservice](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/main/simulator.py)** generates simulators that send data to the OEE application and produces OEE profiles, revealing the OEE calculation results. The data is sent periodically based on the pre-defined frequency and also on shiftplan that the simulators are assigned to.
- The **[profile generator](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/main/profile_generator.py)** creates/deletes OEE calculation profiles from the command line. It is also used as a support script in the main script simulator.py.

There are [extra](https://github.com/SoftwareAG/oee-simulators/tree/main/simulators/extras) features that support the use of simulators and OEE application:

- The **[export profile data](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/extras/ExportProfileData.py)** exports Measurements or/and Alarms from OEE profiles into json data files.
- The **[import data](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/extras/ImportData.py)** uploads Measurements or/and Alarms from json data files to OEE profiles. The sample json data files in [export data](https://github.com/SoftwareAG/oee-simulators/tree/main/simulators/extras/export_data) directory can be used to test the import script.

## Pre-requisite

- Having a Cumulocity tenant with OEE application fully installed ([oee-bundle](https://github.softwareag.com/IOTA/oee-microservices), [apama-oeeapp](https://github.softwareag.com/IOTA/oee-apama), [oee-ui](https://github.softwareag.com/IOTA/oee-ui/actions)) and full administration right to work with inventory, alarms, measurements, events, identity, oee configuration (refer to [cumulocity.json](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/cumulocity.json) for more details on required roles).
- In order to use the OEE-simulators:
  - Prepare microservice zip package:
     - The repository can be cloned and built manually by following the instruction in README.md at section [build-the-docker-image](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/README.md#build-the-docker-image).
     - **Or** download the [release package](https://github.com/SoftwareAG/oee-simulators/releases) from Github release section.
  - Upload the zip package to the Cumulocity microservice section and subscribe to it. It takes a bit of time for all simulators to generate data.

## How to create a simulator

If you are working with simulators and testing software or applications, you may want to create your own sample definitions instead of relying on the ones provided in the repository. This can help you tailor your simulations to specific use cases or scenarios and ensure that they accurately reflect the behavior of the system you are testing.

### 1. Create simulator

There are two main files that must be created/modified in order to establish a simulator:

- [simulator.json](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/main/simulator.json): this json file provides definition for the simulator. The creation of the simulator definition is explained in the [README.md](https://github.com/SoftwareAG/oee-simulators/tree/main/simulators#simulator-microservice) inside the simulators directory.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1nhd6bfkpambk07tfepq.png)


- [profile template](https://github.com/SoftwareAG/oee-simulators/tree/main/simulators/main/profile_templates): This template file is the pre-defined definition for oee profile so that the script can generate oee profiles which connect to the appropriate simulator.

There are a couple of considerations to take into account:

- If you are not familiar with the template creation of oee profile, only copy the sample template and change the `name` field of the oee profile. Any other modifications should be conducted carefully or the oee profile may not work properly.
- The profile template file’s name must be set as the simulator’s **id** definition in simulator.json (for example: sim\_001) and add the “\_profile.template” part to it (sim\_001\_profile.template).
- The template file must be put inside the profile\_templates directory which locates inside the main directory.

There is a feature to set up the shift for the simulators called shiftplan. It can be done by defining shift information in [shiftplans.json](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/main/shiftplans.json). The instruction on defining the shiftplan is written in [README.md](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/README.md) inside simulators directory. After having the shiftplan, the locationId field can be added to the definition of the simulator that follows the shift.

### 2. Check the availability of simulators and oee-profiles

- After running the oee-simulators microservice, wait a bit for it to generate simulators and data for them.

- Open `Device management` application in the Cumulocity platform, click the `Devices` tab on the right-hand side and click the `All devices` option. The simulators which are created by the oee-simulators microservice can be seen here.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a7gl1mlcqvkwza5kjjty.png)
- Now choose any simulator, i.e `Normal #1`, to open the device-info window and click `Child devices`. The oee-profile of the chosen simulator is shown here, i.e `Simulator Normal #1 - 1[OEE calculation profile]`.  
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lm01j9m4c4xr0ipnuq3j.png)
### 3. Check the function of simulators and oee-profiles

- For the simulators, click any simulator and check the `Events` tab. You can see some events appeared like `Availability`, `Piece_Produced`, etc.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64eu78ihhykn591shh7z.png)

- For the oee-profiles, click an oee-profile inside a simulator and check the `Measurements` tab. You can see the graphs such as `Actual production amount`, `Actual production time`, etc.  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2c2m2i3hkrb2hlnd98of.png)


**Notice:** Sometimes, it takes about 1-2 hours so that all simulators can generate events and measurements (maybe longer due to shiftplan).

## Export and import data of oee-profiles

Exporting and importing alarms and measurements data from oee-profiles is crucial for several reasons:

- First, it allows users to back up their data and restore it if necessary, ensuring data continuity and reliability.
- Second, it enables easy data sharing between different applications, systems, or organizations, facilitating collaboration and analysis.
- Finally, exporting and importing data from the Cumulocity platform can help users comply with regulations, audits, and data governance policies, ensuring data privacy, security, and transparency.

Therefore, the scripts [ExportProfileData.py](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/extras/ExportProfileData.py) and [ImportData.py](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/extras/ImportData.py) in `extras` directory are created to solve the issues from these reasons. The manual for the scripts can be found in [README.md](https://github.com/SoftwareAG/oee-simulators/blob/main/simulators/extras/README.md) inside the directory.

There are notices when using these scripts:

- Inside extras, the directory is an `export_data` directory that stores the JSON data files of the simulators. The name of the files follows the external Id of the simulator.
- The export and import script will store and take the data from files in this directory so users should copy the old data files first before running the export script to avoid the loss of any important data.

[Read full topic](https://tech.forums.softwareag.com/t/oee-simulators-introduction/277727/1)