There are several types of errors that can occur in relation to live mapping, and they are treated differently. It is important to understand what happens in various situations, so that you can write code that behaves properly.
In the list below, we have tried to sort the possible types of errors by severity, starting with the most severe errors first.
- Errors during object mapping. These are errors that are encountered when you are associating your objects (mapping targets) with mapping sources, usually by means of calling one of the Map method overloads on the mapper object. Typically, these errors are cause by improper usage of mapping attributes, such that the mapping cannot be created at all. They are basically coding errors, and are reported by throwing a MappingException during the mapping (the Map method call).
- Operation execution errors. These are logical errors that happen when you invoke an operation on the mapper, such as Read, Write, Get or Subscribe. Operation execution errors are similar to the errors encountered during object mapping, except that they could not have been discovered earlier. For example, you may have a conflicting combination of attributes that does not allow the OPC Write operation be performed. Operation execution errors are basically coding errors as well, and are reported by throwing an ExecutionException from the operation method invoked.
-
Update failures. The update failure means that a mapping target could not be updated with a new value. Each update failure is indicated by an UpdateFailure event raised on the mapper object. The event notification contains an Exception indicating the cause of the update failure, and a reference to the mapping source. You can hook your event handler to this event if you need some action be performed in such case.
There may be various reasons for update failures; below are the common specific causes.
- Target access errors. They happen when the live mapping encounters a failure accessing your objects (mapping targets). For example, setting or getting a property on your object may throw an exception, and such exception will be caught. Target access error is represented by an instance of TargetAccessException in an update failure.
- Validation errors. These are errors caused by invalid values passed to or from the mapping target. For example, you may be attempting to write a null reference DAVtq object, a null timestamp, or a null quality. Validation errors are represented by an instance of ValidationException in an update failure. Note that these are validations on the client side, not any validations made by the OPC server.
- Mapping source problems. These are errors related to the actual mapping sources, such as OPC items or OPC properties. For example, the OPC server may be shut down, or the item ID might have changed name and is no longer accessible. Mapping source problems may actually be THE important errors for you to handle, but they have the least severity as far as the live mapping is concerned, because they are treated as just another data being mapped (and sent to your application). There are mapping kinds (see Mapping Kinds) such as Exception or ErrorId that allow you to set up members on your objects that will receive error information in case of mapping source problems.
See Also