Exemple #1
0
        public GeoCoordinate GetGeodeticCoordinateNow()
        {
            var tleISS      = ParserTLE.parseTle(TleLine1, TleLine2, TleLine0);
            var currentTime = new EpochTime(DateTime.UtcNow);
            // TODO: use sdp4 for satellites with medium/high orbit.
            var data             = SatFunctions.getSatPositionAtTime(tleISS, currentTime, Sgp4.wgsConstant.WGS_84);
            var secondsFromStart = (currentTime.getEpoch() - Math.Truncate(currentTime.getEpoch())) * 24 * 60 * 60;
            var omega            = OMEGA_E * secondsFromStart;

            var C = MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.OfArray(
                new double[, ] {
                { Math.Cos(omega), Math.Sin(omega), 0 },
                { -Math.Sin(omega), Math.Cos(omega), 0 },
                { 0, 0, 1 }
            });

            var p = MathNet.Numerics.LinearAlgebra.Double.DenseMatrix.OfArray(
                new double[, ] {
                { data.getX() * 1000 },
                { data.getY() * 1000 },
                { data.getZ() * 1000 }
            });

            var ecr = C * p;

            GpsUtils.EcefToGeodetic(ecr[0, 0], ecr[1, 0], ecr[2, 0], out var lat, out var lon, out var h);

            return(new GeoCoordinate(lat, lon, h));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            modelo = CrossDeviceInfo.Current.Model;

            context     = ApplicationContext;
            printer     = new GertecPrinter(context);
            configPrint = new ConfigPrint();
            printer.setConfigImpressao(configPrint);
            satFunctions = new SatFunctions(context);

            tef = new Tef();

            // ZXing Inicialização
            global::ZXing.Net.Mobile.Forms.Android.Platform.Init();

            //LoadApplication is a Xamarin.Forms method
            LoadApplication(new App());

            currentDateTimeString  = Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy"));
            currentDateTimeStringT = Convert.ToString((data.Hours) + Convert.ToString(data.Minutes) + Convert.ToString(data.Seconds));

            mContext = this;
        }
Exemple #3
0
        public bool IsVisibleFromPointNow(GeoCoordinate observer)
        {
            var tleISS      = ParserTLE.parseTle(TleLine1, TleLine2, TleLine0);
            var currentTime = new EpochTime(DateTime.UtcNow);
            var data        = One_Sgp4.SatFunctions.getSatPositionAtTime(tleISS, currentTime, Sgp4.wgsConstant.WGS_84);

            return(SatFunctions.isSatVisible(new Coordinate(observer.Latitude, observer.Longitude, observer.Altitude), 0, currentTime, data));
        }
Exemple #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.alterar);
            satFunctions = new SatFunctions(this);

            spinner = FindViewById <Spinner>(Resource.Id.spinner1);
            adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleExpandableListItem1, optCod);
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = (adapter);

            txtCodAtual     = FindViewById <EditText>(Resource.Id.txtCodAtual);
            txtCodConfirmar = FindViewById <EditText>(Resource.Id.txtCodConfirmar);
            txtCodNovo      = FindViewById <EditText>(Resource.Id.txtCodNovo);



            txtCodAtual.Text = GlobalValues.codigoAtivacao;

            btnAlterar = FindViewById <Button>(Resource.Id.btnAlterar);



            btnAlterar.Click += delegate
            {
                try
                {
                    var codigoAtivacaoAtual           = txtCodAtual.Text;
                    var codigoAtivacaoNovo            = txtCodNovo.Text;
                    var codigoAtivacaoNovoConfirmacao = txtCodConfirmar.Text;

                    if (!SatUtils.VerificaCodigoAtivacao(codigoAtivacaoAtual) || !SatUtils.VerificaCodigoAtivacao(codigoAtivacaoNovo) || !SatUtils.VerificaCodigoAtivacao(codigoAtivacaoNovoConfirmacao))
                    {
                        SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                        return;
                    }

                    if (codigoAtivacaoNovo != txtCodConfirmar.Text)
                    {
                        SatUtils.MostrarToast(this, "O Novo Código de Ativação e a Confirmação do Novo Código de Ativação não correspondem!");
                        return;
                    }

                    opcao = spinner.SelectedItem.Equals("Código de ativação") ? 1 : 2;

                    GlobalValues.codigoAtivacao = codigoAtivacaoNovo;
                    string     retorno    = satFunctions.TrocarCodAtivacao(codigoAtivacaoAtual, opcao, codigoAtivacaoNovo, SatUtils.GerarNumeroSessao);
                    RetornoSat retornoSat = OperacaoSat.invocarOperacaoSat("TrocarCodAtivacao", retorno);

                    string retornoFormatado = OperacaoSat.formataRetornoSat(retornoSat);
                    SatUtils.DialogoRetorno(this, retornoFormatado);
                }
                catch (Exception e)
                {
                    SatUtils.MostrarToast(this, e.Message);
                }
            };
        }
