Giter VIP home page Giter VIP logo

climate_chamber_control_lib's Introduction

climate chamber lib

This project provides a library to control a Weisstechnik LabEvent climate chamber via an API interface. It allows to set the humidity and temperature, receive error messages and warnings and acknowledge them. The current temperature and humidity can be received by a callback function.

Continuous integration

We maintain the compatibility with different compilers and operating systems by compiling the libary on different systems. The current status of the continuous integration can be found here:

OS Status
Windows Latest Windows latest
Mac OS Latest MAC OS latest
Ubuntu Latest Ubuntu Latest

1. Installation

Download the latest release on GitHub or clone the repository and compile it by your self.

1.1 Manually compile the library

1.2 Required packages

  • CMAKE
  • make (Linux)
  • Ninja (Windows)
  • MinGW (Windows)

On Linux

git clone [email protected]:FlorianFrank/climate_chamber_control_lib.git
git submodule update --init --recursive
./compile.sh

On Windows

git clone [email protected]:FlorianFrank/climate_chamber_control_lib.git
git submodule update --init --recursive
./compile.ps1

By running compile.sh or compile.ps the library, a test application as well as the underlying abstraction library common_tools_lib providing basic functionality like logging or sockets is build. Finally, the library, headers, and the test application is installed in the bin folder and has the following structure:

๐Ÿ“ฆ project
โ”‚     
โ””โ”€โ”€โ”€ ๐Ÿ“‚ bin
โ”‚   โ””โ”€โ”€โ”€ ๐Ÿ“‚ lib
โ”‚   โ”‚    โ”‚  ๐Ÿ“œ climate_chamber_lib
โ”‚   โ”‚    โ”‚  ๐Ÿ“œ common_tools_lib
โ”‚   โ”‚    โ”‚  ๐Ÿ“œ py_climate_chamber_lib
โ”‚   โ””โ”€โ”€โ”€ ๐Ÿ“‚ bin
โ”‚   โ”‚     |  ๐Ÿ“œ ClimateChamberTest.exe
โ”‚   โ””โ”€โ”€โ”€ ๐Ÿ“‚ include
โ”‚        |  ๐Ÿ“œ <include files>
โ”‚
โ”‚
โ””โ”€โ”€โ”€ ๐Ÿ“‚ tmp
     โ”‚   ๐Ÿ“œ <temporary files which can be deleted after the build>

2. Run a simple test program

2.1 Using the C++-interface

Link the climate_chamber_lib to your project and include the header file climate_chamber_control.h.

e.g. using CMAKE

project(SampleProject)

add_subproject(instrument_control_lib)

add_executable(SampleProject main.cpp)
target_include_directory(SampleProject PUBLIC climate_chamber_control_lib/include)
target_link_libraries(SampleProject climate_chamber_control)

A sample program on how to use the climate chamber is provided in following code snipped:

#include <ClimateChamberControl.h>

