Diagnosis
By reading device.getDiagnostics() diagnostics and alarms (getDiagSnapshot() / getAlarms() still available).
Recommended for use with Event Handle exceptions rather than polling on your own. Directly reading diagnostic methods is suitable for scenarios such as display UI .
This page covers only diagnostic snapshots,IOPS /IOCS , and alerts.
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: Is the data GOOD or BAD? |
| Call the Police | Event List / History / Confirm |
Diagnostic Snapshot
| Category | Members | Type | Note |
|---|---|---|---|
| Availability | isOk() | boolean | Check if diagnostics are available. false = Device is not running; reading... getMessage() |
| Availability | isSharedMemoryMapped() | boolean | Is the process data ready? |
| Availability | getMessage() | String | Reason for unavailability; empty when available |
| Availability | getTimestamp() | String | Snapshot Moment. Missing fields are empty. |
| Link | getState() | String | Operational Status Copy |
| Link | isLinkUp() | boolean | Is the network card link up? |
| Link | isConnected() | boolean | Are the cycle data normal? |
| Link | getActiveIocrCount() | long | Number of active IO connections |
| Link | getIocrActive() / getIocrHealthy() | long | IO Connection Activation / Health Bitmap |
| Counting | getHeartbeat() / getCycleCounter() | long | Heartbeat / Cycle Count |
| Counting | getLastError() | long | Recent error codes (0 = None) |
| Counting | getRxFrames() / getTxFrames() | long | Total Number of Frames Received / Sent |
| Counting | getRxRtFrames() / getTxRtFrames() | long | Receive / Transmit RT Cyclic Frame |
| Counting | getDroppedFrames() / getInvalidFrames() | long | Discarded / Illegal Frame |
| Counting | getWatchdogTrips() | long | Number of watchdog timeouts |
| Counting | getLastRxTsc() / getLastTxTsc() | long | Most Recent Received / Sent Frames TSC |
| Process Area | getInputAreaLength() / getOutputAreaLength() | long | I / Q zone length (bytes; a zone-length measure, not the true length of the available data). Rebuilt through negotiation with the IO controller; do not hard-code it. |
| Cycle | getStackCycles() | long | Cycle Counting |
| Cycle | getStackFramesRx() / getStackFramesTx() | long | Receive / Transmit Frame |
| Cycle | getStackMissedTicks() | long | A Missed Beat |
| Cycle | getStackMaxJitterUs() | long | Maximum Jitter (microseconds) |
| Alarm Monitoring | getStackAlarmRxCount() | long | Total Number of Alarms Received from the Controller |
| Alarm Monitoring | getStackAlarmTxAckOk() / getStackAlarmTxAckFail() | long | The alarm on this machine has been acknowledged / Acknowledgment failed |
| Alarm Monitoring | getStackAlarmAckPending() | long | In-Transit Alerts (0/1) |
| Alarm Monitoring | getStackAlarmMaintState() | long | Maintain Request Status |
| Alarm Monitoring | getStackAlarmLastArep() etc. | long | Recently, the controller has been issuing the following alerts: Arep / Slot / Subslot / Type / Seq / Usi / Len |
| Error | getErrorCode() | int | Original error code value (0 = None) |
| Error | getErrorCodeEnum() | PnSRuntimeErrorCode | Enumeration of the preceding item. The unrecognized value is UNKNOWN. |
getDiagSnapshot()
public PnSDiagSnapshot getDiagSnapshot()
Retrieves the current diagnostic snapshot once; suitable for interface refreshes and logging. If the device has not yet booted isOk() == false, a "read getMessage()" operation is not considered an error.
Example:
PnSDiagSnapshot snap = device.getDiagSnapshot();
if (!snap.isOk()) {
System.out.println(snap.getMessage());
return;
}
System.out.println(snap.isLinkUp() ? "Up" : "Down");
System.out.println(snap.isConnected() ? "周期交换正常" : "未建立");
System.out.println("帧: " + snap.getRxFrames() + " / " + snap.getTxFrames());
System.out.println("看门狗: " + snap.getWatchdogTrips());
On-Site Issue Comparison
| On-site Symptoms | See which fields |
|---|---|
| The Ethernet cable isn't plugged in properly. | getDiagSnapshot().isLinkUp() |
| Is the cycle data available? | getDiagSnapshot().isConnected() |
| The watchdog keeps jumping | getDiagSnapshot().getWatchdogTrips() |
| Frames are being dropped | getDroppedFrames() + getInvalidFrames() |
| Is the cycle stable? | getStackMaxJitterUs() + getStackMissedTicks() |
| Controller alarm not cleared | getStackAlarmAckPending() / getStackAlarmTxAckFail() |
| Does this machine have a motion alarm? | getAlarms() / getAlarmCount() |
| Can We Trust Process Data? | getIoStatus().isAllGood() |
Process Data Quality
getIoStatus()
public PnSIoStatus getIoStatus()
Each process data byte corresponds to a status byte: 0x80 = GOOD, 0x00 = BAD. If the connection is lost, all status bytes are set to BAD; GOOD is never set. If the process has not started or has failed, the status is returned as is PnSIoStatus.getEmpty(); no exception is thrown.
| Category | Members | Type | Note |
|---|---|---|---|
| Status Byte | getInputIops() / getInputIocs() | byte[] | Zone I: Provided by the controller / Returned after use by this device. Copies; modifications do not affect this object. |
| Status Byte | getOutputIops() / getOutputIocs() | byte[] | Section Q: Returns after use of this device / controller |
| Criterion | isInputValid() / isOutputValid() | boolean | Whether I has been received this round / whether Q has been written and delivered to the controller (disconnected or not sent = false) |
| Criteria | isInputDataGood() | boolean | Received an "I" and entered — all IOPS GOOD |
| Criteria | isOutputDataGood() | boolean | Have written Q and the output is all IOPS GOOD |
| Criteria | isOutputConsumed() | boolean | Output: All IOCS GOOD (controller has consumed) |
| Criteria | isAllGood() | boolean | Input Valid + Output Valid + Output Consumed |
| Factory | PnSIoStatus.getEmpty() | Static Methods | Empty State (Not Started / Unreadable) |
public enum PnSIoxs {
BAD(0x00), // Invalid data
GOOD(0x80) // Data is valid
}
Example:
PnSIoStatus io = device.getIoStatus();
if (!io.isAllGood()) {
System.out.println(io);
if (!io.isInputDataGood())
System.out.println("控制器送来的数据不可用");
}
Call the Police
public int getAlarmCount()
public int getCriticalAlarmCount()
public java.util.List<AlarmItem> getAlarms()
public java.util.List<AlarmItem> getAlarmHistory()
public void ackAlarm(String id)
public int ackAllAlarms()
If there are no events, return an empty list; this is not a failure. Display the most recent 500 entries in ascending chronological order. A failure results in an exception PnSServiceException.
getAlarms()
public java.util.List<AlarmItem> getAlarms()
Current activity alert. If there are no activity alerts, an empty list is returned; this does not indicate a failure.
Example:
for (PnSService.AlarmItem a : device.getAlarms())
System.out.println(a);
getAlarmHistory()
public java.util.List<AlarmItem> getAlarmHistory()
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 (PnSService.AlarmItem a : device.getAlarmHistory())
System.out.println(a.getOccurredAt() + " " + a.getSeverity() + " " + a.getMessage());
ackAlarm(String id)
public void ackAlarm(String id)
Confirm an event alert. The ID is taken from getAlarms(). An empty string or an invalid ID results in a throw PnSServiceException.
Example:
device.ackAlarm("PnS.LinkDown");
ackAllAlarms()
public int ackAllAlarms()
Acknowledges all event alarms. Returns the number of acknowledged alarms (0 = no event alarms).
Example:
int n = device.ackAllAlarms();
AlarmItem
| Properties | Type | Note |
|---|---|---|
getId() | String | Alert ID (e.g., PnS.LinkDown) |
getSeverity() | String | Severity: Info / Warning / Error / Critical |
getMessage() | String | Alert Message |
getOccurredAt() | OffsetDateTime | Time of the most recent occurrence. Parsing failed: null |
getCount() | int | Number of occurrences (≥1) |
getSource() | String | Source |
I&M Identification
getImData()
public ImData getImData()
Device identification. I&M1–I&M3 has been enabled by the native stack and read back accurately; I&M4 is not enabled (IO when the controller has not been written to, the value read is the stack’s factory default). Missing fields remain empty / 0 / false; no fictitious values are used. getImSupported() Returns String, not int; what is read this time depends on isIm14Supported() / getImNote().
| Category | Members | Type | Note |
|---|---|---|---|
| I&M0 | getVendorId() / getDeviceId() | int | Vendor / Device ID |
| I&M0 | getOrderId() | String | Order Number |
| I&M0 | getSerialNumber() | String | Serial Number |
| I&M0 | getHardwareRevision() / getSoftwareRevision() | String | Hardware / Software Version |
| Identity | getStationName() | String | Site Name |
| Identity | getProductName() | String | Product Name |
| Ability | getImSupported() | String | Enabled I&M record sets are concatenated exactly as specified by the native stack mask; when the slave is not running, only I&MM0 is reported. |
| Ability | isIm14Supported() | boolean | I&M1–4 Whether the read operation was successful; if the slave is not running and the data cannot be read, this value is false, and the field is an empty string. |
| I&M1–4 | getIm1TagFunction() / getIm1TagLocation() | String | Function Label / Installation Location |
| I&M1–4 | getIm2Date() | String | Date |
| I&M1–4 | getIm3Descriptor() | String | Description |
| I&M1–4 | getIm4SignatureHex() | String | Signature (Hexadecimal) |
| Engineering | getImNote() | String | I&M Caliber Explanation |
| Engineering | getProjectOrderNumber() | String | Engineering Order Number |
| Engineering | getProjectHardwareRelease() / getProjectSoftwareRelease() | String | Engineering Hardware / Software Versions |
Example:
PnSService.ImData im = device.getImData();
System.out.println(im.getStationName());
System.out.println(im.getOrderId());
User Records
getRecords()
public UserRecords getRecords()
User area records. An empty list is not a failure.
public static final class UserRecord {
public int getSlot() { }
public int getSubslot() { }
public int getIndex() { }
public int getLength() { }
public String getDataHex() { }
}
public static final class UserRecords {
public UserRecord[] getRecords() { }
public int getCount() { }
public String getTimestamp() { }
}
Example:
PnSService.UserRecords recs = device.getRecords();
int n = recs.getCount();
Reset
resetDevice(String mode)
public void resetDevice(String mode)
Reset the device. mode Invalid / Service Denied exception thrown PnSServiceException. This is a slow operation; do not treat it as a failure.
Parameters:
mode(String) —communicationCommunication reset (soft stop and restart; records retained);factoryFactory reset (completely reset after destruction; records cleared)
Example:
device.resetDevice("communication");