|
1 | | -## New Feature: Current Task Status Reading via SNPX |
| 1 | +## Bug Fixes and Improvements |
2 | 2 |
|
3 | | -The SDK now provides the ability to read the current task status from the robot controller via the SNPX protocol. This allows you to monitor the execution state of programs running on different tasks. |
| 3 | +This version contains a bug fix to make program startup via Telnet more robust. |
4 | 4 |
|
5 | | -### Property Added |
6 | | - |
7 | | -- **`CurrentTaskStatus`**: Provides access to the status of running tasks on the robot controller (now public, previously private) |
8 | | - |
9 | | -### What You Can Read |
10 | | - |
11 | | -For each task, you can access: |
12 | | - |
13 | | -- **`ProgramName`**: Name of the currently executing program |
14 | | -- **`LineNumber`**: Current line number being executed |
15 | | -- **`State`**: Execution state (Stopped, Paused, or Running) |
16 | | -- **`Caller`**: Name of the calling program |
17 | | - |
18 | | -### Quick Example |
| 5 | +### C# Usage Example |
19 | 6 |
|
20 | 7 | ```csharp |
21 | | -using UnderAutomation.Fanuc; |
22 | | -using UnderAutomation.Fanuc.Common; |
23 | | -using UnderAutomation.Fanuc.Snpx.Internal; |
| 8 | +// Run a program on the robot |
| 9 | +var result = robot.Telnet.Run("MYPROGRAM"); |
24 | 10 |
|
25 | | -// Create and connect to robot |
26 | | -FanucRobot robot = new FanucRobot(); |
27 | | -ConnectionParameters parameters = new ConnectionParameters("192.168.0.1"); |
28 | | -parameters.Snpx.Enable = true; |
29 | | -robot.Connect(parameters); |
30 | | - |
31 | | -// Read task status for task 1 (index starts from 1) |
32 | | -RobotTaskStatus task1Status = robot.Snpx.CurrentTaskStatus.Read(1); |
33 | | - |
34 | | -// Display task information |
35 | | -Console.WriteLine($"Program: {task1Status.ProgramName}"); |
36 | | -Console.WriteLine($"Line: {task1Status.LineNumber}"); |
37 | | -Console.WriteLine($"State: {task1Status.State}"); |
38 | | -Console.WriteLine($"Caller: {task1Status.Caller}"); |
39 | | - |
40 | | -// Check task state |
41 | | -switch (task1Status.State) |
| 11 | +if (result.Succeed) |
42 | 12 | { |
43 | | - case RobotTaskState.Running: |
44 | | - Console.WriteLine($"Task 1 is running {task1Status.ProgramName} at line {task1Status.LineNumber}"); |
45 | | - break; |
46 | | - case RobotTaskState.Paused: |
47 | | - Console.WriteLine("Task 1 is paused"); |
48 | | - break; |
49 | | - case RobotTaskState.Stopped: |
50 | | - Console.WriteLine("Task 1 is stopped"); |
51 | | - break; |
| 13 | + Console.WriteLine("Program started successfully"); |
52 | 14 | } |
53 | | - |
54 | | -// Monitor multiple tasks |
55 | | -for (int i = 1; i <= 4; i++) |
| 15 | +else |
56 | 16 | { |
57 | | - var taskStatus = robot.Snpx.CurrentTaskStatus.Read(i); |
58 | | - Console.WriteLine($"Task {i}: {taskStatus}"); |
| 17 | + Console.WriteLine($"Error: {result.ErrorText}"); |
59 | 18 | } |
60 | 19 | ``` |
0 commit comments