ProcesoEjecServ cascaron
parent
87d0517e08
commit
3672be10aa
|
|
@ -155,6 +155,7 @@
|
|||
<Compile Include="Services\LanzaSrv\LanzaOlvServ.cs" />
|
||||
<Compile Include="Services\LanzaSrv\LanzaRecoSrv.cs" />
|
||||
<Compile Include="Services\LimpiezaServ.cs" />
|
||||
<Compile Include="Services\ProcesoEjecServ.cs" />
|
||||
<Compile Include="Services\RecogidaServ.cs" />
|
||||
<Compile Include="ViewModel\Configuracion\DockpaneConfigViewModel.cs" />
|
||||
<Compile Include="ViewModel\Configuracion\PaneConfigViewModel.cs" />
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ namespace OliviaAddInPro.Services
|
|||
return null;
|
||||
}
|
||||
cps.Value = 30;
|
||||
|
||||
|
||||
//prepara el filtro con consulta y espacial
|
||||
SpatialQueryFilter filtro = CreaFiltro(com.ConsultaAmbs, geomAux);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,201 @@
|
|||
using ArcGIS.Desktop.Framework.Threading.Tasks;
|
||||
using OliviaAddIn;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OliviaAddInPro.Services
|
||||
{
|
||||
class ProcesoEjecServ
|
||||
{
|
||||
Cstr_socket soc = null;
|
||||
int m_out;
|
||||
int m_miliseconds;
|
||||
int m_tm_progr;
|
||||
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;
|
||||
CancelableProgressorSource cps;
|
||||
enum TiposActu
|
||||
{
|
||||
ActuMal,
|
||||
ActuNoActu,
|
||||
ActuBien,
|
||||
ActuPermu,
|
||||
ActuMulti,
|
||||
ActuFinOk,
|
||||
ActuSect,
|
||||
ActuPlan,
|
||||
ActuFinNOk,
|
||||
ActuN,
|
||||
}
|
||||
|
||||
|
||||
public ProcesoEjecServ()
|
||||
{
|
||||
|
||||
}
|
||||
public void start(string cfg, CancelableProgressorSource cps)
|
||||
{
|
||||
this.cps = cps;
|
||||
soc = new Cstr_socket();
|
||||
|
||||
str_cfg = cfg;
|
||||
/*
|
||||
await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
|
||||
{
|
||||
run();
|
||||
};*/
|
||||
run();
|
||||
}
|
||||
private void run()
|
||||
{
|
||||
int nint = 0;
|
||||
int nint_max = 10;
|
||||
bool sal = false;
|
||||
bool first_send_cfg = true;
|
||||
bool fin = false;
|
||||
int lastprog = 0;
|
||||
TiposActu pp;
|
||||
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)
|
||||
{
|
||||
err_str = "Error en la comunicación con OliviaTask";
|
||||
actualiza(TiposActu.ActuMal);
|
||||
}
|
||||
else
|
||||
nint++;
|
||||
}
|
||||
else
|
||||
first_send_cfg = false;
|
||||
}
|
||||
|
||||
if (Interlocked.Equals(m_out, 1)) //mira a ver si ha cancelado el usuario
|
||||
{
|
||||
//se ha cancelado, lo envía al OliviaTask
|
||||
envia_cancel();
|
||||
if (!cancela_permu)
|
||||
sal = true;
|
||||
else
|
||||
{
|
||||
Interlocked.Exchange(ref m_out, (int)0);
|
||||
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
|
||||
pp = pide_progr();
|
||||
if (pp > TiposActu.ActuFinOk)
|
||||
fin = true;
|
||||
actualiza(pp);
|
||||
lastprog = Environment.TickCount;
|
||||
}
|
||||
|
||||
} while (!sal);
|
||||
|
||||
//manda cerrar la ventana porque ha terminado
|
||||
cierra();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//MessageBox.Show("Error durante el proceso.", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//funciones auxiliares----------------------------------------
|
||||
private void cierra()
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* Envía la información de la configuración por socket a OliviaTask
|
||||
*/
|
||||
public bool envia_cfg()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Pide por socket la información de sectorización a OliviaTask
|
||||
*/
|
||||
private bool pide_sect()
|
||||
{
|
||||
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 TiposActu pide_progr()
|
||||
{
|
||||
return TiposActu.ActuMal;
|
||||
}
|
||||
/**
|
||||
* Envía a OliviaTask la orden de cancelar el proceso
|
||||
*/
|
||||
private bool envia_cancel()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Actualiza la barra de progreso
|
||||
* bool fallo_soc : indica si ha habido fallo en el socket
|
||||
*/
|
||||
private void actualiza(TiposActu actu)
|
||||
{
|
||||
}
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
/*
|
||||
* 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()
|
||||
{
|
||||
}
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue