Arreglos varios tiempos shp

Gerardo/estandarizacion
Elena 2020-06-02 02:44:40 +02:00
parent 5515f57c6c
commit 1db598ab45
2 changed files with 212 additions and 146 deletions

View File

@ -6960,7 +6960,7 @@ void Colv_limp_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
s = &olv_limp->sec[is]; s = &olv_limp->sec[is];
if(s->namb<=0) if(s->namb<=0)
continue; continue;
s->cost_despl_aux=0; s->cost_despl_aux=0;
sig=FALSE; sig=FALSE;
//busca el ámbito inicial de la planificiación //busca el ámbito inicial de la planificiación
@ -7101,7 +7101,7 @@ BOOL Colv_limp_thr::planifica_fin()
/////////////////////////////////////// ///////////////////////////////////////
//Si es barrido mixto hay que copiar la info en las que no se ha sectorizado //Si es barrido mixto hay que copiar la info en las que no se ha sectorizado
if(olv_limp->barr_mix) if(olv_limp->barr_mix)
copia_info_barr_mix(); copia_info_barr_mix();
/////////////////////////////////// ///////////////////////////////////
//prepara los datos para guardarlos //prepara los datos para guardarlos
@ -7538,9 +7538,9 @@ BOOL Colv_limp_thr::genera_planif_instala(int is, int nvaciados, int ini, int fi
return FALSE; return FALSE;
if(tip_viaje==OLV_IDA_INST) if(tip_viaje==OLV_IDA_INST)
olv_limp->sec[is].t_despl[0]=(float)pp_insta[0].elem[pp_insta[0].nelem-1].coste; olv_limp->sec[is].t_despl[0]=(float)pp_insta[i].elem[pp_insta[i].nelem-1].coste + olv_limp->t_sal;
else if(tip_viaje==OLV_VUELTA_INST) //son impares, implica que la última ida adescargar es a la instalación también else if(tip_viaje==OLV_VUELTA_INST) //son impares, implica que la última ida adescargar es a la instalación también
olv_limp->sec[is].t_despl[1]=(float)pp_insta[pp->ninsta-1].elem[pp_insta[pp->ninsta-1].nelem-1].coste; olv_limp->sec[is].t_despl[1]=(float)pp_insta[i].elem[pp_insta[i].nelem-1].coste + olv_limp->t_sal;
return TRUE; return TRUE;
} }
@ -7964,7 +7964,7 @@ int Colv_limp_thr::rellena_insta_tramos()
if(olv_limp->plan[is].planif_insta[nins-1].nelem==0) if(olv_limp->plan[is].planif_insta[nins-1].nelem==0)
nins--; //es porque la descarga y planta son la misma nins--; //es porque la descarga y planta son la misma
pinsta = olv_limp->plan[is].planif_insta; pinsta = olv_limp->plan[is].planif_insta;
for(it=0;it<nt-1;it++) for(it=0;it<nt;it++)
{ {
tramo = &olv_limp->tramos[is][it]; tramo = &olv_limp->tramos[is][it];
tramo->iins[0]=2*it; tramo->iins[0]=2*it;
@ -7975,14 +7975,20 @@ int Colv_limp_thr::rellena_insta_tramos()
tramo->t_ini -= (float)pinsta[tramo->iins[0]].elem[pinsta[tramo->iins[0]].nelem-1].coste; tramo->t_ini -= (float)pinsta[tramo->iins[0]].elem[pinsta[tramo->iins[0]].nelem-1].coste;
tramo->t_fin += (float)pinsta[tramo->iins[1]].elem[pinsta[tramo->iins[1]].nelem-1].coste; tramo->t_fin += (float)pinsta[tramo->iins[1]].elem[pinsta[tramo->iins[1]].nelem-1].coste;
tramo->t_total_tr=(float) (tramo->t_fin-tramo->t_ini); tramo->t_total_tr=(float) (tramo->t_fin-tramo->t_ini);
tramo->long_tr += pinsta[tramo->iins[0]].m[OLV_DESP] + pinsta[tramo->iins[1]].m[OLV_DESP];
}
if (olv_limp->plan[is].ninsta % 2) //instala y descarga distintos si es impar
{
//para el último tramo
tramo = &olv_limp->tramos[is][nt-1];
//tramo->iins[0] = 2 * it;
tramo->iins[1] = nins - 1;
//tramo->t_ini -= (float)pinsta[tramo->iins[0]].elem[pinsta[tramo->iins[0]].nelem - 1].coste;
tramo->t_fin += (float)pinsta[tramo->iins[1]].elem[pinsta[tramo->iins[1]].nelem - 1].coste;
tramo->t_total_tr = (float)(tramo->t_fin - tramo->t_ini);
tramo->long_tr += pinsta[tramo->iins[1]].m[OLV_DESP];
} }
//para el último tramo
tramo = &olv_limp->tramos[is][it];
tramo->iins[0]=2*it;
tramo->iins[1]=nins-1;
tramo->t_ini -= (float)pinsta[tramo->iins[0]].elem[pinsta[tramo->iins[0]].nelem-1].coste;
tramo->t_fin += (float)pinsta[tramo->iins[1]].elem[pinsta[tramo->iins[1]].nelem-1].coste;
tramo->t_total_tr=(float) (tramo->t_fin-tramo->t_ini);
ii++; ii++;
} }
return ii; return ii;
@ -7999,6 +8005,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
int h,m,s; int h,m,s;
int i, it,ntram,nt,nt_parc; int i, it,ntram,nt,nt_parc;
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
//cuenta el número de sectores no vacíos //cuenta el número de sectores no vacíos
ntram=0; ntram=0;
@ -8019,7 +8026,12 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
return FALSE; return FALSE;
} }
memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
{
free(info);
return FALSE;
}
//SECTOR ya viene //SECTOR ya viene
@ -8036,7 +8048,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8057,7 +8069,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"VIAJE",GdataTable::Tint,&dataDbf)) if(!dbfmgr.AddCol(NULL,"VIAJE",GdataTable::Tint,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8079,7 +8091,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"H_INI",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"H_INI",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8101,7 +8113,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"H_FIN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"H_FIN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8123,7 +8135,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"T_TOTAL",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_TOTAL",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8145,7 +8157,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc += nt; nt_parc += nt;
} }
if (!dbfmgr.AddCol(path_dbf, "M_TOTAL", GdataTable::Tdouble, &dataDbf)) if (!dbfmgr.AddCol(NULL, "M_TOTAL", GdataTable::Tdouble, &dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8167,13 +8179,20 @@ BOOL Colv_limp_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"T_TRAT",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_TRAT",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
} }
memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ);
free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -8246,20 +8265,19 @@ void Colv_limp_thr::rellena_tramos()
} }
tramo->t_tto_tr = (float)(pp->t[OLV_TTO]); tramo->t_tto_tr = (float)(pp->t[OLV_TTO]);
if(pp->planif_insta)
{ //actualiza tiempos de tramos
if(it==0) if (pp->planif_insta)
tramo->t_ini = (float)(olv_limp->t_ini+olv_limp->t_sal+pp->planif_insta[0].elem[pp->planif_insta[0].nelem-1].coste); {
else tramo->t_ini = (float)(pp->planif_insta[2 * it].t[OLV_TTO] + pp->planif_insta[2 * it].elem[pp->planif_insta[2 * it].nelem - 1].coste);
tramo->t_ini = (float)(pp->planif_insta[2*it].t[OLV_TTO]+pp->planif_insta[2*it].elem[pp->planif_insta[2*it].nelem-1].coste); tramo->t_fin = (float)pp->planif_insta[2 * it + 1].t[OLV_TTO];
tramo->t_fin = (float)pp->planif_insta[2 * it + 1].t[OLV_TTO];
} }
else else
{ {
tramo->t_ini = (float)(olv_limp->t_ini+olv_limp->t_sal); tramo->t_ini = (float)olv_limp->t_ini;
tramo->t_fin = (float)(tramo->t_ini + olv_limp->sec[is].cost_ac+olv_limp->t_desc); tramo->t_fin = (float)(tramo->t_ini + olv_limp->sec[is].cost_ac + olv_limp->t_desc);
} }
tramo->t_total_tr = (float) (tramo->t_fin-tramo->t_ini); tramo->t_total_tr = (float) (tramo->t_fin-tramo->t_ini);
} }
} }
@ -8381,6 +8399,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
char nombia[16]; char nombia[16];
int nsec, i, isec_novac; int nsec, i, isec_novac;
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
//cuenta el número de sectores no vacíos //cuenta el número de sectores no vacíos
nsec=0; nsec=0;
@ -8406,7 +8425,12 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
return FALSE; return FALSE;
} }
memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ); memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
{
free(info);
return FALSE;
}
//SECTOR ya viene //SECTOR ya viene
//TRATAMIENTO //TRATAMIENTO
@ -8420,7 +8444,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%s",olv_limp->nomb_tto); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%s",olv_limp->nomb_tto);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8440,7 +8464,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"H_INI",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"H_INI",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8455,13 +8479,13 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
{ {
continue; continue;
} }
tt=olv_limp->t_ini+ olv_limp->sec[i].cost_ac + olv_limp->t_desc + 2*olv_limp->t_sal; tt=olv_limp->t_ini+ olv_limp->sec[i].cost_ac + olv_limp->t_desc;
dame_h_m_s(tt, &h, &m, &s); dame_h_m_s(tt, &h, &m, &s);
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"H_FIN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"H_FIN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8474,12 +8498,12 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
{ {
if(olv_limp->sec[i].namb==0) if(olv_limp->sec[i].namb==0)
continue; continue;
tt=olv_limp->sec[i].cost_ac+olv_limp->t_desc + 2 * olv_limp->t_sal; tt=olv_limp->sec[i].cost_ac+olv_limp->t_desc;
dame_h_m_s(tt, &h, &m, &s); dame_h_m_s(tt, &h, &m, &s);
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"T_TOTAL",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_TOTAL",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8506,7 +8530,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
isec_novac++; isec_novac++;
} }
if (!dbfmgr.AddCol(path_dbf, "M_TOTAL", GdataTable::Tdouble, &dataDbf)) if (!dbfmgr.AddCol(NULL, "M_TOTAL", GdataTable::Tdouble, &dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8524,7 +8548,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"T_INSTA",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_INSTA",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8549,7 +8573,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
isec_novac++; isec_novac++;
} }
if (!dbfmgr.AddCol(path_dbf, "M_INSTA", GdataTable::Tdouble, &dataDbf)) if (!dbfmgr.AddCol(NULL, "M_INSTA", GdataTable::Tdouble, &dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8567,7 +8591,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"T_DESCAN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_DESCAN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8586,7 +8610,7 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"M_RUTA",GdataTable::Tdouble,&dataDbf)) if(!dbfmgr.AddCol(NULL,"M_RUTA",GdataTable::Tdouble,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8719,16 +8743,21 @@ BOOL Colv_limp_thr::guarda_cols_ruta(char *path_shp)
strcat_s(nombia,"DESP"); strcat_s(nombia,"DESP");
} }
if(!dbfmgr.AddCol(path_dbf,nombia,tipodato,&dataDbf,sz)) if(!dbfmgr.AddCol(NULL,nombia,tipodato,&dataDbf,sz))
{ {
free(info); free(info);
return FALSE; return FALSE;
} }
memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ); memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ);
} }
} }
free(info); free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -8743,6 +8772,7 @@ BOOL Colv_limp_thr::guarda_cols_ctrl(char *path_shp)
char *info; char *info;
int nsec, i, isec_novac; int nsec, i, isec_novac;
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
//cuenta el número de sectores no vacíos //cuenta el número de sectores no vacíos
nsec=0; nsec=0;
@ -8764,6 +8794,11 @@ BOOL Colv_limp_thr::guarda_cols_ctrl(char *path_shp)
} }
memset(info,0,nsec*olv_limp->npts_ctrl* OLV_SHP_SZ_CAMP_SZ); memset(info,0,nsec*olv_limp->npts_ctrl* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
{
free(info);
return FALSE;
}
//rellena el nombre del tto //rellena el nombre del tto
k=0; k=0;
@ -8781,7 +8816,7 @@ BOOL Colv_limp_thr::guarda_cols_ctrl(char *path_shp)
isec_novac++; isec_novac++;
k++; k++;
} }
if(!dbfmgr.AddCol(path_dbf,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8803,7 +8838,7 @@ BOOL Colv_limp_thr::guarda_cols_ctrl(char *path_shp)
isec_novac++; isec_novac++;
k++; k++;
} }
if(!dbfmgr.AddCol(path_dbf,"SECUENCIA",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"SECUENCIA",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8833,13 +8868,17 @@ BOOL Colv_limp_thr::guarda_cols_ctrl(char *path_shp)
k++; k++;
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"HORA",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"HORA",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
} }
free(info); free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -8854,6 +8893,7 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
int h,m,s,insta,i,ninsta,ninsta_parc,ninsta_novac; int h,m,s,insta,i,ninsta,ninsta_parc,ninsta_novac;
char tray[OLV_SHP_SZ_CAMP_CHAR]; char tray[OLV_SHP_SZ_CAMP_CHAR];
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
//añade una columna //añade una columna
strcpy_s(path_dbf,MAX_PATH,path_shp); strcpy_s(path_dbf,MAX_PATH,path_shp);
@ -8878,6 +8918,11 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
} }
memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
{
free(info);
return FALSE;
}
//rellena el nombre del tto //rellena el nombre del tto
ninsta_parc=0; ninsta_parc=0;
@ -8895,7 +8940,7 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"TTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8935,7 +8980,7 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"TRAYECTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"TRAYECTO",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8975,7 +9020,7 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"H_INI",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"H_INI",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -8994,6 +9039,8 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
continue; continue;
tt=olv_limp->plan[i].planif_insta[insta].elem[olv_limp->plan[i].planif_insta[insta].nelem-1].coste; tt=olv_limp->plan[i].planif_insta[insta].elem[olv_limp->plan[i].planif_insta[insta].nelem-1].coste;
if((olv_limp->plan[i].planif_insta[insta].ninsta== OLV_IDA_INST) || (olv_limp->plan[i].planif_insta[insta].ninsta == OLV_VUELTA_INST))
tt+= olv_limp->t_sal;
ttt+=tt; ttt+=tt;
dame_h_m_s(tt, &h, &m, &s); dame_h_m_s(tt, &h, &m, &s);
sprintf_s(&info[(insta+ninsta_parc)*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[(insta+ninsta_parc)*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
@ -9001,7 +9048,7 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"T_TOTAL",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_TOTAL",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -9024,7 +9071,7 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"M_TOTAL",GdataTable::Tdouble,&dataDbf)) if(!dbfmgr.AddCol(NULL,"M_TOTAL",GdataTable::Tdouble,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -9032,6 +9079,11 @@ BOOL Colv_limp_thr::guarda_cols_insta(char *path_shp)
memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ);
free(info); free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -9078,12 +9130,14 @@ BOOL Colv_limp_thr::genera_list_rut_ctrl()
continue; continue;
ii=1; ii=1;
i=0; i=0;
t0=olv_limp->t_ini + olv_limp->sec[s].t_despl[0] + olv_limp->t_sal; t0=olv_limp->t_ini + olv_limp->sec[s].t_despl[0];
if ((olv_limp->nod_instal != -1) && (pp->ninsta>0)) if ((olv_limp->nod_instal != -1) && (pp->ninsta>0))
{ {
linst[0] = pp->planif_insta[0].m[OLV_DESP]; linst[0] = pp->planif_insta[0].m[OLV_DESP];
linst[1] = pp->planif_insta[pp->ninsta-1].m[OLV_DESP]; linst[1] = pp->planif_insta[pp->ninsta-1].m[OLV_DESP];
pp->planif_insta[0].t[OLV_TTO] = olv_limp->t_ini + olv_limp->t_sal;
pp->planif_insta[pp->ninsta - 1].t[OLV_TTO] = olv_limp->t_ini + olv_limp->sec[s].cost_ac + olv_limp->t_desc - olv_limp->sec[s].t_despl[1];
} }
////////////////////////////////////////////// //////////////////////////////////////////////
@ -9228,8 +9282,6 @@ ctrl:
//último punto de control e instalación //último punto de control e instalación
if((i==(pp->nelem))&& !mal) if((i==(pp->nelem))&& !mal)
{ {
//REVISAR
olv_limp->t_ini+ olv_limp->sec[s].cost_ac + olv_limp->t_desc + olv_limp->t_sal - olv_limp->sec[s].t_despl[1];
//quita_t_ult_desc(s,&tt); //quita_t_ult_desc(s,&tt);
dame_h_m_s(tt, &h, &m, &seg); dame_h_m_s(tt, &h, &m, &seg);
sprintf_s(fila0,256,"%02d;%04d;%s;%s;%s;%s;%02d:%02d:%02d;\r\n",s+1,ii,calle,"","Control - Fin","",h,m,seg); sprintf_s(fila0,256,"%02d;%04d;%s;%s;%s;%s;%02d:%02d:%02d;\r\n",s+1,ii,calle,"","Control - Fin","",h,m,seg);
@ -9252,9 +9304,9 @@ ctrl:
} }
//final //final
tt = olv_limp->t_ini + olv_limp->sec[s].cost_ac + olv_limp->t_desc + 2 * olv_limp->t_sal; //////////////////////////////////////////////
////////////////////////////////////////////// tt = t0;
dame_h_m_s(tt- olv_limp->t_sal - olv_limp->sec[s].t_despl[1], &h, &m, &seg); dame_h_m_s(tt, &h, &m, &seg);
if (linst[1] == 0) if (linst[1] == 0)
sprintf_s(fila0, 256, "%02d;%04d;%s;%s;%s;%s;%02d:%02d:%02d;\r\n", s + 1, ii, "", "", "Vuelta a instalación", "", h, m, seg); sprintf_s(fila0, 256, "%02d;%04d;%s;%s;%s;%s;%02d:%02d:%02d;\r\n", s + 1, ii, "", "", "Vuelta a instalación", "", h, m, seg);
else else
@ -9266,6 +9318,7 @@ ctrl:
continue; continue;
} }
tt = olv_limp->t_ini + olv_limp->sec[s].cost_ac + olv_limp->t_desc;
////////////////////////////////////////////// //////////////////////////////////////////////
dame_h_m_s(tt, &h, &m, &seg); dame_h_m_s(tt, &h, &m, &seg);
sprintf_s(fila0, 256, "%02d;%04d;%s;%s;%s;%s;%02d:%02d:%02d;\r\n", s + 1, ii, "", "", "Fin", "", h, m, seg); sprintf_s(fila0, 256, "%02d;%04d;%s;%s;%s;%s;%02d:%02d:%02d;\r\n", s + 1, ii, "", "", "Fin", "", h, m, seg);

