Präsentation herunterladen
Die Präsentation wird geladen. Bitte warten
Veröffentlicht von:Hrodgar Schlipf Geändert vor über 10 Jahren
1
1
2
2 Informatik 3 Praktikum 1.Heizobjekt und Toggles 2.Heizungssteuerungs- Automat 3.Testaufbau 4.Simulatoren 5.Histogramm 6.Grafikausgabe (Haus) 7.Bezier mit MFC 8.Prozesse 9.Parallele Prog. I 10.Parallele Prog. II Vorlesung 1.Software-Engineering Grundlagen Softwaremodell Das V-Modell 2.Windows Applikationen Windows 32 API Fensterorientierte Applikationen 3.Parallele Programme Prozesse, Threads Kommunikation zwischen parallelen Programmen Konflikte
3
3 Grundlagen Einführung Modularisierung Interpretative Implementierung von Automaten
4
4 Automaten nicht interpretativ (aus IN1) Implementierung in der Programmstruktur
5
5 Interpretative Implementierung heißt: Umsetzung Ablauflogik in Daten (statt in ein Programm) Verwendung eines für beliebige Anwendungen benutzbaren Interpreter-Programms, das auf diesen Daten arbeitet
6
6 Jetzt: Automaten interpretativ
7
7 Beispielautomat: Dualzahlkonvertierer
8
8 Realisierung:
9
9 Automatentabelle struct AutoTabEintr AutoTab[] = { { ZiffLesen,Inp0, ZiffLesen,Update0, &ConvObj }, { ZiffLesen,Inp1, ZiffLesen,Update1, &ConvObj }, { ZiffLesen,InpEq, Ende, Output, &IOObj }, { Fehler, Reset, ZiffLesen,ResetAction, &ConvObj } }; // per Konvention: Noop==0 und Fehler== -1 enum Events { Inp1, Inp0, InpEq, Reset }; enum Actions { Noop=0, Update0, Update1, Output, ResetAction }; enum Zustaende { ZiffLesen, Ende, Fehler=-1 };
10
10 Verwendung der ISA-Relation class AutoClient { public: virtual void Action(short sActNr) {}; }; class AutoClient { public: virtual void Action(short sActNr) {}; }; class InputOutput: public AutoClient {... void Action(short sActNr); }; class InputOutput: public AutoClient {... void Action(short sActNr); }; class Converter: public AutoClient {... void Action(short sActNr); }; class Converter: public AutoClient {... void Action(short sActNr); }; Is a Spezialisierung
11
11 Verwendung virtueller Funktionen struct AutoTabEintr {public: short sZausg, sEvent, sZfolge, sAction; AutoClient *pAutoClient; }; struct AutoTabEintr {public: short sZausg, sEvent, sZfolge, sAction; AutoClient *pAutoClient; }; struct AutoTabEintr AutoTab[] = { { ZiffLesen,Inp0, ZiffLesen,Update0, &ConvObj }, { ZiffLesen,Inp1, ZiffLesen,Update1, &ConvObj }, { ZiffLesen,InpEq,Ende, Output, &IOObj }, { Fehler, Reset,ZiffLesen,ResetAction,&ConvObj } }; struct AutoTabEintr AutoTab[] = { { ZiffLesen,Inp0, ZiffLesen,Update0, &ConvObj }, { ZiffLesen,Inp1, ZiffLesen,Update1, &ConvObj }, { ZiffLesen,InpEq,Ende, Output, &IOObj }, { Fehler, Reset,ZiffLesen,ResetAction,&ConvObj } };... pTable[i].pAutoClient->Action(pTable[i].sAction);... pTable[i].pAutoClient->Action(pTable[i].sAction);...
12
12 Übersicht
13
13 IOObj: InputOutput cin>>ch; switch(ch) { case '0': sZust=pAutomat->Event(Inp0); break; case '1': sZust=pAutomat->Event(Inp1); break; case '=': sZust=pAutomat->Event(InpEq); break; default: cout<<"Eingabefehler"; break; } if(sZust==Ende) exit(0); if(sZust==Fehler) { cout<<"Falsche Eingabefolge, Reset"; pAutomat->Event(Reset); }
14
14 ConvObj: Converter void Converter::Action(short sActNr) { switch(sActNr) { case Update0: nWert *= 2; break; case Update1: nWert *= 2; nWert += 1; break; case ResetAction: nWert = 0; break; default: break; } int nWert;
15
15 IOObj: InputOutput void InputOutput::Action(short sActNr) { if(sActNr!=Output) cout<<"InputOutput: falsche Aktion "<<sActNr; else cout GetResult()<<" (dezimal)\n"; }
16
16 DualAuto: Automat for(int i=0; i<sAnzTab; i++) if((pTable[i].sZausg==sZustand)&& (pTable[i].sEvent==sEvNo)) { if(pTable[i].sAction != Noop) pTable[i].pAutoClient->Action(pTable[i].sAction); sZustand = pTable[i].sZfolge; return sZustand; } sZustand = Fehler; return sZustand;
17
17 Gesamtprogramm h cpp Hauptprogramm MnA2To10.CPP MsDev alle cpp h
Ähnliche Präsentationen
© 2024 SlidePlayer.org Inc.
All rights reserved.