|
-
Feb 3rd, 2016, 04:06 AM
#1
Thread Starter
Frenzied Member
Developing a component, some questions
Hi!
We are currently developing a vb.net component (class library) that wraps a serialport that communicates to some hardware through modbus. The basic features of this api should be:
1) Provide a set of API functions to invoke certain operations on the hardware (startprocess, stopprocess, changefrequency, getcurrenttemperature)
2) Provide continuous error monitoring and error reporting.
We have 1) already implemented, and we have a rather large set of custom exceptions designed and implemented to catch errors in serial port, modbus etc.
The trick is #2, continous error monitoring. The hardware has built in error monitoring, and writes certain registrys whenever something is wrong, for example the temperature is too high. It then writes an error code and an error status. The component should poll this registry every 1 second and report back if there is an error, then we should handle this and maybe stop the process, change the UI of the calling application, log the error etc.
What is the best way to implement this? Our idea is to have two methods on the API
await myAPI.StartErrorMonitoring()
await myAPI.EndErrorMonitoring()
The first method starts an async task and also exposes an event EquipmentErrorEvent. The caller subscribes to this event, and whenever an error has occured, gets notified through an event handler and can take action. We have numerous issues with this:
* Should the API keep raising events or what should happen after an error event has been raised the first time? Should the API raise an error event for the exact same error?
* If we perform some kind of action (ChangeProcess) and this raises an exception due to a hardware error, we get both an exception from ChangeProcess and an event from the monitoring process. We get a lot of error reporting to orchestrate. Are we making things too complicated for us?
* Should we use the "old" eventhandlers for this? I have read that it doesn't work too well with async/await
Do please provide some input on the current design of the component, and if it can be simplified further?
/H
Last edited by MrNorth; Feb 3rd, 2016 at 04:17 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|