View File

@ -681,7 +681,7 @@ double Colv_reco_thr::dame_coste( Secu_amb * sec, int ini, int fin, Info_sec *s,
if(ini==0)//si ini es 0 falta sumar el coste de la planta a el primer ambito if(ini==0)//si ini es 0 falta sumar el coste de la planta a el primer ambito
{ {
d+=olv_limp->arch_dj.dame_dis(olv_limp->arch_dj.id_instal, 0, s->iamb[sec[ini].iamb],0); d+=olv_limp->arch_dj.dame_dis(olv_limp->arch_dj.id_instal, 0, s->iamb[sec[ini].iamb],0);
//d+=olv_reco->t_sal; d+=olv_reco->t_sal; //suma el coste de la salida
} }
cap_t+=olv_limp->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inf_r.kg;//suma a la carga total la basura del primer ambito cap_t+=olv_limp->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inf_r.kg;//suma a la carga total la basura del primer ambito
@ -707,7 +707,7 @@ double Colv_reco_thr::dame_coste( Secu_amb * sec, int ini, int fin, Info_sec *s,
d+=olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0][olv_reco->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inod[0]].dis;//suma el coste de ir del ultimo ambito a la planta d+=olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0][olv_reco->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inod[0]].dis;//suma el coste de ir del ultimo ambito a la planta
d+=olv_reco->t_descarg;//suma el coste de descargar d+=olv_reco->t_descarg;//suma el coste de descargar
d+=olv_reco->ord_sec_plan[OLV_INSTAL].ctnod[0][olv_reco->nod_plant].dis;//suma el coste de ir de planta a instalacion d+=olv_reco->ord_sec_plan[OLV_INSTAL].ctnod[0][olv_reco->nod_plant].dis;//suma el coste de ir de planta a instalacion
//d+=olv_reco->t_sal;//suma el coste de la llegada d+=olv_reco->t_sal;//suma el coste de la llegada
int iold=-1; int iold=-1;
BOOL errores=FALSE; BOOL errores=FALSE;
@ -876,7 +876,7 @@ double Colv_reco_thr::dame_coste_pon_viajes( Secu_amb * sec, int ini, int fin, I
if(ini==0)//si ini es 0 falta sumar el coste de la planta a el primer ambito if(ini==0)//si ini es 0 falta sumar el coste de la planta a el primer ambito
{ {
d+=olv_limp->arch_dj.dame_dis(olv_limp->arch_dj.id_instal, 0, s->iamb[sec[ini].iamb],0); d+=olv_limp->arch_dj.dame_dis(olv_limp->arch_dj.id_instal, 0, s->iamb[sec[ini].iamb],0);
//d+=olv_reco->t_sal;//suma el coste de la llegada d+=olv_reco->t_sal;//suma el coste de la salida
} }
cap_t+=olv_limp->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inf_r.kg;//suma a la carga total la basura del primer ambito cap_t+=olv_limp->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inf_r.kg;//suma a la carga total la basura del primer ambito
@ -906,8 +906,8 @@ double Colv_reco_thr::dame_coste_pon_viajes( Secu_amb * sec, int ini, int fin, I
nv_p--;//se descuenta uno porque se tiene que terminar en planta nv_p--;//se descuenta uno porque se tiene que terminar en planta
d+=olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0][olv_reco->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inod[0]].dis;//suma el coste de ir del ultimo ambito a la planta d+=olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0][olv_reco->iaso[olv_limp->carto.get(id_ambf).entity()->ref].inod[0]].dis;//suma el coste de ir del ultimo ambito a la planta
d+=olv_reco->ord_sec_plan[OLV_INSTAL].ctnod[0][olv_reco->nod_plant].dis;//suma el coste de ir de planta a instalacion d+=olv_reco->ord_sec_plan[OLV_INSTAL].ctnod[0][olv_reco->nod_plant].dis;//suma el coste de ir de planta a instalacion
d+=olv_reco->t_sal;//suma el coste de la llegada
d+=olv_reco->t_descarg;//suma el coste de descargar d+=olv_reco->t_descarg;//suma el coste de descargar
//d+=olv_reco->t_sal;//suma el coste de la llegada
/////////////////////////// ///////////////////////////
coste=MAYUSCULO; coste=MAYUSCULO;
@ -1205,15 +1205,15 @@ void Colv_reco_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
/////////////////////////////////////////// ///////////////////////////////////////////
//Añade la ruta de la instalación al primer punto //Añade la ruta de la instalación al primer punto
double cc = 0, cc1 = 0;
olv_limp->arch_dj.get_b(s->iamb[secu_ambi[0].iamb],secu_ambi[0].entrada, buf_aux); olv_limp->arch_dj.get_b(s->iamb[secu_ambi[0].iamb],secu_ambi[0].entrada, buf_aux);
Colv_geom::ruta_dj_inv_ok( cc+=Colv_geom::ruta_dj_inv_ok(
olv_reco->nod_instal,//id conjuncion inicial olv_reco->nod_instal,//id conjuncion inicial
&secu2[0], //puntero a secuencia &secu2[0], //puntero a secuencia
buf_aux, //nodos djktra conj final buf_aux, //nodos djktra conj final
olv_limp->conjs.n, olv_limp->conjs.n,
&nsecu2); &nsecu2);
cc += olv_limp->t_sal;
if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_IDA_INST)) if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_IDA_INST))
sal=TRUE; sal=TRUE;
/////////////////////////////////////////// ///////////////////////////////////////////
@ -1222,7 +1222,6 @@ void Colv_reco_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
secu[0]=olv_limp->iaso[olv_limp->carto.get(s->iamb[secu_ambi[0].iamb]).entity()->ref].inod[secu_ambi[0].entrada]; secu[0]=olv_limp->iaso[olv_limp->carto.get(s->iamb[secu_ambi[0].iamb]).entity()->ref].inod[secu_ambi[0].entrada];
aa[s->iamb[secu_ambi[0].iamb]].iseq=0; aa[s->iamb[secu_ambi[0].iamb]].iseq=0;
//olv_limp->t_conv //olv_limp->t_conv
double cc=0, cc1=0;
ss=1; ss=1;
int iam_ped; int iam_ped;
int iam_ent; int iam_ent;
@ -1239,6 +1238,7 @@ void Colv_reco_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0], //nodos djktra conj final olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0], //nodos djktra conj final
olv_limp->conjs.n, olv_limp->conjs.n,
&nsecu2); &nsecu2);
cc += olv_reco->t_descarg;
if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_IDA_PLANT)) if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_IDA_PLANT))
{ {
sal=TRUE; sal=TRUE;
@ -1306,6 +1306,7 @@ void Colv_reco_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0], //nodos djktra conj final olv_reco->ord_sec_plan[OLV_PLANT].ctnod[0], //nodos djktra conj final
olv_limp->conjs.n, olv_limp->conjs.n,
&nsecu2); &nsecu2);
cc += olv_reco->t_descarg;
if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_IDA_PLANT)) if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_IDA_PLANT))
{ {
sal=TRUE; sal=TRUE;
@ -1320,6 +1321,7 @@ void Colv_reco_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
olv_reco->ord_sec_plan[OLV_INSTAL].ctnod[0], //nodos djktra conj final olv_reco->ord_sec_plan[OLV_INSTAL].ctnod[0], //nodos djktra conj final
olv_limp->conjs.n, olv_limp->conjs.n,
&nsecu2); &nsecu2);
cc += olv_limp->t_sal;
if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_VUELTA_INST)) if(!genera_planif_vaci(is,0, nsecu2, secu2,OLV_VUELTA_INST))
{ {
sal=TRUE; sal=TRUE;
@ -1339,8 +1341,8 @@ void Colv_reco_thr::planifica_sub_1(int ithr, Matrix2d<float> &cost_amb)
//genera la ruta y los puntos de control //genera la ruta y los puntos de control
if(!genera_planif(is,s->cost_despl_aux/*-cc*/, ss, secu,OLV_PLAN_RECO)) if(!genera_planif(is,s->cost_despl_aux/*-cc*/, ss, secu,OLV_PLAN_RECO))
sal=TRUE; sal=TRUE;
olv_limp->sec[is].cost_ac=s->cost_despl_aux; //olv_limp->sec[is].cost_ac = s->cost_despl_aux;
//olv_limp->sec[is].cost_ac=(float)(olv_limp->plan[is].elem[olv_limp->plan[is].nelem-1].coste+olv_limp->sec[is].t_despl[0]+olv_limp->sec[is].t_despl[1]); olv_limp->sec[is].cost_ac=(float)(olv_limp->plan[is].elem[olv_limp->plan[is].nelem-1].coste+cc);
} }
////////////////////////////////// //////////////////////////////////
if( secu_ambi) if( secu_ambi)
@ -1487,7 +1489,7 @@ BOOL Colv_reco_thr::genera_list_fila_vaci(Colv_csv *cc, char *fila0, int ielem,
ltot=pp->m[OLV_DESP]; ltot=pp->m[OLV_DESP];
////////////////// //////////////////
//pone el tiempo acumulado, aprovecha y lo guarda aquí //pone el tiempo acumulado anterior, en el que se inicia este vaciado, aprovecha y lo guarda aquí
pp->t[OLV_TTO]=tt; pp->t[OLV_TTO]=tt;
////////////////// //////////////////
@ -1516,14 +1518,17 @@ BOOL Colv_reco_thr::genera_list_fila_vaci(Colv_csv *cc, char *fila0, int ielem,
pp->m[OLV_TTO]=kgac; pp->m[OLV_TTO]=kgac;
////////////////// //////////////////
*t0+=cost_despl+olv_reco->t_descarg;
tt+=cost_despl+olv_reco->t_descarg;
dame_h_m_s(tt, &h, &m, &seg); dame_h_m_s(tt, &h, &m, &seg);
sprintf_s(fila0,256,"%02d;%04d;%s;%.1f;%s;%.1f;%02d:%02d:%02d;\r\n",isec+1,secu,"",kgac,"Ida a descargar",ltot,h,m,seg); sprintf_s(fila0,256,"%02d;%04d;%s;%.1f;%s;%.1f;%02d:%02d:%02d;\r\n",isec+1,secu,"",kgac,"Ida a descargar",ltot,h,m,seg);
if(!cc->escribe(fila0)) if(!cc->escribe(fila0))
{ {
return FALSE; return FALSE;
} }
*t0 += cost_despl + olv_reco->t_descarg;
tt += cost_despl + olv_reco->t_descarg;
if (is_fin)
*t0 = tt;
if(olv_reco->ptos_vaci[iamb]!=(short)OLV_IDA_PLANT) if(olv_reco->ptos_vaci[iamb]!=(short)OLV_IDA_PLANT)
return TRUE; return TRUE;
@ -1554,6 +1559,7 @@ BOOL Colv_reco_thr::genera_list_fila_vaci(Colv_csv *cc, char *fila0, int ielem,
//reinicia, para que no vuelva a entrar //reinicia, para que no vuelva a entrar
olv_reco->ptos_vaci[iamb]=0; olv_reco->ptos_vaci[iamb]=0;
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -1591,6 +1597,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
int h,m,s,j; int h,m,s,j;
int nsec, i, isec_novac,p; int nsec, i, isec_novac,p;
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
//cuenta el número de sectores no vacíos //cuenta el número de sectores no vacíos
nsec=0; nsec=0;
@ -1605,7 +1612,6 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
if(!Colv_limp_thr::guarda_cols_ruta(path_shp)) if(!Colv_limp_thr::guarda_cols_ruta(path_shp))
return FALSE; return FALSE;
//añade una columna a la ruta de tiempo de ruta
strcpy_s(path_dbf,MAX_PATH,path_shp); strcpy_s(path_dbf,MAX_PATH,path_shp);
//cambiaext(path_dbf,".shp",".dbf"); //cambiaext(path_dbf,".shp",".dbf");
strcpy((Cdir_manager::extension_archivo(path_dbf)),"dbf"); strcpy((Cdir_manager::extension_archivo(path_dbf)),"dbf");
@ -1617,27 +1623,25 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
} }
memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ); memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
/*//sustituye la info de hora final {
isec_novac=0; free(info);
for(i=0;i<olv_limp->nsec;i++) return FALSE;
{ }
if(olv_limp->sec[i].namb==0)
{ //elimina col M_DESP
continue; if (!dbfmgr.DelCol(NULL, "M_DESP"))
} {
tt=olv_limp->t_ini+ olv_limp->sec[i].cost_ac + olv_limp->t_desc; free(info);
return FALSE;
dame_h_m_s(tt, &h, &m, &s); }
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; //renombra T_DESP por T_RUTA
} if (!db.rename(db.getInd("T_DESP"),"T_RUTA"))
if(!dbfmgr.AddCol(path_dbf,"H_FIN",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
} }
memset(info,0,nsec* OLV_SHP_SZ_CAMP_SZ);*/
//sustituye col m total //sustituye col m total
isec_novac = 0; isec_novac = 0;
@ -1658,7 +1662,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
isec_novac++; isec_novac++;
} }
if (!dbfmgr.AddCol(path_dbf, "M_TOTAL", GdataTable::Tdouble, &dataDbf)) if (!dbfmgr.AddCol(NULL, "M_TOTAL", GdataTable::Tdouble, &dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1678,7 +1682,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
((int*)info)[isec_novac] = tt; ((int*)info)[isec_novac] = tt;
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"UDS_TRAT",GdataTable::Tint,&dataDbf)) if(!dbfmgr.AddCol(NULL,"UDS_TRAT",GdataTable::Tint,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1696,7 +1700,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
((double*)info)[isec_novac] = tt; ((double*)info)[isec_novac] = tt;
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"KG_TOT_REC",GdataTable::Tdouble,&dataDbf)) if(!dbfmgr.AddCol(NULL,"KG_TOT_REC",GdataTable::Tdouble,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1714,7 +1718,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
((int*)info)[isec_novac] = tt; ((int*)info)[isec_novac] = tt;
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"N_DESCARG",GdataTable::Tint,&dataDbf)) if(!dbfmgr.AddCol(NULL,"N_DESCARG",GdataTable::Tint,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1739,7 +1743,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s); sprintf_s(&info[isec_novac*OLV_SHP_SZ_CAMP_CHAR],OLV_SHP_SZ_CAMP_CHAR,"%02d:%02d:%02d h",h,m,s);
isec_novac++; isec_novac++;
} }
if(!dbfmgr.AddCol(path_dbf,"T_DESCARG",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR)) if(!dbfmgr.AddCol(NULL,"T_DESCARG",GdataTable::Tstring,&dataDbf,OLV_SHP_SZ_CAMP_CHAR))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1763,7 +1767,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
isec_novac++; isec_novac++;
} }
if (!dbfmgr.AddCol(path_dbf, "M_DESCARG", GdataTable::Tdouble, &dataDbf)) if (!dbfmgr.AddCol(NULL, "M_DESCARG", GdataTable::Tdouble, &dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1771,6 +1775,11 @@ BOOL Colv_reco_thr::guarda_cols_ruta(char *path_shp)
memset(info, 0, nsec * OLV_SHP_SZ_CAMP_SZ); memset(info, 0, nsec * OLV_SHP_SZ_CAMP_SZ);
free(info); free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -1785,6 +1794,7 @@ BOOL Colv_reco_thr::guarda_cols_insta(char *path_shp)
//int h; //int h;
int insta, ninsta_parc,ninsta,ninsta_novac; int insta, ninsta_parc,ninsta,ninsta_novac;
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
///////////////////////////////////// /////////////////////////////////////
@ -1814,6 +1824,11 @@ BOOL Colv_reco_thr::guarda_cols_insta(char *path_shp)
} }
memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
{
free(info);
return FALSE;
}
//kg descargados //kg descargados
ninsta_parc=0; ninsta_parc=0;
@ -1835,7 +1850,7 @@ BOOL Colv_reco_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"KG_DESCARG",GdataTable::Tdouble,&dataDbf)) if(!dbfmgr.AddCol(NULL,"KG_DESCARG",GdataTable::Tdouble,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1863,7 +1878,7 @@ BOOL Colv_reco_thr::guarda_cols_insta(char *path_shp)
} }
ninsta_parc+=ninsta_novac; ninsta_parc+=ninsta_novac;
} }
if(!dbfmgr.AddCol(path_dbf,"VIAJE",GdataTable::Tint,&dataDbf)) if(!dbfmgr.AddCol(NULL,"VIAJE",GdataTable::Tint,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1871,6 +1886,11 @@ BOOL Colv_reco_thr::guarda_cols_insta(char *path_shp)
memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ninsta* OLV_SHP_SZ_CAMP_SZ);
free(info); free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -1891,7 +1911,9 @@ BOOL Colv_reco_thr::guarda_cols_ruta_tram(char *path_shp)
char path_dbf[MAX_PATH]; char path_dbf[MAX_PATH];
double tt; double tt;
int i, it,ntram,nt,nt_parc; int i, it,ntram,nt,nt_parc;
Info_planif *pinsta;
ManagerDbfGdataTable dbfmgr; ManagerDbfGdataTable dbfmgr;
GdataTable db;
if(!Colv_limp_thr::guarda_cols_ruta_tram(path_shp)) if(!Colv_limp_thr::guarda_cols_ruta_tram(path_shp))
return FALSE; return FALSE;
@ -1919,22 +1941,34 @@ BOOL Colv_reco_thr::guarda_cols_ruta_tram(char *path_shp)
} }
memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ);
AddColsDbf dataDbf(info); AddColsDbf dataDbf(info);
if (!dbfmgr.LeeDbf(path_dbf, &db))
{
free(info);
return FALSE;
}
//M_DESP //M_RUTA
nt_parc=0; nt_parc=0;
for(i=0;i<olv_limp->nsec;i++) for(i=0;i<olv_limp->nsec;i++)
{ {
if(olv_limp->sec[i].namb==0) if(olv_limp->sec[i].namb==0)
continue; continue;
nt=(int)olv_limp->tramos[i].size(); nt=(int)olv_limp->tramos[i].size();
for(it=0;it<nt;it++) for(it=0;it<nt;it++)
{ {
pinsta=olv_limp->plan[i].planif_insta;
tt=olv_limp->tramos[i][it].long_tr; tt=olv_limp->tramos[i][it].long_tr;
//como es solo ruta le quita las instalaciones
tt -= (pinsta[olv_limp->tramos[i][it].iins[0]].m[OLV_DESP] + pinsta[olv_limp->tramos[i][it].iins[1]].m[OLV_DESP]);
if (olv_limp->tramos[i][it].iins[1] > (olv_limp->tramos[i][it].iins[0] + 1)) //si la planta y la instala no son las mismas
tt -= pinsta[olv_limp->tramos[i][it].iins[1] - 1].m[OLV_DESP];
((double*)info)[nt_parc + it] = tt; ((double*)info)[nt_parc + it] = tt;
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"M_RUTA",GdataTable::Tdouble,&dataDbf)) if(!dbfmgr.AddCol(NULL,"M_RUTA",GdataTable::Tdouble,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1955,7 +1989,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"N_AMB",GdataTable::Tint,&dataDbf)) if(!dbfmgr.AddCol(NULL,"N_AMB",GdataTable::Tint,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1976,7 +2010,7 @@ BOOL Colv_reco_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"UDS_TRAT",GdataTable::Tint,&dataDbf)) if(!dbfmgr.AddCol(NULL,"UDS_TRAT",GdataTable::Tint,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
@ -1997,12 +2031,18 @@ BOOL Colv_reco_thr::guarda_cols_ruta_tram(char *path_shp)
} }
nt_parc+=nt; nt_parc+=nt;
} }
if(!dbfmgr.AddCol(path_dbf,"KG_TOT_REC",GdataTable::Tdouble,&dataDbf)) if(!dbfmgr.AddCol(NULL,"KG_TOT_REC",GdataTable::Tdouble,&dataDbf))
{ {
free(info); free(info);
return FALSE; return FALSE;
} }
memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ); memset(info,0,ntram* OLV_SHP_SZ_CAMP_SZ);
free(info);
if (!dbfmgr.grabaDbf(path_dbf, &db))
{
return FALSE;
}
return TRUE; return TRUE;
} }
//************************************************************************************* //*************************************************************************************
@ -2015,6 +2055,8 @@ void Colv_reco_thr::rellena_tramos()
Info_tramos *tramo; Info_tramos *tramo;
int ie,it,nt; int ie,it,nt;
Colv_limp_thr::rellena_tramos();
for(int is=0;is<olv_limp->nsec;is++) for(int is=0;is<olv_limp->nsec;is++)
{ {
pp=&olv_limp->plan[is]; pp=&olv_limp->plan[is];
@ -2022,27 +2064,13 @@ void Colv_reco_thr::rellena_tramos()
for(it=0;it<nt;it++) for(it=0;it<nt;it++)
{ {
tramo = &olv_limp->tramos[is][it]; tramo = &olv_limp->tramos[is][it];
tramo->namb=0;
tramo->ncont=0; tramo->ncont=0;
for(ie=tramo->ie[0]; ie<=tramo->ie[1];ie++) for(ie=tramo->ie[0]; ie<=tramo->ie[1];ie++)
{ {
tramo->long_tr+=(float) pp->elem[ie].ltot; if (pp->elem[ie].tp != OLV_PLAN_TIP_AMB)
if(pp->elem[ie].tp!=OLV_PLAN_TIP_AMB)
continue; continue;
tramo->namb++;
tramo->ncont+=olv_limp->iaso[olv_limp->iaso[pp->elem[ie].refe].refe2].inf_r.uds; tramo->ncont+=olv_limp->iaso[olv_limp->iaso[pp->elem[ie].refe].refe2].inf_r.uds;
} }
tramo->t_tto_tr = (float)(tramo->ncont*olv_reco->t_tto);
if(it==0)
tramo->t_ini = (float)(olv_limp->t_ini+pp->planif_insta[0].elem[pp->planif_insta[0].nelem-1].coste);
else
tramo->t_ini = (float)(pp->planif_insta[2*it].t[OLV_TTO]+pp->planif_insta[2*it].elem[pp->planif_insta[2*it].nelem-1].coste);
tramo->t_fin = (float)pp->planif_insta[2*it+1].t[OLV_TTO];
tramo->t_total_tr = (float) (tramo->t_fin-tramo->t_ini);
} }
} }
} }
@ -2059,6 +2087,8 @@ int Colv_reco_thr::rellena_insta_tramos()
Info_planif *pinsta; Info_planif *pinsta;
Info_tramos *tramo; Info_tramos *tramo;
Colv_limp_thr::rellena_insta_tramos();
ii=0; //para saber si hace algún tramo o no ii=0; //para saber si hace algún tramo o no
for(int is=0;is<olv_limp->nsec;is++) for(int is=0;is<olv_limp->nsec;is++)
{ {
@ -2069,36 +2099,19 @@ int Colv_reco_thr::rellena_insta_tramos()
if(olv_limp->plan[is].planif_insta[nins-1].nelem==0) if(olv_limp->plan[is].planif_insta[nins-1].nelem==0)
nins--; //es porque la descarga y planta son la misma nins--; //es porque la descarga y planta son la misma
pinsta = olv_limp->plan[is].planif_insta; pinsta = olv_limp->plan[is].planif_insta;
for(it=0;it<nt-1;it++) for(it=0;it<nt;it++)
{ {
tramo = &olv_limp->tramos[is][it]; tramo = &olv_limp->tramos[is][it];
tramo->iins[0]=2*it;
tramo->iins[1]=2*it+1;
/////////////////////////////////////// if (it == 0)//primer tramo, le suma el tiempo de llegar
//Actualiza los tiempos del tramo sumando los tiempos del viaje a inst tramo->t_ini -= olv_limp->t_sal;
tramo->t_ini -= (float)pinsta[tramo->iins[0]].elem[pinsta[tramo->iins[0]].nelem-1].coste; tramo->t_fin += olv_reco->t_descarg;
tramo->t_fin += (float)pinsta[tramo->iins[1]].elem[pinsta[tramo->iins[1]].nelem-1].coste; if(it == (nt-1))
tramo->t_total_tr=(float) (tramo->t_fin-tramo->t_ini); tramo->t_fin += olv_limp->t_sal;
tramo->t_total_tr = (float)(tramo->t_fin - tramo->t_ini);
} }
//para el último tramo ii++;
tramo = &olv_limp->tramos[is][it];
tramo->iins[0]=2*it;
tramo->iins[1]=nins-1;
tramo->t_ini -= (float)pinsta[tramo->iins[0]].elem[pinsta[tramo->iins[0]].nelem-1].coste;
//si la instalación no es la misma que la descarga, le suma el tiempo de ir a descargar y el de ir a la instalación
BOOL notdesc=TRUE;
for(int i=tramo->iins[0]+1;i<=tramo->iins[1];i++)
{
if(notdesc)
{
tramo->t_fin += olv_reco->t_descarg;
notdesc=FALSE;
}
tramo->t_fin += (float)pinsta[i].elem[pinsta[i].nelem-1].coste;
}
tramo->t_total_tr=(float) (tramo->t_fin-tramo->t_ini);
ii++;
} }
return ii; return ii;
} }