Skip to content Skip to main navigation Skip to footer

Electric gate capability

Introduction

The API allows you to control the opening and closing of the electric gate, as well as query its status. The API requires using release libraries version 10.1 and above.

Open or close the electric gate

            RobotApi.getInstance().startControlElectricDoor(0, doorCmd, new ActionListener() {
                    @Override
                    public void onResult(int result, String message, String extraData) {
                        Log.d(TAG, "startControlElectricDoor result:" + result + " message:" + message);
                        LogTools.info("startControlElectricDoor result:" + result + " message:" + message);
                        if (result == Definition.RESULT_OK) {
                            //Control successful
                            Log.d(TAG, "startControlElectricDoor success");
                        } else {
                            //Control failed
                            Log.d(TAG, "startControlElectricDoor failed");
                        }
                    }

                    @Override
                    public void onError(int errorCode, String errorString, String extraData) {
                        Log.d(TAG, "startControlElectricDoor onError: errorCode:" + errorCode + " errorString:" + errorString);
                        if (errorCode == Definition.ERROR_ELECTRIC_DOOR_BLOCK) {
                            //The gate is obstructed (e.g., hand or other objects are caught)
                            Log.d(TAG, "startControlElectricDoor onError: electric door block");
                        } else if (errorCode == Definition.ERROR_ELECTRIC_DOOR_UPPER_BLOCK) {
                            //The upper gate is obstructed (e.g., hand or other objects are caught)
                            Log.d(TAG, "startControlElectricDoor onError: electric door upper block");
                        } else if (errorCode == Definition.ERROR_ELECTRIC_DOOR_LOWER_BLOCK) {
                            //The lower gate is obstructed (e.g., hand or other objects are caught)
                            Log.d(TAG, "startControlElectricDoor onError: electric door lower block");
                        } else if (errorCode == Definition.ERROR_ELECTRIC_DOOR_TIMEOUT) {
                            //Control gate command timed out
                            Log.d(TAG, "startControlElectricDoor onError: electric door timeout");
                        }
                    }

                    @Override
                    public void onStatusUpdate(int status, String data, String extraData) {
                        Log.d(TAG, "onStatusUpdate: status:" + status + " data:" + data);
                        if (status == Definition.STATUS_ELECTRIC_DOOR_BLOCK) {
                            //The gate is obstructed (e.g., hand or other objects are caught), a pinch warning can be issued.
                            Log.d(TAG, "onStatusUpdate: electric door block");
                        } else if (status == Definition.STATUS_ELECTRIC_DOOR_UPPER_BLOCK) {
                            //The upper gate is obstructed (e.g., hand or other objects are caught), a pinch warning can be issued.
                            Log.d(TAG, "onStatusUpdate: electric door upper block");
                        } else if (status == Definition.STATUS_ELECTRIC_DOOR_LOWER_BLOCK) {
                            //The lower gate is obstructed (e.g., hand or other objects are caught), a pinch warning can be issued.
                            Log.d(TAG, "onStatusUpdate: electric door lower block");
                        }
                    }
                });

doorCmd Parameter:

  • Definition.CAN_DOOR_DOOR1_DOOR2_OPEN: Open the upper compartment doors
  • Definition.CAN_DOOR_DOOR1_DOOR2_CLOSE: Close the upper compartment doors
  • Definition.CAN_DOOR_DOOR3_DOOR4_OPEN: Open the lower compartment doors
  • Definition.CAN_DOOR_DOOR3_DOOR4_CLOSE: Close the lower compartment doors
  • Definition.CAN_DOOR_ALL_OPEN: Open all compartment doors
  • Definition.CAN_DOOR_ALL_CLOSE: Close all compartment doors

Register compartment door status listener

Register an electric gate status listener to get the status of the electric gate. Register it where needed according to your business requirements. When the status of the electric gate changes, the onStatusUpdate method will be called back. For example, after issuing open or close gate commands, the status of the electric gate will change. If you need to get the status of the electric gate at any time, you can call the getElectricDoorStatus method.

//Handling of the listener, refer to the processing in the getElectricDoorStatus method.
RobotApi.getInstance().registerStatusListener(Definition.STATUS_CAN_ELECTRIC_DOOR_CTRL, statusListener);

Remove the warehouse door listener

Remove the listener when the electric door status is no longer needed to prevent memory leaks

RobotApi.getInstance().unregisterStatusListener(statusListener);

Actively query the warehouse door status

You can call this method at any time to query the warehouse door status

