Subject:
|
Re: Q: Multitasking, and reacting to sensors
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Tue, 6 Feb 2001 14:02:20 GMT
|
Viewed:
|
1983 times
|
| |
| |
In lugnet.robotics.rcx.nqc, Juergen Stuber writes:
> > Can I define a task in the beginning of the program, then run it only
> > under certain circumstances (like light reading <50),
>
> No, it runs all the time (in RCX2 there are events that can
> do this, but they are more complicated to use).
> You just need to use a loop to wait for the circumstances,
> then do what you want to do.
>
> > or at a certain point in the program?
>
> This is what function or subroutines are good for.
Sorry Juergen, but that's not quite right.
You can start and stop tasks as often as you wish to do.
like this
int do_s_s = 0;
int condition = 0;
task main()
{
while (1)
{
if (condition && !do_s_s)
{
start do_something_special;
do_s_s = 1;
}
if (!condition && do_s_s)
{
stop do_something_special;
do_s_s = 0;
}
// do something and modify condition
}
}
task do_something_special ()
{
while (1)
{
// do something very special
}
}
Rainer
|
|
Message has 1 Reply: | | Re: Q: Multitasking, and reacting to sensors
|
| (...) Ok, I have to admit that I was wrong. But I think most of the time it is the easiest solution to start all the tasks at the beginning and have them run in parallel. And if you want to perform some single action within a task use a (...) (24 years ago, 6-Feb-01, to lugnet.robotics.rcx.nqc)
|
Message is in Reply To:
| | Re: Q: Multitasking, and reacting to sensors
|
| Hej Tobias! (...) No, rather you need a While or Until loop. Normal programming languages are different from the RCX code. In RCX code the watchers are running all the time, in NQC you need to program the repetition yourself. A program for simple (...) (24 years ago, 6-Feb-01, to lugnet.robotics.rcx.nqc)
|
9 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|