Skip to content

Commit 5771159

Browse files
Update to new version : 4.6.0.0
1 parent 0fee27b commit 5771159

File tree

5 files changed

+58
-53
lines changed

5 files changed

+58
-53
lines changed
0 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.5.0.0
1+
4.6.0.0

underautomation/fanuc/snpx/internal/current_task_status.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from UnderAutomation.Fanuc.Snpx.Internal import CurrentTaskStatus as current_task_status
55

66
class CurrentTaskStatus(SnpxAssignableElements2[RobotTaskStatus, int]):
7-
'''Provides access to the current task (program) status on the robot via SNPX.'''
7+
'''Provides access to the current task (program) status on the robot via SNPX. Index starts from 1.'''
88
def __init__(self, _internal = 0):
99
if(_internal == 0):
1010
self._instance = current_task_status()

underautomation/fanuc/snpx/internal/snpx_client_base.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from underautomation.fanuc.snpx.internal.numeric_io import NumericIO
1313
from underautomation.fanuc.snpx.internal.flags import Flags
1414
from underautomation.fanuc.snpx.internal.current_position import CurrentPosition
15+
from underautomation.fanuc.snpx.internal.current_task_status import CurrentTaskStatus
1516
from underautomation.fanuc.snpx.internal.alarm_access import AlarmAccess
1617
from underautomation.fanuc.common.languages import Languages
1718
from underautomation.fanuc.snpx.internal.assignment import Assignment
@@ -220,6 +221,11 @@ def current_position(self) -> CurrentPosition:
220221
'''Current position in world or user frame'''
221222
return CurrentPosition(self._instance.CurrentPosition)
222223

224+
@property
225+
def current_task_status(self) -> CurrentTaskStatus:
226+
'''Current program tasks status. Index starts from 1.'''
227+
return CurrentTaskStatus(self._instance.CurrentTaskStatus)
228+
223229
@property
224230
def active_alarm(self) -> AlarmAccess:
225231
'''Current active alarms'''

whatsNew.md

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,60 @@
1-
## Bug fix : Current position always read wrong motion group
1+
## New Feature: Current Task Status Reading via SNPX
22

3-
`ReadWorldPosition()` and `ReadUserFramePosition()` were silently targeting motion group 0, which does not exist on Fanuc controllers, causing the robot to return wrong position data. Both methods now correctly default to **group 1** (the first motion group).
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.
44

5-
Multi-group robots can still target a specific group explicitly:
5+
### Property Added
66

7-
```csharp
8-
// Read world position : group 1 (default, fixed)
9-
Position pos = robot.Snpx.CurrentPosition.ReadWorldPosition();
10-
11-
// Read in user frame 3 : group 1 (default, fixed)
12-
Position pos = robot.Snpx.CurrentPosition.ReadUserFramePosition(3);
13-
14-
// Read world position on group 2 (multi-group robots)
15-
Position pos = robot.Snpx.CurrentPosition.ReadWorldPosition(2);
16-
17-
// Read in user frame 3 on group 2
18-
Position pos = robot.Snpx.CurrentPosition.ReadUserFramePosition(3, 2);
19-
```
20-
21-
---
7+
- **`CurrentTaskStatus`**: Provides access to the status of running tasks on the robot controller (now public, previously private)
228

23-
## SNPX Numeric Registers : Int16 and Int32 support
9+
### What You Can Read
2410

25-
Numeric registers (`R[]`) can now be read and written as **16-bit** or **32-bit integers** in addition to the existing float format. Two new accessors are available on the SNPX client: `NumericRegistersInt32` and `NumericRegistersInt16`.
11+
For each task, you can access:
2612

27-
This is useful when a Fanuc program stores integer values in numeric registers and you want to avoid float conversion artifacts.
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
2817

29-
### Single register read / write
18+
### Quick Example
3019

3120
```csharp
32-
// Float (existing)
33-
float f = robot.Snpx.NumericRegisters.Read(1);
34-
robot.Snpx.NumericRegisters.Write(1, 3.14f);
35-
36-
// 32-bit integer
37-
int i32 = robot.Snpx.NumericRegistersInt32.Read(1);
38-
robot.Snpx.NumericRegistersInt32.Write(1, 1234567);
39-
40-
// 16-bit integer
41-
short i16 = robot.Snpx.NumericRegistersInt16.Read(1);
42-
robot.Snpx.NumericRegistersInt16.Write(1, 42);
43-
```
44-
45-
### Batch read / write
46-
47-
Batch assignments let you read a contiguous range of registers in a single network round-trip.
48-
49-
```csharp
50-
// Float (existing)
51-
var batchF = robot.Snpx.NumericRegisters.CreateBatchAssignment(1, 10);
52-
float[] floats = batchF.Read();
53-
54-
// 32-bit integer
55-
var batchI32 = robot.Snpx.NumericRegistersInt32.CreateBatchAssignment(1, 10);
56-
int[] ints = batchI32.Read();
57-
58-
// 16-bit integer
59-
var batchI16 = robot.Snpx.NumericRegistersInt16.CreateBatchAssignment(1, 10);
60-
short[] shorts = batchI16.Read();
21+
using UnderAutomation.Fanuc;
22+
using UnderAutomation.Fanuc.Common;
23+
using UnderAutomation.Fanuc.Snpx.Internal;
24+
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)
42+
{
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;
52+
}
53+
54+
// Monitor multiple tasks
55+
for (int i = 1; i <= 4; i++)
56+
{
57+
var taskStatus = robot.Snpx.CurrentTaskStatus.Read(i);
58+
Console.WriteLine($"Task {i}: {taskStatus}");
59+
}
6160
```

0 commit comments

Comments
 (0)