Beispiel #1
0
        private void FromBytesToFormatoPainelCfg(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoRoteiros *roteiros = (FormatoRoteiros *)pSrc;

                    this.versao    = roteiros->versao;
                    this.reservado = roteiros->reservado;
                    this.id        = roteiros->id;
                    this.tarifa    = roteiros->tarifa; // valor da tarifa multiplicado por 100 ex:11,22 é salvo como 1122

                    this.labelNumero       = ArrayLDX2.ByteArrayToString(roteiros->labelNumero, 20);
                    this.labelRoteiro      = ArrayLDX2.ByteArrayToString(roteiros->labelRoteiro, 16);
                    this.labelRoteiroVolta = ArrayLDX2.ByteArrayToString(roteiros->labelRoteiroVolta, 16);

                    for (int i = 0; i < 2; i++)
                    {
                        this.reservado2[i] = roteiros->reservado2[i];
                    }

                    this.crc = roteiros->crc;
                }
            }
        }
        private byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoMensagem)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoMensagem *mensagem = (FormatoMensagem *)pSrc;


                    mensagem->versao    = this.versao;
                    mensagem->reservado = this.reservado;
                    mensagem->id        = this.id;
                    ArrayLDX2.StringToByteArray(mensagem->labelMensagem, this.labelMensagem, 20);

                    for (int i = 0; i < 38; i++)
                    {
                        mensagem->reservado2[i] = this.reservado2[i];
                    }

                    mensagem->crc = this.crc;

                    return(resultado);
                }
            }
        }
Beispiel #3
0
        private byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoRoteiros)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoRoteiros *roteiros = (FormatoRoteiros *)pSrc;

                    roteiros->versao    = this.versao;
                    roteiros->reservado = this.reservado;
                    roteiros->id        = this.id;
                    roteiros->tarifa    = this.tarifa; // valor da tarifa multiplicado por 100 ex:11,22 é salvo como 1122

                    ArrayLDX2.StringToByteArray(roteiros->labelNumero, this.labelNumero, 20);
                    ArrayLDX2.StringToByteArray(roteiros->labelRoteiro, this.labelRoteiro, 16);
                    ArrayLDX2.StringToByteArray(roteiros->labelRoteiroVolta, this.labelRoteiroVolta, 16);

                    for (int i = 0; i < 2; i++)
                    {
                        roteiros->reservado2[i] = this.reservado2[i];
                    }

                    roteiros->crc = this.crc;

                    return(resultado);
                }
            }
        }
Beispiel #4
0
        /*
         * public void Salvar(string diretorio_fonte, String diretorio_saida ,ControladorPontos.Controlador Ctrdl)
         * {
         *  List<string> rots = Directory.EnumerateFiles(diretorio_fonte, "*.rot").ToList();
         *
         *  for (int painel = 0; painel < Ctrdl.QuantidadePaineis; painel++)
         *  {
         *      foreach (String s in rots)
         *      {
         *          Arquivo_RPT arpt = new Arquivo_RPT();
         *
         *          arpt.CriarRoteirosPathPadrao();
         *
         *          //criar um arquivo de vídeo para cada entidade.
         *          arpt.pathExibicaoIda = "videos/" + painel.ToString("d3") + ".v01";
         *          arpt.pathExibicaoVolta = "videos/" + painel.ToString("d3") + ".v01";
         *          arpt.pathNumeroRoteiro = "videos/" + painel.ToString("d3") + ".v01";
         *
         *          arpt.Salvar(diretorio_saida + @"\" + painel.ToString("d2") + @"\roteiros\" +
         *                      s.Substring(s.Length - 7, 3) + ".rpt");
         *      }
         *  }
         * }
         */
        private byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoRoteiroPaths)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc;

                    roteiroPaths->versao    = this.versao;
                    roteiroPaths->reservado = this.reservado;
                    roteiroPaths->idRoteiro = this.idRoteiro;
                    for (int i = 0; i < 58; i++)
                    {
                        roteiroPaths->reservado2[i] = this.reservado2[i];
                    }
                    roteiroPaths->crc = this.crc;
                    ArrayLDX2.StringToByteArray(roteiroPaths->pathExibicaoIda, this.pathExibicaoIda, 64);
                    ArrayLDX2.StringToByteArray(roteiroPaths->pathExibicaoVolta, this.pathExibicaoVolta, 64);
                    ArrayLDX2.StringToByteArray(roteiroPaths->pathNumeroRoteiro, this.pathNumeroRoteiro, 64);

                    return(resultado);
                }
            }
        }
