예제 #1
0
 private void bNACK_Click(object sender, EventArgs e)
 {
     if (acc != null)
     {
         acc.send(CMDPDU.encode_nack());
         log("NACK Enviado!");
     }
 }
예제 #2
0
 private void bEnvia_Click(object sender, EventArgs e)
 {
     if (acc != null)
     {
         acc.send(CMDPDU.encode_estado(Convert.ToInt32(camionID.Value), Convert.ToInt32(estado.SelectedValue), Convert.ToInt32(latencia.Value)));
         log("Estado Enviado!");
     }
 }
예제 #3
0
 public static void ThreadProc()
 {
     _instance.el.WriteEntry("Inicia bucle de la message queue!");
     while (true)
     {
         try
         {
             Message request = _instance.input.Peek();
             // mecanismo de salida del thread.
             if (request.Label.StartsWith("close"))
             {
                 return;
             }
             _instance.el.WriteEntry(String.Format("se recibio un mensaje MQ {0}", request.Label));
             // Label="1121,9,123412341234"
             // 1 => camion
             // 2 => nuevo estado
             // 3 => hora desde epoch
             if (_instance._cmd_a == null)
             {
                 _instance.el.WriteEntry("NO SE PUEDE PROCESAR MSG, NO ESTAMOS CONECTADOS!");
                 Thread.Sleep(1000);
                 continue;
             }
             string[] fields = request.Label.Split(',');
             if (fields.Length != 3)
             {
                 _instance.el.WriteEntry("NO SE PUDO PROCESAR POR ERROR DE FTO: LABEL='" + request.Label + "'");
                 _instance.input.Receive(); // finalmente lo desencolo.
                 continue;
             }
             _instance.el.WriteEntry("SE ENVIA SOLICITUD: LABEL='" + request.Label + "'");
             _instance.request_in_progress = true;
             DateTime original        = new DateTime(Convert.ToInt64(fields[2]));
             int      segundos_afuera = (int)DateTime.Now.Subtract(original).TotalSeconds;
             _instance._cmd_a.send(CMDPDU.encode_estado(Convert.ToInt32(fields[0]), Convert.ToInt32(fields[1]), segundos_afuera == 0 ? 0 : (segundos_afuera / 60) + 1));
             // este semaforo senializa al recebir el ACK
             _instance.log("Se esperara el semaforo!");
             _instance.allDone.WaitOne();
             _instance.log("Request Terminada!");
             _instance.request_in_progress = false;
         }
         catch (Exception ex)
         {
             _instance.el.WriteEntry("Error al procesar un mensaje de la cola entrante.");
             _instance.el.WriteEntry("OS Error:" + ex.Message + "\n" + ex.StackTrace);
             Thread.Sleep(1000);
         }
     }
 }
예제 #4
0
 public override void on_data()
 {
     LOG.log(String.Format("DATA:[{0}];", Encoding.ASCII.GetString(get_buffer(), 0, get_read_bytes())));
     if ((get_buffer()[0] == '?') || // WAKEUP
         (get_buffer()[0] == '!') || // ATTACK DELAY
         (get_buffer()[0] == 'T') || // GPS Autostatus
         (get_buffer()[0] == 'T') || // TEXT MESSAGE
         (get_buffer()[0] == 'M'))    // PREDEFINED MESSAGE
     {
         // esta version no hace nada con lo que pida el command data asi que simplemente nos limitamos a contestar con un ACK
         send(CMDPDU.encode_ack());
         LOG.log(String.Format("Mensaje del HOST type={0}, se contesto con ACK y se ignoro.", get_buffer()[0]));
     }
     else if (get_buffer()[0] == 0x06 || get_buffer()[0] == 'A') // RECIBIMOS ACK
     {
         LOG.ack(true);
     }
     else
     {
         // cualquier rta incomprensible decimos NACK..
         LOG.ack(false);
     }
 }