This page shows how to read the state of a Yaskawa Motoman controller with the SDK, and how to change it: servo power, hold, cycle mode, pendant lock and pendant message. It covers every controller with the High Speed Ethernet Server.

## Read the status

`GetStatusInformation()` reads the mode, the execution state, the hold and the alarm flags in one request.

**C# : StatusRead**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class StatusRead
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        RobotStatusData status = robot.HighSpeedEServer.GetStatusInformation();

        // Mode of the controller
        Console.WriteLine($"Teach: {status.Teach}, play: {status.Play}, remote: {status.CommandRemote}");

        // Cycle mode: step, one cycle or automatic (continuous)
        Console.WriteLine($"Step: {status.Step}, cycle: {status.Cycle}, automatic: {status.Automatic}");

        // Execution
        Console.WriteLine($"Running: {status.Running}, servo on: {status.ServoOn}");

        // Hold, from the pendant, from an external signal or from a command
        Console.WriteLine($"Hold: {status.InHoldStatusPendant} {status.InHoldStatusExternally} {status.InHoldStatusByCommand}");

        // Alarm and error
        Console.WriteLine($"Alarm: {status.Alarming}, error: {status.ErrorOccurring}");
        /**/

        robot.Disconnect();
    }
}
```

**Python : StatusRead**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
status = robot.high_speed_e_server.get_status_information()

# Mode of the controller
print(f"Teach: {status.teach}, play: {status.play}, remote: {status.command_remote}")

# Cycle mode: step, one cycle or automatic (continuous)
print(f"Step: {status.step}, cycle: {status.cycle}, automatic: {status.automatic}")

# Execution
print(f"Running: {status.running}, servo on: {status.servo_on}")

# Hold, from the pendant, from an external signal or from a command
print(f"Hold: {status.in_hold_status_pendant} {status.in_hold_status_externally} {status.in_hold_status_by_command}")

# Alarm and error
print(f"Alarm: {status.alarming}, error: {status.error_occurring}")
##

robot.disconnect()
```

**Matlab : StatusRead**
```matlab
NET.addAssembly(fullfile(pwd, 'net48', 'UnderAutomation.Yaskawa.dll'));
import UnderAutomation.Yaskawa.*
import UnderAutomation.Yaskawa.HighSpeedEServer.*

robot = YaskawaRobot();
robot.Connect('192.168.0.1');

%%
status = robot.HighSpeedEServer.GetStatusInformation();

% Mode, execution and alarm, as Matlab logicals
fprintf('Play: %d, remote: %d
', status.Play, status.CommandRemote);
fprintf('Running: %d, servo on: %d
', status.Running, status.ServoOn);
fprintf('Alarm: %d, error: %d
', status.Alarming, status.ErrorOccurring);
%%

robot.Disconnect();
```

| Property                     | `true` when                                                          |
| ---------------------------- | -------------------------------------------------------------------- |
| `Teach`, `Play`              | The controller is in teach mode, in play mode                        |
| `CommandRemote`              | The controller accepts the commands of the PC                        |
| `Step`, `Cycle`, `Automatic` | The cycle mode: step, one cycle, continuous                          |
| `Running`                    | A job or a move is executed                                          |
| `ServoOn`                    | The servo power is on                                                |
| `InHoldStatusPendant`        | The hold button of the pendant is pressed                            |
| `InHoldStatusExternally`     | The external hold signal is on                                       |
| `InHoldStatusByCommand`      | A hold was sent by `ServoCommand(Hold, true)`                        |
| `Alarming`                   | An alarm is active, see [Alarms](/yaskawa/documentation/hses-alarms) |
| `ErrorOccurring`             | An error message is shown                                            |
| `InGuardSafeOperation`       | The robot is in guard safe operation                                 |

The status is a snapshot. To follow its changes, read it in a loop: see [Monitor the state of the robot](/yaskawa/documentation/how-to-monitor-state).

## Servo power and hold

`ServoCommand(command, value)` switches the servo power, the hold and the pendant lock on or off. It needs the remote mode.