Exemple #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.assinatura);
            satLib = new SatFunctions(this);

            btnAssociar = FindViewById <Button>(Resource.Id.btnAssociar);

            txtCodAtivacao      = FindViewById <EditText>(Resource.Id.txtCodAtivacao);
            txtAssinatura       = FindViewById <EditText>(Resource.Id.txtAssinatura);
            txtCnpjContribuinte = FindViewById <EditText>(Resource.Id.txtCNPJ);
            txtCnpjContribuinte.AddTextChangedListener(new Mask(txtCnpjContribuinte, "##.###.###/####-##"));
            txtCnpjSH = FindViewById <EditText>(Resource.Id.txtSW);
            txtCnpjSH.AddTextChangedListener(new Mask(txtCnpjSH, "##.###.###/####-##"));
            txtCodAtivacao.Text = GlobalValues.codigoAtivacao;

            txtCnpjContribuinte.Text = "03.654.119/0001-76";
            txtCnpjSH.Text           = "16.716.114/0001-72";
            txtAssinatura.Text       = "SGR-SAT SISTEMA DE GESTAO E RETAGUARDA DO SAT";

            btnAssociar.Click += delegate
            {
                var codigoAtivacao = txtCodAtivacao.Text;
                var assinatura     = txtAssinatura.Text;

                if (!SatUtils.VerificaCodigoAtivacao(codigoAtivacao))
                {
                    SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                    return;
                }

                if (string.IsNullOrEmpty(assinatura))
                {
                    SatUtils.MostrarToast(this, "Assinatura AC Inválida!");
                    return;
                }

                string resp = satLib.AssociarSat(
                    SatUtils.SomenteNumeros(txtCnpjContribuinte.Text),
                    SatUtils.SomenteNumeros(txtCnpjSH.Text),
                    codigoAtivacao,
                    assinatura,
                    SatUtils.GerarNumeroSessao);

                RetornoSat retornoSat = OperacaoSat.invocarOperacaoSat("AssociarSAT", resp);

                //* Está função [OperacaoSat.formataRetornoSat] recebe como parâmetro a operação realizada e um objeto do tipo RetornoSat
                //* Retorna uma String com os valores obtidos do retorno da Operação já formatados e prontos para serem exibidos na tela
                // Recomenda-se acessar a função e entender como ela funciona
                string retornoFormatado = OperacaoSat.formataRetornoSat(retornoSat);


                SatUtils.DialogoRetorno(this, retornoFormatado);
                GlobalValues.codigoAtivacao = codigoAtivacao;
            };
        }
Exemple #6
0
        private void DrawLineSet(EpochTime startTime, List <One_Sgp4.Sgp4Data> data, Color c, CoordinateCalculator cCalc, Graphics g)
        {
            foreach (var point in data)
            {
                startTime.addMinutes(0.01);
                var position        = SatFunctions.calcSatSubPoint(startTime, point, Sgp4.wgsConstant.WGS_84);
                var pointOverGround = cCalc.MapPoint(new PointF((float)position.getLongitude(), (float)position.getLatitude()));


                g.FillRectangle(new SolidBrush(c), new RectangleF(pointOverGround, new Size(1, 1)));
            }
        }