Beispiel #5
0
        public void GerarFormatoNovo(string arquivoNome, string diretorioRaiz)
        {
            FileStream fs = File.OpenRead(arquivoNome + Util.Util.sequencial_arquivo_mensagens.ToString("X8") + Util.Util.ARQUIVO_EXT_MPT);

            byte[] dados = new byte[(int)fs.Length];
            fs.Read(dados, 0, dados.Length);
            fs.Close();

            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc;

                    this.versao     = mensagemPaths->versao;
                    this.reservado  = mensagemPaths->reservado;
                    this.idMensagem = mensagemPaths->idMensagem;
                    for (int i = 0; i < 58; i++)
                    {
                        this.reservado2[i] = mensagemPaths->reservado2[i];
                    }
                    this.crc       = mensagemPaths->crc;
                    this.pathVideo = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(mensagemPaths->pathVideo, 64));
                }

                //fs = File.OpenRead(diretorioRaiz + this.pathVideo);
                fs = File.OpenRead(this.pathVideo);
                byte[] dadosVideo = new byte[(int)fs.Length];
                fs.Read(dadosVideo, 0, dadosVideo.Length);
                fs.Close();

                Array.Resize(ref dados, (dados.Length - 64) + dadosVideo.Length);
                Array.Copy(dadosVideo, 0, dados, 64, dadosVideo.Length);

                fixed(byte *pSrc = dados)
                {
                    FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc;

                    mensagemPaths->crc = CalcularCRC(dados);
                }

                fs = File.Create(arquivoNome + Util.Util.sequencial_arquivo_mensagens.ToString("X8") + Util.Util.ARQUIVO_EXT_MPT);
                fs.Write(dados, 0, dados.Length);
                fs.Close();
            }
        }
        private void FromBytesToFormatoPainelCfg(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoMotoristas *roteiros = (FormatoMotoristas *)pSrc;

                    this.versao = roteiros->versao;
                    this.id     = roteiros->id;

                    this.labelIdentificacao = ArrayLDX2.ByteArrayToString(roteiros->labelIdentificacao, 20);
                    this.labelNome          = ArrayLDX2.ByteArrayToString(roteiros->labelNome, 20);

                    this.crc = roteiros->crc;
                }
            }
        }
Beispiel #7
0
        private void FromBytesToFormatoPainelCfg(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc;

                    this.versao     = mensagemPaths->versao;
                    this.reservado  = mensagemPaths->reservado;
                    this.idMensagem = mensagemPaths->idMensagem;
                    for (int i = 0; i < 58; i++)
                    {
                        this.reservado2[i] = mensagemPaths->reservado2[i];
                    }
                    this.crc       = mensagemPaths->crc;
                    this.pathVideo = ArrayLDX2.ByteArrayToString(mensagemPaths->pathVideo, 64);
                }
            }
        }
