Skip to main content

Diagnosis

By reading device.Diagnostics diagnostics and alarms (DiagSnapshot / Alarms still available, 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 .

This page covers only diagnostic snapshots,IOPS /IOCS , and alerts.

Feature Overview​

FeaturesNote
Diagnostic SnapshotLinks, Frame Count, Watchdog, Jitter, Alarm Monitoring
IOPS / IOCSProcess Data Quality: Is the Data GOOD or BAD?
On-Site Issue ComparisonSelect a field based on symptoms
Call the PoliceEvent List / History / Confirm
User RecordsUser Area Record Table (Records)
ResetCommunication Reset / Factory Reset

Diagnostic Snapshot​

CategoryPropertyTypeAccessDescription
AvailabilityOkboolread-onlyChecks whether the device is available. false = Device is not RUN; read Message
SharedMemoryMappedboolread-onlyWhether the process data is ready
Messagestringread-onlyReason for unavailability; empty when available
TimestampDateTimeRead-onlySnapshot creation time
LinksStatestringread-onlyOperational ST description
LinkUpboolread-onlyIs the network interface link up?
Connectedboolread-onlyWhether the cycle data is normal
ActiveIocrCountuintread-onlyNumber of active IO connections
IocrActiveuintread-onlyIO link activation bitmap
IocrHealthyuintread-onlyIO link health bitmap
CountingHeartbeatulongread-onlyHeartbeat count
CycleCounterulongread-onlyCycle counter
LastErrorulongread-onlyLast fault code (0 = none)
RxFrames / TxFramesulongread-onlyTotal number of received / transmitted frames
RxRtFrames / TxRtFramesulongread-onlyReceive / transmit RT cycle frames
DroppedFramesulongread-onlyDropped frames
InvalidFramesulongread-onlyInvalid frames
WatchdogTripsulongread-onlyNumber of watchdog timeouts
LastRxTsc / LastTxTsculongread-onlyLast received / transmitted frame TSC
Process AreaInputAreaLengthuintread-onlyInput area length (bytes). The length is determined by a value negotiated with the IO controller and is automatically matched after link
OutputAreaLengthuintread-onlyOutput area length (bytes). The length is determined by a value negotiated with the IO controller and is automatically matched after link
CycleStackCyclesulongread-onlyCycle count
StackFramesRx / StackFramesTxulongread-onlyReceive / Transmit Frames
StackMissedTicksulongread-onlyMissed ticks
StackMaxJitterUsulongread-onlyMaximum jitter (microseconds)
Alarm MonitoringStackAlarmRxCountulongread-onlyTotal number of alarms received from the controller
StackAlarmTxAckOkulongread-onlyNumber of times the local alarm has been acknowledged
StackAlarmTxAckFailulongread-onlyNumber of local alarm acknowledgment failures
StackAlarmAckPendingulongread-onlyAlarms in transit (0/1)
StackAlarmMaintStateulongread-onlyMaintenance request ST
StackAlarmLastArepuintread-onlyLatest controller alarm: Arep
StackAlarmLastSlotuintread-onlyLast controller alarm: slot
StackAlarmLastSubslotuintread-onlyLatest controller alarm: subslot
StackAlarmLastTypeuintread-onlyLast controller alarm: type
StackAlarmLastSequintread-onlyLast controller alarm: sequence number
StackAlarmLastUsiuintread-onlyLast controller alarm:USI
StackAlarmLastLenuintread-onlyLast controller alarm: load length
faultErrorCodeintread-onlyOriginal fault code value (0 = none)
ErrorCodeEnumPnSRuntimeErrorCoderead-onlyThe enumeration form of the previous item. Unrecognized values are treated as 'Unknown'

DiagSnapshot​

public PnSDiagSnapshot DiagSnapshot { get; }

Retrieves the current diagnostic snapshot once; suitable for interface refreshes and logging. If the device has not yet booted Ok == false, a "read Message" operation is not considered an error.

Return value:

  • PnSDiagSnapshot — Diagnostic Data Snapshot

Stop-loss PnSServiceException.

Example:

PnSDiagSnapshot snap = device.DiagSnapshot;
if (!snap.Ok)
{
Console.WriteLine(snap.Message);
return;
}

Console.WriteLine(snap.LinkUp ? "Up" : "Down");
Console.WriteLine(snap.Connected ? "周期交换正常" : "未建立");
Console.WriteLine($"帧: {snap.RxFrames} / {snap.TxFrames}");
Console.WriteLine($"看门狗: {snap.WatchdogTrips}");

IOPS / IOCS​

IoStatus​

public PnSIoStatus IoStatus { get; }

Each process data byte corresponds to a ST byte: 0x80 = GOOD, 0x00 = BAD. If the link is lost, all ST bytes are set to BAD; GOOD is never reported. If the process has not started or cannot be read, the return value is PnSIoStatus.Empty(all criteria met false), and no exception is thrown. device.Diagnostics.IoStatus This data is the same as that of this property.

Return value:

  • PnSIoStatus — IOPS / IOCS Snapshot
CategoryPropertyTypeAccessDescription
ST BytesInputIops / InputIocsbyte[]read-onlyZone I: Provided by the controller / Returned after consumption by this device. Returns a copy; modifications do not affect this object
OutputIops / OutputIocsbyte[]read-onlyQ-zone: Provided by this device / Reported after consumption by the controller
CriteriaInputValid / OutputValidboolread-onlyIn this round, a message was received from Zone I / a message was written to Q and delivered to the controller (cable break or failure to send = false)
InputDataGoodboolread-onlyI has been received and all IOPS inputs are GOOD
OutputDataGoodboolread-onlyQ has been written and all IOPS outputs are GOOD
OutputConsumedboolread-onlyOutput: All IOCS GOOD (controller has consumed)
AllGoodboolread-onlyinput variable (VAR_INPUT) valid + output variable (VAR_OUTPUT) valid + Output consumed
FactoryPnSIoStatus.EmptyPnSIoStatusRead-onlyEmpty ST (not powered on / cannot be read). All criteria are false

Example:

PnSIoStatus io = device.IoStatus;
if (!io.AllGood)
{
Console.WriteLine(io);
if (!io.InputDataGood)
Console.WriteLine("控制器送来的数据不可用");
}

On-Site Issue Comparison​

On-site SymptomsSee which fields
The Ethernet cable isn't plugged in properly.DiagSnapshot.LinkUp
Is the cycle data available?DiagSnapshot.Connected
The watchdog keeps jumpingDiagSnapshot.WatchdogTrips
Frames are being droppedDroppedFrames + InvalidFrames
Is the cycle stable?StackMaxJitterUs + StackMissedTicks
Controller alarm not clearedStackAlarmAckPending / StackAlarmTxAckFail
Does this machine have a motion alarm?Alarms / AlarmCount

Call the Police​

CategoryPropertyTypeAccessDescription
CountingAlarmCountintread-onlyTotal number of active alarms. Derived from Alarms
CriticalAlarmCountintread-onlyNumber of critical alarms
arrayAlarmsList<PnSAlarmItem>Read-onlyCurrent active alerts. An empty array means there are no active alerts; this does not indicate a failure
AlarmHistoryList<PnSAlarmItem>Read-onlyHistory (last 500 entries, sorted by time in ascending order). Empty array = no history

The old fault-handling method has been removed and replaced with the Alarms / property AlarmHistory. A failure is thrown PnSServiceException.

Alarms​

public List<PnSAlarmItem> Alarms { get; }

Current activity alert. If there are no activity alerts, an empty list is returned; this does not indicate a failure.

Return value:

  • List<PnSAlarmItem> — array of Event Alerts

Example:

foreach (PnSAlarmItem a in device.Alarms)
Console.WriteLine(a.ToString());

AlarmHistory​

public List<PnSAlarmItem> AlarmHistory { get; }

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.

Return value:

  • List<PnSAlarmItem> — History array

Example:

foreach (PnSAlarmItem a in device.AlarmHistory)
Console.WriteLine($"{a.OccurredAt:s} {a.Severity} {a.Message}");

AcknowledgeAlarm​

public void AcknowledgeAlarm(string id)

Confirm an active alert. The ID is taken from Alarms.

Parameters:

  • id (string) — Alert ID. Throws an exception if the string is empty ArgumentException; throws an exception if this ID does not exist. PnSServiceException

Example:

device.AcknowledgeAlarm("PnS.LinkDown");

AcknowledgeAllAlarms​

public int AcknowledgeAllAlarms()

Confirm all activity alarms.

Return value:

  • int — Number of confirmed events (0 = no active alarms)

Example:

int n = device.AcknowledgeAllAlarms();
PnSAlarmItem
PropertiesTypeNote
IdstringAlert ID (e.g., PnS.LinkDown)
SeveritystringSeverity: Info / Warning / Error / Critical
MessagestringAlert Message
OccurredAtDateTimeTime of the most recent occurrence
CountintNumber of occurrences (≥1)
SourcestringSource

User Records​

Records​

public PnSUserRecords Records { get; }

Retrieve the user area record table (Index 0x0000–0x7FFF). Missing fields substitution value to 0 or empty; no values are fabricated. If no records are found, an empty table is returned; this does not indicate a failure. device.Diagnostics.Records The data is the same as this property.

In this tableNone I&M Records

User Area Records (0x0000–0x7FFF) and I&M (0xAFF0–0xAFF4) areTwo Different Index Spaces, involving two different endpoints: This property read operation /api/recordsonly overwrites the user area; I&M in ImData (/api/im).

Don't treat the two endpoints as a single table—you won't find them by Records looking through the I&M index.

Failure Exception PnSServiceException: Service unreachable ServiceUnreachable(server response not 200) NativeError(includes server response errorCode).

Return value:

  • PnSUserRecords — Record Sheet

Example:

PnSUserRecords recs = device.Records;
foreach (PnSUserRecord r in recs.Records)
Console.WriteLine(
$"slot {r.Slot}/{r.Subslot} index 0x{r.Index:X4} len {r.Length} {r.DataHex}");
PnSUserRecords
PropertiesTypeNote
RecordsPnSUserRecord[]Number of records (empty = no records; this does not indicate a failure)
CountintServer-side count (missing fields are set to 0; values are not padded to match the array length)
TimestampDateTimeSnapshot creation time (field missing DateTime.MinValue)
PnSUserRecord
PropertiesTypeNote
SlotushortBay
Subslotushortsubslot
IndexushortRecords Index
LengthushortNumber of data bytes
DataHexstringHexadecimal data (an empty string if the field is missing)

Reset​

ResetDevice()​

public void ResetDevice(string mode)

Reset the IO Device. Use the server's existing start/stop state machine without terminating the server process.

modeBehavior
"communication"Soft Stop and Restart, with Application Parameter Records Retained
"factory"After deletion, the system restarts from scratch, and application parameter records are cleared.

This method is not responsible for IP resetting the communication parameters; this is still triggered DCP ResetToFactory by the controller.

Parameters:

  • mode (string) — "communication" or "factory". An empty string or any other value results in an exception. ArgumentException

Failure: Service Unreachable / Server Rejected PnSServiceException(with "server" in the message errorCode). This is a slow operation (internal shutdown/destruction followed by a restart, which can take several seconds); do not mistake it for a failure.

Example:

device.ResetDevice("communication");
Do not reset while process data is still being exchanged.

If you reset while the controller is still exchanging data in a cycle, the controller will lose the station link and the diagnostic screen will flash. Wait until the link is disconnected before proceeding.