private void button3_Click(object sender, EventArgs e) { var datos = new byte[1024]; SetLoopbackSignature(datos); var mq = new Base64MessageQueue() { Nombre = textBox2.Text }; mq.Push(String.Format("MQTOOL: {0}", injectados++), datos); }
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 void TheWork() { try { while (true) { try { var label = ""; var data = entrante.SafePop(ref label); if (data == null) { continue; } if (VerifyLoopbackSignature(data)) { data_ok++; } else { data_err++; } saliente.Push(label, data); message_counter++; UpdateStats(); } catch (ThreadAbortException) { throw; } catch (Exception e) { T.EXCEPTION(e, "MainLoop"); } } } catch (ThreadAbortException e) { T.EXCEPTION(e, "MainLoop"); T.INFO("TheWork abortado!!!"); } }
private void button1_Click(object sender, EventArgs e) { var queuepath = txtQueueName.Text; if (!MessageQueue.Exists(queuepath)) { return; } Cursor = Cursors.WaitCursor; var mq = new Base64MessageQueue() { Nombre = queuepath }; var datos = new byte[1024]; new Random().NextBytes(datos); for (var i = 0; i < Convert.ToInt32(nudInject.Value); ++i) { mq.Push(String.Format("DATA: {0}", i), datos); } Cursor = Cursors.Default; }
private void Spine_SpineCommand(Commands sig, object data) { try { STrace.Debug(GetType().FullName, String.Format("SPINE/SEÑAL RECIBIDA: signal={0} data={1} ", sig, data)); var dummy = new byte[2]; switch (sig) { case Commands.TEMPORARILY_DISABLE_DEVICE: { var d = FindById((int)data); if (d == null) { STrace.Debug(GetType().FullName, String.Format("SPINE/SEÑAL RECIBIDA: no se encontro el dispositivo {0} para deshabilitarlo temporalmente.", (int)data)); return; } d.DisabledUntil = DateTime.Now.AddHours(1); d.State = DeviceTypes.States.OFFLINE; d.CancelAllTasks(); d.RemoteDeviceState.State = DeviceState.States.MAINT; break; } case Commands.GATEWAY_REFRESH: foreach (var d in DevicesDictionary.Values) { if (d.RemoteDeviceState != null) { d.RemoteDeviceState.Refresh(); } else { STrace.Debug(GetType().FullName, String.Format("DEVICE[{0}]: no se pudo refrescar.", d.LogId)); } } break; case Commands.CONFIGURE_DEVICE: Cmd.Push("CONFIGURE:" + (int)data, dummy); break; case Commands.FOTA_DEVICE: Cmd.Push("FOTA:" + (int)data, dummy); break; case Commands.FULL_QTREE_DEVICE: Cmd.Push("FULLQTREE:" + (int)data, dummy); break; case Commands.QTREE_DEVICE: Cmd.Push("QTREE:" + (int)data, dummy); break; case Commands.REBOOT_DEVICE: Cmd.Push("REBOOT:" + (int)data, dummy); break; case Commands.HEARTBEAT: break; } } catch (Exception e) { STrace.Exception(GetType().FullName, e); } }