Beispiel #8
0
        private byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoMotoristaPaths)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoMotoristaPaths *motoristaPaths = (FormatoMotoristaPaths *)pSrc;

                    motoristaPaths->versao      = this.versao;
                    motoristaPaths->idMotorista = this.idMotorista;

                    motoristaPaths->crc = this.crc;

                    ArrayLDX2.StringToByteArray(motoristaPaths->pathExibicaoId, this.pathExibicaoID, 64);
                    ArrayLDX2.StringToByteArray(motoristaPaths->pathExibicaoNome, this.pathExibicaoNome, 64);

                    return(resultado);
                }
            }
        }
        private byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoMotoristas)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoMotoristas *roteiros = (FormatoMotoristas *)pSrc;

                    roteiros->versao = this.versao;
                    roteiros->id     = this.id;

                    ArrayLDX2.StringToByteArray(roteiros->labelIdentificacao, this.labelIdentificacao, 20);
                    ArrayLDX2.StringToByteArray(roteiros->labelNome, this.labelNome, 20);

                    roteiros->crc = this.crc;

                    return(resultado);
                }
            }
        }
        private void FromBytesToFormatoPainelCfg(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoMensagem *mensagem = (FormatoMensagem *)pSrc;

                    this.versao        = mensagem->versao;
                    this.reservado     = mensagem->reservado;
                    this.id            = mensagem->id;
                    this.labelMensagem = ArrayLDX2.ByteArrayToString(mensagem->labelMensagem, 20);

                    for (int i = 0; i < 38; i++)
                    {
                        this.reservado2[i] = mensagem->reservado2[i];
                    }

                    this.crc = mensagem->crc;
                }
            }
        }
Beispiel #11
0
        public byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoItemAlternancia)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoItemAlternancia *fItemAlternancia = (FormatoItemAlternancia *)pSrc;

                    fItemAlternancia->qntExibicoes = this.qntExibicoes;

                    for (int i = 0; i < this.exibicoes.Count; i++)
                    {
                        fItemAlternancia->exibicoes[i] = (byte)this.exibicoes[i];
                    }

                    ArrayLDX2.StringToByteArray(fItemAlternancia->nomeAlternancia, this.NomeAlternancia, 32);

                    return(resultado);
                }
            }
        }
        private void FromBytesToFormatoPainelCfg(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoListaArquivos *listaArquivos = (FormatoListaArquivos *)pSrc;

                    Byte[] temporario = new byte[listaArquivos->qtdArquivos];

                    this.versao = listaArquivos->versao;

                    this.qtdArquivos = listaArquivos->qtdArquivos;

                    this.crc = listaArquivos->crc;
                    for (int i = 0; i < this.qtdArquivos; i++)
                    {
                        this.listaPaths.Add(string.Empty);
                        this.listaPaths[i] = ArrayLDX2.ByteArrayToString(pSrc + sizeof(FormatoListaArquivos) + (i * Util.Util.ARQUIVO_LST_PATH_SIZE), Util.Util.ARQUIVO_LST_PATH_SIZE);
                    }
                }
            }
        }
Beispiel #13
0
        private byte[] toByteArray()
        {
            unsafe
            {
                Byte[] resultado = new Byte[sizeof(FormatoMensagemPaths)];

                fixed(byte *pSrc = resultado)
                {
                    FormatoMensagemPaths *mensagemPaths = (FormatoMensagemPaths *)pSrc;

                    mensagemPaths->versao     = this.versao;
                    mensagemPaths->reservado  = this.reservado;
                    mensagemPaths->idMensagem = this.idMensagem;
                    for (int i = 0; i < 58; i++)
                    {
                        mensagemPaths->reservado2[i] = this.reservado2[i];
                    }
                    mensagemPaths->crc = this.crc;
                    ArrayLDX2.StringToByteArray(mensagemPaths->pathVideo, this.pathVideo, 64);

                    return(resultado);
                }
            }
        }