**C# : StatusServo**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class StatusServo
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Switch the servo power on. The SDK waits up to PowerOnTimeoutMilliseconds (8 s)
        robot.HighSpeedEServer.ServoCommand(OnOffCommandType.Servo, true);

        // Hold the robot, then release the hold
        robot.HighSpeedEServer.ServoCommand(OnOffCommandType.Hold, true);
        robot.HighSpeedEServer.ServoCommand(OnOffCommandType.Hold, false);

        // Switch the servo power off
        robot.HighSpeedEServer.ServoCommand(OnOffCommandType.Servo, false);
        /**/

        robot.Disconnect();
    }
}
```

**Python : StatusServo**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters
from underautomation.yaskawa.high_speed_e_server.on_off_command_type import OnOffCommandType

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
# Switch the servo power on. The SDK waits up to power_on_timeout_milliseconds (8 s)
robot.high_speed_e_server.servo_command(OnOffCommandType.Servo, True)

# Hold the robot, then release the hold
robot.high_speed_e_server.servo_command(OnOffCommandType.Hold, True)
robot.high_speed_e_server.servo_command(OnOffCommandType.Hold, False)

# Switch the servo power off
robot.high_speed_e_server.servo_command(OnOffCommandType.Servo, False)
##

robot.disconnect()
```

| `OnOffCommandType` | `true`                                            | `false`            |
| ------------------ | ------------------------------------------------- | ------------------ |
| `Servo`            | Servo power on                                    | Servo power off    |
| `Hold`             | Hold: the robot stops on its path, servo stays on | Release the hold   |
| `HLock`            | Lock the pendant                                  | Unlock the pendant |

The servo power takes several seconds to come on. For this command the SDK waits `PowerOnTimeoutMilliseconds` (8000 ms by default) instead of `DataTimeoutMilliseconds`.

## Lock the pendant

When a PC drives the cell, lock the pendant so that nobody changes the mode or starts a job from it at the same time.

**C# : StatusPendantLock**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class StatusPendantLock
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Lock the programming pendant, so that nobody changes the mode or starts a job from it
        robot.HighSpeedEServer.ServoCommand(OnOffCommandType.HLock, true);

        // Unlock it
        robot.HighSpeedEServer.ServoCommand(OnOffCommandType.HLock, false);
        /**/

        robot.Disconnect();
    }
}
```

**Python : StatusPendantLock**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters
from underautomation.yaskawa.high_speed_e_server.on_off_command_type import OnOffCommandType

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
# Lock the programming pendant, so that nobody changes the mode or starts a job from it
robot.high_speed_e_server.servo_command(OnOffCommandType.HLock, True)

# Unlock it
robot.high_speed_e_server.servo_command(OnOffCommandType.HLock, False)
##

robot.disconnect()
```

## Cycle mode

`SwitchingCommand` selects how a job runs when it is started: step by step, one cycle, or in a loop.

**C# : StatusCycleMode**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class StatusCycleMode
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Execute the job step by step
        robot.HighSpeedEServer.SwitchingCommand(SwitchingCommands.Step);

        // Execute the job once
        robot.HighSpeedEServer.SwitchingCommand(SwitchingCommands.Cycle);

        // Execute the job in a loop
        robot.HighSpeedEServer.SwitchingCommand(SwitchingCommands.Continue);
        /**/

        robot.Disconnect();
    }
}
```

**Python : StatusCycleMode**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters
from underautomation.yaskawa.high_speed_e_server.switching_commands import SwitchingCommands

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
# Execute the job step by step
robot.high_speed_e_server.switching_command(SwitchingCommands.Step)

# Execute the job once
robot.high_speed_e_server.switching_command(SwitchingCommands.Cycle)

# Execute the job in a loop
robot.high_speed_e_server.switching_command(SwitchingCommands.Continue_)
##

robot.disconnect()
```

In Python, `SwitchingCommands.Continue` is written `SwitchingCommands.Continue_`.

## Message on the pendant

`Display(message)` shows a message to the operator on the programming pendant. The message has 24 characters at most: a longer one is cut.

**C# : StatusDisplay**
```csharp
using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;

public class StatusDisplay
{
    static void Main()
    {
        var robot = new YaskawaRobot();
        robot.Connect("192.168.0.1");

        /**/
        // Show a message on the programming pendant, 24 characters at most
        robot.HighSpeedEServer.Display("Part 42 done");
        /**/

        robot.Disconnect();
    }
}
```

**Python : StatusDisplay**
```python
from underautomation.yaskawa.yaskawa_robot import YaskawaRobot
from underautomation.yaskawa.connect_parameters import ConnectParameters

robot = YaskawaRobot()
robot.connect(ConnectParameters("192.168.0.1"))

##
# Show a message on the programming pendant, 24 characters at most
robot.high_speed_e_server.display("Part 42 done")
##

robot.disconnect()
```

