Lahman, how ya doing?
- From: glhansen@xxxxxxxxxxxxxxxxxxxxx (Gregory L. Hansen)
- Date: Sun, 24 Apr 2005 19:48:53 +0000 (UTC)
Some time ago we hit many keys concerning OOP, and discussed a simulation
of a thermal control system. I've been playing with that in the last few
days. Yes, it's taken me this long to get a round tuit. Turned out I had
to do some pretty heavy review of the basics, too. But I've gotten to a
basic design that I'm happy with, and I'm not sure if it's quite what
you'd had in mind, but it was influenced by it. And I just wanted to let
you know, sort of as appreciation for the time you'd spent. I think my
simple main() pretty much sums it up.
#include "control.h"
int main()
{
ControlBlock c1(1), c2(2), c3(3);
Timer t1(3); // trigger every 3 seconds
t1.add_task(&c1);
t1.add_task(&c2);
DoubleTimer t2(5,7); // event1 every 5 s, event2 every 7
t2.add_task(&c3);
Clock clock; // default 1 tick per second
clock.add_timer(&t1);
clock.add_timer(&t2);
for (int i = 0; i < 10; i++)
clock.tick();
return 0;
}
This isn't really "real" yet-- e.g. ControlBlock has some diagnostic
members (the parameters are just to give each a unique identity when they
report), and will become the ancestor to derived classes, including a
chart recorder that saves as a data point an average and standard
deviation over a given time. That's what DoubleTimer is for, because
there will be a sampling time and an averaging time, similarly to the
apparatus. But it reflects what I want "real" to be. There'll be
separate timers for the analog peices, the digital controllers, the chart
recorders, and the switch that turns the beam on and off-- four total,
each with one or more tasks, or control blocks, to manage. All on one
clock.
I'd started with a Timer class that keeps the total time separately in
each individual instantiation, but I thought that wasn't quite logically
representative since there's only one time. I thought it still wasn't
worthwhile changing that until I realized that main() was pretty much
doing what I'd have Clock doing anyway.
Ultimately I'd like to "fit" control parameters to find ideal control. So
select a set of PID parameters, generate a curve, fit the curve to a
model, test the model against what we'd like the control to be, and repeat.
Anyway, just checking in. Thanks for the help.
--
"Awareness means not just a vague, comfortable, fuzzy feeling. It means
explicit knowledge of current conditions." -- NBSR Radiation Safety
Training
.
- Follow-Ups:
- Re: Lahman, how ya doing?
- From: cstb
- Re: Lahman, how ya doing?
- From: H. S. Lahman
- Re: Lahman, how ya doing?
- From: Robert C . Martin
- Re: Lahman, how ya doing?
- Prev by Date: Re: author of this article?
- Next by Date: Re: author of this article?
- Previous by thread: author of this article?
- Next by thread: Re: Lahman, how ya doing?
- Index(es):
Relevant Pages
|
Loading