<div align="center">
<img src="images/logo.png" alt="Logo">

Kongsberg Simulator
==============
</div>

The Kongsberg Simulator is a REST API designed to generate generic data for a WITSML server using ETP 1.2, enabling the simulation of WITSML 2.1 data.

## Table of Contents
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)

## Installation
There are no installation steps required. To run the simulator, simply double-click the .exe file. This will open a shell that hosts the Kongsberg Simulator API.

## Configuration
The simulator uses Kestrel to host the API. By default, the API listens on port 5000, but you can change this and other settings in an appsettings.json file. 
Simply create a file named appsettings.json and place it in the same directory as the .exe file. 
Add the following settings to the file, adjusting the URL as needed:
```json
{
  "Kestrel": {
    "Endpoints": {
      "MyHttpEndpoint": {
        "Url": "http://+:8080"
      }
    }
  }
}
```
For additional Kestrel settings, including SSL configuration, refer to this guide [here](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel/endpoints?view=aspnetcore-9.0)

## Usage
The Kongsberg Simulator includes a Swagger UI for interacting with the API. 


<img src="images/restApiSwager.png" alt="Logo">

### Controllers Explained
* Channels: This controller allows you to create, read, update, and delete channels. By default, a list of channels is already available for data simulation.
* ChannelSets: This controller enables you to create, read, update, and delete channel sets. A list of channel sets is pre-created for data simulation.
* Job: This controller lets you create, read, update, delete, start, stop, and view the current job status. No jobs are created by default.

Any configuration updates, such as modifying a job or channel, or creating a new job or channel set, will be saved in a state file. This file is located in the Roaming directory of the user running the Simulator: C:\Users\\<user\>\AppData\Roaming\WitsmlSimulator\State.bin. The state file persists through Simulator restarts and upgrades. To revert to default settings, simply delete this file.

<span style="color:Orange">Warning: Deleting this file will remove all changes made to the Simulator configuration.</span>

### How to use the API
When running the API for the first time, you need to create a job that includes details on how to connect to a WITSML server. This job will utilize all the configurations for the WITSML objects to simulate data to a server under one or more wells.

Once you've created the job, you can start it by sending a POST request to \{id\}/start. The simulator will then begin sending data to the server. To check the current status of the job, simply send a GET request to the \{id\}/status endpoint.

To stop the job, simply send a POST request to the \{id\}/stop endpoint.