RobotApi.getInstance().getElectricDoorStatus(0, new CommandListener() {
            @Override
            public void onResult(int result, String message, String extraData) {
                super.onResult(result, message, extraData);
                Log.d(TAG, "getElectricDoorStatus result:" + result + " message:" + message);
                if (result == 1 && !TextUtils.isEmpty(message)) {
                    CanElectricDoorBean doorBean = GsonUtil.fromJson(message, CanElectricDoorBean.class);
                    //Door1 and door2 are the upper warehouse doors, and door3 and door4 are the lower warehouse doors.
                    //The status of the upper warehouse doors.
                    if (doorBean.getDoor1() == Definition.CAN_DOOR_STATUS_RUNNING || doorBean.getDoor2() ==                                                                                 Definition.CAN_DOOR_STATUS_RUNNING) {
                        Log.d(TAG, "upper door is running");
                        //Do not execute open or close commands when the warehouse doors are in motion.
                    }
                    if (doorBean.getDoor1() == Definition.CAN_DOOR_STATUS_OPEN && doorBean.getDoor2() == Definition.CAN_DOOR_STATUS_OPEN) {
                        Log.d(TAG, "upper door is open");
                    }
                    if (doorBean.getDoor1() == Definition.CAN_DOOR_STATUS_CLOSE && doorBean.getDoor2() == Definition.CAN_DOOR_STATUS_CLOSE) {
                        Log.d(TAG, "upper door is close");
                    }
                    //The status of the lower warehouse doors.
                    if (doorBean.getDoor3() == Definition.CAN_DOOR_STATUS_RUNNING || doorBean.getDoor4() == Definition.CAN_DOOR_STATUS_RUNNING) {
                        Log.d(TAG, "lower door is running");
                        //Do not execute open or close commands when the warehouse door is in motion.
                    }
                    if (doorBean.getDoor3() == Definition.CAN_DOOR_STATUS_OPEN && doorBean.getDoor4() == Definition.CAN_DOOR_STATUS_OPEN) {
                        Log.d(TAG, "lower door is open");
                    }
                    if (doorBean.getDoor3() == Definition.CAN_DOOR_STATUS_CLOSE && doorBean.getDoor4() == Definition.CAN_DOOR_STATUS_CLOSE) {
                        Log.d(TAG, "lower door is close");
                    }

                    //The door's stall state; stalling may occur when opening or closing the door.
                    //Blocked while closing the door.
                    if (doorBean.getUpStatus() == Definition.CAN_DOOR_STATUS_BLOCK_AND_BOUNCE) {
                        Log.d(TAG, "upper door is block and bounce");
                    }
                    if (doorBean.getDownStatus() == Definition.CAN_DOOR_STATUS_BLOCK_AND_BOUNCE) {
                        Log.d(TAG, "lower door is block and bounce");
                    }
                    //Blocked while opening the door.
                    if (doorBean.getUpStatus() == Definition.CAN_DOOR_STATUS_BLOCKING_STOP) {
                        Log.d(TAG, "upper door is blocking stop");
                    }
                    if (doorBean.getDownStatus() == Definition.CAN_DOOR_STATUS_BLOCKING_STOP) {
                        Log.d(TAG, "lower door is blocking stop");
                    }
                } else {
                    Log.d(TAG, "getElectricDoorStatus onResult: Failure to get status");
                }
            }
        });

Status Description:

  • Definition.CAN_DOOR_STATUS_RUNNING: The electric door is executing a task.
  • Definition.CAN_DOOR_STATUS_OPEN: The warehouse door is open.
  • Definition.CAN_DOOR_STATUS_CLOSE: The warehouse door is closed.
  • Definition.CAN_DOOR_STATUS_BLOCK_AND_BOUNCE: Blocked while closing (in this case, remove the obstruction and retry).
  • Definition.CAN_DOOR_STATUS_BLOCKING_STOP: Blocked while opening (in this case, remove the obstruction and retry).

Usage Instructions:

The upper warehouse door consists of two doors, returned as door1 and door2; the lower warehouse door also consists of two doors, returned as door3 and door4.

To query the status of the upper warehouse door, you can check the status of both door1 and door2 simultaneously. To query the status of the lower warehouse door, you can check the status of both door3 and door4 simultaneously.

After issuing the command to open or close the warehouse door, if you query immediately, the warehouse door will still be in the process of opening or closing, and you will not get the expected status of “already open” or “already closed”. You need to wait for a certain period before querying.

Specific Usage Reference Demo

GREETBOTMINILUCKIDELIVERBOTBIGSCREENBOTLuckibot pro Autodoor
NoNoNoNoNoYes