Beispiel #14
0
        private void FromBytesToFormatoPainelCfg(byte[] dados)
        {
            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc;

                    this.versao    = roteiroPaths->versao;
                    this.reservado = roteiroPaths->reservado;
                    this.idRoteiro = roteiroPaths->idRoteiro;

                    for (int i = 0; i < 58; i++)
                    {
                        this.reservado2[i] = roteiroPaths->reservado2[i];
                    }
                    this.crc = roteiroPaths->crc;

                    this.pathExibicaoIda   = ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoIda, 64);
                    this.pathExibicaoVolta = ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoVolta, 64);
                    this.pathNumeroRoteiro = ArrayLDX2.ByteArrayToString(roteiroPaths->pathNumeroRoteiro, 64);
                }
            }
        }
Beispiel #15
0
        public void GerarFormatoNovo(string arquivoNome, string diretorioRaiz)
        {
            UInt32     offsetId   = 0;
            UInt32     offsetNome = 0;
            FileStream fs         = File.OpenRead(arquivoNome + Util.Util.sequencial_arquivo_motoristas.ToString("X8") + Util.Util.ARQUIVO_EXT_DPT);

            byte[] dados = new byte[(int)fs.Length];
            fs.Read(dados, 0, dados.Length);
            fs.Close();

            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoMotoristaPaths *motoristaPaths = (FormatoMotoristaPaths *)pSrc;

                    this.versao      = motoristaPaths->versao;
                    this.idMotorista = motoristaPaths->idMotorista;

                    this.crc              = motoristaPaths->crc;
                    this.pathExibicaoID   = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(motoristaPaths->pathExibicaoId, 64));
                    this.pathExibicaoNome = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(motoristaPaths->pathExibicaoNome, 64));
                }

                if (this.pathExibicaoID.Contains(":"))
                {
                    fs = File.OpenRead(this.pathExibicaoID);
                }
                else
                {
                    fs = File.OpenRead(diretorioRaiz + this.pathExibicaoID);
                }

                byte[] dadosVideoId = new byte[(int)fs.Length];
                fs.Read(dadosVideoId, 0, dadosVideoId.Length);
                fs.Close();

                offsetId = 64;
                Array.Resize(ref dados, (dados.Length - (2 * 64)) + dadosVideoId.Length);
                Array.Copy(dadosVideoId, 0, dados, offsetId, dadosVideoId.Length);

                if (this.pathExibicaoNome.Contains(":"))
                {
                    fs = File.OpenRead(this.pathExibicaoNome);
                }
                else
                {
                    fs = File.OpenRead(diretorioRaiz + this.pathExibicaoNome);
                }

                byte[] dadosVideoNome = new byte[(int)fs.Length];
                fs.Read(dadosVideoNome, 0, dadosVideoNome.Length);
                fs.Close();

                offsetNome = (UInt32)(offsetId + dadosVideoId.Length);
                Array.Resize(ref dados, dados.Length + dadosVideoNome.Length);
                Array.Copy(dadosVideoNome, 0, dados, offsetNome, dadosVideoNome.Length);

                BitConverter.GetBytes(offsetId).CopyTo(dados, 4);
                BitConverter.GetBytes(offsetNome).CopyTo(dados, 8);

                fixed(byte *pSrc = dados)
                {
                    FormatoMotoristaPaths *motoristaPaths = (FormatoMotoristaPaths *)pSrc;

                    motoristaPaths->crc = CalcularCRC(dados);

                    BitConverter.GetBytes(motoristaPaths->crc).CopyTo(dados, Util.Util.CRCPosition1);
                }

                fs = File.Create(arquivoNome + Util.Util.sequencial_arquivo_motoristas.ToString("X8") + Util.Util.ARQUIVO_EXT_DPT);
                fs.Write(dados, 0, dados.Length);
                fs.Close();
            }
        }
