Servicios lanza proceso

ConfiguracionSimplificada
Gerardo 2022-01-27 22:24:30 +01:00
parent 65b8854b07
commit ff5648dea3
12 changed files with 710 additions and 5 deletions

140
Conexion/Cstr_socket.cs Normal file
View File

@ -0,0 +1,140 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace OliviaAddIn
{
unsafe public class Cstr_socket
{
//variables------------------------
private IntPtr sc;
//----------------------------------
public Cstr_socket()
{
sc = IntPtr.Zero;
}
~Cstr_socket()
{
termina();
}
//funciones-----------------------
//devuelve -1 si no se ha podido crear socket
//0 si no se puede conectar
//1 si conectado
public bool conecta(string ip, int puerto)
{
termina();
try
{
sc = str_socket_crea();
}
catch
{
sc = IntPtr.Zero;
}
if (sc == IntPtr.Zero)
return false;
try
{
return str_socket_conecta(sc, ip, puerto) != 0;
}
catch
{
termina();
return false;
}
}
public bool envia(string txt)
{
if (sc == IntPtr.Zero)
return false;
try
{
return 0 != str_socket_envia(sc, txt);
}
catch
{
termina();
return false;
}
}
public string recibe()
{
int nb = -2;
if (sc == IntPtr.Zero)
return "";
try
{
nb = str_socket_recive(sc);
if(nb<=0)//error
return "";
StringBuilder data = new StringBuilder("", nb);
str_socket_dame_buf(sc, data);
return data.ToString();
}
catch
{
termina();
}
return "";
}
public string dame_error()
{
if (sc == IntPtr.Zero)
return "Socket nulo";
try
{
StringBuilder data = new StringBuilder("Sin errores", 1024);
str_socket_dame_error(sc,data);
return data.ToString();
}
catch
{
termina();
}
return "Error en el socket de la dll utiles.dll";
}
public void termina()
{
if (sc != IntPtr.Zero)
{
try
{
str_socket_borra(sc);
}
catch
{
sc = IntPtr.Zero;
}
sc = IntPtr.Zero;
}
}
//funciones auxiliares------------------------------
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern IntPtr str_socket_crea();
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_conecta(IntPtr soc, String ip, int puerto);
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_envia(IntPtr soc, String txt);
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_recive(IntPtr soc);
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern void str_socket_dame_buf(IntPtr soc, StringBuilder buf);
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern void str_socket_dame_error(IntPtr soc, StringBuilder error);//llamar con 1024 de espacio
[DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern void str_socket_borra(IntPtr soc);
}
}

View File

@ -696,7 +696,72 @@ namespace OliviaAddInPro.Helper
msgOut = "";
if (!System.IO.Directory.Exists(outpath))
System.IO.Directory.CreateDirectory(outpath);
ReiniciaOutStr();
//FeatureClass fc = HelperGdb.GetFtClass(pathLayerIn);
//fc.
/*
using (RowCursor rowCursor = fc.Search(filter))
{
while (rowCursor.MoveNext())
{
using (Row row = rowCursor.Current)
{
if (row is Feature ft)
{
var sh = ft.GetShape();
sh = ft.GetShape();
sh.
}
}
}
}*/
//Selection selFeatures = featureClass.Select(filter, SelectionType.ObjectID, SelectionOption.Normal);
// make a value array of strings to be passed to ExecuteToolAsync
System.Threading.CancellationTokenSource _cts1 = new System.Threading.CancellationTokenSource();
cps.Status = "Guardando geometria a shp";
string[] args1 = { pathLayerIn, outpath };
IGPResult gpResult1 = Geoprocessing.ExecuteToolAsync("FeatureClassToFeatureClass", args1,
null, _cts1.Token,
(event_name, o) => // implement delegate and handle events
{
switch (event_name)
{
case "OnValidate":
break;
case "OnProgressMessage":
{
string msg = string.Format("{0}: {1}", new object[] { event_name, (string)o });
//progrDialog.Message = (string)o;
Debug.WriteLine(msg);
}
break;
case "OnProgressPos":
{
string msg2 = string.Format("{0}: {1} %", new object[] { event_name, (int)o });
Debug.WriteLine(msg2);
break;
}
}
}).Result;
System.Threading.CancellationTokenSource _cts= new System.Threading.CancellationTokenSource();
cps.Status = "Guardando geometria a shp";
@ -752,6 +817,14 @@ namespace OliviaAddInPro.Helper
}
/*
//filtra entidades---
var pn = string.Format("{0}{1}.{2}", pathLayerIn, nameShp);
FeatureClass fc = HelperGdb.GetFtClass(pn);
var f = new ArcGIS.Core.Data.QueryFilter();
//f.
fc.DeleteRows*/
return true;
}