Exemple #7
0
        public void DrawLocation(Graphics g, CoordinateCalculator cCalc)
        {
            Sgp4Data position    = SatFunctions.getSatPositionAtTime(Tle, new EpochTime(TimeKeeper.Now()), Sgp4.wgsConstant.WGS_84);
            var      point       = SatFunctions.calcSatSubPoint(new EpochTime(TimeKeeper.Now()), position, Sgp4.wgsConstant.WGS_84);
            var      mappedPoint = cCalc.MapPoint(new PointF((float)point.getLongitude(), (float)point.getLatitude()));

            mappedPoint = new PointF((float)Math.Round(mappedPoint.X), (float)Math.Round(mappedPoint.Y));

            g.DrawImage(Properties.Resources.satellite, mappedPoint.X - 25, mappedPoint.Y - 25, 50, 50);
            var font = new Font("Times New Roman", 18, FontStyle.Bold, GraphicsUnit.Pixel);

            g.DrawString(Name, font, new SolidBrush(Color.OrangeRed), mappedPoint.X, mappedPoint.Y + 15);
        }
Exemple #8
0
        public void TestSatContact()
        {
            Tle tleISS = ParserTLE.parseTle(
                "1 25544U 98067A   19356.46068278  .00000035  00000-0  86431-5 0  9990",
                "2 25544  51.6420 147.9381 0007793  61.6458  55.7201 15.50124783204461",
                "ISS 1");

            Coordinate position  = new Coordinate(35, 18, 0);
            EpochTime  startTime = new EpochTime(0, 0, 0, 2020, 1, 6);

            List <Pass> passes = SatFunctions.CalculatePasses(position, tleISS, startTime, 1, 1);

            Assert.AreEqual(8, passes.Count);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ativacao);

            satLib = new SatFunctions(this);

            txtCNPJContribuinte      = FindViewById <EditText>(Resource.Id.txtCNPJ);
            txtCNPJContribuinte.Text = "03.654.119/0001-76";
            txtCNPJContribuinte.AddTextChangedListener(new Mask(txtCNPJContribuinte, "##.###.###/####-##"));
            txtCodAtivacao      = FindViewById <EditText>(Resource.Id.txtCodAtivacao);
            txtconfCodAtivacao  = FindViewById <EditText>(Resource.Id.txtConfCodAtivacao);
            btnAtivarSat        = FindViewById <Button>(Resource.Id.buttonAtivar);
            txtCodAtivacao.Text = GlobalValues.codigoAtivacao;

            btnAtivarSat.Click += delegate
            {
                var codigoAtivacao            = txtCodAtivacao.Text;
                var codigoAtivacaoConfirmacao = txtconfCodAtivacao.Text;

                if (!SatUtils.VerificaCodigoAtivacao(codigoAtivacao))
                {
                    SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                    return;
                }

                if (codigoAtivacao != codigoAtivacaoConfirmacao)
                {
                    SatUtils.MostrarToast(this, "O Código de Ativação e a Confirmação do Código de Ativação não correspondem!");
                    return;
                }

                GlobalValues.codigoAtivacao = codigoAtivacao;
                string resp = satLib.AtivarSat(txtCodAtivacao.Text.ToString(),
                                               SatUtils.SomenteNumeros(txtCNPJContribuinte.Text),
                                               SatUtils.GerarNumeroSessao);

                RetornoSat retornoSat = OperacaoSat.invocarOperacaoSat("AtivarSAT", resp);

                //* Está função [OperacaoSat.formataRetornoSat] recebe como parâmetro a operação realizada e um objeto do tipo RetornoSat
                //* Retorna uma String com os valores obtidos do retorno da Operação já formatados e prontos para serem exibidos na tela
                // Recomenda-se acessar a função e entender como ela funciona
                string retornoFormatado = OperacaoSat.formataRetornoSat(retornoSat);



                SatUtils.DialogoRetorno(this, retornoFormatado);
            };
        }