Beispiel #16
0
        public void GerarFormatoNovo(string arquivoNome, string diretorioRaiz)
        {
            UInt32     offsetIda    = 0;
            UInt32     offsetVolta  = 0;
            UInt32     offsetNumero = 0;
            FileStream fs           = File.OpenRead(arquivoNome + Util.Util.sequencial_arquivo_roteiros.ToString("X8") + Util.Util.ARQUIVO_EXT_RPT);

            byte[] dados = new byte[(int)fs.Length];
            fs.Read(dados, 0, dados.Length);
            fs.Close();

            unsafe
            {
                fixed(byte *pSrc = dados)
                {
                    FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc;

                    this.versao    = roteiroPaths->versao;
                    this.reservado = roteiroPaths->reservado;
                    this.idRoteiro = roteiroPaths->idRoteiro;
                    for (int i = 0; i < 58; i++)
                    {
                        this.reservado2[i] = roteiroPaths->reservado2[i];
                    }
                    this.crc = roteiroPaths->crc;

                    this.pathExibicaoIda   = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoIda, 64));
                    this.pathExibicaoVolta = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(roteiroPaths->pathExibicaoVolta, 64));
                    this.pathNumeroRoteiro = Util.Util.TrataDiretorio(ArrayLDX2.ByteArrayToString(roteiroPaths->pathNumeroRoteiro, 64));
                }

                if (this.pathExibicaoIda.Contains(":"))
                {
                    fs = File.OpenRead(this.pathExibicaoIda);
                }
                else
                {
                    fs = File.OpenRead(diretorioRaiz + this.pathExibicaoIda);
                }

                byte[] dadosVideoIda = new byte[(int)fs.Length];
                fs.Read(dadosVideoIda, 0, dadosVideoIda.Length);
                fs.Close();

                offsetIda = 64;
                Array.Resize(ref dados, (dados.Length - (3 * 64)) + dadosVideoIda.Length);
                Array.Copy(dadosVideoIda, 0, dados, offsetIda, dadosVideoIda.Length);

                if (this.pathExibicaoVolta.Contains(":"))
                {
                    fs = File.OpenRead(this.pathExibicaoVolta);
                }
                else
                {
                    fs = File.OpenRead(diretorioRaiz + this.pathExibicaoVolta);
                }

                byte[] dadosVideoVolta = new byte[(int)fs.Length];
                fs.Read(dadosVideoVolta, 0, dadosVideoVolta.Length);
                fs.Close();

                offsetVolta = (UInt32)(offsetIda + dadosVideoIda.Length);
                Array.Resize(ref dados, dados.Length + dadosVideoVolta.Length);
                Array.Copy(dadosVideoVolta, 0, dados, offsetVolta, dadosVideoVolta.Length);

                if (this.pathNumeroRoteiro.Contains(":"))
                {
                    fs = File.OpenRead(this.pathNumeroRoteiro);
                }
                else
                {
                    fs = File.OpenRead(diretorioRaiz + this.pathNumeroRoteiro);
                }
                byte[] dadosVideoNumero = new byte[(int)fs.Length];
                fs.Read(dadosVideoNumero, 0, dadosVideoNumero.Length);
                fs.Close();

                offsetNumero = (UInt32)(offsetVolta + dadosVideoVolta.Length);
                Array.Resize(ref dados, dados.Length + dadosVideoNumero.Length);
                Array.Copy(dadosVideoNumero, 0, dados, offsetNumero, dadosVideoNumero.Length);

                BitConverter.GetBytes(offsetIda).CopyTo(dados, 4);
                BitConverter.GetBytes(offsetVolta).CopyTo(dados, 8);
                BitConverter.GetBytes(offsetNumero).CopyTo(dados, 12);

                fixed(byte *pSrc = dados)
                {
                    FormatoRoteiroPaths *roteiroPaths = (FormatoRoteiroPaths *)pSrc;

                    roteiroPaths->crc = CalcularCRC(dados);

                    BitConverter.GetBytes(roteiroPaths->crc).CopyTo(dados, Util.Util.CRCPosition1);
                }

                fs = File.Create(arquivoNome + Util.Util.sequencial_arquivo_roteiros.ToString("X8") + Util.Util.ARQUIVO_EXT_RPT);
                fs.Write(dados, 0, dados.Length);
                fs.Close();
            }
        }