///<summary> ///List of all events in HomeSeer. Used to enable Linq queries on events. ///</summary> ///<returns>Generic.List() of all EventData</returns> ///<remarks>By Moskus</remarks> public List <HomeSeerAPI.strEventData> Events1() { var ret = new List <HomeSeerAPI.strEventData>(); var allEvents = Hs.Event_Info_All().ToList(); return(allEvents); }
///<summary> ///Logging ///</summary> ///<param name="Message">The message to be logged</param> ///<param name="Log_Level">Normal, Warning or Error</param> ///<remarks>HSPI_SAMPLE_BASIC</remarks> public static void Log(string message, LogType logLevel = LogType.Normal) { try { switch (logLevel) { case LogType.Debug: //if (_settings.DebugLog) { Hs.WriteLog(PluginName + " Debug", message); } break; case LogType.Normal: Hs.WriteLog(PluginName, message); break; case LogType.Warning: Hs.WriteLog(PluginName + " Warning", message); break; case LogType.Error: Hs.WriteLog(PluginName + " ERROR", message); break; } } catch (Exception ex) { Console.WriteLine($"Error in Log(): '{message}'. {ex.Message}"); } }
///<summary> ///List of all events in HomeSeer. Used to enable Linq queries on events. ///</summary> ///<returns>Generic.List() of all EventData</returns> ///<remarks>By Moskus</remarks> public List <HomeSeerAPI.strEventData> Events() { var ret = new List <HomeSeerAPI.strEventData>(); foreach (HomeSeerAPI.strEventData eventData in Hs.Event_Info_All()) { ret.Add(eventData); } return(ret); }
public override string InitIO(string port) { // debug Hs.WriteLog(Name, "Entering InitIO"); // initialise everything here, return a blank string only if successful, or an error message // debug Hs.WriteLog(Name, "Completed InitIO"); return(""); }
public override void ShutdownIO() { // debug Hs.WriteLog(Name, "Entering ShutdownIO"); // shut everything down here // let our console wrapper know we are finished Shutdown = true; // debug Hs.WriteLog(Name, "Completed ShutdownIO"); }
private void ejecutarAlgoritmo() { // se crea un archivo donde se almacenarán los resumenes string bestResume = "MejorResumen.txt"; File.Delete(bestResume); FileStream streamResumen = new FileStream(bestResume, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter writerResumen = new StreamWriter(streamResumen); // se crea el archivo en donde se almacenarán los resultados string fileName = "Resultado.txt"; File.Delete(fileName); FileStream stream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter writer = new StreamWriter(stream); //OJOOOOOOOOOOOOOO QUITAR ALGUNOS CAMPOS _texto = "ITERAC HMCR PRESI_ALFA PRESI_BETA PRESI_GAMMA RECU_ALFA RECU_BETA RECU_GAMMA MAX_PRESICION MAX_RECUERDO PROMEDIO_PRESICION PROMEDIO_RECUERDO"; writer.WriteLine(_texto); ///cantidad de palabras que debe cotener el resume int longRe = Convert.ToInt16(cbxCantidadPalabras.SelectedItem); //se hace un recorrido de los archivos a resumir. // for (int k = 0; k < urlArchivo.Count; k++) // { List <string> resumen = new List <string>(); Hs objHs = new Hs(); //AGREGADO PARA MA Memetico objMA; Agente objAgente = new Agente(); ///coeficientes double[] cftes = new double[3]; List <string> mejorResumenHS = new List <string>(); ///AGREGADO PARA MA List <string> mejorResumenMA = new List <string>(); List <string> mejorResumen = new List <string>(); /// url de la lista de archivos cargados inicialmente ///cargar el archivo a resumir, sacar stopword, sacar frases, ... RepresentacionDoc objRepre = new RepresentacionDoc(urlArchivo); double Hmcr = Convert.ToDouble(txtHMCR.Text); ///Numero de iteraciones int Ni = Convert.ToInt16(cbxNi.SelectedItem); ///algortimo para maxima presicion y recuerdo float Max_Precision = 0; float Max_Recall = 0; float Average_Precision = 0; float Average_Recall = 0; double beta, alfa, gamma; beta = Convert.ToDouble(txtBeta.Text); alfa = Convert.ToDouble(txtAlfa.Text); gamma = Convert.ToDouble(txtGamma.Text); cftes[0] = alfa; cftes[1] = beta; cftes[2] = gamma; double mejorBetaP = 0, mejorAlfaP = 0, mejorGammaP = 0; double mejorBetaR = 0, mejorAlfaR = 0, mejorGammaR = 0; float[] presiRecuer = new float[2]; //buscar los mejores coeficientes for (int i = 0; i < 10; i++) { alfa = Convert.ToDouble(i) / 10; cftes[0] = alfa; for (int j = 0; j < 10 - i; j++) { beta = Convert.ToDouble(j) / 10; cftes[1] = beta; gamma = 1 - beta - alfa; cftes[2] = gamma; //Run HS and Compute Precision and Recall //LLAMAR A MEMETICO objMA = new Memetico(objRepre.Frases.Count, longRe, objRepre.MatrizSimilituF, objRepre.MatrizPesosFrases, cftes, objRepre.Frases); /* * MA: * double[] CostosCaracteristicas = new double[objRepre.MatrizPesosFrases.GetLength(0)-2]; * CostosCaracteristicas = objMA.CostosCaracteristicas(objRepre.MatrizSimilituF, objRepre.MatrizPesosFrases);*/ //mejorResumenHS = objHs.ejecutarHS(Hmcr, Ni, objRepre.Frases, objRepre.MatrizPesosFrases, objRepre.MatrizSimilituF, cftes,longRe); objAgente = objMA.Ejecutar(); ///METODO Q CONVIERTA UN VECTOR SLN DE 1'S Y 0'S EN UN LIST<STRING> mejorResumenMA = objMA.ObtenerTexto(objAgente, objRepre.Frases); for (int t = 0; t < mejorResumenMA.Count; t++) { txtResultados.Text += mejorResumenMA[i] + " "; } //retorna la presicion y el recuerdo de este resumen //presiRecuer = calcularPreRecu(mejorResumenHS);-->HS //AGREGADO PARA MA //presiRecuer = calcularPreRecu(mejorResumenMA); Console.WriteLine("aqui"); /*if (presiRecuer[0] > Max_Precision) * { * Max_Precision = presiRecuer[0]; * mejorBetaP = beta; * mejorAlfaP = alfa; * mejorGammaP = gamma; * mejorResumen = mejorResumenHS; * } * if (presiRecuer[1] > Max_Recall) * { * Max_Recall = presiRecuer[1]; * mejorBetaR = beta; * mejorAlfaR = alfa; * mejorGammaR = gamma; * mejorResumen = mejorResumenHS; * } * Average_Precision = Average_Precision + presiRecuer[0]; * Average_Recall = Average_Recall + presiRecuer[1];*/ } } /*Average_Precision = Average_Precision / 66; * Average_Recall = Average_Recall / 66; * * texto = Ni.ToString() + " " + Hmcr.ToString() + " " + mejorAlfaP.ToString() + " " + mejorBetaP.ToString() + " " + mejorGammaP.ToString() + " " + mejorAlfaR.ToString() + " " + mejorBetaR.ToString() + " " + mejorGammaR.ToString() + " " + Max_Precision.ToString() + " " + Max_Recall.ToString() + " " + Average_Precision.ToString() + " " + Average_Recall.ToString(); * writer.WriteLine(texto); * * Console.WriteLine("Precision: " + Max_Precision.ToString() + " Recuerdo:" + Max_Recall.ToString()); * //Console.WriteLine("Preciscion:" + presiRecuer[0] + "Recuerdo " + presiRecuer[1]); * writerResumen.Close(); * writer.Close();*/ }
private void up(Hs m,int c) { MethodInvoker i = delegate { Thread.Sleep(2); switch (m) { case Hs.md5: pmd5.Value = ((c * 100) / ToDo); lmd5.Text = string.Format("MD5:\t {0:N3}%", ((double)c * 100.0D) / (double)ToDo); break; case Hs.sha1: psha1.Value = ((c * 100) / ToDo); lsha1.Text = string.Format("SHA1:\t {0:N3}%", ((double)c * 100.0D) / (double)ToDo); break; case Hs.sha256: psha256.Value = ((c * 100) / ToDo); lsha256.Text = string.Format("SHA256:\t {0:N3}%", ((double)c * 100.0D) / (double)ToDo); break; case Hs.sha512: psha512.Value = ((c * 100) / ToDo); lsha512.Text = string.Format("SHA512:\t {0:N3}%", ((double)c * 100.0D) / (double)ToDo); break; case Hs.lm: break; case Hs.ntlm: break; default: break; } }; Thread.Sleep(10); if (this.InvokeRequired) this.BeginInvoke(i); else i.Invoke(); }
/// <summary> /// 2. Helper for above GetDevices - selects devices filtered by Location and/or Location2 /// </summary> /// <param name="Location"></param> /// <param name="Location2"></param> /// <param name="devices">Full DeviceDictHS, can be "null", then will retrieve inside</param> /// <param name="min_vspsCount">Filter devices if their vspsCount exceeds this number</param> /// <param name="exclude">List<dev_ids> to exclude</param> /// <returns>List of pairs (Name=name, Value=deviceID) for dropbox</returns> public static MyPairList GetDevices(string Location, string Location2, DeviceDictHS devices = null, int min_vspsCount = 0, DeviceIdList exclude = null) { IHSApplication _hs = null; //IHSApplication _hs = Hs; if (devices == null) { devices = Devices(); } if (exclude == null) { exclude = new DeviceIdList(); } MyPairList items = new MyPairList(); foreach (int deviceId in devices.Keys) { if (exclude.Contains(deviceId)) { continue; } HSDevice device = devices[deviceId]; string name = device.get_Name(_hs); string dev_loc = device.get_Location(_hs); string dev_loc2 = device.get_Location2(_hs); // Select devices matching Loc/Loc2, or if Loc/Loc2 not specified if ((String.IsNullOrEmpty(Location) || Location == dev_loc) && (String.IsNullOrEmpty(Location2) || Location2 == dev_loc2) ) { // If Loc/Loc2 not specified - prepend them to device name if (String.IsNullOrEmpty(Location)) { name = "[" + dev_loc + "] " + name; } if (String.IsNullOrEmpty(Location2)) { name = "[" + dev_loc2 + "] " + name; } int num_vsps = 0; if (min_vspsCount > 0) { VSVGPairs.VSPair[] vsps = Hs.DeviceVSP_GetAllStatus(deviceId); num_vsps = vsps.Length; } if (num_vsps >= min_vspsCount) { items.Add(new MyPair(name, deviceId)); } } } return(items); }
///<summary> ///List of all devices in HomeSeer. Used to enable Linq queries on devices. ///</summary> ///<returns>Generic.List() of all devices</returns> ///<remarks>By Moskus</remarks> public static DeviceDictHS Devices() { DeviceDictHS ret = new DeviceDictHS(); Scheduler.Classes.clsDeviceEnumeration deviceEnumeration = (clsDeviceEnumeration)Hs.GetDeviceEnumerator(); while (!deviceEnumeration.Finished) { HSDevice device = deviceEnumeration.GetNext(); ret[device.get_Ref(null)] = device; } return(ret); }
public override void SetDeviceValue(int refId, double value, bool trigger = true) { Hs.SetDeviceValueByRef(refId, value, trigger); }