Exemple #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.teste);
            satFunctions = new SatFunctions(this);

            btnConsultar        = FindViewById <Button>(Resource.Id.btnConsultarSat);
            btnStatus           = FindViewById <Button>(Resource.Id.buttonStatus);
            btnTeste            = FindViewById <Button>(Resource.Id.buttonFimaFim);
            btnVendas           = FindViewById <Button>(Resource.Id.buttonTesteVenda);
            btnCancelamento     = FindViewById <Button>(Resource.Id.buttonCancelamento);
            btnSessao           = FindViewById <Button>(Resource.Id.buttonConsultarSessao);
            txtCodAtivacao      = FindViewById <EditText>(Resource.Id.txtCodAtivacao);
            txtCodAtivacao.Text = GlobalValues.codigoAtivacao;

            InitFuncoes();
        }
Exemple #11
0
    /*****************************************************************************
    * @function name : calECIDateAndVelocity
    * @author : Kaguya
    * @date : 2020/12/3 12:38
    * @inparam :
    * @outparam :
    * @last change :
    * @usage : 基于one_sgp4项目,计算航天器基于ECI坐标系下的位置和速度
    *****************************************************************************/
    public void calECIDateAndVelocity()
    {
        Tle       tleISS    = ParserTLE.parseTle(first, second, "ISS 1");
        DateTime  t         = new DateTime(data[0], data[1], data[2], data[3], data[4], data[5]);
        EpochTime startTime = new EpochTime(t);
        Sgp4Data  sate      = SatFunctions.getSatPositionAtTime(tleISS, startTime, Sgp4.wgsConstant.WGS_84);

        One_Sgp4.Point3d position = sate.getPositionData();
        ECI    = new double[3];
        ECI[0] = position.x;
        ECI[1] = position.y;
        ECI[2] = position.z;

        velocity    = new double[3];
        velocity[0] = sate.getVelocityData().x;
        velocity[1] = sate.getVelocityData().y;
        velocity[2] = sate.getVelocityData().z;
        velocity    = getECEF(velocity, data);
    }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            // Plugin NFC: Initialization
            CrossNFC.Init(this);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            mContext     = this;
            tef          = new TEF.Tef();
            satFunctions = new SatFunctions(Application.Context);

            LoadApplication(new App());
        }
Exemple #13
0
        public void TestSatGroundPosition(int hh, int mm, int ss, int yyyy, int MM, int dd)
        {
            Tle tleISS = ParserTLE.parseTle(
                "1 25544U 98067A   19356.46068278  .00000035  00000-0  86431-5 0  9990",
                "2 25544  51.6420 147.9381 0007793  61.6458  55.7201 15.50124783204461",
                "ISS 1");


            EpochTime testTime = new EpochTime(hh, mm, ss, yyyy, MM, dd);
            Sgp4Data  data     = SatFunctions.getSatPositionAtTime(tleISS, testTime, Sgp4.wgsConstant.WGS_84);

            Assert.IsNotNull(data);
            Coordinate ground = SatFunctions.calcSatSubPoint(testTime, data, Sgp4.wgsConstant.WGS_84);

            Assert.Greater(ground.getHeight(), 0);
            Assert.LessOrEqual(ground.getLongitude(), 180.0);
            Assert.Greater(ground.getLongitude(), -180.0);
            Assert.LessOrEqual(ground.getLatitude(), 90.0);
            Assert.Greater(ground.getLatitude(), -90.0);
        }
Exemple #14
0
        private void btnCalc_Click(object sender, EventArgs e)
        {
            var location = _db.GetPosition();
            var home     = new Coordinate(Decimal.ToDouble(location.lat), Decimal.ToDouble(location.lng));

            lviewPasses.Items.Clear();
            List <SatPass> satPasses = new List <SatPass>();

            foreach (var sat in _satellites.SelectedSatellites)
            {
                var passes = SatFunctions.CalculatePasses(home, sat.Tle, new EpochTime(dtpStart.Value), 15, (int)nbxSpanDays.Value, Sgp4.wgsConstant.WGS_84);
                passes.ForEach(p => satPasses.Add(new SatPass(sat.Name, p)));
            }

            satPasses = satPasses
                        .Where(p => p.Pass.getPassDetailOfMaxElevation().elevation >= (double)nbxMinElev.Value)
                        .OrderBy(p => p.Pass.getStartEpoch().getEpoch())
                        .ToList();

            foreach (var pass in satPasses)
            {
                string[] arr = new string[4];
                arr[0] = pass.Pass.getPassDetailOfMaxElevation().time.toDateTime().ToLocalTime().ToString();
                arr[1] = pass.Name;
                arr[2] = (pass.Pass.getPassDetailsAtEnd().time.toDateTime() - pass.Pass.getPassDetailsAtStart().time.toDateTime()).ToString();
                arr[3] = Math.Round(pass.Pass.getPassDetailOfMaxElevation().elevation, 2).ToString();

                var itm = new ListViewItem(arr);
                lviewPasses.Items.Add(itm);
            }

            var settings = new PassSettingDto(location, dtpStart.Value, (int)nbxSpanDays.Value, (double)nbxMinElev.Value,
                                              _satellites.SelectedSatellites.Select(s => s.Name).ToArray());

            btnGenPdf.Enabled = true;

            lastSettings = settings;
            lastPasses   = satPasses;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);

            printer     = new GertecPrinter(mainActivity);
            configPrint = new ConfigPrint();
            printer.setConfigImpressao(configPrint);
            satFunctions = new SatFunctions(context);

            modelo = CrossDeviceInfo.Current.Model;

            // ZXing Inicialização
            global::ZXing.Net.Mobile.Forms.Android.Platform.Init();

            //LoadApplication is a Xamarin.Forms method
            LoadApplication(new App());

            mContext = this;
        }
Exemple #16
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.teste);
            satFunctions = new SatFunctions(this);

            btnConsultar    = FindViewById <Button>(Resource.Id.buttonConsultar);
            btnStatus       = FindViewById <Button>(Resource.Id.buttonStatus);
            btnTeste        = FindViewById <Button>(Resource.Id.buttonFimaFim);
            btnVendas       = FindViewById <Button>(Resource.Id.buttonTesteVenda);
            btnCancelamento = FindViewById <Button>(Resource.Id.buttonCancelamento);
            btnSessao       = FindViewById <Button>(Resource.Id.buttonConsultarSessao);

            list_resposta         = FindViewById <ListView>(Resource.Id.lvRetorno);
            items                 = new List <string>();
            adapter               = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, items);
            list_resposta.Adapter = adapter;

            txtCodAtivacao      = FindViewById <EditText>(Resource.Id.txtCodAtivacao);
            txtCodAtivacao.Text = GlobalValues.codigoAtivacao;


            InitFuncoes();
        }
Exemple #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ferramentas);
            satFunctions = new SatFunctions(this);

            btnBloquear    = FindViewById <Button>(Resource.Id.btnBloquear);
            btnDesbloquear = FindViewById <Button>(Resource.Id.btnDesbloquear);
            btnLog         = FindViewById <Button>(Resource.Id.btnLog);
            btnAtualizar   = FindViewById <Button>(Resource.Id.btnAtualizar);
            btnVersao      = FindViewById <Button>(Resource.Id.btnVersao);
            txtCodAtivacao = FindViewById <EditText>(Resource.Id.txtCodAtivacao);

            txtCodAtivacao.Text = GlobalValues.codigoAtivacao;

            btnBloquear.Click += delegate
            {
                if (!SatUtils.VerificaCodigoAtivacao(txtCodAtivacao.Text))
                {
                    SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                    return;
                }

                RespostaSat("BloquearSat");
            };

            btnDesbloquear.Click += delegate
            {
                if (!SatUtils.VerificaCodigoAtivacao(txtCodAtivacao.Text))
                {
                    SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                    return;
                }

                RespostaSat("DesbloquearSat");
            };

            btnLog.Click += delegate
            {
                if (!SatUtils.VerificaCodigoAtivacao(txtCodAtivacao.Text))
                {
                    SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                    return;
                }


                try
                {
                    RespostaSat("ExtrairLog");
                }
                catch (Exception e)
                {
                    SatUtils.MostrarToast(this, e.Message);
                }
            };

            btnAtualizar.Click += delegate
            {
                if (!SatUtils.VerificaCodigoAtivacao(txtCodAtivacao.Text))
                {
                    SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                    return;
                }

                RespostaSat("AtualizarSoftware");
            };

            btnVersao.Click += delegate
            {
                RespostaSat("Versao");
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.rede);
            satFunctions = new SatFunctions(this);

            btnConfigurar       = FindViewById <Button>(Resource.Id.buttonEnviar);
            txtCodAtivacao      = FindViewById <EditText>(Resource.Id.txtCodAtivacao);
            txtIp               = FindViewById <EditText>(Resource.Id.txtIp);
            txtMascara          = FindViewById <EditText>(Resource.Id.txtMascara);
            txtGateway          = FindViewById <EditText>(Resource.Id.txtGateway);
            txtDns              = FindViewById <EditText>(Resource.Id.txtDns);
            txtDns2             = FindViewById <EditText>(Resource.Id.txtDns2);
            txtProxyIp          = FindViewById <EditText>(Resource.Id.txtProxyIp);
            txtPorta            = FindViewById <EditText>(Resource.Id.txtPorta);
            txtUser             = FindViewById <EditText>(Resource.Id.txtUser);
            txtPassword         = FindViewById <EditText>(Resource.Id.txtPassword);
            spinnerTipoRede     = FindViewById <Spinner>(Resource.Id.tipoRede);
            spinnerOptDns       = FindViewById <Spinner>(Resource.Id.optDns);
            spinnerOptProxy     = FindViewById <Spinner>(Resource.Id.optProxy);
            txtCodAtivacao.Text = GlobalValues.codigoAtivacao;


            ArrayAdapter adp = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, tipoRede);

            adp.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);
            spinnerTipoRede.Adapter       = adp;
            spinnerTipoRede.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerTipoRede_ItemSelected);

            ArrayAdapter adp2 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, optDns);

            adp2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);
            spinnerOptDns.Adapter       = adp2;
            spinnerOptDns.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerOptDns_ItemSelected);

            ArrayAdapter adp3 = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, optProxy);

            adp3.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerItem);
            spinnerOptProxy.Adapter       = adp3;
            spinnerOptProxy.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerOptProxy_ItemSelected);

            btnConfigurar.Click += delegate
            {
                try
                {
                    var codigoAtivacao = txtCodAtivacao.Text;

                    if (!SatUtils.VerificaCodigoAtivacao(codigoAtivacao))
                    {
                        SatUtils.MostrarToast(this, "Código de Ativação deve ter entre 8 a 32 caracteres!");
                        return;
                    }

                    ConfiguracaoRede config = new ConfiguracaoRede();

                    // Monta as tags do XML sobre a parte de REDE
                    if (spinnerTipoRede.SelectedItem.Equals("Estático"))
                    {
                        config.tipoLan = "IPFIX";


                        if (!string.IsNullOrEmpty(txtIp.Text))
                        {
                            config.lanIP = txtIp.Text;
                        }

                        if (!string.IsNullOrEmpty(txtMascara.Text))
                        {
                            config.lanMask = txtMascara.Text;
                        }

                        if (!string.IsNullOrEmpty(txtGateway.Text))
                        {
                            config.lanGW = txtGateway.Text;
                        }

                        // Monta as tags do XML sobre a parte de DNS
                        if (spinnerOptDns.SelectedItem.Equals("Sim"))
                        {
                            if (!string.IsNullOrEmpty(txtDns.Text))
                            {
                                config.lanDNS1 = txtDns.Text;
                            }

                            if (!string.IsNullOrEmpty(txtDns2.Text))
                            {
                                config.lanDNS2 = txtDns2.Text;
                            }
                        }
                        else
                        {
                            config.lanDNS1 = "8.8.8.8";
                            config.lanDNS2 = "4.4.4.4";
                        }
                    }
                    else
                    {
                        config.tipoLan = "DHCP";
                    }


                    // Monta as tags do XML sobre a parte de PROXY
                    if (spinnerOptProxy.SelectedItem.Equals("Não usa proxy"))
                    {
                        config.proxy = "0";
                    }

                    else if (spinnerOptProxy.SelectedItem.Equals("Proxy com configuração"))
                    {
                        config.proxy = "1";

                        if (!string.IsNullOrEmpty(txtProxyIp.Text))
                        {
                            config.proxy_ip = txtProxyIp.Text;
                        }

                        if (!string.IsNullOrEmpty(txtPorta.Text))
                        {
                            config.proxy_porta = txtPorta.Text;
                        }

                        if (!string.IsNullOrEmpty(txtUser.Text))
                        {
                            config.proxy_user = txtUser.Text;
                        }

                        if (!string.IsNullOrEmpty(txtPassword.Text))
                        {
                            config.proxy_senha = txtPassword.Text;
                        }
                    }
                    else
                    {
                        config.proxy = "2";
                        if (!string.IsNullOrEmpty(txtProxyIp.Text))
                        {
                            config.proxy_ip = txtProxyIp.Text;
                        }

                        if (!string.IsNullOrEmpty(txtPorta.Text))
                        {
                            config.proxy_porta = txtPorta.Text;
                        }

                        if (!string.IsNullOrEmpty(txtUser.Text))
                        {
                            config.proxy_user = txtUser.Text;
                        }

                        if (!string.IsNullOrEmpty(txtPassword.Text))
                        {
                            config.proxy_senha = txtPassword.Text;
                        }
                    }

                    string     resp       = satFunctions.EnviarConfRede(SatUtils.GerarNumeroSessao, config.GerarXml(), codigoAtivacao);
                    RetornoSat retornoSat = OperacaoSat.invocarOperacaoSat("EnviarConfRede", resp);

                    //* Está função [OperacaoSat.formataRetornoSat] recebe como parâmetro a operação realizada e um objeto do tipo RetornoSat
                    //* Retorna uma String com os valores obtidos do retorno da Operação já formatados e prontos para serem exibidos na tela
                    // Recomenda-se acessar a função e entender como ela funciona
                    GlobalValues.codigoAtivacao = codigoAtivacao;
                    String retornoFormatado = OperacaoSat.formataRetornoSat(retornoSat);

                    SatUtils.DialogoRetorno(this, retornoFormatado);
                }
                catch (Exception e)
                {
                    Toast.MakeText(this, e.Message.ToString(), ToastLength.Long).Show();
                }
            };
        }