int main() {
    ClimateChamberControl chamber;
    if(!chamber.initialize("<your_ip_address>")) // The standard port to access the climate chamber is 8080
        std::cout << "Error: " << chamber.GetLastError() << std::endl;
        
    chamber.setTargetTemperature(26.5);
    chamber.setTargetHumidity(30.0);
    
    chamber.startMonitorThread(5000);
    
    auto callback = [](float humidity, float temperature) {
        std::cout << "Humidity: " << humidity << " Temperature: " << temperature << std::endl;
    };
    
    chamber.RegisterTemperatureCallback(callback);
    
    chamber.startExecution();
    
    /*** Do some stuff here ***/

    chamber.stopExecution();
    chamber.Deinitialize();

2.1 Using the python-interface

The library can be accessed by a python interface as well. To run the library requires a python version > 3.10. The lib can be installed using pip by executing pip install . in the root directory of this project. You can import it using the following command:

from py_climate_chamber_lib import *

The api itself is identical to the C++ API described in Section 3.

from py_climate_chamber_lib import *

chamber = ClimateChamberControl()

if not chamber.initialize("<your_ip_address>"):
    chamber.get_last_error()

chamber.set_target_temperature(26.5)
chamber.set_target_humidity(30.0)

chamber.start_monitor_thread(5000)

callback = lambda humidity, temperature: print("Humidity: " + str(humidity) + " Temperature: " + str(temperature))

chamber.register_humid_temp_callback(callback)
chamber.start_execution()

# Do some stuff here

chamber.stop_execution()
chamber.deinitialize()

3 API-description (C++-interface)

The api supports following functions:

Method Name Description Return value
bool initialize(ipAddr, port, channel); Establishes a connection to the climate chamber. Returns true if the connection could be established successfully.
bool deInitialize() Closes the connection to the climate chamber. True if command was successful.
bool retrieveClimateChamberStatus() Sends a status request to the climate chamber to get the current temperature and humidity and stores them in the climate chamber object. True if command was successful.
float getCurrentTemperature() Get the temperature retrieved from the last retrieveClimateChamberStatus() call. Last retrieved temperature.
float getCurrentHumidity() Get the humidity retrieved from the last retrieveClimateChamberStatus() call. Last retrieved humidity.
float getTargetTemperature() Returns the target temperature which should finally be reached during a cool down or heat up progress. Target temperature.
float getTargetHumidity() Returns the target humidity which should finally be reached. Target humidity.
bool setTargetTemperature() Sets the target temperature to reach after starting or stopping the chamber. True if command was successful.
bool setTargetHumidity() Sets the target humidity to reach after starting or stopping the chamber. True if command was successful.
bool startExecution() Starts the climate chamber to heat up or cool down to the temperature and humidity adjusted by setTargetHumidity and setTargetTemperature. True if command was successful.
bool stopExecution() Stops the execution of the climate chamber. True if command was successful.
bool startProgram(id) Start a specific program stored on the climate chamber, identified by an id. True if command was successful.
bool stopProgram() Stop a currently running program. True if command was successful.
bool getErrorCode(errCode) Starts the climate chamber to heat up or cool down to the temperature and humidity adjusted by setTargetHumidity and setTargetTemperature. True if command was successful.
bool acknowledgeErrors() Acknowledge all errors stored in the error buffer. True if command was successful.
bool startMonitorThread(int intervalMs) Starts a thread which periodically calls retrieveClimateChamberStatus() to update the current temperature. True if command was successful.
bool registerHumidityTemperatureCallback(callback Function) Registers a callback function which is called everytime the temperature or humidity of the chamber changes. -
bool isRunning() Returns if the chamber is currently running or not. True if cahmber is running, otherwise return False.

4 API-description (Python-interface)

Method Name Description Return value
bool initialize(ipAddr, port, channel); Establishes a connection to the climate chamber. Returns true if the connection could be established successfully.
bool deInitialize() Closes the connection to the climate chamber. True if command was successful.
bool retrieve_climate_chamber_status() Sends a status request to the climate chamber to get the current temperature and humidity and stores them in the climate chamber object. True if command was successful.
float get_current_temperature() Get the temperature retrieved from the last retrieveClimateChamberStatus() call. Last retrieved temperature.
float get_current_humidity() Get the humidity retrieved from the last retrieveClimateChamberStatus() call. Last retrieved humidity.
float get_target_temperature() Returns the target temperature which should finally be reached during a cool down or heat up progress. Target temperature.
float get_target_humidity() Returns the target humidity which should finally be reached. Target humidity.
bool set_target_temperature() Sets the target temperature to reach after starting or stopping the chamber. True if command was successful.
bool set_target_humidity() Sets the target humidity to reach after starting or stopping the chamber. True if command was successful.
bool start_execution() Starts the climate chamber to heat up or cool down to the temperature and humidity adjusted by setTargetHumidity and setTargetTemperature. True if command was successful.
bool stop_execution() Stops the execution of the climate chamber. True if command was successful.
bool start_program(id) Start a specific program stored on the climate chamber, identified by an id. True if command was successful.
bool stop_program() Stop a currently running program. True if command was successful.
bool get_error_code(errCode) Starts the climate chamber to heat up or cool down to the temperature and humidity adjusted by setTargetHumidity and setTargetTemperature. True if command was successful.
bool acknowledge_errors() Acknowledge all errors stored in the error buffer. True if command was successful.
bool start_monitor_thread(int intervalMs) Starts a thread which periodically calls retrieveClimateChamberStatus() to update the current temperature. True if command was successful.
bool register_humid_temp_callback(callback Function) Registers a callback function which is called everytime the temperature or humidity of the chamber changes. -
bool is_running() Returns if the chamber is currently running or not. True if cahmber is running, otherwise return False.

climate_chamber_control_lib's People

Contributors

alexanderbraml avatar derbambus avatar florianfrank avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

climate_chamber_control_lib's Issues

Feature: Add Continous Integration

  • Add Continous Integration building the libaries and sample executables
  • Additionally export the python interface as artifact
  • Add a badge to the README.md

Feature: Improve README.md

Add additional information, e.g. how to checkout the repo, how to build it and give an overview over the most important functions.

Feature: Directly return error codes

Problem:

  • The current two step approach of returning a boolean value of each function and afterwards calling the error makes the code unreadable

Solution:

  • Directly return the error code instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.