To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 884
883  |  885
Subject: 
Event dispatch
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Sun, 17 Dec 2000 17:54:38 GMT
Viewed: 
1998 times
  
In the SDK2 documentation for the new Lego-Scripting language events are used
as follows:


sensor Opto on 2
Opto is light as percent

event gloomy when Opto is 0..20
event dull when Opto is 30 .. 40
event intense when Opto is 80 .. 100

main {
    start lightWatcher
    trigger gloomy, dull, intense     // initial level trigerring ?????
}

watcher lightWatcher monitor gloomy, dull, intense {
    if gloomy { "stack" }
    if dull { "stack" }
    if intense {"stack" }
}

How would this translate to NQC?

The first part seems to be clear, but I'm not quite shure.

#define GLOOMY 0
#define DULL 1
#define INTENSE 2
#define OPTO Sensor_2

task main() {
    SetSensot(OPTO, SENSOR_LIGHT);
    SetEvent(GLOOMY,OPTO,EVENT_TYPE_LOW);
    SetEvent(DULL,OPTO,EVENT_TYPE_NORMAL);
    SetEvent(INTENSE,OPTO,EVENT_TYPE_HIGH);

    CalibrateEvent(GLOOMY,0,20,10);    / Is This OK??
    until (EventState(GLOOMY) !=5);
    CalibrateEvent(DULL,30,40,10);
    until (EventState(DULL) !=5);
    CalibrateEvent(INTENSE,80,100,10);
    until (EventState(INTENSE) !=5);

    Start LightWatcher;
}

But what about the event dispatch? Is somethig like this possible?

task LightWatcher() {
    do while true() {
        monitor (EVENT_MASK(GLOOMY) |
                 EVENT_MASK(DULL) |
                 EVENT_MASK(INTENSE) ) {
            / do something
        }
        catch {
            switch ( ?????)  {    / What should be the expression?
                GLOOMY:
                      / perform GLOOMY action
                DULL:
                      / perform DULL action
                INTENSE:
                      / perform INTENSE action
                default:
            }
        }
    }
}


How can I react in LightWatcher to the correct triggering event?
Do I have to write a separate monitorong task  for each event I want do  to
handle in a specific way?

Or can I distinguish between events using EvenState() somehow?
What are the EventStates of Events of  Boolean Events (0/1 or 0/2)?

What happens if we are in a handler and the same or another event fires
again?

TZS



Message has 1 Reply:
  Re: Event dispatch
 
(...) I think the choice of whether to have a single task waiting on multiple events or multiple tasks each servicing a single event depends on the following questions: 1) Is there a single activity that should be happening that gets interrupted by (...) (24 years ago, 17-Dec-00, to lugnet.robotics.rcx.nqc)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR