Organización por carpetas y añadido IniFile y Socket

master
Elena 2019-12-17 01:15:01 +01:00
parent a425c17e97
commit 816d618daa
63 changed files with 902 additions and 87 deletions

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 funciones de la dll igt_base.dll";
}
public void termina()
{
if (sc != IntPtr.Zero)
{
try
{
str_socket_borra(sc);
}
catch
{
sc = IntPtr.Zero;
}
sc = IntPtr.Zero;
}
}
//funciones auxiliares------------------------------
[DllImport("igt_base.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern IntPtr str_socket_crea();
[DllImport("igt_base.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_conecta(IntPtr soc, String ip, int puerto);
[DllImport("igt_base.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_envia(IntPtr soc, String txt);
[DllImport("igt_base.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern int str_socket_recive(IntPtr soc);
[DllImport("igt_base.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern void str_socket_dame_buf(IntPtr soc, StringBuilder buf);
[DllImport("igt_base.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("igt_base.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
unsafe public static extern void str_socket_borra(IntPtr soc);
}
}

356
OliviaAddIn/Base/IniFile.cs Normal file
View File

@ -0,0 +1,356 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
namespace OliviaAddIn
{
public class IniFile
{
#region "Declarations"
// *** Lock for thread-safe access to file and local cache ***
private object m_Lock = new object();
// *** File name ***
private string m_FileName = null;
public string FileName
{
get
{
return m_FileName;
}
}
// *** Lazy loading flag ***
//private bool m_Lazy = false;
// *** Local cache ***
public Dictionary<string, Dictionary<string, string>> m_Sections = new Dictionary<string,Dictionary<string, string>>();
// *** Local cache modified flag ***
private bool m_CacheModified = false;
#endregion
#region "Methods"
// *** Constructor ***
public IniFile(string FileName)
{
Initialize(FileName, false);
}
//modo_escritura true, modo edición: se escribe desde el principio, false solo lectura o conserva lo que hubiera
public IniFile(string FileName, bool modo_escritura)
{
Initialize(FileName, modo_escritura);
}
// *** Initialization ***
private void Initialize(string FileName, bool modo_escritura)
{
m_FileName = FileName;
Refresh();
if (modo_escritura)
m_Sections.Clear();
}
// *** Read file contents into local cache ***
public void Refresh()
{
lock (m_Lock)
{
StreamReader sr = null;
try
{
// *** Clear local cache ***
m_Sections.Clear();
// *** Open the INI file ***
try
{
if (!File.Exists(m_FileName))
return;
sr = new StreamReader(m_FileName, Encoding.Default);
}
catch (FileNotFoundException)
{
return;
}
// *** Read up the file content ***
Dictionary<string, string> CurrentSection = null;
string s;
while ((s = sr.ReadLine()) != null)
{
s = s.Trim();
// *** Check for section names ***
if (s.StartsWith("[") && s.EndsWith("]"))
{
if (s.Length > 2)
{
string SectionName = s.Substring(1,s.Length-2);
// *** Only first occurrence of a section is loaded ***
if (m_Sections.ContainsKey(SectionName))
{
CurrentSection = null;
}
else
{
CurrentSection = new Dictionary<string, string>();
m_Sections.Add(SectionName,CurrentSection);
}
}
}
else if (CurrentSection != null)
{
// *** Check for key+value pair ***
int i;
if ((i=s.IndexOf('=')) > 0)
{
int j = s.Length - i - 1;
string Key = s.Substring(0,i).Trim();
if (Key.Length > 0)
{
// *** Only first occurrence of a key is loaded ***
if (!CurrentSection.ContainsKey(Key))
{
string Value = (j > 0) ? (s.Substring(i+1,j).Trim()) : ("");
CurrentSection.Add(Key,Value);
}
}
}
}
}
}
finally
{
// *** Cleanup: close file ***
if (sr != null) sr.Close();
sr = null;
}
}
}
// *** Flush local cache content ***
public void salvar()
{
lock(m_Lock)
{
// *** If local cache was not modified, exit ***
if (!m_CacheModified) return;
m_CacheModified=false;
// *** Open the file ***
StreamWriter sw = new StreamWriter(m_FileName, false, Encoding.Default);
try
{
// *** Cycle on all sections ***
bool First = false;
foreach (KeyValuePair<string, Dictionary<string, string>> SectionPair in m_Sections)
{
Dictionary<string, string> Section = SectionPair.Value;
if (First) sw.WriteLine();
First = true;
// *** Write the section name ***
sw.Write('[');
sw.Write(SectionPair.Key);
sw.WriteLine(']');
// *** Cycle on all key+value pairs in the section ***
foreach (KeyValuePair<string, string> ValuePair in Section)
{
// *** Write the key+value pair ***
sw.Write(ValuePair.Key);
sw.Write('=');
sw.WriteLine(ValuePair.Value);
}
}
}
finally
{
// *** Cleanup: close file ***
if (sw != null) sw.Close();
sw = null;
}
}
}
// *** Read a value from local cache ***
public string GetValue(string SectionName, string Key, string DefaultValue)
{
// *** Lazy loading ***
//if (m_Lazy)
{
// m_Lazy = false;
//Refresh();
}
lock (m_Lock)
{
// *** Check if the section exists ***
Dictionary<string, string> Section;
if (!m_Sections.TryGetValue(SectionName, out Section)) return DefaultValue;
// *** Check if the key exists ***
string Value;
if (!Section.TryGetValue(Key, out Value)) return DefaultValue;
// *** Return the found value ***
return Value;
}
}
// *** Insert or modify a value in local cache ***
public void SetValue(string SectionName, string Key, string Value)
{
// *** Lazy loading ***
//if (m_Lazy)
{
// m_Lazy = false;
//Refresh();
}
lock (m_Lock)
{
// *** Flag local cache modification ***
m_CacheModified = true;
// *** Check if the section exists ***
Dictionary<string, string> Section;
if (!m_Sections.TryGetValue(SectionName, out Section))
{
// *** If it doesn't, add it ***
Section = new Dictionary<string, string>();
m_Sections.Add(SectionName,Section);
}
// *** Modify the value ***
if (Section.ContainsKey(Key)) Section.Remove(Key);
Section.Add(Key, Value);
}
}
// *** Encode byte array ***
private string EncodeByteArray(byte[] Value)
{
if (Value == null) return null;
StringBuilder sb = new StringBuilder();
foreach (byte b in Value)
{
string hex = Convert.ToString(b,16);
int l = hex.Length;
if (l > 2)
{
sb.Append(hex.Substring(l-2,2));
}
else
{
if (l < 2) sb.Append("0");
sb.Append(hex);
}
}
return sb.ToString();
}
// *** Decode byte array ***
private byte[] DecodeByteArray(string Value)
{
if (Value == null) return null;
int l = Value.Length;
if (l < 2) return new byte[] { };
l /= 2;
byte[] Result = new byte[l];
for (int i=0; i<l; i++) Result[i] = Convert.ToByte(Value.Substring(i*2,2),16);
return Result;
}
// *** Getters for various types ***
public bool GetValue(string SectionName, string Key, bool DefaultValue)
{
string StringValue=GetValue(SectionName, Key, DefaultValue.ToString(System.Globalization.CultureInfo.InvariantCulture));
int Value;
if (int.TryParse(StringValue, out Value)) return (Value != 0);
return DefaultValue;
}
public int GetValue(string SectionName, string Key, int DefaultValue)
{
string StringValue=GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
int Value;
if (int.TryParse(StringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out Value)) return Value;
return DefaultValue;
}
public long GetValue(string SectionName, string Key, long DefaultValue)
{
string StringValue = GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
long Value;
if (long.TryParse(StringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out Value)) return Value;
return DefaultValue;
}
public double GetValue(string SectionName, string Key, double DefaultValue)
{
string StringValue=GetValue(SectionName, Key, DefaultValue.ToString(CultureInfo.InvariantCulture));
double Value;
if (double.TryParse(StringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out Value)) return Value;
return DefaultValue;
}
public byte[] GetValue(string SectionName, string Key, byte[] DefaultValue)
{
string StringValue = GetValue(SectionName, Key, EncodeByteArray(DefaultValue));
try
{
return DecodeByteArray(StringValue);
}
catch (FormatException)
{
return DefaultValue;
}
}
// *** Setters for various types ***
public void SetValue(string SectionName, string Key, bool Value)
{
SetValue(SectionName, Key, (Value) ? ("1") : ("0"));
}
public void SetValue(string SectionName, string Key, int Value)
{
SetValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void SetValue(string SectionName, string Key, long Value)
{
SetValue(SectionName, Key, Value.ToString(CultureInfo.InvariantCulture));
}
public void SetValue(string SectionName, string Key, double Value)
{
SetValue(SectionName, Key, Value.ToString("0.0000000",CultureInfo.InvariantCulture));
}
public void SetValue(string SectionName, string Key, byte[] Value)
{
SetValue(SectionName, Key, EncodeByteArray(Value));
}
#endregion
}
}

View File

@ -966,7 +966,7 @@ namespace OliviaAddIn
app = ArcMap.Application;
mx_doc = (ESRI.ArcGIS.ArcMapUI.IMxDocument)(app.Document);
nmapas = mx_doc.Maps.Count;
for (int j = 0; j < nmapas; j++)
{

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SisNetBase;
using OliviaDef;
using System.Runtime.InteropServices;
using Microsoft.Win32;

View File

@ -453,7 +453,304 @@ namespace OliviaAddIn
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Organica, n, info);
//bilateral -satélite - envases
info[0] = 480;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Envases, n, info);
//bilateral -satélite - papel
info[0] = -2160;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Papel, n, info);
//bilateral -satélite - vidrio
info[0] = -2050;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Trasera - satélite - organico, resto
n = 4;
info[0] = -500;
info[1] = -500;
info[2] = 0;
info[3] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Trasera - satélite - envases
info[0] = 0;
info[1] = 0;
info[2] = 0;
info[3] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Trasera - satélite - papel
info[0] = -220;
info[1] = -330;
info[2] = -550;
info[3] = -770;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Papel, n, info);
//Trasera - satélite - vidrio
info[0] = 0;
info[1] = 0;
info[2] = 0;
info[3] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Satelite, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Trasera - 2 ejes - resto, org
n = 6;
info[0] = 0;
info[1] = -500;
info[2] = -1000;
info[3] = -1500;
info[4] = -2000;
info[5] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Trasera - 2 ejes - envases
info[0] = 0;
info[1] = 0;
info[2] = 0;
info[3] = 0;
info[4] = 0;
info[5] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Trasera - 2 ejes - papel
info[0] = -880;
info[1] = -1100;
info[2] = -1320;
info[3] = -1540;
info[4] = -1760;
info[5] = -1870;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Papel, n, info);
//Trasera - 2 ejes - vidrio
info[0] = 0;
info[1] = 0;
info[2] = 0;
info[3] = 0;
info[4] = 0;
info[5] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Trasera - 3 ejes - resto, org
n = 4;
info[0] = 0;
info[1] = 0;
info[2] = 0;
info[3] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Trasera - 3 ejes - envases
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Trasera - 3 ejes - papel
info[0] = -1980;
info[1] = -2200;
info[2] = -2420;
info[3] = -2530;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Papel, n, info);
//Trasera - 3 ejes - vidrio
info[0] = 0;
info[1] = 0;
info[2] = 0;
info[3] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Trasera,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Lateral - 2 ejes - resto, org
n = 2;
info[0] = -500;
info[1] = -1000;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Lateral - 2 ejes - envases
n = 2;
info[0] = 0;
info[1] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Lateral - 2 ejes - papel
info[0] = -1650;
info[1] = -1870;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Papel, n, info);
//Lateral - 2 ejes - vidrio
info[0] = 0;
info[1] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Lateral - 3 ejes - resto, org
n = 3;
info[0] = 0;
info[1] = 0;
info[2] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Lateral - 3 ejes - envases
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Lateral - 3 ejes - vidrio
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Lateral - 3 ejes - papel
info[0] = -2310;
info[1] = -2530;
info[2] = -2860;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Lateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Papel, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Superior - 2 ejes - resto, org
n = 2;
info[0] = 0;
info[1] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Superior - 2 ejes - envases
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Superior - 2 ejes - vidrio
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Superior - 2 ejes - papel
info[0] = -1760;
info[1] = -1870;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Papel, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Superior - 3 ejes - resto, org
n = 3;
info[0] = 0;
info[1] = 0;
info[2] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Superior - 2 ejes - envases
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Superior - 2 ejes - vidrio
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Superior - 3 ejes - papel
info[0] = -2200;
info[1] = -2530;
info[2] = -2750;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Papel, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Bilateral - 2 ejes - resto, org
n = 3;
info[0] = 0;
info[1] = 0;
info[2] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Bilateral - 2 ejes - envases
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Bilateral - 2 ejes - vidrio
rellena_carg_offset((int)RecogidaDef.TiposCarga.Superior,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Bilateral - 2 ejes - papel
info[0] = 1820;
info[1] = 2080;
info[2] = 2340;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Papel, n, info);
//Bilateral - 2 ejes - vidrio
info[0] = -140;
info[1] = -160;
info[2] = -180;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
////////////////////////////////////////////////////////////////////////////////////////////////
//Bilateral - 3 ejes - resto, org
n = 3;
info[0] = 0;
info[1] = 0;
info[2] = 0;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Organica, n, info);
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes2, (int)RecogidaDef.TiposFracción.Resto, n, info);
//Bilateral - 3 ejes - envases
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Envases, n, info);
//Bilateral - 3 ejes - vidrio
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
//Bilateral - 3 ejes - papel
info[0] = -2200;
info[1] = -2530;
info[2] = -2860;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Papel, n, info);
/*
* //Trasera - satélite - envases
n = 4;
info[0] = -760;
info[1] = -1140;
@ -675,6 +972,7 @@ namespace OliviaAddIn
info[2] = -260;
rellena_carg_offset((int)RecogidaDef.TiposCarga.Bilateral,
(int)RecogidaDef.TiposVehic.Ejes3, (int)RecogidaDef.TiposFracción.Vidrio, n, info);
*/
}