Exemple #19
0
        static void Main(string[] args)
        {
            //Parse three line element
            Tle tleISS = ParserTLE.parseTle(
                "1 25544U 98067A   19097.23063721 -.00000469  00000-0  00000+0 0  9999",
                "2 25544  51.6449 353.9503 0002279 151.1697 290.4275 15.52495932164239",
                "ISS 1");

            //Parse tle from file
            if (System.IO.File.Exists("tleData.txt"))
            {
                List <Tle> tleList = ParserTLE.ParseFile("tleData.txt");
            }

            //Get TLE from Space-Track.org
            //list of satellites by their NORAD ID
            string[] noradIDs = { "8709", "43572" };
            try
            {
                One_Sgp4.SpaceTrack.GetSpaceTrack(noradIDs, "USERNAME", "PASSWORD");
            }
            catch { Console.Out.WriteLine("Error could not retrive TLE's from Space-Track, Login credentials might be wrong"); }


            //Create Time points
            EpochTime startTime   = new EpochTime(DateTime.UtcNow);
            EpochTime anotherTime = new EpochTime(2018, 100.5); //(Year 2017, 100 day at 12:00 HH)
            EpochTime stopTime    = new EpochTime(DateTime.UtcNow.AddHours(1));

            //Add 15 Seconds to EpochTime
            anotherTime.addTick(15);
            //Add 20 Min to EpochTime
            anotherTime.addMinutes(15);
            //Add 1 hour to EpochTime
            anotherTime.addHours(1);
            //Add 2 Days to EpochTime
            anotherTime.addDays(2);
            Console.Out.WriteLine(anotherTime.ToString());


            //Calculate Satellite Position and Speed
            One_Sgp4.Sgp4 sgp4Propagator = new Sgp4(tleISS, Sgp4.wgsConstant.WGS_84);
            //set calculation parameters StartTime, EndTime and caclulation steps in minutes
            sgp4Propagator.runSgp4Cal(startTime, stopTime, 1 / 30.0); // 1/60 => caclulate sat points every 2 seconds
            List <One_Sgp4.Sgp4Data> resultDataList = new List <Sgp4Data>();

            //Return Results containing satellite Position x,y,z (ECI-Coordinates in Km) and Velocity x_d, y_d, z_d (ECI-Coordinates km/s)
            resultDataList = sgp4Propagator.getRestults();

            //Coordinate of an observer on Ground lat, long, height(in meters)
            One_Sgp4.Coordinate observer = new Coordinate(35.554595, 18.888574, 0);
            //Convert to ECI coordinate system
            One_Sgp4.Point3d eci = observer.toECI(startTime.getLocalSiderealTime());
            //Get Local SiderealTime for Observer
            double localSiderealTime = startTime.getLocalSiderealTime(observer.getLongitude());

            //TESTING MIR

            //TEST ECI
            EpochTime T_eciTime = new EpochTime(09, 00, 00, 1995, 10, 1);

            //Test GMST
            if (T_eciTime.getLocalSiderealTime() == 2.524218)
            {
            }
            Coordinate T_eciCoo = new Coordinate(40, -75);
            var        t_eci    = T_eciCoo.toECI(T_eciTime.getLocalSiderealTime());
            //Coordinate equals x' = 1703.295 km, y' = 4586.650 km, z' = 4077.984 km.


            EpochTime  t_time = new EpochTime(12, 46, 0, 1995, 11, 18);
            Coordinate t_cord = new Coordinate(45.0, -93);
            Sgp4Data   mirPos = new Sgp4Data();

            mirPos.setX(-4400.594);
            mirPos.setY(1932.870);
            mirPos.setZ(4760.712);
            var lookAngels = SatFunctions.calcSphericalCoordinate(t_cord, t_time, mirPos);
            var onGround   = SatFunctions.calcSatSubPoint(t_time, mirPos, Sgp4.wgsConstant.WGS_72);
            var r          = t_cord.toECI(t_time.getLocalSiderealTime());


            //Calculate if Satellite is Visible for a certain Observer on ground at certain timePoint
            bool satelliteIsVisible = One_Sgp4.SatFunctions.isSatVisible(observer, 0.0, startTime, resultDataList[0]);

            //Calculate Sperical Coordinates from an Observer to Satellite
            //returns 3D-Point with range(km), azimuth(radians), elevation(radians) to the Satellite
            One_Sgp4.Point3d spherical = One_Sgp4.SatFunctions.calcSphericalCoordinate(observer, startTime, resultDataList[0]);

            //Calculate the Next 5 Passes over a point
            //for a location, Satellite, StartTime, Accuracy in Seconds = 15sec, MaxNumber of Days = 5 Days, Wgs constant = WGS_84
            //Returns pass with Location, StartTime of Pass, EndTime Of Pass, Max Elevation in Degrees
            List <Pass> passes = One_Sgp4.SatFunctions.CalculatePasses(observer, tleISS, new EpochTime(DateTime.UtcNow), 15, 5, Sgp4.wgsConstant.WGS_84);

            foreach (var p in passes)
            {
                Console.Out.WriteLine(p.ToString());
            }
        }