Skip to main content

Diagnosis

By reading device.getDiagnostics() diagnostics and alarms (getDiagSnapshot() / getAlarms() still available).​

Use in conjunction with the event

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​

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

Diagnostic Snapshot​

CategoryMembersTypeNote
AvailabilityisOk()booleanCheck if diagnostics are available. false = Device is not running; reading... getMessage()
AvailabilityisSharedMemoryMapped()booleanIs the process data ready?
AvailabilitygetMessage()StringReason for unavailability; empty when available
AvailabilitygetTimestamp()StringSnapshot Moment. Missing fields are empty.
LinkgetState()StringOperational Status Copy
LinkisLinkUp()booleanIs the network card link up?
LinkisConnected()booleanAre the cycle data normal?
LinkgetActiveIocrCount()longNumber of active IO connections
LinkgetIocrActive() / getIocrHealthy()longIO Connection Activation / Health Bitmap
CountinggetHeartbeat() / getCycleCounter()longHeartbeat / Cycle Count
CountinggetLastError()longRecent error codes (0 = None)
CountinggetRxFrames() / getTxFrames()longTotal Number of Frames Received / Sent
CountinggetRxRtFrames() / getTxRtFrames()longReceive / Transmit RT Cyclic Frame
CountinggetDroppedFrames() / getInvalidFrames()longDiscarded / Illegal Frame
CountinggetWatchdogTrips()longNumber of watchdog timeouts
CountinggetLastRxTsc() / getLastTxTsc()longMost Recent Received / Sent Frames TSC
Process AreagetInputAreaLength() / getOutputAreaLength()longI / 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.
CyclegetStackCycles()longCycle Counting
CyclegetStackFramesRx() / getStackFramesTx()longReceive / Transmit Frame
CyclegetStackMissedTicks()longA Missed Beat
CyclegetStackMaxJitterUs()longMaximum Jitter (microseconds)
Alarm MonitoringgetStackAlarmRxCount()longTotal Number of Alarms Received from the Controller
Alarm MonitoringgetStackAlarmTxAckOk() / getStackAlarmTxAckFail()longThe alarm on this machine has been acknowledged / Acknowledgment failed
Alarm MonitoringgetStackAlarmAckPending()longIn-Transit Alerts (0/1)
Alarm MonitoringgetStackAlarmMaintState()longMaintain Request Status
Alarm MonitoringgetStackAlarmLastArep() etc.longRecently, the controller has been issuing the following alerts: Arep / Slot / Subslot / Type / Seq / Usi / Len
ErrorgetErrorCode()intOriginal error code value (0 = None)
ErrorgetErrorCodeEnum()PnSRuntimeErrorCodeEnumeration 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 SymptomsSee which fields
The Ethernet cable isn't plugged in properly.getDiagSnapshot().isLinkUp()
Is the cycle data available?getDiagSnapshot().isConnected()
The watchdog keeps jumpinggetDiagSnapshot().getWatchdogTrips()
Frames are being droppedgetDroppedFrames() + getInvalidFrames()
Is the cycle stable?getStackMaxJitterUs() + getStackMissedTicks()
Controller alarm not clearedgetStackAlarmAckPending() / 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.

CategoryMembersTypeNote
Status BytegetInputIops() / getInputIocs()byte[]Zone I: Provided by the controller / Returned after use by this device. Copies; modifications do not affect this object.
Status BytegetOutputIops() / getOutputIocs()byte[]Section Q: Returns after use of this device / controller
CriterionisInputValid() / isOutputValid()booleanWhether I has been received this round / whether Q has been written and delivered to the controller (disconnected or not sent = false)
CriteriaisInputDataGood()booleanReceived an "I" and entered — all IOPS GOOD
CriteriaisOutputDataGood()booleanHave written Q and the output is all IOPS GOOD
CriteriaisOutputConsumed()booleanOutput: All IOCS GOOD (controller has consumed)
CriteriaisAllGood()booleanInput Valid + Output Valid + Output Consumed
FactoryPnSIoStatus.getEmpty()Static MethodsEmpty 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
PropertiesTypeNote
getId()StringAlert ID (e.g., PnS.LinkDown)
getSeverity()StringSeverity: Info / Warning / Error / Critical
getMessage()StringAlert Message
getOccurredAt()OffsetDateTimeTime of the most recent occurrence. Parsing failed: null
getCount()intNumber of occurrences (≥1)
getSource()StringSource

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().

CategoryMembersTypeNote
I&M0getVendorId() / getDeviceId()intVendor / Device ID
I&M0getOrderId()StringOrder Number
I&M0getSerialNumber()StringSerial Number
I&M0getHardwareRevision() / getSoftwareRevision()StringHardware / Software Version
IdentitygetStationName()StringSite Name
IdentitygetProductName()StringProduct Name
AbilitygetImSupported()StringEnabled 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.
AbilityisIm14Supported()booleanI&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–4getIm1TagFunction() / getIm1TagLocation()StringFunction Label / Installation Location
I&M1–4getIm2Date()StringDate
I&M1–4getIm3Descriptor()StringDescription
I&M1–4getIm4SignatureHex()StringSignature (Hexadecimal)
EngineeringgetImNote()StringI&M Caliber Explanation
EngineeringgetProjectOrderNumber()StringEngineering Order Number
EngineeringgetProjectHardwareRelease() / getProjectSoftwareRelease()StringEngineering 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) — communication Communication reset (soft stop and restart; records retained); factory Factory reset (completely reset after destruction; records cleared)

Example:

device.resetDevice("communication");