Binary file not shown.

View File

@ -2,11 +2,11 @@
<Name>OLIVIA AddIn</Name>
<AddInID>{0718b3b3-5422-4d80-97ad-f72b18a3e476}</AddInID>
<Description>Add-In de ArcMap para la herramienta de optimización de la limpieza viaria, OLIVIA.</Description>
<Version>1.1.0.12</Version>
<Version>2.0.0.0</Version>
<Image>Images\OliviaAddIn.png</Image>
<Author>Intergeo Tecnología</Author>
<Company>Intergeo Tecnología</Company>
<Date>15/03/2019</Date>
<Author>VSM</Author>
<Company>VSM</Company>
<Date>15/12/2019</Date>
<Targets>
<Target name="Desktop" version="10.2" />
</Targets>
@ -14,7 +14,7 @@
<ArcMap>
<Commands>
<Button id="Intergeo_Tecnología_OliviaAddIn_ButtonInicio" class="ButtonInicio" message="Add-In para ArcMap de la herramienta de optimización de la limpieza viaria, OLIVIA." caption="OLIVIA" tip="OLIVIA - Optimización de la Limpieza Viaria" category="OLVIA Add-In Controls" image="Images\ButtonInicio.png">
<Help heading="OLIVIA AddIn - Optimización de la Limpieza Viaria">Add-In para ArcMap desarrollado por Intergeo Tecnología para la herramienta de optimización de la limpieza viaria, OLIVIA.</Help>
<Help heading="OLIVIA AddIn - Optimización de la Limpieza Viaria">Add-In para ArcMap desarrollado para la herramienta de optimización de la limpieza viaria, OLIVIA.</Help>
</Button>
</Commands>
</ArcMap>

