void banen(int tilstand);
int konverter(int tilstand);
int main()
{
clk ur;
int tilstand = 5;
OpenPortTalk();
int sek = 0; //husk sek = milisekunder!
outp(0x378, 0);
while(tilstand < 13 && tilstand > 0)
{
tilstand = 2;
sek = 600;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);
tilstand = 3;
sek = 2400;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);
tilstand = 5; //brems
sek = 100;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);
tilstand = 1;
sek = 2500;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);
tilstand = 8; //brems
sek = 75;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);
tilstand = 5; //brems
sek = 100;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);
tilstand = 14;
banen(tilstand);
outp(0x378, konverter(tilstand));
outp(0x378, 0);
cout << "\tBilens tilstand er: " << tilstand;
}
ClosePortTalk();
return 0;
}
void banen(int tilstand)
{
int a=1;
cout << endl;
cout << " BANEN:" << endl;
for(int g1 = 1; g1 < 4; g1++) {
cout << " ----------------------------" << endl;
cout << " | | | |" << endl;
cout << " ";
for(int h1 = 1; h1 < 4; h1++) {
if(g1 == 1 && h1 == 1) {
cout << "| " << " " << "VF" << " " << " ";
}
if(g1 == 1 && h1 == 2) {
cout << "| " << " " << "F " << " " << " ";
}
if(g1 == 1 && h1 == 3) {
cout << "| " << " " << "HF" << " " << " ";
}
if(g1 == 2 && h1 == 1) {
cout << "| " << " " << "V " << " " << " ";
}
if(g1 == 2 && h1 == 2) {
cout << "| " << " " << " " << " " << " ";
}
if(g1 == 2 && h1 == 3) {
cout << "| " << " " << "H " << " " << " ";
}
if(g1 == 3 && h1 == 1) {
cout << "| " << " " << "VT" << " " << " ";
}
if(g1 == 3 && h1 == 2) {
cout << "| " << " " << "T " << " " << " ";
}
if(g1 == 3 && h1 == 3) {
cout << "| " << " " << "HT" << " " << " ";
}
}
cout << "|" << endl;
cout << " ";
for(int i1 = 1; i1 < 4; i1++) {
if(tilstand == a) {
cout << "| " << " x";
a++;
} else {
if(a < 10) {
cout << "| " << " " << a++;
} else {
cout << "| " << " " << a++;
}
}
}
cout << "|" << endl;
}
cout << " ----------------------------" << endl;
cout << endl;
}
int konverter(int tilstand) {
if(tilstand == 3) {
return 49;
}
if(tilstand == 2) {
return 1;
}
if(tilstand == 1) {
return 17;
}
if(tilstand == 6) {
return 48;
}
if(tilstand == 5) {
return 0;
}
if(tilstand == 4) {
return 16;
}
if(tilstand == 9) {
return 51;
}
if(tilstand == 8) {
return 3;
}
if(tilstand == 7) {
return 19;
}
}