## Try it in the demo application

Everything on this page can be tried without writing code, in the **Status** page of the [demo application](/yaskawa/documentation/demo-app).

![Status page of the Yaskawa SDK demo application](/yaskawa/WinformsScreenshots/Status.jpg)

Its C# source is [StatusControl.cs](https://github.com/underautomation/Yaskawa.NET/blob/main/UnderAutomation.Yaskawa.Showcase.Forms/Components/StatusControl.cs).

## Reference

**Methods of HighSpeedEServerClientBase**
```csharp
// Displays a popup message on the robot programming pendant. Message will appear as a notification to the operator.
RobotDataHeader Display(string message);

// Reads the current operational status of the robot controller. Returns information about mode (teach/play), running state, hold status, alarms, and servo power.
RobotStatusData GetStatusInformation();

// Executes hold/servo/HLock on/off commands. For servo control, this enables or disables motor power to the robot. Servo must be ON for the robot to move.
RobotDataHeader ServoCommand(OnOffCommandType command, bool value);

// Switches the robot execution mode between Step, Cycle, and Continuous.
RobotDataHeader SwitchingCommand(SwitchingCommands command);
```

Every method also exists in an asynchronous version, with the same name followed by `Async` and an optional `CancellationToken`.

**Members of HighSpeedEServer.RobotStatusData**
```csharp
public class RobotStatusData : RobotData {
    // Gets whether an alarm is currently active.
    // Check GetAlarm() for detailed alarm information.
    public bool Alarming { get; }

    // Gets whether the robot is in automatic operation mode.
    // When true, the robot can operate automatically without pendant interaction.
    public bool Automatic { get; }

    // Gets whether remote command mode is enabled.
    // When true, the robot accepts commands from external sources (including this API).
    public bool CommandRemote { get; }

    // Gets whether the robot is in cycle execution mode.
    // When true, the robot executes one complete cycle then stops.
    public bool Cycle { get; }

    // Gets whether an error condition is occurring.
    // Errors may prevent normal operation until resolved.
    public bool ErrorOccurring { get; }

    // Gets whether the robot is in guard safe operation mode.
    // Indicates collaborative/safety-rated operation mode is active.
    public bool InGuardSafeOperation { get; }

    // Gets whether the robot is held by a command (software hold).
    // A hold command was issued via the API or job instruction.
    public bool InHoldStatusByCommand { get; }

    // Gets whether the robot is held by an external hold signal.
    // External safety circuit has triggered a hold condition.
    public bool InHoldStatusExternally { get; }

    // Gets whether the robot is held by the programming pendant.
    // Operator has pressed hold on the pendant.
    public bool InHoldStatusPendant { get; }

    // Gets whether the robot is in play mode.
    // In play mode, the robot can execute programmed jobs.
    public bool Play { get; }

    // Gets whether the robot is currently running (executing a job).
    public bool Running { get; }

    // Gets whether servo power is enabled.
    // Servo must be ON for the robot to move.
    public bool ServoOn { get; }

    // Gets whether the robot is in step (single-step) execution mode.
    // When true, the robot executes one instruction at a time.
    public bool Step { get; }

    // Gets whether the robot is in teach mode.
    // In teach mode, the robot can be manually positioned and jobs can be edited.
    public bool Teach { get; }
}
```

**Members of HighSpeedEServer.OnOffCommandType**
```csharp
public enum OnOffCommandType : byte {
    // Lock Teach Pendant. Value: 3.
    HLock = 3

    // Hold command - pauses robot motion while maintaining servo power.
    // Robot can resume from held position. Value: 1.
    Hold = 1

    // Servo power command - enables or disables motor power to the robot.
    // Servo must be ON for the robot to move. Value: 2.
    Servo = 2
}
```

**Members of HighSpeedEServer.SwitchingCommands**
```csharp
public enum SwitchingCommands {
    // Continuous mode - robot executes the program continuously until stopped.
    // Normal production operation mode.
    Continue = 3

    // Cycle mode - robot executes one complete cycle of the program then stops.
    // Useful for testing or single-part operations.
    Cycle = 1

    // Step mode - robot executes one instruction at a time, stopping after each.
    // Useful for debugging and detailed program verification.
    Step = 2
}
```