View File

@ -6,7 +6,6 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SisNetBase;
using OliviaDef;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesGDB;

View File

@ -1030,7 +1030,7 @@ namespace OliviaAddIn
pro_inic.Close();
return true;
}
catch (Exception)
catch (Exception ex)
{
if (pro_inic != null)
pro_inic.Close();

View File

@ -24,7 +24,7 @@ namespace OliviaAddIn
/**
* Socket de conexión al OliviaTask
*/
Cigt_str_socket soc = null;
Cstr_socket soc = null;
Thread m_thread;
int m_out;
int m_miliseconds;
@ -94,7 +94,7 @@ namespace OliviaAddIn
public void start(string cfg)
{
soc = new Cigt_str_socket();
soc = new Cstr_socket();
str_cfg = cfg;

View File

@ -2,10 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SisNetBase;
using OliviaDef;
using System.Diagnostics;
using SisNetBase.Modulos;
using System.IO;
using System.Threading;
using System.Windows.Forms;

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SisNetBase;
using OliviaDef;
using System.IO;
using System.Windows.Forms;

View File

@ -523,6 +523,20 @@ namespace OliviaAddIn
public void inicia_coords(string dir, string nomb_class)
{
OliviaGlob.coorsys_in = FunGDB.dame_factory_code(dir, nomb_class);
////////////////////////////////////////////////////////////////////////////////////////////
//comprueba si son proyectadas
ISpatialReferenceFactory3 spatialReferenceFactory = null;
ISpatialReference spatialReference;
spatialReferenceFactory = (ISpatialReferenceFactory3)new SpatialReferenceEnvironment();
spatialReference = spatialReferenceFactory.CreateSpatialReference(OliviaGlob.coorsys_in);
if (!(spatialReference is IProjectedCoordinateSystem))
{
//no son proyectadas, proyecta a utm30
OliviaGlob.coorsys_in = (int)esriSRProjCS4Type.esriSRProjCS_ETRS1989_UTM_Zone_30N;
}
if (OliviaGlob.coorsys_in < 0)
OliviaGlob.coorsys_in = OliviaGlob.coorsys;
OliviaGlob.coorsys = OliviaGlob.coorsys_in;
@ -1299,7 +1313,10 @@ namespace OliviaAddIn
simbologia.Width = 1;
sym = (ISymbol)simbologia;
check_valunic(feat, valor_unico, sym, indice);
if (!check_valunic(feat, valor_unico, sym, indice))
{
break;
}
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(feat);
@ -1334,7 +1351,10 @@ namespace OliviaAddIn
simbologia.OutlineColor = color;
sym = (ISymbol)simbologia;
check_valunic(feat, valor_unico, sym, indice);
if (!check_valunic(feat, valor_unico, sym, indice))
{
break;
}
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(feat);
@ -1358,7 +1378,7 @@ namespace OliviaAddIn
/*
* Comprueba si el valor unico existe. Si no existe se añade al array de valores unicos.
*/
public void check_valunic(IFeature feat, IUniqueValueRenderer valor_unico, ISymbol simbologia, int indice)
public bool check_valunic(IFeature feat, IUniqueValueRenderer valor_unico, ISymbol simbologia, int indice)
{
string valor_clase;
bool exist_valor;
@ -1383,10 +1403,12 @@ namespace OliviaAddIn
valor_unico.set_Label(valor_clase, valor_clase);
valor_unico.set_Symbol(valor_clase, (ISymbol)simbologia);
}
return true;
}
catch (Exception)
{
MessageBox.Show("Error al crear el listado de valores únicos.", "Olivia", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}

View File

@ -774,23 +774,18 @@ namespace OliviaAddIn
{
int ind;
IFields campos;
ISpatialReferenceFactory3 spatialReferenceFactory;
ISpatialReferenceFactory3 spatialReferenceFactory=null;
ISpatialReference spatialReference;
String shapeFieldName;
IField shapeField;
IGeometryDef geom_def, dest_geom;
IGeometryDef geom_def, dest_geom=null;
IClone geom_clon, dest_clon;
IGeometryDefEdit geom_edit;
IGeometryDefEdit geom_edit=null;
IProjectedCoordinateSystem coord_proy;
try
{
campos = fc.Fields;
//se genera un sistema de referencia espacial: de coordenadas proyectadas a coorsys
spatialReferenceFactory = (ISpatialReferenceFactory3)new SpatialReferenceEnvironment();
coord_proy = spatialReferenceFactory.CreateProjectedCoordinateSystem(coorsys);
spatialReference = (ISpatialReference)coord_proy;
campos = fc.Fields;
//se consigue la forma (shape) de la featureclass de interés
shapeFieldName = fc.ShapeFieldName;
ind = fc.FindField(shapeFieldName);
@ -809,6 +804,9 @@ namespace OliviaAddIn
ISpatialReference spatialReference_aux = (ISpatialReference)coord_proy_aux;
geom_edit.SpatialReference_2 = spatialReference_aux;
}*/
//se genera un sistema de referencia espacial: de coordenadas proyectadas a coorsys
spatialReferenceFactory = (ISpatialReferenceFactory3)new SpatialReferenceEnvironment();
spatialReference = spatialReferenceFactory.CreateProjectedCoordinateSystem(coorsys);
geom_edit.SpatialReference_2 = spatialReference;//se modifica el sistema de referencia de coordenadas al generado esriSRProjCS_WGS1984UTM_30N
}
catch (Exception)
@ -938,6 +936,7 @@ namespace OliviaAddIn
{
return null;
}
//castea la capa a IGeoDataset, de donde obtendrá el envelope
gds = (IGeoDataset)capa;
//crea un polígono partiendo del rectángulo envelope
@ -945,6 +944,7 @@ namespace OliviaAddIn
segcol = (ISegmentCollection)poli;
segcol.SetRectangle(gds.Extent);
geom_envelope = (IGeometry)poli;
//libera
FunGDB.libera(capa);

View File

@ -52,6 +52,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="ESRI.ArcGIS.ADF.Local, Version=10.2.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86, processorArchitecture=MSIL" />
@ -146,82 +147,84 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Base\Cstr_socket.cs" />
<Compile Include="Base\IniFile.cs" />
<Compile Include="ButtonInicio.cs" />
<Compile Include="Comun.cs" />
<Compile Include="ComunDef.cs" />
<Compile Include="Base\Comun.cs" />
<Compile Include="Base\ComunDef.cs" />
<Compile Include="Config.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Config.esriaddinx</DependentUpon>
</Compile>
<Compile Include="LimpCampos.cs">
<Compile Include="Dlg\LimpCampos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormCampos.cs">
<Compile Include="Dlg\FormCampos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FormCampos.Designer.cs">
<Compile Include="Dlg\FormCampos.Designer.cs">
<DependentUpon>FormCampos.cs</DependentUpon>
</Compile>
<Compile Include="DatosCsv.cs">
<Compile Include="Dlg\DatosCsv.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DatosCsv.Designer.cs">
<Compile Include="Dlg\DatosCsv.Designer.cs">
<DependentUpon>DatosCsv.cs</DependentUpon>
</Compile>
<Compile Include="DatosGDB.cs" />
<Compile Include="DatosGDBEx.cs" />
<Compile Include="DatosGDBLimp.cs" />
<Compile Include="DatosGDBReco.cs" />
<Compile Include="EditTxtPlant.cs">
<Compile Include="Gdb\DatosGDB.cs" />
<Compile Include="Gdb\DatosGDBEx.cs" />
<Compile Include="Gdb\DatosGDBLimp.cs" />
<Compile Include="Gdb\DatosGDBReco.cs" />
<Compile Include="Dlg\EditTxtPlant.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="EditTxtPlant.Designer.cs">
<Compile Include="Dlg\EditTxtPlant.Designer.cs">
<DependentUpon>EditTxtPlant.cs</DependentUpon>
</Compile>
<Compile Include="Ejecuta.cs" />
<Compile Include="EjecutaLimp.cs" />
<Compile Include="EjecutaReco.cs" />
<Compile Include="FunGDB.cs" />
<Compile Include="InicioDlg.cs">
<Compile Include="Ejecuta\Ejecuta.cs" />
<Compile Include="Ejecuta\EjecutaLimp.cs" />
<Compile Include="Ejecuta\EjecutaReco.cs" />
<Compile Include="Gdb\FunGDB.cs" />
<Compile Include="Dlg\InicioDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="InicioDlg.Designer.cs">
<Compile Include="Dlg\InicioDlg.Designer.cs">
<DependentUpon>InicioDlg.cs</DependentUpon>
</Compile>
<Compile Include="LimpiezaDef.cs" />
<Compile Include="LimpiezaDlg.cs">
<Compile Include="Base\LimpiezaDef.cs" />
<Compile Include="Dlg\LimpiezaDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="LimpiezaDlg.Designer.cs">
<Compile Include="Dlg\LimpiezaDlg.Designer.cs">
<DependentUpon>LimpiezaDlg.cs</DependentUpon>
</Compile>
<Compile Include="Limpieza.cs" />
<Compile Include="ListCapasMaqueta.cs">
<Compile Include="Base\Limpieza.cs" />
<Compile Include="Dlg\ListCapasMaqueta.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ListCapasMaqueta.Designer.cs">
<Compile Include="Dlg\ListCapasMaqueta.Designer.cs">
<DependentUpon>ListCapasMaqueta.cs</DependentUpon>
</Compile>
<Compile Include="ListForm.cs">
<Compile Include="Dlg\ListForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ListForm.Designer.cs">
<Compile Include="Dlg\ListForm.Designer.cs">
<DependentUpon>ListForm.cs</DependentUpon>
</Compile>
<Compile Include="ListCamposVal.cs" />
<Compile Include="Maqueta.cs" />
<Compile Include="OliviaGlob.cs" />
<Compile Include="Parquimetros.cs" />
<Compile Include="ProgresoEjec.cs">
<Compile Include="Dlg\ListCamposVal.cs" />
<Compile Include="Base\Maqueta.cs" />
<Compile Include="Base\OliviaGlob.cs" />
<Compile Include="Base\Parquimetros.cs" />
<Compile Include="Dlg\ProgresoEjec.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ProgresoEjec.Designer.cs">
<Compile Include="Dlg\ProgresoEjec.Designer.cs">
<DependentUpon>ProgresoEjec.cs</DependentUpon>
</Compile>
<Compile Include="ProgresoInic.cs">
<Compile Include="Dlg\ProgresoInic.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ProgresoInic.Designer.cs">
<Compile Include="Dlg\ProgresoInic.Designer.cs">
<DependentUpon>ProgresoInic.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
@ -235,24 +238,24 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="RecoCampos.cs">
<Compile Include="Dlg\RecoCampos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Recogida.cs" />
<Compile Include="RecogidaDef.cs" />
<Compile Include="RecogidaDlg.cs">
<Compile Include="Base\Recogida.cs" />
<Compile Include="Base\RecogidaDef.cs" />
<Compile Include="Dlg\RecogidaDlg.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="RecogidaDlg.Designer.cs">
<Compile Include="Dlg\RecogidaDlg.Designer.cs">
<DependentUpon>RecogidaDlg.cs</DependentUpon>
</Compile>
<Compile Include="SensCampos.cs">
<Compile Include="Dlg\SensCampos.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SensCampos.Designer.cs">
<Compile Include="Dlg\SensCampos.Designer.cs">
<DependentUpon>SensCampos.cs</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="Base\Settings.cs" />
</ItemGroup>
<ItemGroup>
<AddInContent Include="Config.esriaddinx">
@ -289,37 +292,37 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FormCampos.resx">
<EmbeddedResource Include="Dlg\FormCampos.resx">
<DependentUpon>FormCampos.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DatosCsv.resx">
<EmbeddedResource Include="Dlg\DatosCsv.resx">
<DependentUpon>DatosCsv.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="EditTxtPlant.resx">
<EmbeddedResource Include="Dlg\EditTxtPlant.resx">
<DependentUpon>EditTxtPlant.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="InicioDlg.resx">
<EmbeddedResource Include="Dlg\InicioDlg.resx">
<DependentUpon>InicioDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LimpCampos.resx">
<EmbeddedResource Include="Dlg\LimpCampos.resx">
<DependentUpon>LimpCampos.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LimpiezaDlg.resx">
<EmbeddedResource Include="Dlg\LimpiezaDlg.resx">
<DependentUpon>LimpiezaDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LimpiezaDlg.yo-NG.resx">
<EmbeddedResource Include="Dlg\LimpiezaDlg.yo-NG.resx">
<DependentUpon>LimpiezaDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ListCapasMaqueta.resx">
<EmbeddedResource Include="Dlg\ListCapasMaqueta.resx">
<DependentUpon>ListCapasMaqueta.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ListForm.resx">
<EmbeddedResource Include="Dlg\ListForm.resx">
<DependentUpon>ListForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProgresoEjec.resx">
<EmbeddedResource Include="Dlg\ProgresoEjec.resx">
<DependentUpon>ProgresoEjec.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProgresoInic.resx">
<EmbeddedResource Include="Dlg\ProgresoInic.resx">
<DependentUpon>ProgresoInic.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
@ -327,13 +330,13 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="RecoCampos.resx">
<EmbeddedResource Include="Dlg\RecoCampos.resx">
<DependentUpon>RecoCampos.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RecogidaDlg.resx">
<EmbeddedResource Include="Dlg\RecogidaDlg.resx">
<DependentUpon>RecogidaDlg.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="SensCampos.resx">
<EmbeddedResource Include="Dlg\SensCampos.resx">
<DependentUpon>SensCampos.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
@ -390,6 +393,7 @@
<Name>OliviaDef</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<PropertyGroup>
<ZipFileExtension>esriAddIn</ZipFileExtension>
<AddInTargetProduct>Desktop</AddInTargetProduct>

View File

@ -8,9 +8,9 @@ using System.Runtime.InteropServices;
[assembly: AssemblyTitle("OliviaAddIn")]
[assembly: AssemblyDescription("AddIn para ArcGIS de la herramienta OLIVIA - Optimización de la Limpieza Viaria")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Intergeo Tecnología")]
[assembly: AssemblyCompany("VSM")]
[assembly: AssemblyProduct("OliviaAddIn")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.8.0")]
[assembly: AssemblyFileVersion("1.0.8.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]