View File

@ -38,7 +38,12 @@ namespace OliviaAddInPro.Model
/**
* Instancia para las funciones de exportación y demás
*/
public LimpiezaServ Serv { get; set; } = null;
/**
* Ancho de vía, en metros
*/
public double AnchoVia { get; set; } = LimpiezaDef.Parametros.ancho_via;
public Limpieza()
{
Serv = new LimpiezaServ(this);

View File

@ -34,9 +34,33 @@ namespace OliviaAddInPro.Model
}
return defec;
}
#region PropiedadesOcultas
public OliviaConf()
{
Ip = "0.0.0.0";
Puerto = 19995;
TiempoOutSocket = 20;
}
#region PropiedadesOcultas
#region parametrosConexion
/**
* IP donde va a realizar la conexión a OliviaTask, se inicializa al arrancar con la local
*/
[Browsable(false)]
public string Ip { get; set; }
/**
* Puerto local donde va a realizar la conexión a OliviaTask, se inicializa al arrancar
*/
[Browsable(false)]
public int Puerto { get; set; }
/**
* Time out de la conexión con OliviaTask, en seg
*/
[Browsable(false)]
public int TiempoOutSocket { get; set; }
#endregion
#region Paths
[Browsable(false)]
public string path_work { get; set; }

View File

@ -50,6 +50,21 @@ namespace OliviaAddInPro.Model
public static string PathSimbVSM; //<Path de la galeria de estilos aplicada por VSM
public static string PathSimbESRI; //<Path de la galeria de estilos de ESRI
};
public struct Conexion
{
/**
* IP donde va a realizar la conexión a OliviaTask, se inicializa al arrancar con la local
*/
public static string Ip;
/**
* Puerto local donde va a realizar la conexión a OliviaTask, se inicializa al arrancar
*/
public static int Puerto;
/**
* Time out de la conexión con OliviaTask, en seg
*/
public static int TiempoOutSocket;
};
private static TiposEjecucion tipoEjec = TiposEjecucion.Ninguno;
public static Limpieza limp = new Limpieza();
@ -163,7 +178,10 @@ namespace OliviaAddInPro.Model
Paths.PathGdbNw = c.red_carreteras;
Paths.PathSimbVSM = c.PathSimbVSM;
Paths.PathSimbESRI = c.PathSimbESRI;
//puerto = c.puerto;
Conexion.Puerto = c.Puerto;
Conexion.Ip = c.Ip;
Conexion.TiempoOutSocket = c.TiempoOutSocket;
//buff_export = c.buffer_export;
///////////////////////////////////////

23
Model/Respuesta.cs Normal file
View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OliviaAddInPro.Model
{
public class Respuesta<T>
{
public T Value { get; set; }
public List<string> Error { get; set; }
public bool HasError
{
get
{
return Error.Any();
}
}
}
}

View File

