Diagnosis
By reading svc.diagnostics diagnostics and alarms (diag_snapshot and alarms are still available; they contain the same data).
We recommend using Event Handle driver exceptions rather than polling on your own. Directly reading diagnostic properties is suitable for scenarios such as display UI .
Feature Overview
| Features | Note |
|---|---|
| Diagnostic Snapshot | Links, Frame Count, Watchdog, Jitter, Alarm Monitoring |
| On-Site Issue Comparison | Select a field based on symptoms |
| Process Data Quality | IOPS / IOCS |
| Call the Police | Event List / History / Confirm |
Diagnostic Snapshot
| Grouping | Properties | Type | Note |
|---|---|---|---|
| Availability | ok | bool | Check if it is available. False = Device is not running; read message |
| Availability | shared_memory_mapped | bool | Is the process data ready? |
| Availability | message | str | Reason for unavailability; empty when available |
| Availability | timestamp | datetime | None | Snapshot generation time. Parsing failed: None |
| Link | state | str | Operational Status Copy |
| Link | link_up | bool | Is the network card link up? |
| Link | connected | bool | Are the cycle data normal? |
| Link | active_iocr_count | int | Number of active IO connections |
| Link | iocr_active | int | IO Connect the activation bitmap |
| Link | iocr_healthy | int | IO Connecting Health Bitmaps |
| Counting | heartbeat | int | Heart Rate Count |
| Counting | cycle_counter | int | Cycle Count |
| Counting | last_error | int | Recent error codes (0 = None) |
| Counting | rx_frames / tx_frames | int | Total Number of Frames Received / Sent |
| Counting | rx_rt_frames / tx_rt_frames | int | Receive / Transmit RT Cyclic Frame |
| Counting | dropped_frames | int | Discarded Frames |
| Counting | invalid_frames | int | Illegal Frame |
| Counting | watchdog_trips | int | Number of watchdog timeouts |
| Counting | last_rx_tsc / last_tx_tsc | int | Most Recent Received / Sent Frames TSC |
| Process Area | input_area_length | int | Enter the zone length (in bytes). The length is determined by a value negotiated by the IO controller and is automatically matched after connection. |
| Process Area | output_area_length | int | Output zone length (bytes). The length is determined by a value negotiated by the IO controller and is automatically matched after connection. |
| Cycle | stack_cycles | int | Cycle Counting |
| Cycle | stack_frames_rx / stack_frames_tx | int | Receive / Transmit Frame |
| Cycle | stack_missed_ticks | int | A Missed Beat |
| Cycle | stack_max_jitter_us | int | Maximum Jitter (microseconds) |
| Alarm Monitoring | stack_alarm_rx_count | int | Total Number of Alarms Received from the Controller |
| Alarm Monitoring | stack_alarm_tx_ack_ok | int | Number of times the unit's alarm has been acknowledged |
| Alarm Monitoring | stack_alarm_tx_ack_fail | int | Number of failed alarm acknowledgments on this unit |
| Alarm Monitoring | stack_alarm_ack_pending | int | In-Transit Alerts (0/1) |
| Alarm Monitoring | stack_alarm_maint_state | int | Maintain Request Status |
| Alarm Monitoring | stack_alarm_last_arep | int | Recently, the controller issued an alarm: Arep |
| Alarm Monitoring | stack_alarm_last_slot | int | Recently, the controller issued an alarm: Bay |
| Alarm Monitoring | stack_alarm_last_subslot | int | Recently, the controller issued an alarm: sub-bay |
| Alarm Monitoring | stack_alarm_last_type | int | The controller recently issued an alarm: Type |
| Alarm Monitoring | stack_alarm_last_seq | int | The controller recently issued an alarm: Serial Number |
| Alarm Monitoring | stack_alarm_last_usi | int | Recently, the controller has been issuing an alarm:USI |
| Alarm Monitoring | stack_alarm_last_len | int | The controller recently issued an alarm: load length |
| Error | error_code | int | Original error code value (0 = none) |
| Error | error_code_enum | PnSRuntimeErrorCode | Enumeration format for the previous item. Unrecognized negative values are classified as UNKNOWN, and positive values are classified as WIN32_ERROR. |
diag_snapshot
@property
def diag_snapshot(self) -> PnSServiceDiagSnapshot
Retrieves the current diagnostic snapshot once; suitable for interface refreshes and logging. If the device has not yet booted ok == False, a message"read" operation is not considered an error. This can also be written as PnSDiagSnapshot.
Example:
snap = svc.diag_snapshot
if not snap.ok:
print(snap.message)
else:
print("Up" if snap.link_up else "Down")
print("周期交换正常" if snap.connected else "未建立")
print(f"帧: {snap.rx_frames} / {snap.tx_frames}")
print(f"看门狗: {snap.watchdog_trips}")
On-Site Issue Comparison
| On-site Symptoms | See which fields |
|---|---|
| The Ethernet cable isn't plugged in properly. | diag_snapshot.link_up |
| Is the cycle data available? | diag_snapshot.connected |
| The watchdog keeps jumping | diag_snapshot.watchdog_trips |
| Frames are being dropped | dropped_frames + invalid_frames |
| Is the cycle stable? | stack_max_jitter_us + stack_missed_ticks |
| Controller alarm not cleared | stack_alarm_ack_pending / stack_alarm_tx_ack_fail |
| Does this machine have a motion alarm? | alarms / alarm_count |
Process Data Quality
io_status
@property
def io_status(self) -> PnSServiceIoStatus
IOPS / IOCS Snapshot. 0x80 = GOOD, 0x00 = BAD. If disconnected, all values are set to BAD. If not started or if the operation fails, return an empty state; all criteria are met False. This can also be written as PnSIoStatus.
| Properties | Type | Note |
|---|---|---|
| input_iops / input_iocs | bytes | Enter IOPS / IOCS |
| output_iops / output_iocs | bytes | Output IOPS / IOCS |
| input_valid | bool | I received an offer from Group I this round |
| output_valid | bool | Whether Q has been written this round and delivered to the controller (disconnected or not sent = False) |
| input_data_good | bool | Received and entered IOPS All GOOD |
| output_data_good | bool | Written and outputted IOPS All GOOD |
| output_consumed | bool | Output: All IOCS GOOD |
| all_good | bool | All three of the above are true. |
Example:
if not svc.io_status.all_good:
print(svc.io_status)
Call the Police
| Grouping | Properties | Type | Note |
|---|---|---|---|
| Counting | alarm_count | int | Total number of event alerts. From the same source alarms as |
| Counting | critical_alarm_count | int | Number of Critical Alarms |
| List | alarms | list[PnSServiceAlarm] | Current activity alerts. Empty list = No activity alerts; not a failure. |
| List | alarm_history | list[PnSServiceAlarm] | History (last 500 entries, sorted by time in ascending order). Empty list = no history |
alarms
@property
def alarms(self) -> list
Alert on current activity. If there is no activity, an empty list is returned; this does not indicate a failure. This can also be written as PnSAlarmItem.
Example:
for a in svc.alarms:
print(a)
alarm_history
@property
def alarm_history(self) -> list
Alert History (last 500 entries, sorted by time in ascending order). If no history is found, an empty list is returned; this is not a failure.
Example:
for a in svc.alarm_history:
print(a.occurred_at, a.severity, a.message)
acknowledge_alarm
def acknowledge_alarm(self, alarm_id: str) -> None
Confirm an event alert. The ID is taken from alarms. A null ID throws an exception; PnSServiceError if the ID does not exist, an exception is also thrown. ack_alarm Synonymous.
Example:
svc.acknowledge_alarm("PnS.LinkDown")
acknowledge_all_alarms
def acknowledge_all_alarms(self) -> int
Confirm all activity alarms. ack_all_alarms Synonym.
Return value:
int— Number of confirmed events (0 = no active alarms)
Example:
n = svc.acknowledge_all_alarms()
PnSServiceAlarm
| Properties | Type | Note |
|---|---|---|
| id | str | Alert ID (e.g., PnS.LinkDown) |
| severity | str | Severity: Info / Warning / Error / Critical |
| message | str | Alert Message |
| occurred_at | datetime | None | Time of the most recent occurrence. Parsing failed: None |
| count | int | Number of occurrences (≥1) |
| source | str | Source |
Identification
im_data
@property
def im_data(self) -> PnSServiceImData
Order number, serial number, station name. Leave fields blank if missing / 0 / False. You may also write it as PnSImData.
Example:
im = svc.im_data
print(im.station_name, hex(im.vendor_id), hex(im.device_id), im.order_id)