Skip to main content
Skip table of contents

HTTP Sample Mover

This protocol guide is designed for customers integrating the Prediktera Generic HTTP - Sample Mover system into their server infrastructure. It details the commands and data formats your server will receive from the client part we provide, enabling you to control a generic tray or conveyor belt effectively.

Parameters

Host

Specify the IP address or host name along with the protocol.

May include any additional path information.

EXAMPLE https://localhost:8080/deviceControl

Type of mover

  • Tray

  • Conveyor

If the stage is a linear tray or a conveyor.

The Tray type of mover will receive the Move command and the Conveyor type of mover will receive Start / Stop.

Overview

Our system sends commands to your server through HTTP POST requests, allowing you to start, stop, and adjust the speed of your conveyor belt or tray mover. This guide outlines the expected command formats and how to respond to these requests.

Expected Commands

Your server will receive commands structured as JSON objects within the body of POST requests. Here are the commands you should expect.

HTTP status response codes outside of 200-299 will result in runtime error.

Start

Initiates the movement of a conveyor belt.

A response should be sent when the conveyor is up to the requested speed, sending 200 OK to indicate the successful starting of the conveyor.

  • Received JSON Payload

JSON
{
    "command": "start",
    "speed": 50
}

Property

Data Type

Comment

speed

Float32

Unit: mm/sec

Stop

Halts the movement of the tray or conveyor belt. Default timeout 10 seconds.

  • Received JSON Payload

JSON
{
    "command": "stop"
}

Move

Initiates the movement of a tray and wait for movement to finish.

  • Received JSON Payload

JSON
{
    "command": "move",
    "speed": 50,
    "destinationPosition": 230
}

Property

Data Type

Comment

speed

Float32

Unit: mm/sec

destinationPosition

Float32

Destination location in mm

Implementing the Server Logic

Upon receiving a command, your server should parse the JSON payload and execute the corresponding action on the tray or conveyor belt. Ensure your server sends an HTTP response back to acknowledge the receipt and execution of the command.

Success Response

For successful command execution, respond with:

JSON
{
    "status": "success"
}

Error Response

In case of an error (e.g., invalid command, execution failure), respond with:

JSON
{
    "status": "error",
    "message": "Detailed error message"
}

Example server

PY
from flask import Flask, request, jsonify

app = Flask(__name__)


# http://127.0.0.1:5500/command
@app.route('/command', methods=['POST'])
def handle_command():
    data = request.json
    command = data.get('command')
    destination_position = data.get('destinationPosition', 'N/A')
    speed = data.get('speed', 'N/A')

    print(f"Received data: {data}")

    if command == 'start' and isinstance(speed, (int, float)):
        # TODO: start action
        response = {'status': 'success'}
    elif command == 'stop':
        # TODO: stop action - only applicable when Conveyor type is selected
        response = {'status': 'success'}
    elif command == 'move' and isinstance(speed, (int, float)) and isinstance(destination_position, (int, float)):
        # TODO: move action - only applicable when Tray type is selected
        response = {'status': 'success'}
    else:
        response = {'status': 'error', 'message': 'Invalid command'}

    return jsonify(response)


if __name__ == '__main__':
    app.run(debug=True, port=5500)

Support

Should you require assistance with the protocol or encounter any issues, please reach out to our support team for help: support@prediktera.com

Follow this article for additional information on device configuration: Hardware and settings guide

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.