@ -133,6 +133,7 @@
<Compile Include="Button\ButtonLimp.cs" />
<Compile Include="Button\ButtonMaq.cs" />
<Compile Include="Button\ButtonRec.cs" />
<Compile Include="Conexion\Cstr_socket.cs" />
<Compile Include="Helper\EnabledComboBoxItem.cs" />
<Compile Include="Helper\CheckedListItem.cs" />
<Compile Include="Helper\HelperGdb.cs" />
@ -141,6 +142,7 @@
<Compile Include="Model\ESRI.ArcGIS.Geometry.esriSRProjCS4Type.cs" />
<Compile Include="Model\Recogida.cs" />
<Compile Include="Model\RecogidaDef.cs" />
<Compile Include="Model\Respuesta.cs" />
<Compile Include="Model\TratamientoComun.cs" />
<Compile Include="Model\Limpieza.cs" />
<Compile Include="Model\LimpiezaDef.cs" />
@ -148,6 +150,9 @@
<Compile Include="Model\OliviaConf.cs" />
<Compile Include="Model\OliviaDef.cs" />
<Compile Include="Services\ConfigServ.cs" />
<Compile Include="Services\LanzaSrv\LanzaLimpSrv.cs" />
<Compile Include="Services\LanzaSrv\LanzaOlvServ.cs" />
<Compile Include="Services\LanzaSrv\LanzaRecoSrv.cs" />
<Compile Include="Services\LimpiezaServ.cs" />
<Compile Include="Services\RecogidaServ.cs" />
<Compile Include="ViewModel\Configuracion\DockpaneConfigViewModel.cs" />
@ -327,6 +332,7 @@
<ItemGroup>
<Resource Include="Images\openfolder.png" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!--
PackageAction can be:
@ -336,6 +342,7 @@
-->
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PackageAction>BuildDefault</PackageAction>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PackageAction>BuildDefault</PackageAction>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,112 @@
using OliviaAddInPro.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OliviaAddInPro.Services.LanzaSrv
{
public class LanzaLimpSrv: LanzaOlvServ
{
public LanzaLimpSrv()
{
}
/**
* Comienza las funciones de ejecución
* modo 0 la primera vez, va a sectorizar, modo 1 la segunda vez, planifica
*/
public Respuesta<bool> ejec(Limpieza limp, int modo, string NombreTratamiento)
{
var res = new Respuesta<bool>();
if (limp == null)
{
res.Error.Add("Error en la recopilación de datos para el procesado");
res.Value = false;
return res;
}
OliviaGlob.TipoEjec = TiposEjecucion.Limp;//OliviaDef.GeneralDef.TiposOliv.OlivLimp;
/*
if (!OliviaGlob.gdb_limp.exporta(limp, modo == (int)Ejecuta.ModosEjec.Planif))
{
res.Error.Add(OliviaGlob.gdb_limp.err_st;
res.Value = false;
return res;
}
*/
//configura el string de opciones
if (!configura_ops_geo(limp, modo))
{
res.Error.Add("Error al configurar opciones");
res.Value = false;
return res;
}
//this.limp = limp;
//Llama al ejecuta del padre
return base.ejec(NombreTratamiento);
}
/**
* Configura el str de opciones que va a mandar a OliviaTask
* modo 0 la primera vez, va a sectorizar, modo 1 la segunda vez, planifica
*/
public bool configura_ops_geo(Limpieza limp, int modo)
{
string str;
string modo_str = "";
int r = 0;
if ((limp.TipoTto < 0) || (limp.TipoTto >= (int)LimpiezaDef.TiposTto.TtoN))
return false;
if (limp.RespCirc)
r = 1; //restricción de circulación
if (modo == 0)
modo_str = GeneralDef.SockConf;
else if (modo == 1)
modo_str = GeneralDef.SockConfPlan;
var conf=ConfigServ.Serv.Leer();
//van ParamLimpN parámetros, sin incluir "CONFIGURACION", si se añaden, incrementar ParamLimpN
str = GeneralDef.EjecGeoParamSep + modo_str + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_tto + GeneralDef.EjecGeoParamIgual + limp.Ttto + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_res + GeneralDef.EjecGeoParamIgual + r + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_uto + GeneralDef.EjecGeoParamIgual + (int)limp.UdsTTto + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_vdp + GeneralDef.EjecGeoParamIgual + limp.VDespl + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_tco + GeneralDef.EjecGeoParamIgual + limp.TConv + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_tdc + GeneralDef.EjecGeoParamIgual + limp.TDescan + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_tdp + GeneralDef.EjecGeoParamIgual + limp.TDesplIniFin + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_tca + GeneralDef.EjecGeoParamIgual + limp.TDescarg + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_hini + GeneralDef.EjecGeoParamIgual + limp.HIni + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_trafic + GeneralDef.EjecGeoParamIgual + limp.Trafico + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_npt + GeneralDef.EjecGeoParamIgual + limp.NPtosCtrl + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_sec + GeneralDef.EjecGeoParamIgual + limp.NSect + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GL_anc + GeneralDef.EjecGeoParamIgual + limp.AnchoVia + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_coox + GeneralDef.EjecGeoParamIgual + limp.CoordsInstal.X + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GG_cooy + GeneralDef.EjecGeoParamIgual + limp.CoordsInstal.Y + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GG_ais + GeneralDef.EjecGeoParamIgual + (limp.IgnoAis?1:0) + " " +
//campos del dbf de limpieza para leer
GeneralDef.EjecGeoParamSep + GeneralDef.GAA_obser + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Campos.consulta_observ + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAA_anch_tip + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Campos.consulta_anch_tip + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAA_tipolo + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Campos.consulta_tipolo + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAA_entid + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Campos.consulta_entidad + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAL_aparc + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Atributos.atr_aparc + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAL_bord + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Atributos.atr_bord + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAL_acera + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Atributos.atr_acera + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAL_peat + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Atributos.atr_peat + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAL_ap_lin + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Atributos.atr_ap_lin + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GAL_ap_bat + GeneralDef.EjecGeoParamIgual + LimpiezaDef.Atributos.atr_ap_bat + " ";
base.str_cfg = str;
return true;
}
}
}

