PLC API Dokumentáció

Üdvözöljük a PLC API-ban!

Ez az API lehetővé teszi a PLC (Programmable Logic Controller) adatok olvasását és kezelését HTTP kéréseken keresztül. Az API Docker konténerben fut és REST végpontokat biztosít a motorvédők állapotának lekérdezéséhez, próba bitek kapcsolgatásához és receptek kezeléséhez.

API Végpontok

🏥 Állapot Ellenőrzés

GET
/health

Az API állapotának ellenőrzése.

Példa válasz:
{"status": "healthy", "timestamp": "2024-01-27T10:30:00"}

⚡ Motorvédők Olvasása

GET
/api/motorvedok

Az összes motorvédő állapotának lekérdezése a DB1-ből (26 darab).

Példa válasz:
{
  "success": true,
  "data": {
    "motorvedo_1": false,
    "motorvedo_2": true,
    ...
  },
  "timestamp": "2024-01-27T10:30:00"
}

🔄 Próba Bitek Kapcsolgatása

POST
/api/proba/toggle

A Próba7 (DBX0.6) és Próba9 (DBX1.0) bitek átkapcsolása a DB8-ban.

Példa válasz:
{
  "success": true,
  "data": {
    "proba7": {"old": false, "new": true},
    "proba9": {"old": true, "new": false}
  },
  "timestamp": "2024-01-27T10:30:00"
}

📋 Receptek Listázása

GET
/api/recipes

Az összes tárolt recept lekérdezése.

Példa válasz:
{
  "success": true,
  "data": [...],
  "count": 5,
  "timestamp": "2024-01-27T10:30:00"
}

➕ Új Recept Létrehozása

POST
/api/recipes

Új recept feltöltése JSON formátumban.

Példa kérés:
{
  "name": "Recept 1",
  "description": "Leírás",
  "parameters": {...}
}

🔍 Recept Lekérdezése

GET
/api/recipes/{id}

Egy konkrét recept lekérdezése ID alapján.

Használat

Docker Indítása

docker-compose up --build

Példa Kérések

Motorvédők lekérdezése:
curl http://localhost:5000/api/motorvedok
Próba bitek kapcsolgatása:
curl -X POST http://localhost:5000/api/proba/toggle
Új recept feltöltése:
curl -X POST -H "Content-Type: application/json" \
  -d '{"name":"Teszt Recept","description":"Teszt"}' \
  http://localhost:5000/api/recipes

Konfiguráció

A PLC kapcsolat beállításai környezeti változókkal módosíthatók:

  • PLC_IP: PLC IP címe (alapértelmezett: 10.1.2.2)
  • RACK: PLC rack száma (alapértelmezett: 0)
  • SLOT: PLC slot száma (alapértelmezett: 2)

Welcome to the PLC API!

This API enables reading and managing PLC (Programmable Logic Controller) data through HTTP requests. The API runs in a Docker container and provides REST endpoints for querying motor protection status, toggling test bits, and managing recipes.

API Endpoints

🏥 Health Check

GET
/health

Check the API status.

Example response:
{"status": "healthy", "timestamp": "2024-01-27T10:30:00"}

⚡ Read Motor Protections

GET
/api/motorvedok

Query all motor protection states from DB1 (26 pieces).

Example response:
{
  "success": true,
  "data": {
    "motorvedo_1": false,
    "motorvedo_2": true,
    ...
  },
  "timestamp": "2024-01-27T10:30:00"
}

🔄 Toggle Test Bits

POST
/api/proba/toggle

Toggle Próba7 (DBX0.6) and Próba9 (DBX1.0) bits in DB8.

Example response:
{
  "success": true,
  "data": {
    "proba7": {"old": false, "new": true},
    "proba9": {"old": true, "new": false}
  },
  "timestamp": "2024-01-27T10:30:00"
}

📋 List Recipes

GET
/api/recipes

Query all stored recipes.

Example response:
{
  "success": true,
  "data": [...],
  "count": 5,
  "timestamp": "2024-01-27T10:30:00"
}

➕ Create New Recipe

POST
/api/recipes

Upload a new recipe in JSON format.

Example request:
{
  "name": "Recipe 1",
  "description": "Description",
  "parameters": {...}
}

🔍 Get Recipe

GET
/api/recipes/{id}

Query a specific recipe by ID.

Usage

Start Docker

docker-compose up --build

Example Requests

Query motor protections:
curl http://localhost:5000/api/motorvedok
Toggle test bits:
curl -X POST http://localhost:5000/api/proba/toggle
Upload new recipe:
curl -X POST -H "Content-Type: application/json" \
  -d '{"name":"Test Recipe","description":"Test"}' \
  http://localhost:5000/api/recipes

Configuration

PLC connection settings can be modified with environment variables:

  • PLC_IP: PLC IP address (default: 10.1.2.2)
  • RACK: PLC rack number (default: 0)
  • SLOT: PLC slot number (default: 2)