//sends a decoded message (target) and a base station objects using the TCP socket
        public bool SendTarget(decodedMessage target, DataAcquisitionStation bs)
        {
            try
            {
                //formatter who serializes, and stream for serialized data
                Stream msSerialized = Serialize(target);
                Stream bsSerialized = Serialize(bs);

                //create encryptor
                RainDollController rainDoll = new RainDollController();
                //encrypt serialized object
                byte[] encrypted = rainDoll.Encrypt(msSerialized);
                byte[] encryptedBS = rainDoll.Encrypt(bsSerialized);

                //put the serialized data into a transporter
                SerialDataTransporter transporter = new SerialDataTransporter();
                transporter.data = encrypted;
                transporter.bsdata = encryptedBS;

                //send the transporter to the write buffer
                SendObject(transporter);
            }
            catch(SerializationException e)
            {
                return false;
            }
            catch //pokemon exception handling
            {
                return false;
            }

            return true;
        }
Exemplo n.º 2
0
        //sends a decoded message (target) and a base station objects using the TCP socket
        public bool SendTarget(decodedMessage target, DataAcquisitionStation bs)
        {
            try
            {
                //formatter who serializes, and stream for serialized data
                Stream msSerialized = Serialize(target);
                Stream bsSerialized = Serialize(bs);

                //create encryptor
                RainDollController rainDoll = new RainDollController();
                //encrypt serialized object
                byte[] encrypted   = rainDoll.Encrypt(msSerialized);
                byte[] encryptedBS = rainDoll.Encrypt(bsSerialized);

                //put the serialized data into a transporter
                SerialDataTransporter transporter = new SerialDataTransporter();
                transporter.data   = encrypted;
                transporter.bsdata = encryptedBS;

                //send the transporter to the write buffer
                SendObject(transporter);
            }
            catch (SerializationException e)
            {
                return(false);
            }
            catch     //pokemon exception handling
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        //sends a decoded message (target) using ZMQ
        //this is the non-decrypting version of SendTarget method
        bool SendPlainTarget(decodedMessage target)
        {
            try
            {
                //formatter who serializes, and stream for serialized data
                Stream msSerialized = Serialize(target);

                //transform the serialized data to a byte array
                byte[] serialObj = streamToBytes(msSerialized);

                //put the serialized data into a transporter
                SerialDataTransporter transporter = new SerialDataTransporter();
                transporter.data   = serialObj;
                transporter.bsdata = baseStationData;

                //send the transporter to the write buffer
                SendObject(transporter);
            }
            catch (SerializationException e)
            {
                return(false);
            }
            catch     //pokemon exception handling
            {
                return(false);
            }

            return(true);
        }
        private void btAgregar_Click(object sender, EventArgs e)
        {
            //Agregaremos uno a uno los objetivos a la lista
            decodedMessage objetivo = new decodedMessage();

               // MessageBox.Show("Indice" + cbTiposObjetivos.SelectedIndex);

            //Del tipo seleccionado en la lista, le indicamos que tipo de objetivo es a traves de su msgType
            switch (cbTiposObjetivos.SelectedIndex)
            {
                case 0: objetivo.msgType = 1;  //class A
                break;
                case 1: objetivo.msgType = 18; //class B
                break;
                case 2: objetivo.msgType = 9;  //SART
                break;
                case 3: objetivo.msgType = 21; //AtoN
                break;

            }

            if (objetivo.msgType > 0)
            {
                //validacion del MMSI
                if (conversionValidaInt64(tbMMSI.Text))
                {
                    objetivo.MMSI = System.Convert.ToInt64(tbMMSI.Text);
                    //validacion del campo nombre del Objetivo
                    if (tbNombre.Text != "")
                    {
                        objetivo.shipname = tbNombre.Text;
                        //validacion del campo latitud
                        if ((conversionValidaDouble(tbLatitude.Text) == true) && (tbLatitude.Text != ""))
                        {
                            objetivo.lat = (float)(System.Convert.ToDouble(tbLatitude.Text));
                            //validacion del campo longitud
                            if ((conversionValidaDouble(tbLongitud.Text) == true) && (tbLongitud.Text != ""))
                            {
                                objetivo.lon = (float)(System.Convert.ToDouble(tbLongitud.Text));
                                //validacion del campo rumbo
                                if (conversionValidaDouble(tbRumbo.Text) && (tbRumbo.Text != ""))
                                {
                                    objetivo.course = (float)(System.Convert.ToDouble(tbRumbo.Text));
                                    //validacion del campo velocidad
                                    if (conversionValidaDouble(tbVelocidad.Text) && (tbVelocidad.Text != ""))
                                    {
                                        objetivo.speed = (float)(System.Convert.ToDouble(tbVelocidad.Text));
                                        //inicializamos con un timestamp en el campo lastTime
                                        //check for the current time stamp

                                        double now = TimeController.timeStamp();

                                        objetivo.lastTime = now;

                                        //MessageBox.Show("mas" + now);
                                        //finalmente, agregamos el objetivo
                                        listaObjetivos.Add(objetivo);
                                        //limpiamos cajas de texto
                                        tbMMSI.Clear();
                                        tbNombre.Clear();
                                        tbLatitude.Clear();
                                        tbLongitud.Clear();
                                        tbRumbo.Clear();
                                        tbVelocidad.Clear();
                                        //informamos al usuario
                                        //MessageBox.Show("Objetivo Agregado");
                                    }
                                    else
                                    {
                                        MessageBox.Show("El campo, Velocidad no es valido, o esta vacio");
                                        tbVelocidad.Clear();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("El campo, Rumbo no es valido, o esta vacio");
                                    tbRumbo.Clear();
                                }
                            }
                            else
                            {
                                MessageBox.Show("El campo, Longitud no es valido, o esta vacio");
                                tbLongitud.Clear();
                            }
                        }
                        else
                        {
                            MessageBox.Show("El campo, Latitud no es valido, ó esta vacio");
                            tbLatitude.Clear();
                        }
                    }
                    else
                    {
                       MessageBox.Show("El campo, nombre de la Embarcación, no puede estar vacio");
                    }

                }
                else
                {
                    MessageBox.Show("El campo, MMSI de la Embarcación, no es valido ó esta vacio.");
                    tbMMSI.Clear();
                }
            }//de la validacion del combo box
            else
            {

                MessageBox.Show("Seleccione un tipo de Objetivo");
            }//else de la validacion del combo box
        }
Exemplo n.º 5
0
        private void btAgregar_Click(object sender, EventArgs e)
        {
            //Agregaremos uno a uno los objetivos a la lista
            decodedMessage objetivo = new decodedMessage();

            // MessageBox.Show("Indice" + cbTiposObjetivos.SelectedIndex);

            //Del tipo seleccionado en la lista, le indicamos que tipo de objetivo es a traves de su msgType
            switch (cbTiposObjetivos.SelectedIndex)
            {
            case 0: objetivo.msgType = 1;                      //class A
                break;

            case 1: objetivo.msgType = 18;                     //class B
                break;

            case 2: objetivo.msgType = 9;                      //SART
                break;

            case 3: objetivo.msgType = 21;                     //AtoN
                break;
            }

            if (objetivo.msgType > 0)
            {
                //validacion del MMSI
                if (conversionValidaInt64(tbMMSI.Text))
                {
                    objetivo.MMSI = System.Convert.ToInt64(tbMMSI.Text);
                    //validacion del campo nombre del Objetivo
                    if (tbNombre.Text != "")
                    {
                        objetivo.shipname = tbNombre.Text;
                        //validacion del campo latitud
                        if ((conversionValidaDouble(tbLatitude.Text) == true) && (tbLatitude.Text != ""))
                        {
                            objetivo.lat = (float)(System.Convert.ToDouble(tbLatitude.Text));
                            //validacion del campo longitud
                            if ((conversionValidaDouble(tbLongitud.Text) == true) && (tbLongitud.Text != ""))
                            {
                                objetivo.lon = (float)(System.Convert.ToDouble(tbLongitud.Text));
                                //validacion del campo rumbo
                                if (conversionValidaDouble(tbRumbo.Text) && (tbRumbo.Text != ""))
                                {
                                    objetivo.course = (float)(System.Convert.ToDouble(tbRumbo.Text));
                                    //validacion del campo velocidad
                                    if (conversionValidaDouble(tbVelocidad.Text) && (tbVelocidad.Text != ""))
                                    {
                                        objetivo.speed = (float)(System.Convert.ToDouble(tbVelocidad.Text));
                                        //inicializamos con un timestamp en el campo lastTime
                                        //check for the current time stamp

                                        double now = TimeController.timeStamp();

                                        objetivo.lastTime = now;

                                        //MessageBox.Show("mas" + now);
                                        //finalmente, agregamos el objetivo
                                        listaObjetivos.Add(objetivo);
                                        //limpiamos cajas de texto
                                        tbMMSI.Clear();
                                        tbNombre.Clear();
                                        tbLatitude.Clear();
                                        tbLongitud.Clear();
                                        tbRumbo.Clear();
                                        tbVelocidad.Clear();
                                        //informamos al usuario
                                        //MessageBox.Show("Objetivo Agregado");
                                    }
                                    else
                                    {
                                        MessageBox.Show("El campo, Velocidad no es valido, o esta vacio");
                                        tbVelocidad.Clear();
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("El campo, Rumbo no es valido, o esta vacio");
                                    tbRumbo.Clear();
                                }
                            }
                            else
                            {
                                MessageBox.Show("El campo, Longitud no es valido, o esta vacio");
                                tbLongitud.Clear();
                            }
                        }
                        else
                        {
                            MessageBox.Show("El campo, Latitud no es valido, ó esta vacio");
                            tbLatitude.Clear();
                        }
                    }
                    else
                    {
                        MessageBox.Show("El campo, nombre de la Embarcación, no puede estar vacio");
                    }
                }
                else
                {
                    MessageBox.Show("El campo, MMSI de la Embarcación, no es valido ó esta vacio.");
                    tbMMSI.Clear();
                }
            }            //de la validacion del combo box
            else
            {
                MessageBox.Show("Seleccione un tipo de Objetivo");
            }            //else de la validacion del combo box
        }
        //sends a decoded message (target) using ZMQ
        //this is the non-decrypting version of SendTarget method
        bool SendPlainTarget(decodedMessage target)
        {
            try
            {
                //formatter who serializes, and stream for serialized data
                Stream msSerialized = Serialize(target);

                //transform the serialized data to a byte array
                byte[] serialObj = streamToBytes(msSerialized);

                //put the serialized data into a transporter
                SerialDataTransporter transporter = new SerialDataTransporter();
                transporter.data = serialObj;
                transporter.bsdata = baseStationData;

                //send the transporter to the write buffer
                SendObject(transporter);
            }
            catch(SerializationException e)
            {
                return false;
            }
            catch //pokemon exception handling
            {
                return false;
            }

            return true;
        }