locked
Custom Events and custome Event Manager? RRS feed

  • Question

  • Hello everyone,

    I have asked a few questions on here previously and have had excellent feedback, so "THANKS" to a everyone.
    I am building an application to run a film processor I have rebuilt, All the code written so far has been to get the variuos components working:

    Temperature Controllers,
    Level Sensors
    Relay Board etc.

    Now I am trying to pull all the different Classes together to make one app.
    This app needs to do some Pre-Checks before the processing can start... check water level (Level Class) and turn ON water inlet solenoid, wait until water level is at the minimum level, then turn ON recirculation pumps and the temperature controllers (these are PID units that independently monitor the water temp and switch on/off heater elements. I can set the Set-Point and monitor the Current temp via my App).

    Other hardware that needs to be monitored during the film processing cycle are some micro-switches that tell me app the position of a tray that rotates to drain chemistry, then returns to its base position ready for the next chemical. Once film processing begins, then timers will dictate other actions... development time, wash time, polling the ADAC board to check microswitch status etc

    My thought is to create a Custom Event Manager that handles all the custom events fired by the various classes

    All the code examples I can find regarding custom events, all seem to occur "within" one class... I.E. the custom event declaration, raising the custom event and capturing that event.

    I was wondering if it is possible to raise a custom event in one class and capture it in another class?

    I.E. class:levelControl, raises an event levelHi(1) > CustomEvent Class receives the custom event and sends an event to relayBoard class startRecirc(1), relayBoard receives this event and energises the appropriate relays on the relay board and the pumps start (and the Temp Control units are started too)

    Does this sound like a feasible strategy?

    If so, can anyone suggest a code example of the above to get me started?

    Cheers Mark

    Monday, August 20, 2012 10:50 PM

All replies

  • I think you can.

    Set All handlers:

        public class AllHandlers
        {
            public void AEventHandler()
            {
            }
            public void BEventHandler()
            {
            }
        }

    Add the event delegate in your class anywhere.

    Have a nice day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Tuesday, August 21, 2012 11:19 AM
  • Thanks Ghost... I should have mentioned... I am writing this as a one-off app just to get my processor running. I am a newbie to VB (and I'm not enjoying the experience), so I don't understand your reply... especially " add the event delegate". Cheers Mark
    Tuesday, August 21, 2012 11:38 AM