Kthut lp trình
0101010101010101100001
0101010101010101100001
0101010101010101100001
0101010100101010100101
0101010100101010100101
0101010100101010100101
1010011000110010010010
1010011000110010010010
1010011000110010010010
1100101100100010000010
1100101100100010000010
1100101100100010000010
0101010101010101100001
0101010101010101100001
0101010101010101100001
0101010100101010100101
0101010100101010100101
0101010100101010100101
1010011000110010010010
1010011000110010010010
1010011000110010010010
1100101100100010000010
1100101100100010000010
1100101100100010000010
0101010101010101100001
0101010101010101100001
0101010101010101100001
0101010100101010100101
0101010100101010100101
0101010100101010100101
1010011000110010010010
1010011000110010010010
1010011000110010010010
1100101100100010000010
1100101100100010000010
1100101100100010000010
8/13/2007
y = A*x + B*u;
x = C*x + d*u;
StateController
start()
stop()
LQGController
start()
stop()
Chương 8: Tiếntitưduy lptrình
hướng ₫ốitượng
2
Chương 8: Tiếntitưduy hướng đốitượng
Nidung chương 8
8.1 Đặtvn₫ề
8.2 Giithiuvídchương trình phng
8.3 Tưduy "rt" cổ₫in
8.4 Tưduy hướng hàm
8.5 Tưduy datrên₫ốitượng (object-based)
8.6 Tưduy thcshướng ₫ốitượng
3
Chương 8: Tiếntitưduy hướng đốitượng
8.1 Đặtvn₫ề
„Designing object-oriented software is hard, and designing reusable
object-oriented software is even harder...It takes a long time for
novices to learn what object-oriented design is all about. Exprienced
designers evidently know something inexperienced ones don't...
One thing expert designers know
not
to do is solve every problem from
first principles. Rather, they reuse solutions that have worked for
them in the past. When they find a good solution, they use it again
and again. Such experience is part of what makes them experts.
Consequently, you'll find recurring patterns of classes and
communicating objects in many object-oriented systems. These
patterns solve specific design problems and make object-oriented
design more flexible, elegant, and ultimately reusable...“
Erich Gamma et. al.:
Design Patterns: Elements of Reusable Object-
Oriented Software
, Addison-Wesley, 1995.
4
Chương 8: Tiếntitưduy hướng đốitượng
8.2 Phnmmmôphng kiuFBD
StaticGain Limiter Integrator
Sum Scope
1(t)
Nhimv:
Xây dng phnmm₫ể htr phng thigianthcmt
cách linh hot, mmdo, áp ng ₫ượccácyêucucatng
bài toán cth
Trướcmtchưacnhtrtong dng kiukéothbng
công cụ₫ha
5
Chương 8: Tiếntitưduy hướng đốitượng
8.3 Tưduy rtcổ₫in
// SimProg1.cpp
#include <iostream.h>
#include <conio.h>
#include <windows.h>
void main() {
double K =1,I=0, Ti = 5;
double Hi = 10, Lo = -10;
double Ts = 0.5;
double r =1, y=0, e, u, ub;
cout << "u\ty";
while (!kbhit()) {
e = r-y; // Sum block
u = K*e; // Static Gain
ub = max(min(u,Hi),Lo); // Limiter
I += ub*Ts/Ti; // Integrator state
y = I; // Integrator output
cout << '\n' << u << '\t' << y;
cout.flush();
Sleep(long(Ts*1000));
}
}