An open API service indexing awesome lists of open source software.

https://github.com/yanndr/thermometer

A Temperature Library in C# .net Core
https://github.com/yanndr/thermometer

alert converter csharp dotnet-core grpc temperature thermometer threshold

Last synced: about 1 year ago
JSON representation

A Temperature Library in C# .net Core

Awesome Lists containing this project

README

          

[![Build Status](https://travis-ci.org/yanndr/Thermometer.svg?branch=master)](https://travis-ci.org/yanndr/Thermometer)

# Introduction
This is a C# .net core Temperature/Thermometer Library.

This library allows you to convert temperature units, so far Kelvin, Celsius and Fahrenheit.

There are three thermometers: Basic Thermometer, MultiUnit Thermometer and an AlerterThermometer.

The Alerter Thermometer allows you to set up temperature thresholds to receive an alert when the temperature reaches your chosen threshold.

# Usage

```
var converter = new TemperatureConverter(new ConverterFactory(
new List
{
new CelsiusConverter(),
new FahrenheitConverter()
}));

var alerters = new List
{
new DropAlert("Freezing alert", 0.0m, 0.5m,()=>Console.WriteLine("----Freezing Alert------s")),
new RaiseAlert("Boiling alert", 100, 0.5m,()=>Console.WriteLine("----Boiling Alert----")),
new BidirectionalAlert("Nice temperature alert", 28.0m, 1m,()=>Console.WriteLine("----Other Alert------s"))
};

thermometer = new AlerterThermometer(Unit.Celsius,converter, alerters);
```

In the solution you will find an example console project that shows how to use the library: thermometer-console .

# Prerequistes
```
- .net Core or Docker
```

# Build and Test
Build the solution:
```
> dotnet restore
> dotnet build
```

Run the tests:
```
> dotnet test ./ThermometerLibrary.Tests/ThermometerLibrary.Tests.csproj
```

# Run the examples

Run the example with dotnet:
```
> dotnet run -p ThermometerConsole/ThermometerConsole.csproj
```

Run the server example with dotnet:
```
> dotnet run -p ThermometerSercice/ThermometerService.csproj
```

Run the Temperature updater example to feed the Termomether servie with dotnet:
```
> dotnet run -p TemperatureUpdater/TemperatureUpdater.csproj
```

Run the example with Docker:
```
- build the image:
> docker build -t thermometer-console .
```

- Run the container
```
> docker run -it --rm thermometer-console
```