View File

@ -0,0 +1,191 @@
using OliviaAddInPro.Model;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace OliviaAddInPro.Services.LanzaSrv
{
/*
* ejecuta antiguo
* */
public class LanzaOlvServ
{
//*************************************************************************************
//Enums
public enum ModosEjec
{
Secto,
Planif,
SoloPlanif,
}
//*************************************************************************************
//Variables
/**
* Cadena general de escritura de parámetros de configuración para envío por socket
*/
public string str_cfg;
/**
* Cadena general de escritura de parámetros para envío por socket
*/
public string str;
public string NombreTratamiento;
//*************************************************************************************
public LanzaOlvServ()
{
str = "";
}
~LanzaOlvServ() // destructor (finalizers)
{
// cleanup statements...
}
public Respuesta<bool> ejec(string NTratamiento)
{
NombreTratamiento = NTratamiento;
add_cfg_comun();
//lanza ventana marchando que lanza proceso en bucle para actualizar barra progreso
//OliviaGlob.progr_eje = new ProgresoEjec();
//lanza proceso OliviaTask
var res = lanza();
if (!res.Value)
{
res.Error.Add("Error al arrancar OliviaTask (programa de procesado de datos): No ha arrancado correctamente la instancia OliviaTask");
res.Value = true;
return res;
}
//OliviaGlob.progr_eje.start(str_cfg);
return res;
}
/**
* Añade al str de cfg los parametros de configuración comunes a limpieza y recogida
*/
private void add_cfg_comun()
{
str_cfg = str_cfg +
//campos de la red navegable
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_onew + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_onew + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_kph + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_kph + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_fow + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_fow + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTC_name + GeneralDef.EjecGeoParamIgual + ComunDef.CamposNW.cons_name + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_TF + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_TF + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_FT + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_FT + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_N + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_N + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GTA_pedes + GeneralDef.EjecGeoParamIgual + ComunDef.AtributosNW.atr_pedes + " " +
//nombre del tratamiento
GeneralDef.EjecGeoParamSep + GeneralDef.GG_strtto + GeneralDef.EjecGeoParamIgual + NombreTratamiento + " " +
//paths de archivos
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pd + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathData + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pn + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathNW + " ";
}
/**
* Arranca el proceso OliviaTask con los parámetros correspondientes
*/
private Respuesta<bool> lanza()
{
Process[] pg;
string args;
ProcessStartInfo pfi;
var res = new Respuesta<bool>();
try
{
//van ParamN parámetros, sin incluir, si se añaden, incrementar ParamN
args = GeneralDef.EjecGeoParamSep + GeneralDef.GG_tipo + GeneralDef.EjecGeoParamIgual + ((int)OliviaGlob.TipoEjec).ToString() + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_ip + GeneralDef.EjecGeoParamIgual + OliviaGlob.Conexion.Ip + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_port + GeneralDef.EjecGeoParamIgual + OliviaGlob.Conexion.Puerto + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_tout + GeneralDef.EjecGeoParamIgual + OliviaGlob.Conexion.TiempoOutSocket + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pt + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathTemp + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_pcfg + GeneralDef.EjecGeoParamIgual + OliviaGlob.Paths.PathCfg + " ";
pfi = new ProcessStartInfo(OliviaGlob.Paths.PathExeOlivia, args);
System.Diagnostics.Process.Start(pfi);
//comprueba que haya arrancado OliviaTask
//le da 2 seg de margen para que arranque
pg = Is_process(GeneralDef.NombOlvTasks, 2, true);
if (pg == null)
{
res.Error.Add(string.Format("No está OliviaTask, args= {0}", args));
res.Value = false;
return res;
}
}
catch (Exception e)
{
res.Error.Add(string.Format("Error al lanzar proceso, args= {0}", e.Message));
res.Value = false;
return res;
}
res.Value = true;
return res;
}
/**
* Itera para comprobar que ha arrancado bien un proceso, o ver si está arrancado
* int t_max : seg espera
* bool espera_start : si true, se quiere esperar t_max a que arranque,
* si false, se quiere esperar a que se cierre
* Devuelve el proceso si está, para cancelarlo, y null si no está
*/
public Process[] Is_process(string nombproc, int t_max, bool espera_start)
{
bool esta_geo = !espera_start;
int veces = 0;
int veces_max;
int milis_sleep = 50;
if (t_max <= 0)
t_max = 1;
veces_max = t_max * 1000 / milis_sleep;
Process[] pg = new Process[0];
//si ya está arrancado y se quiere esperar a que se cierre, esta_geo=true y espera_start=false;
//por lo que se cumple !espera_start && esta_geo
//tiene que esperar si esta_geo==true
//cuando se quiere esperar a que arranque, esta_geo=false y espera_start=true
//por lo que se cumple (espera_start && !esta_geo)
//en este caso, tiene que esperar si esta_geo==False
while (((espera_start && !esta_geo) || (!espera_start && esta_geo)) && (veces < veces_max))
{
try
{
pg = Process.GetProcessesByName(nombproc);
if (pg.Length == 0)
esta_geo = false;
else
esta_geo = true;
}
catch (InvalidOperationException)
{
esta_geo = false;
}
if (((espera_start && !esta_geo) || (!espera_start && esta_geo)))
{
veces++;
Thread.Sleep(milis_sleep);
}
}
if (esta_geo)
return pg;
else
return null;
}
}
}

