public static bool HasError(this IList <BacnetPropertyValue> propertyValues, BacnetErrorCodes error) { return(propertyValues .SelectMany(p => p.value) .Where(v => v.Tag == BacnetApplicationTags.BACNET_APPLICATION_TAG_ERROR) .Any(v => v.As <BacnetError>().error_code == error)); }
/*****************************************************************************************************/ static void handler_OnWritePropertyRequest(BacnetClient sender, BacnetAddress adr, byte invoke_id, BacnetObjectId object_id, BacnetPropertyValue value, BacnetMaxSegments max_segments) { lock (device) { BaCSharpObject bacobj = device.FindBacnetObject(object_id); if (bacobj != null) { ErrorCodes error = bacobj.WritePropertyValue(sender, adr, value, true); if (error == ErrorCodes.Good) { sender.SimpleAckResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id); } else { BacnetErrorCodes bacEr = BacnetErrorCodes.ERROR_CODE_OTHER; if (error == ErrorCodes.WriteAccessDenied) { bacEr = BacnetErrorCodes.ERROR_CODE_WRITE_ACCESS_DENIED; } if (error == ErrorCodes.OutOfRange) { bacEr = BacnetErrorCodes.ERROR_CODE_VALUE_OUT_OF_RANGE; } sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_WRITE_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_DEVICE, bacEr); } } else { sender.ErrorResponse(adr, BacnetConfirmedServices.SERVICE_CONFIRMED_READ_PROPERTY, invoke_id, BacnetErrorClasses.ERROR_CLASS_OBJECT, BacnetErrorCodes.ERROR_CODE_UNKNOWN_OBJECT); } } }
private void m_comm_OnError(BacnetClient sender, BacnetAddress adr, BacnetPduTypes type, BacnetConfirmedServices service, byte invoke_id, BacnetErrorClasses error_class, BacnetErrorCodes error_code, byte[] buffer, int offset, int length) { if (invoke_id == m_wait_invoke_id) { Error = new Exception("Error from device: " + error_class + " - " + error_code); } }
public BacnetError(BacnetErrorClasses errorClass, BacnetErrorCodes errorCode) { error_class = errorClass; error_code = errorCode; }
public BacnetError(uint errorClass, uint errorCode) { error_class = (BacnetErrorClasses)errorClass; error_code = (BacnetErrorCodes)errorCode; }
public void ErrorResponse(BacnetAddress adr, BacnetConfirmedServices service, byte invoke_id, BacnetErrorClasses error_class, BacnetErrorCodes error_code) { Trace.WriteLine("Sending ErrorResponse ... ", null); EncodeBuffer b = GetEncodeBuffer(m_client.HeaderLength); NPDU.Encode(b, BacnetNpduControls.PriorityNormalMessage, adr.RoutedSource, null, DEFAULT_HOP_COUNT, BacnetNetworkMessageTypes.NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, 0); APDU.EncodeError(b, BacnetPduTypes.PDU_TYPE_ERROR, service, invoke_id); Services.EncodeError(b, error_class, error_code); m_client.Send(b.buffer, m_client.HeaderLength, b.offset - m_client.HeaderLength, adr, false, 0); }
private void OnError(BacnetClient sender, BacnetAddress adr, BacnetPduTypes type, BacnetConfirmedServices service, byte invokeId, BacnetErrorClasses errorClass, BacnetErrorCodes errorCode, byte[] buffer, int offset, int length) { if (invokeId != _waitInvokeId) { return; } Error = new Exception("Error from device: " + errorClass + " - " + errorCode); }
public BacnetError(BacnetErrorClasses error_class, BacnetErrorCodes error_code) { this.error_class = error_class; this.error_code = error_code; }