private static void ProcessPosition(GPSPosition position) { //last_point = new GPSPoint(position.Time.ToUniversalTime(), (float)position.dblLatitude, (float)position.dblLongitude, Convert.ToInt32(position.flSpeed)) last_point = new GPSPoint(position.Time, (float)position.dblLatitude, (float)position.dblLongitude, Convert.ToInt32(position.flSpeed)) { Course = position.flHeading }; T.INFO(last_point.ToString()); double delta_distance = -1; mobile.Fix(last_point); if (destination_point != null) { delta_distance = Distances.Rhumb(last_point, destination_point); T.TRACE(String.Format("TRACKER: delta_distance={0}", delta_distance)); //Locked = delta_distance <= destination_area_radio; /*if (delta_distance <= destination_radio) * { * T.INFO("TRACKER: Llegamos al destino. Informando."); * Beep("gps_in_destination"); * posicion.Clear(); * destination_point = null; * var dummy = new byte[2]; * dummy[0] = 0; * posicion.Push(last_point.AsMessage((int)delta_distance), dummy); * mobile.ActiveOT(last_point, active_ot); * }*/ } if (last_sent_point == null || (last_point.Date - last_sent_point.Date).TotalSeconds >= fix_interval) { T.INFO("TRACKER: fix seleccionado para enviar."); last_sent_point = last_point; mobile.Fix(last_sent_point); posicion.Clear(); var dummy = new byte[2]; dummy[0] = 0; posicion.Push(last_sent_point.AsMessage((int)delta_distance), dummy); } }
private static void ProcessCommand(string comando) { if (!running) { return; } var data = comando.Split(";".ToCharArray()); if (data[0] == "CLOSE") { var closer = data.GetLength(0) == 3 ? data[2] : "UNKNOW"; T.INFO("CORE: application exit required from " + closer); running = false; Application.Exit(); return; } if (data[0] == "STATUS") { T.INFO("CORE: status requerido"); var dd = new byte[2]; //status.Push(network_status ? "Activo, En Linea" : "Activo, Sin Conexion", dd); return; } if (data.GetLength(0) >= 4) { if (data[0] == "GC") { active_ot = Convert.ToInt32(data[1]); var culture = new CultureInfo("en-US"); var lat = Convert.ToSingle(data[2], culture); var lon = Convert.ToSingle(data[3], culture); destination_point = new GPSPoint(DateTime.Now, lat, lon); destination_radio = Convert.ToInt32(data[4]); T.INFO("CORE: Configurando punto destino."); T.INFO(destination_point.AsMessage(destination_radio)); } } else { T.NOTICE("CORE: Comando desconocido. " + comando); } }