// Styring_af_Bil.cpp : Defines the entry point for the console application.
// E
#include
#include "stdio.h"
#include "windows.h"
#include "pt_ioctl.c"
#include "PortTalk_ioctl.h"
#include "f_clk.h"
using namespace std;

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 = 1200;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 3; //drej
sek = 750;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 2; //op
sek = 700;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 3; //drej
sek = 650;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 2; //-------------->
sek = 500;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 5; //brems
sek = 600;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 8; //bak <------------------
sek = 1750;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 9; //drej nedad bakkende
sek = 600;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 2; //op igen
sek = 2000;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 3; //drej
sek = 800;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 2; //------------------>
sek = 400;
banen(tilstand);
outp(0x378, konverter(tilstand));
cout << "\tBilens stilstand er: "<< tilstand;
ur.startClk (sek);

tilstand = 8; //brems
sek = 200;
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; }
}