Resolver errores merge
parent
3110a03174
commit
32959793ad
|
|
@ -0,0 +1,78 @@
|
||||||
|
using ArcGIS.Core.Geometry;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OliviaAddInPro.Helper;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using ArcGIS.Core.CIM;
|
||||||
|
using ArcGIS.Core.Data;
|
||||||
|
using OliviaAddInPro.Services;
|
||||||
|
using static OliviaAddInPro.Model.ComunDef;
|
||||||
|
using ArcGIS.Desktop.Framework.Contracts;
|
||||||
|
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||||
|
using OliviaAddInPro.Services.LanzaSrv;
|
||||||
|
|
||||||
|
namespace OliviaAddInPro.Model
|
||||||
|
{
|
||||||
|
public class Limpieza : TratamientoComun
|
||||||
|
{
|
||||||
|
//**********************************************
|
||||||
|
//Se recogen en PaneLimpiezaSub1
|
||||||
|
/**
|
||||||
|
* Ámbitos de trabajo elegidos
|
||||||
|
*/
|
||||||
|
public bool[] AmbitosSel { get; set; } = new bool[(int)LimpiezaDef.AmbitsTra.AmbN];
|
||||||
|
/**
|
||||||
|
* Indica si respeta el sentido de circulación o no
|
||||||
|
*/
|
||||||
|
public bool RespCirc { get; set; } = false;
|
||||||
|
/**
|
||||||
|
* Tipo de unidades del tiempo de tto
|
||||||
|
*/
|
||||||
|
public int UdsTTto { get; set; } = (int)GeneralDef.OlvTiposTto.OlvTipTtoNoDef;
|
||||||
|
/**
|
||||||
|
* Instancia para las funciones de exportación y demás
|
||||||
|
*/
|
||||||
|
|
||||||
|
public LimpiezaServ Serv { get; set; } = null;
|
||||||
|
public LanzaLimpSrv LanzaSrv { get; set; } = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ancho de vía, en metros
|
||||||
|
*/
|
||||||
|
public double AnchoVia { get; set; } = LimpiezaDef.Parametros.ancho_via;
|
||||||
|
public Limpieza()
|
||||||
|
{
|
||||||
|
Serv = new LimpiezaServ(this);
|
||||||
|
LanzaSrv = new LanzaLimpSrv();
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
ProceSrv = new ProcesoEjecServ();
|
||||||
|
ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||||
|
>>>>>>> Gerardo/MarchandoUnaDe
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Respuesta<TiposEjecucion> Ejecuta(ModosEjec modo)
|
||||||
|
{
|
||||||
|
Respuesta<bool> res = new Respuesta<bool> { Value=false};
|
||||||
|
Respuesta<TiposEjecucion> res2 = new Respuesta<TiposEjecucion> (){ Value = TiposEjecucion.FinEjecNOk };
|
||||||
|
res = Serv.Ejecuta(modo);
|
||||||
|
if (res.Value)
|
||||||
|
{
|
||||||
|
res=LanzaSrv.ejec(this, modo, TipoTtoStr);
|
||||||
|
if (res.Value)
|
||||||
|
{
|
||||||
|
ProceSrv.ConfigConex();
|
||||||
|
res2 = ProceSrv.start(LanzaSrv.str_cfg, ProgrSrc._ProgrSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res.HasError)
|
||||||
|
{
|
||||||
|
res2.Error.AddRange(res.Error);
|
||||||
|
}
|
||||||
|
return res2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using OliviaAddInPro.Helper;
|
||||||
|
using OliviaAddInPro.Services;
|
||||||
|
using ArcGIS.Core.Geometry;
|
||||||
|
using static OliviaAddInPro.Model.ComunDef;
|
||||||
|
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||||
|
using OliviaAddInPro.Services.LanzaSrv;
|
||||||
|
|
||||||
|
namespace OliviaAddInPro.Model
|
||||||
|
{
|
||||||
|
class Recogida : TratamientoComun
|
||||||
|
{
|
||||||
|
//**********************************************
|
||||||
|
//Se recogen en PaneRecogidaSub1
|
||||||
|
/**
|
||||||
|
* Tipo de fracción
|
||||||
|
*/
|
||||||
|
public int TipoFrac { get; set; } = -1;
|
||||||
|
/**
|
||||||
|
* Tipo de fracción
|
||||||
|
*/
|
||||||
|
public string TipoFracStr { get; set; } = string.Empty;
|
||||||
|
/**
|
||||||
|
* Tipo de carga
|
||||||
|
*/
|
||||||
|
public int TipoCarg { get; set; } = -1;
|
||||||
|
/**
|
||||||
|
* Tipo de carga
|
||||||
|
*/
|
||||||
|
public string TipoCargStr { get; set; } = string.Empty;
|
||||||
|
/**
|
||||||
|
* Tipo de Vehículo
|
||||||
|
*/
|
||||||
|
public int TipoVehic { get; set; } = -1;
|
||||||
|
/**
|
||||||
|
* Tipo de Lateralidad
|
||||||
|
*/
|
||||||
|
public int TipoLate { get; set; } = -1;
|
||||||
|
/**
|
||||||
|
* kg capac camión
|
||||||
|
*/
|
||||||
|
public int KgMaxVehic { get; set; } = 0;
|
||||||
|
/**
|
||||||
|
* dens contenedor
|
||||||
|
*/
|
||||||
|
public int DensCont { get; set; } = 0;
|
||||||
|
/**
|
||||||
|
* Tiempo de vaciado del contenedor, en seg
|
||||||
|
*/
|
||||||
|
public int TVaciCont { get; set; } = 0;
|
||||||
|
/**
|
||||||
|
* kg de carga en cada contenedor
|
||||||
|
*/
|
||||||
|
public int KgCont { get; set; } = 0;
|
||||||
|
/**
|
||||||
|
* grados en º de giro del vehículo
|
||||||
|
*/
|
||||||
|
public int GiroVehic { get; set; } = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
public double AnchoVehiculo
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
public RecogidaServ Serv { get; set; } = null;
|
||||||
|
public LanzaRecoSrv LanzaSrv { get; set; } = null;
|
||||||
|
public Recogida()
|
||||||
|
{
|
||||||
|
Serv = new RecogidaServ(this);
|
||||||
|
<<<<<<< HEAD
|
||||||
|
LanzaSrv = new LanzaRecoSrv();
|
||||||
|
=======
|
||||||
|
ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||||
|
>>>>>>> Gerardo/MarchandoUnaDe
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Respuesta<TiposEjecucion> Ejecuta(ModosEjec modo)
|
||||||
|
{
|
||||||
|
Respuesta<bool> res = new Respuesta<bool> { Value = false };
|
||||||
|
Respuesta<TiposEjecucion> res2 = new Respuesta<TiposEjecucion>() { Value = TiposEjecucion.FinEjecNOk };
|
||||||
|
res = Serv.Ejecuta(modo);
|
||||||
|
if (res.Value)
|
||||||
|
{
|
||||||
|
res = LanzaSrv.ejec(this, modo, TipoTtoStr);
|
||||||
|
if (res.Value)
|
||||||
|
{
|
||||||
|
ProceSrv.ConfigConex();
|
||||||
|
res2 = ProceSrv.start(LanzaSrv.str_cfg, ProgrSrc._ProgrSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res.HasError)
|
||||||
|
{
|
||||||
|
res2.Error.AddRange(res.Error);
|
||||||
|
}
|
||||||
|
return res2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
||||||
using ArcGIS.Core.Geometry;
|
using ArcGIS.Core.Geometry;
|
||||||
using ArcGIS.Desktop.Internal.Layouts.Utilities;
|
using ArcGIS.Desktop.Internal.Layouts.Utilities;
|
||||||
using OliviaAddInPro.Helper;
|
using OliviaAddInPro.Helper;
|
||||||
|
using OliviaAddInPro.Model.contract;
|
||||||
using OliviaAddInPro.Services;
|
using OliviaAddInPro.Services;
|
||||||
using static OliviaAddInPro.Model.ComunDef;
|
using static OliviaAddInPro.Model.ComunDef;
|
||||||
|
|
||||||
|
|
@ -138,7 +139,7 @@ namespace OliviaAddInPro.Model
|
||||||
|
|
||||||
public TratamientoComun()
|
public TratamientoComun()
|
||||||
{
|
{
|
||||||
ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog);
|
ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||||
ProceSrv = new ProcesoEjecServ();
|
ProceSrv = new ProcesoEjecServ();
|
||||||
FinProceSrv = new FinProcServ();
|
FinProceSrv = new FinProcServ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ namespace OliviaAddInPro.Services
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
public Respuesta<bool> start(string cfg, CancelableProgressorSource cps)
|
public Respuesta<TiposEjecucion> start(string cfg, IprocessManager cps)
|
||||||
{
|
{
|
||||||
this.cps = cps;
|
this.cps = cps;
|
||||||
soc = new Cstr_socket();
|
soc = new Cstr_socket();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,511 @@
|
||||||
|
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||||
|
using OliviaAddIn;
|
||||||
|
using OliviaAddInPro.Model;
|
||||||
|
using OliviaAddInPro.Model.contract;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OliviaAddInPro.Services
|
||||||
|
{
|
||||||
|
public class ProcesoEjecServ
|
||||||
|
{
|
||||||
|
Cstr_socket soc = null;
|
||||||
|
int m_out=0;
|
||||||
|
int m_miliseconds=200;
|
||||||
|
int m_tm_progr=1000;
|
||||||
|
int modo_fin = 0;
|
||||||
|
bool cancela = false;
|
||||||
|
bool cancela_fin = false;
|
||||||
|
bool conectado = false;
|
||||||
|
bool permu = false;
|
||||||
|
bool cancela_permu = false;
|
||||||
|
int progr = 0;
|
||||||
|
string args = "";
|
||||||
|
string str_cfg = "";
|
||||||
|
string tarea = "";
|
||||||
|
public string err_str = "";
|
||||||
|
double x, y;
|
||||||
|
IprocessManager cps;
|
||||||
|
enum TiposActu
|
||||||
|
{
|
||||||
|
ActuMal,
|
||||||
|
ActuNoActu,
|
||||||
|
ActuBien,
|
||||||
|
ActuPermu,
|
||||||
|
ActuMulti,
|
||||||
|
ActuFinOk,
|
||||||
|
ActuSect,
|
||||||
|
ActuPlan,
|
||||||
|
ActuFinNOk,
|
||||||
|
ActuN,
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Ip { get; set; }
|
||||||
|
public int Puerto { get; set; }
|
||||||
|
|
||||||
|
public ProcesoEjecServ()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
public Respuesta<TiposEjecucion> start(string cfg, CancelableProgressorSource cps)
|
||||||
|
=======
|
||||||
|
public Respuesta<bool> start(string cfg, IprocessManager cps)
|
||||||
|
>>>>>>> Gerardo/MarchandoUnaDe
|
||||||
|
{
|
||||||
|
this.cps = cps;
|
||||||
|
soc = new Cstr_socket();
|
||||||
|
|
||||||
|
str_cfg = cfg;
|
||||||
|
/*
|
||||||
|
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
|
||||||
|
{
|
||||||
|
run();
|
||||||
|
};*/
|
||||||
|
return run();
|
||||||
|
}
|
||||||
|
private Respuesta<TiposEjecucion> run()
|
||||||
|
{
|
||||||
|
int nint = 0;
|
||||||
|
int nint_max = 5;
|
||||||
|
bool sal = false;
|
||||||
|
bool first_send_cfg = true;
|
||||||
|
bool fin = false;
|
||||||
|
int lastprog = 0;
|
||||||
|
var res = new Respuesta<TiposEjecucion>() { Value = TiposEjecucion.FinEjecNOk };
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Thread.Sleep(m_miliseconds);
|
||||||
|
|
||||||
|
if (first_send_cfg)//a continuación envía la configuración
|
||||||
|
{
|
||||||
|
Thread.Sleep(500);
|
||||||
|
if (!envia_cfg())
|
||||||
|
{
|
||||||
|
if (nint >= nint_max)
|
||||||
|
{
|
||||||
|
res.Error.Add("Error en la comunicación con OliviaTask");
|
||||||
|
var act = new Respuesta<TiposActu>() { Value = TiposActu.ActuFinNOk };
|
||||||
|
act.Error.AddRange(res.Error);
|
||||||
|
actualiza(act);
|
||||||
|
sal = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nint++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
first_send_cfg = false;
|
||||||
|
nint = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cps.Getcancelled()) //mira a ver si ha cancelado el usuario
|
||||||
|
{
|
||||||
|
//se ha cancelado, lo envía al OliviaTask
|
||||||
|
envia_cancel();
|
||||||
|
if (!cancela_permu)
|
||||||
|
sal = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cancela_permu = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!first_send_cfg && ((Math.Abs(Environment.TickCount) - lastprog) >= m_tm_progr) && !fin) //en caso normal, todo va bien, pide el progreso y la tarea
|
||||||
|
{
|
||||||
|
//solo pide la programación cada m_tm_progr milis
|
||||||
|
var pp = pide_progr();
|
||||||
|
if (pp .Value> TiposActu.ActuFinOk)
|
||||||
|
fin = true;
|
||||||
|
if(pp.HasError)
|
||||||
|
{
|
||||||
|
if (nint >= nint_max)
|
||||||
|
{
|
||||||
|
res.Error.Add(pp.Error.FirstOrDefault());
|
||||||
|
sal = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nint++;
|
||||||
|
}
|
||||||
|
actualiza(pp);
|
||||||
|
lastprog = Environment.TickCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (!sal);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
res.Error.Add(e.Message);
|
||||||
|
//MessageBox.Show("Error durante el proceso.", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
if (!res.HasError)
|
||||||
|
res.Value = TiposEjecucion.FinEjecOk;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
//funciones auxiliares----------------------------------------
|
||||||
|
private bool conecta()
|
||||||
|
{
|
||||||
|
if (!conectado)
|
||||||
|
{
|
||||||
|
if (!soc.conecta(Ip, Puerto))
|
||||||
|
{
|
||||||
|
conectado = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
conectado = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Envía la información de la configuración por socket a OliviaTask
|
||||||
|
*/
|
||||||
|
public bool envia_cfg()
|
||||||
|
{
|
||||||
|
string args;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!conecta())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (str_cfg == null || str_cfg.Length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!soc.envia(str_cfg))
|
||||||
|
{
|
||||||
|
conectado = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
args = soc.recibe();
|
||||||
|
if ((args.Length == 0) || (args != GeneralDef.SockConfOk))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Pide por socket la información de sectorización a OliviaTask
|
||||||
|
*/
|
||||||
|
private bool pide_sect()
|
||||||
|
{
|
||||||
|
//pide sectorización porque ya ha sido avisado de que ha terminado
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!conecta())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
//pide secto
|
||||||
|
if (!soc.envia(GeneralDef.SockSect))
|
||||||
|
{
|
||||||
|
conectado = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//recibe sectorización
|
||||||
|
args = soc.recibe();
|
||||||
|
if (args.Length == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Pide por socket la información de progreso a OliviaTask
|
||||||
|
* Devuelve 0 si ha ido mal, 1 si ha ido bien, 2 si ha recibido que hay que pedir sectorización
|
||||||
|
*/
|
||||||
|
private Respuesta<TiposActu> pide_progr()
|
||||||
|
{
|
||||||
|
TiposActu tt;
|
||||||
|
int i;
|
||||||
|
var res = new Respuesta<TiposActu> { Value = TiposActu.ActuMal };
|
||||||
|
//pide progreso y tarea por la que va
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!conecta())
|
||||||
|
{
|
||||||
|
res.Error.Add("Error en la comunicación con OliviaTask");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//pide progreso
|
||||||
|
if (!soc.envia(GeneralDef.SockProgr))
|
||||||
|
{
|
||||||
|
conectado = false;
|
||||||
|
res.Error.Add("Error en la comunicación con OliviaTask");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//recibe progreso
|
||||||
|
args = soc.recibe();
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
res.Value = TiposActu.ActuNoActu;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//comprueba progreso
|
||||||
|
try
|
||||||
|
{
|
||||||
|
progr = Convert.ToInt32(args);
|
||||||
|
if (progr < 0 || progr > GeneralDef.ProgrMax)
|
||||||
|
{
|
||||||
|
res.Value = TiposActu.ActuNoActu;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
res.Value = TiposActu.ActuNoActu;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//pide tarea
|
||||||
|
if (!soc.envia(GeneralDef.SockTarea))
|
||||||
|
{
|
||||||
|
res.Error.Add( "");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
//recibe tarea
|
||||||
|
args = soc.recibe();
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
res.Error.Add("Error recibe tarea mal");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
if (args == "0") //se ha mezclado el progreso, vuelve a recibir la tarea
|
||||||
|
args = soc.recibe();
|
||||||
|
if (args.Length == 0)
|
||||||
|
{
|
||||||
|
res.Error.Add("Error recibe tarea mal");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
tt = TiposActu.ActuBien;
|
||||||
|
//comprueba tarea
|
||||||
|
if (args.StartsWith(GeneralDef.SockSectFin))
|
||||||
|
{
|
||||||
|
i = GeneralDef.SockSectFin.Length;
|
||||||
|
tt = TiposActu.ActuSect;
|
||||||
|
}
|
||||||
|
else if (args.StartsWith(GeneralDef.SockPlanFin))
|
||||||
|
{
|
||||||
|
i = GeneralDef.SockPlanFin.Length;
|
||||||
|
tt = TiposActu.ActuPlan;
|
||||||
|
}
|
||||||
|
else if (args.StartsWith(GeneralDef.SockFinOk))
|
||||||
|
{
|
||||||
|
i = GeneralDef.SockFinOk.Length;
|
||||||
|
tt = TiposActu.ActuFinOk;
|
||||||
|
}
|
||||||
|
else if (args.StartsWith(GeneralDef.SockFinNOk))
|
||||||
|
{
|
||||||
|
i = GeneralDef.SockFinNOk.Length;
|
||||||
|
tt = TiposActu.ActuFinNOk;
|
||||||
|
}
|
||||||
|
else if (args.Contains("permutaciones"))
|
||||||
|
{
|
||||||
|
tt = TiposActu.ActuPermu;
|
||||||
|
}
|
||||||
|
else if (args.Contains("multitask"))
|
||||||
|
{
|
||||||
|
tt = TiposActu.ActuMulti;
|
||||||
|
}
|
||||||
|
modo_fin = (int)tt;
|
||||||
|
|
||||||
|
tarea = args.Substring(i);
|
||||||
|
res.Value = tt;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
res.Error.Add("Error al preguntar por el progreso.");
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Envía a OliviaTask la orden de cancelar el proceso
|
||||||
|
*/
|
||||||
|
private Respuesta<bool> envia_cancel()
|
||||||
|
{
|
||||||
|
var res = new Respuesta<bool> { Value = false };
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!conectado)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
//envía cancel
|
||||||
|
if (!soc.envia(GeneralDef.SockCanc))
|
||||||
|
return res;
|
||||||
|
|
||||||
|
//recibe respuesta
|
||||||
|
args = soc.recibe();
|
||||||
|
if (args.Length == 0)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
//comprueba que ok
|
||||||
|
if (args != GeneralDef.SockCancOk)
|
||||||
|
return res;
|
||||||
|
res.Value = true;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
res.Error.Add("Error al cancelar el progreso.");
|
||||||
|
res.Value = false;
|
||||||
|
//MessageBox.Show("Error al cancelar el progreso.", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Actualiza la barra de progreso
|
||||||
|
* bool fallo_soc : indica si ha habido fallo en el socket
|
||||||
|
*/
|
||||||
|
private void actualiza(Respuesta<TiposActu> actu)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
permu = false;
|
||||||
|
//actualiza la barra de tarea y el texto
|
||||||
|
switch (actu.Value)
|
||||||
|
{
|
||||||
|
case TiposActu.ActuBien:
|
||||||
|
{
|
||||||
|
pon_progr(progr);
|
||||||
|
pon_texto(tarea);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuMal:
|
||||||
|
{
|
||||||
|
if (actu.HasError)
|
||||||
|
pon_texto(actu.Error.FirstOrDefault());
|
||||||
|
else
|
||||||
|
pon_texto(tarea);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuFinOk:
|
||||||
|
{
|
||||||
|
pon_progr(100);
|
||||||
|
pon_texto("Finalizado proceso con éxito");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuFinNOk:
|
||||||
|
{
|
||||||
|
pon_progr(100);
|
||||||
|
err_str = "Finalizado proceso con fallos\n" + tarea;
|
||||||
|
pon_texto(err_str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuSect:
|
||||||
|
{
|
||||||
|
pon_progr(100);
|
||||||
|
pon_texto("Finalizada sectorización\n" + tarea);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuPlan:
|
||||||
|
{
|
||||||
|
pon_progr(100);
|
||||||
|
pon_texto("Finalizada planificación\n" + tarea);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuPermu:
|
||||||
|
{
|
||||||
|
permu = true;
|
||||||
|
pon_texto(tarea);
|
||||||
|
//pon_estilo(ProgressBarStyle.Marquee);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TiposActu.ActuMulti:
|
||||||
|
{
|
||||||
|
pon_texto(tarea);
|
||||||
|
//pon_estilo(ProgressBarStyle.Marquee);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (actu != TiposActu.ActuPermu && actu != TiposActu.ActuMulti)
|
||||||
|
pon_estilo(ProgressBarStyle.Continuous);*/
|
||||||
|
pon_barstate(actu.Value);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//MessageBox.Show("Error al actualizar el progreso.", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Para poder actualizar el texto de la ventana de progreso hay que llamar a invoke
|
||||||
|
* porque está desde otro thread
|
||||||
|
*/
|
||||||
|
private void pon_texto(String txt)
|
||||||
|
{
|
||||||
|
cps.SetEstado(txt);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Para poder actualizar la barra de progreso hay que llamar a invoke
|
||||||
|
* porque está desde otro thread
|
||||||
|
* Actualiza el tipo de progreso y el texto
|
||||||
|
*/
|
||||||
|
private void pon_estilo()
|
||||||
|
{
|
||||||
|
//cps.Status
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Para poder actualizar la barra de progreso hay que llamar a invoke
|
||||||
|
* porque está desde otro thread
|
||||||
|
* Actualiza el estilo para indicar que ha habido error
|
||||||
|
*/
|
||||||
|
private void pon_barstate(TiposActu actu)
|
||||||
|
{
|
||||||
|
int col = 1;
|
||||||
|
|
||||||
|
|
||||||
|
if ((actu == TiposActu.ActuMal) || (actu == TiposActu.ActuFinNOk))
|
||||||
|
cps.SetProceso("Proceso Finalizado con errores.");
|
||||||
|
else if(actu == TiposActu.ActuFinOk)
|
||||||
|
cps.SetProceso("Proceso Finalizado.");
|
||||||
|
|
||||||
|
if (actu > TiposActu.ActuFinOk)
|
||||||
|
cps.SetEstado("Calculando...");
|
||||||
|
if ((actu == TiposActu.ActuPermu) && !cancela)
|
||||||
|
cps.SetEstado("Calculando Permutaciones...");
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Para poder actualizar la barra de progreso hay que llamar a invoke
|
||||||
|
* porque está desde otro thread
|
||||||
|
* Actualiza el progreso
|
||||||
|
*/
|
||||||
|
private void pon_progr(int pro)
|
||||||
|
{
|
||||||
|
cps.SetProgress( pro);
|
||||||
|
}
|
||||||
|
|
||||||
|
//configura los parámetros de la conexión
|
||||||
|
public void ConfigConex()
|
||||||
|
{
|
||||||
|
var conf = ConfigServ.Serv.Leer();
|
||||||
|
Puerto = conf.Puerto;
|
||||||
|
Ip = conf.Ip;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ namespace OliviaAddInPro
|
||||||
/**
|
/**
|
||||||
* Acciones para comenzar ejecución
|
* Acciones para comenzar ejecución
|
||||||
*/
|
*/
|
||||||
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
|
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
|
||||||
{
|
{
|
||||||
string err = "";
|
string err = "";
|
||||||
//marchando
|
//marchando
|
||||||
|
|
@ -191,9 +191,7 @@ namespace OliviaAddInPro
|
||||||
HelperGlobal.ponMsg(err);
|
HelperGlobal.ponMsg(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
OliviaGlob.limp.ComienzaEjec(modo);
|
||||||
Action<TareaRes> ac = OliviaGlob.finEjecuta;
|
|
||||||
OliviaGlob.Limp.EjecutaAsync(modo, ac);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,14 @@ using OliviaAddInPro.Helper;
|
||||||
using static OliviaAddInPro.Model.ComunDef;
|
using static OliviaAddInPro.Model.ComunDef;
|
||||||
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||||
using ArcGIS.Desktop.Framework.Contracts;
|
using ArcGIS.Desktop.Framework.Contracts;
|
||||||
|
|
||||||
namespace OliviaAddInPro
|
namespace OliviaAddInPro
|
||||||
{
|
{
|
||||||
class PaneLimpiezaViewModel : PanelViewModelBase
|
class PaneLimpiezaViewModel : PanelViewModelBase
|
||||||
{
|
{
|
||||||
private PaneLimpiezaSub1ViewModel _subPanel1ViewModel;
|
private PaneLimpiezaSub1ViewModel _subPanel1ViewModel;
|
||||||
|
Limpieza limp;
|
||||||
|
public MarchandoUnaDe marchando;
|
||||||
public PaneLimpiezaViewModel()
|
public PaneLimpiezaViewModel()
|
||||||
{
|
{
|
||||||
_subPanel1ViewModel = new PaneLimpiezaSub1ViewModel();
|
_subPanel1ViewModel = new PaneLimpiezaSub1ViewModel();
|
||||||
|
|
@ -31,7 +33,7 @@ namespace OliviaAddInPro
|
||||||
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/time.png")), Resource1.String_tiempos, _subPanel4ViewModel)
|
new OptionsMenuItem(new BitmapImage(new Uri("pack://application:,,,/OliviaAddInPro;component/Resources/time.png")), Resource1.String_tiempos, _subPanel4ViewModel)
|
||||||
};
|
};
|
||||||
SelectedOption = OptionsMenu[0];
|
SelectedOption = OptionsMenu[0];
|
||||||
// OliviaGlob.limp = OliviaGlob.Limp;
|
limp = OliviaGlob.Limp;
|
||||||
}
|
}
|
||||||
public override string DisplayName
|
public override string DisplayName
|
||||||
{
|
{
|
||||||
|
|
@ -77,7 +79,12 @@ namespace OliviaAddInPro
|
||||||
err_str = "No se ha seleccionado ninguna Capa de Limpieza";
|
err_str = "No se ha seleccionado ninguna Capa de Limpieza";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
OliviaGlob.limp.CapaElems = _subPanel1ViewModel.CapaElems;
|
limp.CapaElems = _subPanel1ViewModel.CapaElems;
|
||||||
|
//pone que la capa de elementos es la red navegable, que es la que va a exportar
|
||||||
|
if (_subPanel1ViewModel.SelOpAmb == 1)
|
||||||
|
{
|
||||||
|
limp.CapaElems = OliviaGlob.Paths.PathGdbNw;
|
||||||
|
}
|
||||||
|
|
||||||
//lee el tipo tto
|
//lee el tipo tto
|
||||||
if (_subPanel1ViewModel.TipoTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
|
if (_subPanel1ViewModel.TipoTto == (int)LimpiezaDef.TiposTto.TtoNoDef)
|
||||||
|
|
@ -85,31 +92,26 @@ namespace OliviaAddInPro
|
||||||
err_str = "No se ha seleccionado ningún Tipo de Tratamiento";
|
err_str = "No se ha seleccionado ningún Tipo de Tratamiento";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
<<<<<<< HEAD
|
|
||||||
OliviaGlob.limp.TipoTto = _subPanel1ViewModel.TipoTto;
|
|
||||||
|
|
||||||
=======
|
|
||||||
limp.TipoTto = _subPanel1ViewModel.TipoTto;
|
limp.TipoTto = _subPanel1ViewModel.TipoTto;
|
||||||
limp.TipoTtoStr = LimpiezaDef.tto_gdb[_subPanel1ViewModel.TipoTto];
|
limp.TipoTtoStr = LimpiezaDef.tto_gdb[_subPanel1ViewModel.TipoTto];
|
||||||
>>>>>>> Elena/reco
|
|
||||||
//lee el/los ámbito seleccionado
|
//lee el/los ámbito seleccionado
|
||||||
if (!_subPanel1ViewModel.lee_ambitos())
|
if (!_subPanel1ViewModel.lee_ambitos())
|
||||||
{
|
{
|
||||||
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
|
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
OliviaGlob.limp.AmbitosSel = _subPanel1ViewModel.AmbitosSel;
|
limp.AmbitosSel = _subPanel1ViewModel.AmbitosSel;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < OliviaGlob.limp.AmbitosSel.Length; i++)
|
for (i = 0; i < limp.AmbitosSel.Length; i++)
|
||||||
if (OliviaGlob.limp.AmbitosSel[i])
|
if (limp.AmbitosSel[i])
|
||||||
break;
|
break;
|
||||||
if(i>= OliviaGlob.limp.AmbitosSel.Length)
|
if(i>= limp.AmbitosSel.Length)
|
||||||
{
|
{
|
||||||
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
|
err_str = "No se ha seleccionado ningún Ámbito de trabajo";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//lee si respeta circulacion
|
//lee si respeta circulacion
|
||||||
OliviaGlob.limp.RespCirc = _subPanel1ViewModel.RespCirc;
|
limp.RespCirc = _subPanel1ViewModel.RespCirc;
|
||||||
|
|
||||||
//lee velo de desplazamiento
|
//lee velo de desplazamiento
|
||||||
int vv = -1;
|
int vv = -1;
|
||||||
|
|
@ -123,7 +125,7 @@ namespace OliviaAddInPro
|
||||||
err_str = "La velocidad de desplazamiento no está dentro de los límites configurados";
|
err_str = "La velocidad de desplazamiento no está dentro de los límites configurados";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
OliviaGlob.limp.VDespl = vv;
|
limp.VDespl = vv;
|
||||||
|
|
||||||
//lee tiempo de tto
|
//lee tiempo de tto
|
||||||
if ((_subPanel1ViewModel.TimeTto == 0) ||
|
if ((_subPanel1ViewModel.TimeTto == 0) ||
|
||||||
|
|
@ -132,11 +134,31 @@ namespace OliviaAddInPro
|
||||||
err_str = "El tiempo de tratamiento no está dentro de los límites configurados";
|
err_str = "El tiempo de tratamiento no está dentro de los límites configurados";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
OliviaGlob.limp.Ttto = _subPanel1ViewModel.TimeTto;
|
limp.Ttto = _subPanel1ViewModel.TimeTto;
|
||||||
OliviaGlob.limp.UdsTTto = _subPanel1ViewModel.UdsTTto;
|
limp.UdsTTto = _subPanel1ViewModel.UdsTTto;
|
||||||
|
|
||||||
|
//lee el ancho medio de la vía si está visible (se ha seleccionado la opción genérica Eje de calles)
|
||||||
|
limp.AnchoVia = LimpiezaDef.Parametros.ancho_via;
|
||||||
|
if (_subPanel1ViewModel.VisTextAnchoVia == System.Windows.Visibility.Visible)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
limp.AnchoVia = Convert.ToDouble(_subPanel1ViewModel.TextAnchoVia);
|
||||||
|
if ((limp.AnchoVia == 0) || (limp.AnchoVia > LimpiezaDef.Parametros.ancho_viaM) || (limp.AnchoVia < LimpiezaDef.Parametros.ancho_viam))
|
||||||
|
{
|
||||||
|
err_str = "El ancho de la vía no está dentro de los límites configurados";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
err_str = "El formato introducido para el ancho de la vía no es válido.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//lee las propiedades comunes a recogida
|
//lee las propiedades comunes a recogida
|
||||||
if (!LeeComun(OliviaGlob.limp,out err_str))
|
if (!LeeComun(limp,out err_str))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -155,28 +177,32 @@ namespace OliviaAddInPro
|
||||||
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
|
public void Ejecuta(OliviaAddInPro.Services.ModosEjec modo)
|
||||||
{
|
{
|
||||||
string err = "";
|
string err = "";
|
||||||
|
<<<<<<< HEAD
|
||||||
|
//comprueba datos de la ventana
|
||||||
|
=======
|
||||||
|
//marchando
|
||||||
|
|
||||||
|
|
||||||
|
OliviaGlob.Limp.ProgrSrc = new MyCancelableProgressorSource(OliviaGlob.progrDialog.GetViewModel());
|
||||||
OliviaGlob.progrDialog.Show();
|
OliviaGlob.progrDialog.Show();
|
||||||
var progSrc = new CancelableProgressorSource(OliviaGlob.progrDialog);
|
|
||||||
|
|
||||||
|
//oculta la ventana
|
||||||
|
OliviaGlob.ShowHidePane(false);
|
||||||
|
|
||||||
|
>>>>>>> Gerardo/MarchandoUnaDe
|
||||||
if (!Lee(out err))
|
if (!Lee(out err))
|
||||||
{
|
{
|
||||||
HelperGlobal.ponMsg(err);
|
HelperGlobal.ponMsg(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
|
OliviaGlob.Limp.ComienzaEjec(modo);
|
||||||
|
=======
|
||||||
|
|
||||||
Action<TareaRes> ac = finEjecuta;
|
Action<TareaRes> ac = OliviaGlob.finEjecuta;
|
||||||
OliviaGlob.Limp.EjecutaAsync(modo, progSrc, ac);
|
OliviaGlob.Limp.EjecutaAsync(modo, ac);
|
||||||
}
|
|
||||||
public void finEjecuta(TareaRes res)
|
>>>>>>> Gerardo/MarchandoUnaDe
|
||||||
{
|
|
||||||
OliviaGlob.progrDialog.Hide();
|
|
||||||
if (res.Errores)
|
|
||||||
{
|
|
||||||
HelperGlobal.ponMsg(res.msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue