From be1c7e5098d91bad7f1a0fffca8378a1412b6a45 Mon Sep 17 00:00:00 2001 From: Gerardo Date: Tue, 8 Feb 2022 21:45:31 +0100 Subject: [PATCH] Avance comunicacion con olivia task --- Conexion/Cstr_socket.cs | 12 ++++++------ Model/Limpieza.cs | 22 +++++++++++++++++++++- Model/Respuesta.cs | 4 ++++ Services/EjecServ.cs | 6 ++++-- Services/LanzaSrv/LanzaLimpSrv.cs | 8 ++++---- Services/LanzaSrv/LanzaOlvServ.cs | 10 +--------- Services/LanzaSrv/LanzaRecoSrv.cs | 10 +++++----- Services/ProcesoEjecServ.cs | 1 + 8 files changed, 46 insertions(+), 27 deletions(-) diff --git a/Conexion/Cstr_socket.cs b/Conexion/Cstr_socket.cs index c42ecaf..0da6bff 100644 --- a/Conexion/Cstr_socket.cs +++ b/Conexion/Cstr_socket.cs @@ -116,25 +116,25 @@ namespace OliviaAddIn } } //funciones auxiliares------------------------------ - [DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [DllImport("utiles.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] unsafe public static extern IntPtr str_socket_crea(); - [DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [DllImport("utiles.dll", CallingConvention = CallingConvention.Cdecl, 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)] + [DllImport("utiles.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] unsafe public static extern int str_socket_recive(IntPtr soc); - [DllImport("utiles.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)] + [DllImport("utiles.dll", CallingConvention = CallingConvention.Cdecl, 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)] + [DllImport("utiles.dll", CallingConvention = CallingConvention.Cdecl, 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)] + [DllImport("utiles.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] unsafe public static extern void str_socket_borra(IntPtr soc); } } diff --git a/Model/Limpieza.cs b/Model/Limpieza.cs index aef3624..f8c5c07 100644 --- a/Model/Limpieza.cs +++ b/Model/Limpieza.cs @@ -51,6 +51,8 @@ namespace OliviaAddInPro.Model public Limpieza() { Serv = new LimpiezaServ(this); + LanzaSrv = new LanzaLimpSrv(); + ProceSrv = new ProcesoEjecServ(); } public TareaRes Ejecuta(ModosEjec modo, CancelableProgressorSource cps) @@ -60,8 +62,26 @@ namespace OliviaAddInPro.Model res = Serv.Sectoriza(cps); else if (modo == ModosEjec.Planifica) res = Serv.Planifica(cps); - // + //if(!res.Errores) + if (res.Errores) + { + var res1=LanzaSrv.ejec(this, modo, TipoTtoStr); + if (!res1.HasError) + { + var conf = ConfigServ.Serv.Leer(); + ProceSrv.Puerto = conf.Puerto; + ProceSrv.Ip = conf.Ip; + res1 = ProceSrv.start(LanzaSrv.str_cfg, cps); + } + + if (res1.HasError) + { + res.Errores = true; + res.msg = ""; + res1.Error.ForEach(e=> res.msg+=e+".\n "); + } + } return res; } public async void EjecutaAsync(ModosEjec modo, CancelableProgressorSource cps, Action ffin) diff --git a/Model/Respuesta.cs b/Model/Respuesta.cs index dea26fa..a1c2f91 100644 --- a/Model/Respuesta.cs +++ b/Model/Respuesta.cs @@ -19,5 +19,9 @@ namespace OliviaAddInPro.Model return Error.Any(); } } + public Respuesta() + { + Error = new List(); + } } } diff --git a/Services/EjecServ.cs b/Services/EjecServ.cs index 23365a4..61e775f 100644 --- a/Services/EjecServ.cs +++ b/Services/EjecServ.cs @@ -16,8 +16,10 @@ namespace OliviaAddInPro.Services public enum ModosEjec { Sectoriza, - Planifica - } + Planifica, + SoloPlanifica + + } //Clase que realiza las funciones de la ejecución public class EjecServ { diff --git a/Services/LanzaSrv/LanzaLimpSrv.cs b/Services/LanzaSrv/LanzaLimpSrv.cs index 765484b..51aafcf 100644 --- a/Services/LanzaSrv/LanzaLimpSrv.cs +++ b/Services/LanzaSrv/LanzaLimpSrv.cs @@ -18,7 +18,7 @@ namespace OliviaAddInPro.Services.LanzaSrv * Comienza las funciones de ejecución * modo 0 la primera vez, va a sectorizar, modo 1 la segunda vez, planifica */ - public Respuesta ejec(Limpieza limp, int modo, string NombreTratamiento) + public Respuesta ejec(Limpieza limp, ModosEjec modo, string NombreTratamiento) { var res = new Respuesta(); if (limp == null) @@ -56,7 +56,7 @@ namespace OliviaAddInPro.Services.LanzaSrv * 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) + private bool configura_ops_geo(Limpieza limp, ModosEjec modo) { string str; string modo_str = ""; @@ -68,9 +68,9 @@ namespace OliviaAddInPro.Services.LanzaSrv if (limp.RespCirc) r = 1; //restricción de circulación - if (modo == 0) + if (modo == ModosEjec.Sectoriza) modo_str = GeneralDef.SockConf; - else if (modo == 1) + else if (modo == ModosEjec.Planifica) modo_str = GeneralDef.SockConfPlan; var conf=ConfigServ.Serv.Leer(); //van ParamLimpN parámetros, sin incluir "CONFIGURACION", si se añaden, incrementar ParamLimpN diff --git a/Services/LanzaSrv/LanzaOlvServ.cs b/Services/LanzaSrv/LanzaOlvServ.cs index a8bf125..c3f24ca 100644 --- a/Services/LanzaSrv/LanzaOlvServ.cs +++ b/Services/LanzaSrv/LanzaOlvServ.cs @@ -14,14 +14,6 @@ namespace OliviaAddInPro.Services.LanzaSrv * */ public class LanzaOlvServ { - //************************************************************************************* - //Enums - public enum ModosEjec - { - Secto, - Planif, - SoloPlanif, - } //************************************************************************************* //Variables /** @@ -103,7 +95,7 @@ namespace OliviaAddInPro.Services.LanzaSrv 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() + " " + + args = GeneralDef.EjecGeoParamSep + GeneralDef.GG_tipo + GeneralDef.EjecGeoParamIgual + (((int)OliviaGlob.TipoEjec)-1).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 + " " + diff --git a/Services/LanzaSrv/LanzaRecoSrv.cs b/Services/LanzaSrv/LanzaRecoSrv.cs index 38dbef0..2849b1a 100644 --- a/Services/LanzaSrv/LanzaRecoSrv.cs +++ b/Services/LanzaSrv/LanzaRecoSrv.cs @@ -16,7 +16,7 @@ namespace OliviaAddInPro.Services.LanzaSrv * Comienza las funciones de ejecución * modo 0 la primera vez, va a sectorizar, modo 1 la segunda vez, planifica */ - public Respuesta ejec(Recogida reco, int modo, string NombreTratamiento) + public Respuesta ejec(Recogida reco, ModosEjec modo, string NombreTratamiento) { var res = new Respuesta(); res.Value = false; @@ -52,15 +52,15 @@ namespace OliviaAddInPro.Services.LanzaSrv * 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) + private bool configura_ops_geo(Recogida reco, ModosEjec modo) { string str, modo_str = ""; - if (modo == (int)ModosEjec.Secto) + if (modo == ModosEjec.Sectoriza) modo_str = GeneralDef.SockConf; - else if (modo == (int)ModosEjec.Planif) + else if (modo == ModosEjec.Planifica) modo_str = GeneralDef.SockConfPlan; - else if (modo == (int)ModosEjec.SoloPlanif) + else if (modo == ModosEjec.SoloPlanifica) modo_str = GeneralDef.SockConfTodo; var conf = ConfigServ.Serv.Leer(); //van ParamLimpN parámetros, sin incluir "CONFIGURACION", si se añaden, incrementar ParamLimpN diff --git a/Services/ProcesoEjecServ.cs b/Services/ProcesoEjecServ.cs index 3eae35c..aec1ceb 100644 --- a/Services/ProcesoEjecServ.cs +++ b/Services/ProcesoEjecServ.cs @@ -90,6 +90,7 @@ namespace OliviaAddInPro.Services var act = new Respuesta() { Value = TiposActu.ActuMal }; act.Error.AddRange(res.Error); actualiza(act); + sal = true; } else nint++;