//---------------------------------------------------------------------------
#include <vcl.h>
#include "About_Unit1.h"
#include <stdio.h>
#include <math.h>
#include "cesta.h"
#pragma hdrstop
#include "Krizovatka_Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ComboBox1->ItemIndex = 0;
ComboBox2->ItemIndex = 0;
StringGrid1->Enabled = false;
StringGrid1->Cells[0][0] = "z/do";
for ( int i=1; i < StringGrid1->RowCount; i++ )
{
StringGrid1->Cells[i][0] = i;
StringGrid1->Cells[0][i] = i;
StringGrid1->Cells[i][i] = " ------";
}
vypis_status ("Vyber typ hlavnej a vedlajsej komunikacia a stlac Pouzi");
Iv_grid->Cells[0][0]="Iv";
PageControl1->ActivePage=TabSheet1;
StringGrid2->Visible = false;
// inicializacia premennych :
help = 0;
help_1 = 0;
tb = 2;
zlta = 3;
nova = false;
cislo_planu = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Pouzi_0Click(TObject *Sender)
{
if ( help == 0 )
{
if ( ComboBox1->Text == "MZ 20,5/50 - B1" )
{
if ( ComboBox2->Text == "MO 11,5/40 - C1" )
{
// Pouzi->Enabled = false;
Nova1->Enabled = true;
vypoc_Ip();
vypis_status ("Vypln tabulku a stlac Pouzi");
Label5->Visible = false;
for ( int i=1; i < Iv_grid->RowCount; i++ )
{
Iv_grid->Cells[0][i] = "";
}
help = 1;
StringGrid1->Enabled = true;
StringGrid1->Cells[2][1] = IntToStr(516);
StringGrid1->Cells[3][1] = IntToStr(277);
StringGrid1->Cells[4][1] = IntToStr(253);
StringGrid1->Cells[1][2] = IntToStr(504);
StringGrid1->Cells[3][2] = IntToStr(290);
StringGrid1->Cells[4][2] = IntToStr(252);
StringGrid1->Cells[1][3] = IntToStr(38);
StringGrid1->Cells[2][3] = IntToStr(33);
StringGrid1->Cells[4][3] = IntToStr(129);
StringGrid1->Cells[1][4] = IntToStr(29);
StringGrid1->Cells[2][4] = IntToStr(35);
StringGrid1->Cells[3][4] = IntToStr(136);
}
else vypis ("Nebol vybrany typ vedlajsej komunikacie ! ", 1);
}
else vypis ("Nebol vybrany typ hlavnej komunikacie ! ", 1);
}
else if ( help == 1 )
{
for ( int i=1; i < StringGrid1->ColCount; i++ )
{
for ( int j=1; j < StringGrid1->RowCount; j++ )
{
if ( i != j )
{
matica[i-1][j-1] = StrToInt(StringGrid1->Cells[i][j]);
}
}
}
int sucet = 0;
int max = 0;
// stanovenie Ivi :
for ( int i=1; i < StringGrid1->RowCount; i++ )
{
sucet = 0;
for ( int j=1; j < StringGrid1->ColCount; j++ )
{
if ( i != j )
{
sucet += StrToInt(StringGrid1->Cells[j][i]);
}
}
Iv_grid->Cells[0][i] = IntToStr (sucet);
if ( sucet > max ) max = sucet;
}
// Posudenie kapacity :
if ( hlavna.Ip > max )
{
Label5->Visible = true;
Label5->Caption = "Funkcna skupina a trieda vyhovuju, "+IntToStr(hlavna.Ip)+" > "+IntToStr(max);
TabSheet1->Highlighted = false;
// karta Schema :
TabSheet2->Enabled = true;
Image1->Visible = true;
// karta Navrh svetelnej signalizacie I :
TabSheet3->Enabled = true;
Label6->Enabled = true;
Image2->Visible = true;
Image3->Visible = true;
// karta Navrh svetelnej signalizacie II :
TabSheet4->Highlighted = true;
Pouzi_1->Enabled = true;
Label7->Enabled = true;
Label8->Visible = true;
L1_label->Visible = true;
L1_edit->Visible = true;
L2_label->Visible = true;
L2_edit->Visible = true;
L3_label->Visible = true;
L3_edit->Visible = true;
v1_label->Visible = true;
v1_edit->Visible = true;
v2_label->Visible = true;
v2_edit->Visible = true;
vytvor_fazy();
Pouzi_0->Enabled = false;
vypis_status("Pokracuj na karte Navrh svetelnej signalizacie II - Po zmene hodnot stlac Pouzi");
}
else
{
Label5->Visible = true;
Label5->Caption = "Funkcna skupina a trieda NEVYHOVUJE, "+IntToStr(hlavna.Ip)+" < "+IntToStr(max);
vypis_status ("Vyber typ hlavnej a vedlajsej komunikacia a stlac Pouzi");
help = 0;
}
}
}
//---------------------------------------------------------------------------
int TForm1::vypis(AnsiString vypis, int typ_vypisu)
{
int vrat = 0;
// info :
if ( typ_vypisu == 0 )
{
Application->MessageBox( vypis.c_str(), "Info", MB_OK | MB_ICONINFORMATION | MB_APPLMODAL );
}
// upozornenie :
else if ( typ_vypisu == 1 )
{
Application->MessageBox( vypis.c_str(), "Upozornenie", MB_OK | MB_ICONWARNING | MB_APPLMODAL );
}
// YES NO dialog :
else if ( typ_vypisu == 2 )
{
vrat = Application->MessageBox( vypis.c_str(), "Upozornenie", MB_YESNO | MB_ICONQUESTION | MB_APPLMODAL );
}
return vrat;
}
void TForm1::vypis_status(AnsiString text)
{
StatusBar1->SimpleText = text;
}
// Stanovenie pripustnich int. Ip :
void TForm1::vypoc_Ip(void)
{
if ( ComboBox1->Text == "MZ 20,5/50 - B1" )
{
hlavna.Iz = 2900;
hlavna.kk = 0.8;
hlavna.ks = 0.87;
hlavna.km = 0.96;
hlavna.kb = 0.9;
hlavna.Ip = ceil(hlavna.Iz*hlavna.kk*hlavna.ks*hlavna.km*hlavna.kb);
Label3->Visible = true;
Label3->Caption = "Ip pre hlavnu : "+ IntToStr(hlavna.Ip);
}
if ( ComboBox2->Text == "MO 11,5/40 - C1" )
{
vedlajsia.Ip = 200;
Label4->Visible = true;
Label4->Caption = "Ip pre vedlajsiu : "+ IntToStr(vedlajsia.Ip);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if ( ACol == ARow )
StringGrid1->Options >> goEditing;
else
StringGrid1->Options << goEditing;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Pouzi_1Click(TObject *Sender)
{
if ( help_1 == 0 )
{
L1 = StrToInt( L1_edit->Text );
L2 = StrToInt( L2_edit->Text );
L3 = StrToInt( L3_edit->Text );
v1 = StrToInt( v1_edit->Text );
v2 = StrToInt( v2_edit->Text );
vytvor_pruhy();
tab_medzicasov();
Label9->Enabled = true;
Label10->Enabled = true;
StringGrid2->Visible = true;
priprav_tabulku_2();
help_1 = 1;
vypis_status("V tabulke vypln stlpce : R , S , s1 , s2 , s3. Stlac Pouzi");
}
else
{
stupen_saturacie();
stratove_casy();
TabSheet4->Highlighted = false;
// Stanovenie optimalneho radenia faz :
TabSheet5->Highlighted = true;
Label12->Enabled = true;
c0 = ( 1.5*L + 5 ) / ( 1 - Y );
cn = 1.5*c0;
Label13->Caption = "Optimalna dlzka riadiaceho cyklu : " + FloatToStrF ( c0 ,ffFixed,3,1 ) + " s";
Label13->Visible = true;
Label14->Caption = "Navrhova dlzka zeleneho cyklu : " + FloatToStrF ( cn ,ffFixed,3,1 ) + " s";
Label14->Visible = true;
Label16->Caption = "Minim. dlzka zeleneho signalu zi = 4 s";
Label16->Visible = true;
// ---------------------------------
Label15->Enabled = true;
StringGrid3->Visible = true;
vykonnost_krizovatky();
Pouzi_1->Enabled = false;
}
}
//---------------------------------------------------------------------------
// Navrh schemy krizovatky :
void TForm1::vytvor_pruhy(void)
{
for ( int i=0; i < POC_PRUHOV ; i++ )
{
pruhy[i].cislo = i;
pruhy[i].n = 1;
if ( i < 8 ) pruhy[i].sirka = 3.25;
else pruhy[i].sirka = 3;
// 1 :
if ( i == 0 )
{
pruhy[i].skut_cislo = 0;
pruhy[i].odkial = 1;
pruhy[i].kam = 3;
}
else if ( i == 1 )
{
pruhy[i].skut_cislo = 1;
pruhy[i].odkial = 1;
pruhy[i].kam = 2;
}
else if ( i == 2 )
{
pruhy[i].skut_cislo = 2;
pruhy[i].odkial = 1;
pruhy[i].kam = 2;
}
else if ( i == 3 )
{
pruhy[i].skut_cislo = 3;
pruhy[i].odkial = 1;
pruhy[i].kam = 4;
}
// 2 :
else if ( i == 4 )
{
pruhy[i].skut_cislo = 4;
pruhy[i].odkial = 2;
pruhy[i].kam = 4;
}
else if ( i == 5 )
{
pruhy[i].skut_cislo = 5;
pruhy[i].odkial = 2;
pruhy[i].kam = 1;
}
else if ( i == 6 )
{
pruhy[i].skut_cislo = 6;
pruhy[i].odkial = 2;
pruhy[i].kam = 1;
}
else if ( i == 7 )
{
pruhy[i].skut_cislo = 7;
pruhy[i].odkial = 2;
pruhy[i].kam = 3;
}
// 3 :
else if ( i == 8 )
{
pruhy[i].skut_cislo = 8;
pruhy[i].odkial = 3;
pruhy[i].kam = 1;
}
else if ( i == 9 )
{
pruhy[i].skut_cislo = 8;
pruhy[i].odkial = 3;
pruhy[i].kam = 4;
}
else if ( i == 10 )
{
pruhy[i].skut_cislo = 9;
pruhy[i].odkial = 3;
pruhy[i].kam = 2;
}
// 4 :
else if ( i == 11 )
{
pruhy[i].skut_cislo = 10;
pruhy[i].odkial = 4;
pruhy[i].kam = 1;
}
else if ( i == 12 )
{
pruhy[i].skut_cislo = 11;
pruhy[i].odkial = 4;
pruhy[i].kam = 3;
}
else if ( i == 13 )
{
pruhy[i].skut_cislo = 11;
pruhy[i].odkial = 4;
pruhy[i].kam = 2;
}
}
}
//---------------------------------------------------------------------------
void TForm1::zapis(FILE *subor)
{
fprintf ( subor, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> \n");
fprintf ( subor, "<html>\n");
fprintf ( subor, "<head>\n");
fprintf ( subor, "<title>Križovatka</title>\n");
fprintf ( subor, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1250\">\n");
fprintf ( subor, "<head>\n");
fprintf ( subor, "<body>\n");
fprintf ( subor, "\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<center><H2><u>NÁVRH SVETELNEJ SIGNALIZÁCIE</u></H2></center>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>1. Smerovanie vozidiel na križovatke</u></H3>\n");
fprintf ( subor, "<p>Výpoètové zaťaženie komunikácie [ j. voz/hod ] :</p>\n");
fprintf ( subor, "<TABLE border=\"1\">\n");
fprintf ( subor, "<TR><TH>z/do</TH><TH> 1 </TH><TH> 2 </TH><TH> 3 </TH><TH> 4 </TH></TR>\n");
for ( int i = 0; i < 4; i++ )
{
fprintf ( subor, "<TR><TH> %d </TH>" , i+1 );
for ( int j = 0; j < 4; j++ )
{
if ( matica[j][i] == 0 ) fprintf ( subor, "<TD align=\"center\"> - </TD>" );
else fprintf ( subor, "<TD align=\"right\"> %d </TD>" , matica[j][i] );
}
fprintf ( subor, "</TR>\n");
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>2. Návrh fázovania cyklov</u></H3>\n");
Image2->Picture->SaveToFile("smery.bmp");
Image3->Picture->SaveToFile("fazy.bmp");
fprintf ( subor, "<p>\n");
fprintf ( subor, "<IMG SRC=\"smery.bmp\" ALIGN=\"left\" ALT=\"Smery v križovatke\" WIDTH=\"230\" HEIGHT=\"229\">\n");
fprintf ( subor, "<IMG SRC=\"fazy.bmp\" HSPACE=\"50\" ALIGN=\"middle\" ALT=\"Fázy\" WIDTH=\"330\" HEIGHT=\"324\">\n");
fprintf ( subor, "</p>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>3. Výpoèet medzièasov</u></H3>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<TABLE border=\"1\">\n");
fprintf ( subor, "<TR>");
fprintf ( subor, "<TH colspan=\"3\" rowspan=\"3\">Tab. medzièasov</TH>");
fprintf ( subor, "<TH colspan=\"12\">odchádzajú-vyprazdòujúce vozidlá</TH>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "<TR>");
fprintf ( subor, "<TH colspan=\"3\"> I. </TH>");
fprintf ( subor, "<TH> II. </TH>");
fprintf ( subor, "<TH colspan=\"3\"> I. </TH>");
fprintf ( subor, "<TH> II. </TH>");
fprintf ( subor, "<TH colspan=\"2\"> III. </TH>");
fprintf ( subor, "<TH colspan=\"2\"> IV. </TH>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "<TR>");
for ( int i = 0; i < 12; i++ )
{
if ( i < 10 )
fprintf ( subor, "<TH> %d </TH>" , i+1);
else
fprintf ( subor, "<TH> %d </TH>" , i+1);
}
fprintf ( subor, "</TR>\n");
fprintf ( subor, "<TR>");
fprintf ( subor, "<TH rowspan=\"12\">vstupujúce vozidlá</TH>");
int cis_pruhu = 0;
int pole[6][2] = { { 1 , 3 } , { 2 , 1 } , { 1 , 3 } ,
{ 2 , 1 } , { 3 , 2 } , { 4 , 2 } };
AnsiString vyp = "";
for ( int i = 0; i < 6; i++ )
{
if ( pole[i][0] == 1 ) vyp = "I.";
else if ( pole[i][0] == 2 ) vyp = "II.";
else if ( pole[i][0] == 3 ) vyp = "III.";
else if ( pole[i][0] == 4 ) vyp = "IV.";
if ( i > 0 ) fprintf ( subor, "<TR>");
fprintf ( subor, "<TH rowspan=\"%d\"> %s </TH>" , pole[i][1] , vyp.c_str() );
for ( int j = 0; j < pole[i][1]; j++ )
{
if ( j > 0 ) fprintf ( subor, "<TR>");
fprintf ( subor, "<TH> %d </TH>" , ( cis_pruhu + 1 ) );
for ( int k = 0 ; k < SKUT_POC_PRUHOV ; k++ )
{
if ( tab_medzicas[cis_pruhu][k] == 0 )
fprintf ( subor, "<TD> </TD>");
else
{
vyp = FloatToStrF ( tab_medzicas[cis_pruhu][k], ffFixed, 3, 1 );
fprintf ( subor, "<TD> %s s </TD>" , vyp.c_str() );
// fprintf ( subor, "<TD> %.1f s </TD>" , tab_medzicas[cis_pruhu][k]);
}
}
fprintf ( subor, "</TR>\n");
cis_pruhu++;
}
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>4. Stupeò saturácie</u></H3>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<TABLE border=\"1\">\n");
fprintf ( subor, "<TR>");
fprintf ( subor, "<TH rowspan=\"2\">sig. sk</TH>");
fprintf ( subor, "<TH> šírka </TH>");
fprintf ( subor, "<TH> R </TH>");
fprintf ( subor, "<TH> S </TH>");
fprintf ( subor, "<TH> s<SUB>1</SUB> </TH>");
fprintf ( subor, "<TH> s<SUB>2</SUB> </TH>");
fprintf ( subor, "<TH> s<SUB>3</SUB> </TH>");
fprintf ( subor, "<TH> s </TH>");
fprintf ( subor, "<TH> S' </TH>");
fprintf ( subor, "<TH> M' </TH>");
fprintf ( subor, "<TH> n </TH>");
fprintf ( subor, "<TH> y<SUB>i</SUB> </TH>");
fprintf ( subor, "<TH> y<SUB>i</SUB><SUP>max</SUP> </TH>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TD> [m] </TD>");
fprintf ( subor, "<TD> [m] </TD>");
fprintf ( subor, "<TD> j.voz/h </TD>");
fprintf ( subor, "<TD> % </TD>");
fprintf ( subor, "<TD> % </TD>");
fprintf ( subor, "<TD> % </TD>");
fprintf ( subor, "<TD> % </TD>");
fprintf ( subor, "<TD> j.voz/h </TD>");
fprintf ( subor, "<TD> j.voz/h </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "</TR>\n");
int pole_poc[4] = { 4 , 4 , 2 , 2 };
int pruh = 1;
int riadok = 2;
for ( int i=0 ; i < 4 ; i++ )
{
for ( int j=0 ; j < pole_poc[i] ; j++ )
{
fprintf ( subor, "<TR>");
fprintf ( subor, "<TH> %d </TH>" , pruh );
for ( int k=1 ; k < 12 ; k++ )
{
fprintf ( subor, "<TD> %s </TD>" , StringGrid2->Cells[k][pruh+1].c_str() );
if ( k == 11 )
if ( j == 0 )
{
fprintf ( subor, "<TD rowspan=\"%d\"> %s </TD>" , pole_poc[i] , StringGrid2->Cells[12][ pruh + pole_poc[i] ].c_str() );
}
riadok++;
}
fprintf ( subor, "</TR>\n");
if ( i < 3 )
if ( j == ( pole_poc[i] - 1 ) )
{
fprintf ( subor, "<TR>");
fprintf ( subor, "<TD bgcolor=\"black\" height=\"1\" colspan=\"13\"></TD>");
fprintf ( subor, "</TR>\n");
}
pruh++;
}
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "<p>Stupeò saturácie celej križovatky Y = suma y<SUB>i</SUB><SUP>max</SUP> = %.3f</p>\n" , Y );
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>5. Stratové èasy</u></H3>\n");
fprintf ( subor, "<br>\n");
fprintf ( subor, "<TABLE border=\"1\">\n");
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TH colspan=\"4\"> poradie fáz </TH>");
fprintf ( subor, "<TH colspan=\"7\">medzièasy t<SUB>m</SUB> [s]</TH>");
fprintf ( subor, "<TH> suma t<SUB>m</SUB> </TH>");
fprintf ( subor, "<TH> I<SUB>i</SUB> [s] </TH>");
fprintf ( subor, "</TR>\n");
AnsiString pom = "";
for ( int i=0 ; i < 6 ; i++ )
{
fprintf ( subor, "<TR align=\"center\">");
for ( int j=0 ; j < 4 ; j++ )
{
fprintf ( subor, "<TD>");
if ( straty[i].por_faz[j] == 1 ) pom = "I.";
else if ( straty[i].por_faz[j] == 2 ) pom = "II.";
else if ( straty[i].por_faz[j] == 3 ) pom = "III.";
else if ( straty[i].por_faz[j] == 4 ) pom = "IV.";
fprintf ( subor, " %s " , pom.c_str() );
fprintf ( subor, "</TD>");
}
for ( int j=0 ; j < 4 ; j++ )
{
pom = FloatToStrF ( straty[i].medzicasy[j], ffFixed, 3, 1 );
fprintf ( subor, "<TD>");
// fprintf ( subor, " %.1f s " , straty[i].medzicasy[j] );
fprintf ( subor, " %s s " , pom.c_str() );
fprintf ( subor, "</TD>");
if ( j < 3 )
{
fprintf ( subor, "<TD> </TD>");
}
}
fprintf ( subor, "<TD>");
fprintf ( subor, " %.0f " , straty[i].suma_tm );
fprintf ( subor, "</TD>");
fprintf ( subor, "<TD>");
fprintf ( subor, " %.0f " , straty[i].Ii );
fprintf ( subor, "</TD>");
fprintf ( subor, "</TR>\n");
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "<p>Stratový èas celej križovatky L = min(I<SUB>i</SUB>) = %.1f s</p>\n" , L );
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>6. Stanovenie optimálneho radenia fáz</u></H3>\n");
fprintf ( subor, "<H4><u>Posúdenie výkonnosti križovatky</u></H4>\n");
fprintf ( subor, "<TABLE border=\"1\">\n");
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TH> sig. sk. </TH>");
fprintf ( subor, "<TH> y<SUB>i</SUB> </TH>");
fprintf ( subor, "<TH> z<SUB>i</SUB> </TH>");
fprintf ( subor, "<TH> z<SUB>i</SUB>'</SUP> </TH>");
fprintf ( subor, "<TH> S<SUB>i</SUB>' </TH>");
fprintf ( subor, "<TH> n<SUB>i</SUB> </TH>");
fprintf ( subor, "<TH colspan=\"2\"> Posúdenie </TH>");
fprintf ( subor, "<TH> </TH>");
fprintf ( subor, "<TH colspan=\"2\"> Rezerva R<SUB>i</SUB> </TH>");
fprintf ( subor, "<TH> </TH>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "<TD> [s] </TD>");
fprintf ( subor, "<TD> [s] </TD>");
fprintf ( subor, "<TD> j.voz/h </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "<TD> K<SUB>i</SUB> </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "<TD> M' </TD>");
fprintf ( subor, "<TD> j.voz/h </TD>");
fprintf ( subor, "<TD> % </TD>");
fprintf ( subor, "<TD> </TD>");
fprintf ( subor, "</TR>\n");
for ( int i=2 ; i < ( 2 + SKUT_POC_PRUHOV ) ; i++ )
{
fprintf ( subor, "<TR align=\"center\">");
for ( int j=0 ; j < StringGrid3->ColCount ; j++ )
{
fprintf ( subor, "<TD> %s </TD>" , StringGrid3->Cells[j][i].c_str() );
}
fprintf ( subor, "</TR>\n");
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "<p>Križovatka vyhovuje</p>\n" );
signalny_plan(subor);
// fprintf ( subor, "\n");
fprintf ( subor, "</body>\n");
fprintf ( subor, "</html>\n");
}
void __fastcall TForm1::Uloz1Click(TObject *Sender)
{
ForceCurrentDirectory = true; // aby ponukol aktualny adresar
SaveDialog1->Filter = "HTML subor ( *.html )|*.HTML";
SaveDialog1->FileName="";
if ( SaveDialog1->Execute() )
{
AnsiString nazov = SaveDialog1->FileName;
FILE *subor = fopen ( nazov.c_str() , "wt");
if ( subor == NULL )
{
vypis("Nepodarilo sa vytvorit subor. \nKrizovatka neulozena ! ! !", 1);
}
zapis ( subor );
fclose(subor);
}
}
//---------------------------------------------------------------------------
void TForm1::stupen_saturacie(void)
{
// S', M', yi :
float S , R , M , s ;
int pom = 0 , cislo = 0 , n = 1;
int ind = 0 , poc = 0 , pocet = 0 , z = 0 , kam = 0 ;
int pole_ind[2] , index = 0;
for ( int i=2 ; i < 2+SKUT_POC_PRUHOV ; i++ )
{
S = StrToFloat ( StringGrid2->Cells[3][i] );
if ( StringGrid2->Cells[2][i] != "-" )
if ( StringGrid2->Cells[2][i] != " " )
if ( StringGrid2->Cells[2][i] != "" )
{
pom = 1;
}
if ( pom == 1 )
{
R = StrToFloat ( StringGrid2->Cells[2][i] );
cislo = (int) ceil ( S / ( 1 + 5 / ( 3.28*R ) ) );
StringGrid2->Cells[8][i] = cislo;
}
else if ( pom == 0 )
{
s = StrToFloat ( StringGrid2->Cells[7][i] );
if ( s > 0 ) s = s * (-1);
cislo = (int) ceil ( S * ( 1 + s * 0.02 ) );
StringGrid2->Cells[8][i] = cislo;
}
for ( int j=0 ; j < POC_PRUHOV ; j++ )
{
if ( pruhy[j].skut_cislo == ind )
{
poc++;
pole_ind[index] = j;
index++;
z = pruhy[j].odkial;
kam = pruhy[j].kam;
// break;
}
}
if ( poc == 1 )
{
for ( int j=0 ; j < POC_PRUHOV ; j++ )
{
if ( pruhy[j].odkial == z )
if ( pruhy[j].kam == kam )
{
pocet++;
}
}
M = matica[ pruhy[pole_ind[0]].kam-1 ][ pruhy[pole_ind[0]].odkial-1 ] / pocet;
}
else if ( poc == 2 )
{
M = matica[ pruhy[pole_ind[0]].kam-1 ][ pruhy[pole_ind[0]].odkial-1 ] +
matica[ pruhy[pole_ind[1]].kam-1 ][ pruhy[pole_ind[1]].odkial-1 ];
}
StringGrid2->Cells[9][i] = M;
n = StrToInt ( StringGrid2->Cells[10][i] );
StringGrid2->Cells[11][i] = FloatToStrF ( M / ( n * cislo ) ,ffFixed,4,3 ) ;
// reset :
index = 0;
poc = 0;
pocet = 0;
pom = 0;
// pre novu iteraciu :
ind++;
}
// stupen saturacie = yi max :
int pole_poc[4] = { 4 , 4 , 2 , 2 };
int riadok = 2;
float max_yi = 0;
for ( int i=0 ; i < 4 ; i++ )
{
for ( int j=0 ; j < pole_poc[i] ; j++ )
{
if ( j == 0 )
max_yi = StrToFloat ( StringGrid2->Cells[11][riadok] );
else
{
if ( StrToFloat ( StringGrid2->Cells[11][riadok] ) > max_yi )
max_yi = StrToFloat ( StringGrid2->Cells[11][riadok] );
}
riadok++;
}
StringGrid2->Cells[12][riadok-1] = FloatToStrF ( max_yi, ffFixed, 4, 3 ) ;
Y += max_yi;
}
Label11->Visible = true;
Label11->Caption = "Suma yi max : " + FloatToStrF ( Y, ffFixed, 4, 3 ) ;
}
void TForm1::priprav_tabulku_2(void)
{
StringGrid2->Cells[0][1] = " sig.sk";
StringGrid2->Cells[1][0] = " sirka";
StringGrid2->Cells[1][1] = " [m]";
StringGrid2->Cells[2][0] = " R";
StringGrid2->Cells[2][1] = " [m]";
StringGrid2->Cells[3][0] = " S";
StringGrid2->Cells[3][1] = "[j.voz/h]";
StringGrid2->Cells[4][0] = " s1";
StringGrid2->Cells[4][1] = " %";
StringGrid2->Cells[5][0] = " s2";
StringGrid2->Cells[5][1] = " %";
StringGrid2->Cells[6][0] = " s3";
StringGrid2->Cells[6][1] = " %";
StringGrid2->Cells[7][0] = " s";
StringGrid2->Cells[7][1] = " %";
StringGrid2->Cells[8][0] = " S'";
StringGrid2->Cells[8][1] = "[j.voz/h]";
StringGrid2->Cells[9][0] = " M'";
StringGrid2->Cells[9][1] = "[j.voz/h]";
StringGrid2->Cells[10][0] = " n";
StringGrid2->Cells[11][0] = " yi";
StringGrid2->Cells[12][0] = " yi max";
for ( int i=2; i < StringGrid2->RowCount; i++ )
{
StringGrid2->Cells[0][i] = " "+IntToStr(i-1);
}
// sirka , S :
for ( int i=0; i < 12; i++ )
{
if ( i < 8 )
StringGrid2->Cells[1][i+2] = 3.25;
else
StringGrid2->Cells[1][i+2] = 3;
StringGrid2->Cells[3][i+2] = 1700;
StringGrid2->Cells[10][i+2] = 1;
}
// R :
StringGrid2->Cells[2][2] = 50.1;
StringGrid2->Cells[2][5] = 15;
StringGrid2->Cells[2][6] = 50.1;
StringGrid2->Cells[2][9] = 15;
StringGrid2->Cells[2][10] = 15;
StringGrid2->Cells[2][11] = 47.03;
StringGrid2->Cells[2][12] = 47.03;
StringGrid2->Cells[2][13] = 15;
// s1 , s2 , s3 , s :
AnsiString pole[SKUT_POC_PRUHOV][3] = {
{ "-0,5" , "-2" , "-" } ,
{ "1,5" , "-0,5" , "-" } ,
{ "1,5" , "-0,5" , "-" } ,
{ "1,5" , "-0,5" , "-2" } ,
{ "0,5" , "-2" , "-" } ,
{ "0,5" , "-1,5" , "-" } ,
{ "0,5" , "-1,5" , "-" } ,
{ "0,5" , "-2" , "-" } ,
{ "2" , "0,5" , "-1,5" } ,
{ "2" , "-0,5" , "-" } ,
{ "2" , "0,5" , "-1,5" } ,
{ "2" , "0,5" , "-2" }
};
int ii = 0 , jj = 0;
float max_s = 0;
for ( int i=2 ; i < 2+SKUT_POC_PRUHOV ; i++ )
{
jj = 0;
for ( int j=4 ; j < 7 ; j++ )
{
StringGrid2->Cells[j][i] = pole[ii][jj];
jj++;
if ( j == 4 )
max_s = StrToFloat(StringGrid2->Cells[j][i]);
else
{
if ( StringGrid2->Cells[j][i] != "-" )
if ( StringGrid2->Cells[j][i] != " " )
if ( StringGrid2->Cells[j][i] != "" )
if ( StrToFloat(StringGrid2->Cells[j][i]) > max_s )
max_s = StrToFloat(StringGrid2->Cells[j][i]);
}
}
StringGrid2->Cells[7][i] = FloatToStr(max_s);
ii++;
};
}
void __fastcall TForm1::StringGrid2SelectCell(TObject *Sender, int ACol,
int ARow, bool &CanSelect)
{
if ( ( ACol == 2 ) ||
( ACol == 4 ) ||
( ACol == 5 ) ||
( ACol == 6 ) )
StringGrid2->Options << goEditing;
else
StringGrid2->Options >> goEditing;
}
//---------------------------------------------------------------------------
// Kolizne body, tabulka medzicasov :
void TForm1::tab_medzicasov(void)
{
// tabulka medzicasov :
float cas = 0;
int ind[23][2] = { { 0, 7 } , { 0, 11 } , { 1, 7 } , { 1, 8 } ,
{ 1, 9 } , { 1, 11 } , { 2, 7 } , { 2, 8 } ,
{ 2,11 } , { 3, 4 } , { 3, 5 } , { 3, 6 } ,
{ 3, 8 } , { 3, 11 } , { 4, 8 } , { 5, 8 } ,
{ 5,10 } , { 5, 11 } , { 6, 8 } , { 6,11 } ,
{ 7, 8 } , { 7, 11 } , { 8,11 } };
int j , k;
for ( int i = 0 ; i < 23 ; i++ )
{
cas = ( L1 + L3 ) / v1 - L2/v2 + tb;
if ( cas < 4 ) cas = 4;
j = ind[i][0];
k = ind[i][1];
tab_medzicas[j][k] = tab_medzicas[k][j] = cas;
}
}
// Navrh faz cyklov :
void TForm1::vytvor_fazy(void)
{
int pole[POC_FAZ][MAX_PRUHOV+1] = {
{ 6 , 0 , 1 , 2 , 4 , 5 , 6 , -1 , -1 },
{ 2 , 3 , 7 , -1 , -1 , -1 , -1 , -1 , -1 },
{ 2 , 8 , 9 , -1 , -1 , -1 , -1 , -1 , -1 },
{ 2 , 10 , 11 , -1 , -1 , -1 , -1 , -1 , -1 } };
for ( int i = 0 ; i < POC_FAZ ; i++ )
{
faza[i].poc_pruhov = pole[i][0];
for ( int j = 0 ; j < faza[i].poc_pruhov ; j++ )
{
faza[i].cis_pruhov[j] = pole[i][j+1];
}
}
}
// Poradie faz :
void TForm1::stratove_casy(void)
{
int pole[6][4] = { { 1, 2, 3, 4 },
{ 1, 2, 4, 3 },
{ 1, 3, 2, 4 },
{ 1, 3, 4, 2 },
{ 1, 4, 2, 3 },
{ 1, 4, 3, 2 } };
// poradie faz :
for ( int i = 0 ; i < 6 ; i++ )
{
for ( int j = 0 ; j < 4 ; j++ )
{
straty[i].por_faz[j] = pole[i][j];
}
}
// medzicasy :
float max = 4;
float suma_1 = 0 , suma_2 = 0;
int ii = 0;
for ( int i = 0 ; i < 6 ; i++ )
{
suma_1 = 0;
suma_2 = 0;
for ( int j = 0 ; j < POC_FAZ ; j++ )
{
max = 4;
for ( int k = 0 ; k < faza[j].poc_pruhov ; k++ )
{
ii = faza[j].cis_pruhov[k];
for ( int l = 0 ; l < SKUT_POC_PRUHOV ; l++ )
{
if ( tab_medzicas[ii][l] > max )
max = tab_medzicas[ii][l];
}
}
straty[i].medzicasy[j] = max;
suma_1 += straty[i].medzicasy[j];
suma_2 += straty[i].medzicasy[j] - zlta + tb;
}
straty[i].suma_tm = suma_1;
straty[i].Ii = suma_2;
}
// optimalne radenie faz :
index_optimalne = 0;
for ( int i = 1 ; i < 6 ; i++ )
{
if ( straty[i].Ii < straty[index_optimalne].Ii )
index_optimalne = i;
}
L = straty[index_optimalne].Ii;
}
void TForm1::vykonnost_krizovatky(void)
{
StringGrid3->Cells[0][0] = " sig.sk";
StringGrid3->Cells[1][0] = " yi";
StringGrid3->Cells[2][0] = " zi";
StringGrid3->Cells[2][1] = " [s]";
StringGrid3->Cells[3][0] = " zi'";
StringGrid3->Cells[3][1] = " [s]";
StringGrid3->Cells[4][0] = " Si'";
StringGrid3->Cells[4][1] = " j.voz/h";
StringGrid3->Cells[5][0] = " ni";
StringGrid3->Cells[6][0] = " Posud";
StringGrid3->Cells[7][0] = "enie ";
StringGrid3->Cells[6][1] = " Ki";
StringGrid3->Cells[8][1] = " M'";
StringGrid3->Cells[9][0] = " Rezer";
StringGrid3->Cells[10][0] = "va Ri";
StringGrid3->Cells[9][1] = " j.voz/h";
StringGrid3->Cells[10][1] = " %";
for ( int i=2; i < StringGrid3->RowCount; i++ )
{
StringGrid3->Cells[0][i] = " "+IntToStr(i-1);
}
// yi , Si' , ni , Mi :
for ( int i=2; i < StringGrid3->RowCount; i++ )
{
StringGrid3->Cells[1][i] = StringGrid2->Cells[11][i];
StringGrid3->Cells[4][i] = StringGrid2->Cells[8][i];
StringGrid3->Cells[5][i] = StringGrid2->Cells[10][i];
StringGrid3->Cells[8][i] = StringGrid2->Cells[9][i];
}
// zi , zi' :
float yi = 0 , zi = 0;
for ( int i=2 ; i < 2+SKUT_POC_PRUHOV ; i++ )
{
yi = StrToFloat ( StringGrid3->Cells[1][i] );
zi = ( yi * ( cn - L ) / Y ) - 1;
if ( zi < 4 ) zi = 4;
StringGrid3->Cells[2][i] = FloatToStrF ( zi ,ffFixed,3,1 ) ;
StringGrid3->Cells[3][i] = FloatToStrF ( ( zi + 1 ) ,ffFixed,3,1 ) ;
}
// Ki :
float zi_ciarka = 0 , M = 0 , K = 0;
int Ki , Si_ciarka , M_ciarka = 0;
int ni = 1;
int poc_vyh = 0;
for ( int i=2 ; i < 2+SKUT_POC_PRUHOV ; i++ )
{
Si_ciarka = StrToInt ( StringGrid3->Cells[4][i] );
zi_ciarka = StrToFloat ( StringGrid3->Cells[3][i] );
ni = StrToInt ( StringGrid3->Cells[5][i] );
M_ciarka = StrToInt ( StringGrid3->Cells[8][i] );
// Ki :
Ki = 0.9 * Si_ciarka * zi_ciarka * ni / cn;
StringGrid3->Cells[6][i] = FloatToStrF ( Ki ,ffFixed,4,0 ) ;
// Ri , % :
StringGrid3->Cells[9][i] = Ki - M_ciarka;
K = (float) Ki;
M = (float) M_ciarka;
StringGrid3->Cells[10][i] = FloatToStrF ( ( M / K * 100 ) ,ffFixed,3,0 ) ;
if ( Ki > M_ciarka )
{
StringGrid3->Cells[7][i] = " >";
StringGrid3->Cells[11][i] = "vyhovuje";
poc_vyh++;
}
else
{
StringGrid3->Cells[7][i] = " <";
StringGrid3->Cells[11][i] = "nevyhov";
}
}
if ( poc_vyh == SKUT_POC_PRUHOV )
{
Label17->Caption = "Krizovatka vyhovuje";
Label17->Visible = true;
Uloz->Enabled = true;
Uloz1->Enabled = true;
vypis_status("Na prezarenie signalneho planu treba krizovatku ulozit");
}
else
{
Label17->Caption = "Krizovatka NEVYHOVUJE";
Label17->Visible = true;
vypis_status("Skus vytvorit novu krizovatku");
}
}
void TForm1::signalny_plan(FILE *subor)
{
int ind = 0 , p = 0;
float max = 0;
int pocet = 0;
AnsiString okraj = "\"35\"";
AnsiString sirka = "\"5\"";
AnsiString vyska = "\"9\"";
AnsiString vyska_1 = "\"27\"";
AnsiString vyp = "";
// vypocet dlzky casov farieb pre jednotlive fazy :
for ( int i = 0 ; i < POC_FAZ ; i++ )
{
max = 0;
// vyber fazy :
ind = straty[index_optimalne].por_faz[i] - 1;
for ( int j = 0 ; j < faza[ind].poc_pruhov ; j++ )
{
p = faza[ind].cis_pruhov[j];
if ( StrToFloat ( StringGrid3->Cells[2][p+2] ) > max )
max = StrToFloat ( StringGrid3->Cells[2][p+2] );
}
faza[ind].zelena = (float) ceil ( max );
faza[ind].zlta = straty[index_optimalne].medzicasy[i];
faza[ind].cervena = (float) ceil ( cn - faza[ind].zelena );
}
// pocet policok resp. dlzka casovej osi :
ind = straty[index_optimalne].por_faz[0] - 1;
pocet = ( faza[ind].zelena + faza[ind].zlta + faza[ind].cervena + faza[ind].zlta );
fprintf ( subor, "<br>\n");
fprintf ( subor, "<H3><u>7. Signálny plán križovatky</u></H3>\n");
// fprintf ( subor, "<FONT FACE=\"Verdana, Arial CE\" SIZE=\"2\">");
// fprintf ( subor, "<FONT SIZE=\"2\">");
// tabulka 1 :
fprintf ( subor, "<TABLE border=\"1\">\n");
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TD valign=\"top\">");
// tabulka 1.1 :
fprintf ( subor, "<TABLE border=\"1\">\n");
// fprintf ( subor, "<TABLE border=\"1\" cellpadding=\"10\">\n");
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TH rowspan=\"1\"> Fáza </TH>");
fprintf ( subor, "<TH rowspan=\"1\"> Sig. skup. </TH>");
fprintf ( subor, "<TH rowspan=\"1\"> z<SUB>j</SUB>[s] </TH>");
fprintf ( subor, "</TR>\n");
for ( int i = 0 ; i < POC_FAZ ; i++ )
{
// vyber fazy :
ind = straty[index_optimalne].por_faz[i] - 1;
if ( (ind+1) == 1 ) vyp = "I.";
else if ( (ind+1) == 2 ) vyp = "II.";
else if ( (ind+1) == 3 ) vyp = "III.";
else if ( (ind+1) == 4 ) vyp = "IV.";
fprintf ( subor, "<TR align=\"center\">" );
fprintf ( subor, "<TD rowspan=\"%d\"> %s </TD>" , faza[ind].poc_pruhov , vyp.c_str() );
for ( int j = 0 ; j < faza[ind].poc_pruhov ; j++ )
{
p = faza[ind].cis_pruhov[j];
vyp = StringGrid3->Cells[2][p+2];
if ( j > 0 ) fprintf ( subor, "<TR align=\"center\">");
// fprintf ( subor, "<TD height=%s> %d </TD>" , vyska_1.c_str() , p+1 );
// fprintf ( subor, "<TD height=%s> %s </TD>" , vyska_1.c_str() , vyp.c_str() );
fprintf ( subor, "<TD> %d </TD>" , p+1 );
fprintf ( subor, "<TD> %s </TD>" , vyp.c_str() );
// fprintf ( subor, "<TD> %d <TABLE border=\"0\"><TR><TD> </TD></TR><TR><TD> </TD></TR></TABLE></TD>" , p+1 );
// fprintf ( subor, "<TD> %s <TABLE border=\"0\"><TR><TD> </TD></TR><TR><TD> </TD></TR></TABLE></TD>" , vyp.c_str() );
fprintf ( subor, "</TR>\n");
}
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "</TD>");
fprintf ( subor, "<TD valign=\"top\">");
// tabulka 1.2 :
fprintf ( subor, "<TABLE border=\"0\" cellspacing=\"0\">\n");
fprintf ( subor, "<TR align=\"top\">");
fprintf ( subor, "<TD>");
// tabulka 1.2.1 :
fprintf ( subor, "<TABLE border=\"0\" cellspacing=\"0\">\n");
// fprintf ( subor, "<COLGROUP span=%d width=60>" , (pocet+1) );
// fprintf ( subor, "<COLGROUP span=%d width=60>" , (pocet+1) );
// for ( int i = 0 ; i < 3 ; i++ )
for ( int i = 1 ; i < 3 ; i++ )
{
fprintf ( subor, "<TR align=\"center\">");
fprintf ( subor, "<TH width=%s> </TH>" , okraj.c_str() );
if ( i == 0 )
{
for ( int j = 0 ; j <= pocet ; j++ )
{
fprintf ( subor, "<TH width=%s bgcolor=\"white\"> </TH>" , sirka.c_str() ) ;
}
}
else if ( i == 1 )
{
for ( int j = 0 ; j <= pocet ; j++ )
{
if ( ( j%4 ) == 0 )
{
if ( j < 10 )
{
fprintf ( subor, "<TH width=%s> %d </TH>" , sirka.c_str() , j );
continue;
}
if ( 9 < j < 100 )
{
fprintf ( subor, "<TH width=%s>%d </TH>" , sirka.c_str() , j );
continue;
}
if ( j > 99 )
{
fprintf ( subor, "<TH width=%s>%d</TH>" , sirka.c_str() , j );
continue;
}
}
else
{
fprintf ( subor, "<TH width=%s bgcolor=\"white\"> </TH>" , sirka.c_str() ) ;
}
}
}
else if ( i == 2 )
{
for ( int j = 0 ; j <= pocet ; j++ )
{
if ( ( j%4 ) == 0 )
{
fprintf ( subor, "<TH width=%s>|</TH>" , sirka.c_str() );
}
else
{
fprintf ( subor, "<TH width=%s bgcolor=\"white\"> </TH>" , sirka.c_str() ) ;
}
}
}
fprintf ( subor, "<TH width=%s> </TH>" , okraj.c_str() );
fprintf ( subor, "</TR>\n");
}
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "</TD>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "<TR align=\"top\">");
fprintf ( subor, "<TD>");
// tabulka 1.2.2 :
// <FONT SIZE=\"1\">
fprintf ( subor, "<TABLE border=\"0\" cellspacing=\"0\">\n");
fprintf ( subor, "<TR align=\"center\">");
okraj = "\"23\"";
float bod = (float)865/(float)88;
plan->AutoSize = true;
int w = bod*pocet;
plan->Picture->Bitmap->Width = w ;
int h = 304;
plan->Picture->Bitmap->Height= h;
plan->Canvas->Brush->Color = clWhite;
plan->Canvas->FillRect(Rect(0,0,plan->Width,plan->Height));
int y = 5 , pos = 26;
int x1 , x2;
int vys = 13;
int pred;
// plan->Canvas->Font->Height = 6;
for ( int i = 0 ; i < POC_FAZ ; i++ )
{
// vyber fazy :
ind = straty[index_optimalne].por_faz[i] - 1;
for ( int j = 0 ; j < faza[ind].poc_pruhov ; j++ )
{
p = faza[ind].cis_pruhov[j];
if ( i == 0 )
{
x1 = 10;
x2 = (int)(faza[ind].zelena*bod);
plan->Canvas->Brush->Color = clGreen;
plan->Canvas->FillRect(Rect(0,y,x2,y+vys));
plan->Canvas->TextOut(x1, y, FloatToStr(faza[ind].zelena)+" s");
x1 = x2;
x2 = x1 + (int)(faza[ind].zlta*bod);
plan->Canvas->Brush->Color = clYellow;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
x1 = x2;
x2 = x1 + (int)(faza[ind].cervena*bod);
plan->Canvas->Brush->Color = clRed;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
x1 = x2;
x2 = x1 + (int)(faza[ind].zlta*bod);
plan->Canvas->Brush->Color = clMaroon;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
// break;
pred = (int)(faza[ind].zelena + faza[ind].zlta/2 );
y += pos;
}
else
{
if ( ( i > 1 ) && ( j == 0 ) ) pred += (int)faza[ind-1].zelena + (int)faza[ind-1].zlta + (int)faza[ind-1].zlta/2;
x1 = 0;
x2 = pred*bod;
plan->Canvas->Brush->Color = clRed;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
x1 = x2;
x2 = x1 + (int)(faza[ind].zlta*bod);
plan->Canvas->Brush->Color = clMaroon;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
x1 = x2;
x2 = x1 + (int)(faza[ind].zelena*bod);
plan->Canvas->Brush->Color = clGreen;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
plan->Canvas->TextOut(x1+10, y, FloatToStr(faza[ind].zelena)+" s");
x1 = x2;
x2 = x1 + (int)(faza[ind].zlta*bod);
plan->Canvas->Brush->Color = clYellow;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
x1 = x2;
x2 = plan->Width; // x1 + (int)(faza[ind].zlta*bod);
plan->Canvas->Brush->Color = clRed;
plan->Canvas->FillRect(Rect(x1,y,x2,y+vys));
y += pos;
}
}
}
cislo_planu++;
const AnsiString nazov = "plan_"+IntToStr(cislo_planu)+".bmp";
plan->Picture->SaveToFile(nazov);
fprintf ( subor, "<TH width=%s> </TH>" , okraj.c_str() );
fprintf ( subor, "<TD background=\"%s\" align=\"top\" width=\"%d\" height=\"%d\"></TD>" , nazov.c_str() , w , h );
fprintf ( subor, "</TR>\n");
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "</TD>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "</TD>");
fprintf ( subor, "</TR>\n");
fprintf ( subor, "</TABLE>\n");
fprintf ( subor, "<br><br>\n");
}
void __fastcall TForm1::Nova1Click(TObject *Sender)
{
StringGrid1->Enabled = false;
StringGrid1->Cells[0][0] = "z/do";
for ( int i=1; i < StringGrid1->ColCount; i++ )
for ( int j=1; j < StringGrid1->RowCount; j++ )
{
StringGrid1->Cells[i][j] = "";
}
for ( int i=0; i < StringGrid2->ColCount; i++ )
for ( int j=0; j < StringGrid2->RowCount; j++ )
{
StringGrid2->Cells[i][j] = "";
}
for ( int i=0; i < StringGrid3->ColCount; i++ )
for ( int j=0; j < StringGrid3->RowCount; j++ )
{
StringGrid3->Cells[i][j] = "";
}
for ( int i=1; i < StringGrid1->RowCount; i++ )
{
StringGrid1->Cells[i][0] = i;
StringGrid1->Cells[0][i] = i;
StringGrid1->Cells[i][i] = " ------";
Iv_grid->Cells[0][i] = "";
}
vypis_status ("Vyber typ hlavnej a vedlajsej komunikacia a stlac Pouzi");
Iv_grid->Cells[0][0]="Iv";
PageControl1->ActivePage=TabSheet1;
StringGrid2->Visible = false;
StringGrid3->Visible = false;
Label3->Visible = false;
Label4->Visible = false;
Label5->Visible = false;
Label5->Caption = "";
TabSheet1->Highlighted = true;
TabSheet2->Highlighted = false;
TabSheet3->Highlighted = false;
TabSheet4->Highlighted = false;
TabSheet5->Highlighted = false;
// karta Schema :
TabSheet2->Enabled = false;
Image1->Visible = false;
// karta Navrh svetelnej signalizacie I :
TabSheet3->Enabled = false;
Label6->Enabled = false;
Image2->Visible = false;
Image3->Visible = false;
// karta Navrh svetelnej signalizacie II :
Pouzi_1->Enabled = false;
Label7->Enabled = false;
Label8->Visible = false;
L1_label->Visible = false;
L1_edit->Visible = false;
L2_label->Visible = false;
L2_edit->Visible = false;
L3_label->Visible = false;
L3_edit->Visible = false;
v1_label->Visible = false;
v1_edit->Visible = false;
v2_label->Visible = false;
v2_edit->Visible = false;
Label11->Visible = false;
Label10->Enabled = false;
Label7->Enabled = false;
// karta :
Label12->Enabled = false;
Label15->Enabled = false;
Label13->Visible = false;
Label14->Visible = false;
Label16->Visible = false;
Label17->Visible = false;
Label17->Caption = "";
Uloz->Enabled = false;
// inicializacia premennych :
help = 0;
help_1 = 0;
tb = 2;
zlta = 3;
nova = false;
Y = 0;
Nova1->Enabled = false;
Uloz1->Enabled = false;
Pouzi_0->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Koniec1Click(TObject *Sender)
{
Form1->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Oprograme1Click(TObject *Sender)
{
AboutBox->ShowModal();
}
//---------------------------------------------------------------------------