View File

@ -0,0 +1,103 @@
using OliviaAddInPro.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OliviaAddInPro.Services.LanzaSrv
{
class LanzaRecoSrv: LanzaOlvServ
{
public LanzaRecoSrv()
{
}
/**
* Comienza las funciones de ejecución
* modo 0 la primera vez, va a sectorizar, modo 1 la segunda vez, planifica
*/
public Respuesta<bool> ejec(Recogida reco, int modo)
{
var res = new Respuesta<bool>();
res.Value = false;
if (reco == null)
{
res.Error.Add( "Error en la recopilación de datos para el procesado");
return res;
}
//OliviaGlob.tip_oliv = OliviaDef.GeneralDef.TiposOliv.OlivResi;
OliviaGlob.TipoEjec = TiposEjecucion.Reco;//OliviaDef.GeneralDef.TiposOliv.OlivResi;
/*if (!OliviaGlob.gdb_reco.exporta(reco, modo == (int)Ejecuta.ModosEjec.Planif))
{
err_str = OliviaGlob.gdb_reco.err_st;
return false;
}*/
//configura el string de opciones
if (!configura_ops_geo(reco, modo))
{
res.Error.Add("Error al configurar opciones");
return res;
}
this.reco = reco;
//Llama al ejecuta del padre
return base.ejec();
}
/**
* Configura el str de opciones que va a mandar a OliviaTask
* modo 0 la primera vez, va a sectorizar, modo 1 la segunda vez, planifica
*/
public bool configura_ops_geo(Recogida reco, int modo)
{
string str, modo_str = "";
if (modo == (int)ModosEjec.Secto)
modo_str = GeneralDef.SockConf;
else if (modo == (int)ModosEjec.Planif)
modo_str = GeneralDef.SockConfPlan;
else if (modo == (int)ModosEjec.SoloPlanif)
modo_str = GeneralDef.SockConfTodo;
//van ParamLimpN parámetros, sin incluir "CONFIGURACION", si se añaden, incrementar ParamLimpN
str = GeneralDef.EjecGeoParamSep + modo_str + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_camp_cap + GeneralDef.EjecGeoParamIgual + reco.rec_capac + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_kgM + GeneralDef.EjecGeoParamIgual + reco.carg_max_vehic + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_camp_kgrec + GeneralDef.EjecGeoParamIgual + reco.rec_kg + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_camp_uds + GeneralDef.EjecGeoParamIgual + reco.rec_uds + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_kgrecog + GeneralDef.EjecGeoParamIgual + reco.rec_kgrec_cont + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_carga_cont + GeneralDef.EjecGeoParamIgual + reco.carga_max + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_dens + GeneralDef.EjecGeoParamIgual + reco.dens_cont + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_tco + GeneralDef.EjecGeoParamIgual + reco.TConv + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_tdc + GeneralDef.EjecGeoParamIgual + reco.TDescan + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_tvc + GeneralDef.EjecGeoParamIgual + reco.t_vaci + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_tdca + GeneralDef.EjecGeoParamIgual + reco.TDescarg + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_tsal + GeneralDef.EjecGeoParamIgual + reco.t_despl_insta + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_hini + GeneralDef.EjecGeoParamIgual + reco.HIni + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_trafic + GeneralDef.EjecGeoParamIgual + reco.trafico + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_npt + GeneralDef.EjecGeoParamIgual + reco.NPtosCtrl + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_sec + GeneralDef.EjecGeoParamIgual + reco.NSect + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_anc + GeneralDef.EjecGeoParamIgual + reco.anch_vehic + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_gir + GeneralDef.EjecGeoParamIgual + reco.giro_vehic + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_coox + GeneralDef.EjecGeoParamIgual + reco.CoordsInstal.X + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GG_cooy + GeneralDef.EjecGeoParamIgual + reco.CoordsInstal.Y + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GR_descx + GeneralDef.EjecGeoParamIgual + reco.coords_descarg[0] + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GR_descy + GeneralDef.EjecGeoParamIgual + reco.coords_descarg[1] + " " +//coordenadas
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_id + GeneralDef.EjecGeoParamIgual + reco.id_sens + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_url + GeneralDef.EjecGeoParamIgual + reco.url_sens + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_fecha + GeneralDef.EjecGeoParamIgual + reco.fecha_sens + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_fechaf + GeneralDef.EjecGeoParamIgual + reco.fechaf_sens + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_sens_modo + GeneralDef.EjecGeoParamIgual + reco.media + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GG_ais + GeneralDef.EjecGeoParamIgual + (reco.IgnoAis?1:0) + " " +
GeneralDef.EjecGeoParamSep + GeneralDef.GR_lateral + GeneralDef.EjecGeoParamIgual + reco.lateralidad + " ";
base.str_cfg = str;
return true;
}
}
}

View File

@ -1,18 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using OliviaAddInPro.Model;
using OliviaAddInPro.Services;
namespace OliviaAddInPro
{
class PaneConfigViewModel : PanelViewModelBase
{
private OliviaConf conf=null;
public PaneConfigViewModel()
{
{
OnRefres();
}