Skip to main content

Diagnosis

By reading svc.diagnostics diagnostics and alarms (diag_snapshot and alarms are still available; they contain the same data).​

Use in conjunction with the event

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​

FeaturesNote
Diagnostic SnapshotLinks, Frame Count, Watchdog, Jitter, Alarm Monitoring
On-Site Issue ComparisonSelect a field based on symptoms
Process Data QualityIOPS / IOCS
Call the PoliceEvent List / History / Confirm

Diagnostic Snapshot​

GroupingPropertiesTypeNote
AvailabilityokboolCheck if it is available. False = Device is not running; read message
Availabilityshared_memory_mappedboolIs the process data ready?
AvailabilitymessagestrReason for unavailability; empty when available
Availabilitytimestampdatetime | NoneSnapshot generation time. Parsing failed: None
LinkstatestrOperational Status Copy
Linklink_upboolIs the network card link up?
LinkconnectedboolAre the cycle data normal?
Linkactive_iocr_countintNumber of active IO connections
Linkiocr_activeintIO Connect the activation bitmap
Linkiocr_healthyintIO Connecting Health Bitmaps
CountingheartbeatintHeart Rate Count
Countingcycle_counterintCycle Count
Countinglast_errorintRecent error codes (0 = None)
Countingrx_frames / tx_framesintTotal Number of Frames Received / Sent
Countingrx_rt_frames / tx_rt_framesintReceive / Transmit RT Cyclic Frame
Countingdropped_framesintDiscarded Frames
Countinginvalid_framesintIllegal Frame
Countingwatchdog_tripsintNumber of watchdog timeouts
Countinglast_rx_tsc / last_tx_tscintMost Recent Received / Sent Frames TSC
Process Areainput_area_lengthintEnter the zone length (in bytes). The length is determined by a value negotiated by the IO controller and is automatically matched after connection.
Process Areaoutput_area_lengthintOutput zone length (bytes). The length is determined by a value negotiated by the IO controller and is automatically matched after connection.
Cyclestack_cyclesintCycle Counting
Cyclestack_frames_rx / stack_frames_txintReceive / Transmit Frame
Cyclestack_missed_ticksintA Missed Beat
Cyclestack_max_jitter_usintMaximum Jitter (microseconds)
Alarm Monitoringstack_alarm_rx_countintTotal Number of Alarms Received from the Controller
Alarm Monitoringstack_alarm_tx_ack_okintNumber of times the unit's alarm has been acknowledged
Alarm Monitoringstack_alarm_tx_ack_failintNumber of failed alarm acknowledgments on this unit
Alarm Monitoringstack_alarm_ack_pendingintIn-Transit Alerts (0/1)
Alarm Monitoringstack_alarm_maint_stateintMaintain Request Status
Alarm Monitoringstack_alarm_last_arepintRecently, the controller issued an alarm: Arep
Alarm Monitoringstack_alarm_last_slotintRecently, the controller issued an alarm: Bay
Alarm Monitoringstack_alarm_last_subslotintRecently, the controller issued an alarm: sub-bay
Alarm Monitoringstack_alarm_last_typeintThe controller recently issued an alarm: Type
Alarm Monitoringstack_alarm_last_seqintThe controller recently issued an alarm: Serial Number
Alarm Monitoringstack_alarm_last_usiintRecently, the controller has been issuing an alarm:USI
Alarm Monitoringstack_alarm_last_lenintThe controller recently issued an alarm: load length
Errorerror_codeintOriginal error code value (0 = none)
Errorerror_code_enumPnSRuntimeErrorCodeEnumeration 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 SymptomsSee 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 jumpingdiag_snapshot.watchdog_trips
Frames are being droppeddropped_frames + invalid_frames
Is the cycle stable?stack_max_jitter_us + stack_missed_ticks
Controller alarm not clearedstack_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.

PropertiesTypeNote
input_iops / input_iocsbytesEnter IOPS / IOCS
output_iops / output_iocsbytesOutput IOPS / IOCS
input_validboolI received an offer from Group I this round
output_validboolWhether Q has been written this round and delivered to the controller (disconnected or not sent = False)
input_data_goodboolReceived and entered IOPS All GOOD
output_data_goodboolWritten and outputted IOPS All GOOD
output_consumedboolOutput: All IOCS GOOD
all_goodboolAll three of the above are true.

Example:

if not svc.io_status.all_good:
print(svc.io_status)

Call the Police​

GroupingPropertiesTypeNote
Countingalarm_countintTotal number of event alerts. From the same source alarms as
Countingcritical_alarm_countintNumber of Critical Alarms
Listalarmslist[PnSServiceAlarm]Current activity alerts. Empty list = No activity alerts; not a failure.
Listalarm_historylist[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
PropertiesTypeNote
idstrAlert ID (e.g., PnS.LinkDown)
severitystrSeverity: Info / Warning / Error / Critical
messagestrAlert Message
occurred_atdatetime | NoneTime of the most recent occurrence. Parsing failed: None
countintNumber of occurrences (≥1)
sourcestrSource

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)