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
/health
Check the API status.
{"status": "healthy", "timestamp": "2024-01-27T10:30:00"}
⚡ Read Motor Protections
/api/motorvedok
Query all motor protection states from DB1 (26 pieces).
{
"success": true,
"data": {
"motorvedo_1": false,
"motorvedo_2": true,
...
},
"timestamp": "2024-01-27T10:30:00"
}
🔄 Toggle Test Bits
/api/proba/toggle
Toggle Próba7 (DBX0.6) and Próba9 (DBX1.0) bits in DB8.
{
"success": true,
"data": {
"proba7": {"old": false, "new": true},
"proba9": {"old": true, "new": false}
},
"timestamp": "2024-01-27T10:30:00"
}
📋 List Recipes
/api/recipes
Query all stored recipes.
{
"success": true,
"data": [...],
"count": 5,
"timestamp": "2024-01-27T10:30:00"
}
➕ Create New Recipe
/api/recipes
Upload a new recipe in JSON format.
{
"name": "Recipe 1",
"description": "Description",
"parameters": {...}
}
🔍 Get Recipe
/api/recipes/{id}
Query a specific recipe by ID.
Usage
Start Docker
docker-compose up --build
Example Requests
curl http://localhost:5000/api/motorvedok
curl -X POST http://localhost:5000/api/proba/toggle
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)