viernes, 11 de octubre de 2013

Search characters into a string in Visual Basic



Since time ago I wanted to Post this entry because sometimes we want to read substrings in a main string. Of course obviously such tool doesn’t exist therefore we must create it.
Microsoft provides one tool and it is the following:

Dim text As String = "I have been playing tennis since I was a child"
Dim character As String = "I was a child"
Dim number As Integer

number = InStr(1,text, character, CompareMethod.Binary)

In this case when we want to know which is the position than one substring these code back to us the position where these. This code is amazing because you can search a string and not character, in this case when I want to search “I was a child” into “I have been playing tennis since I was a child”, this back to us the position where begin “I was a child” than is 34.

I want to show one example:

We suppose that I want to modify “I was a child” and then put “I was 19” in the main string, like this:
“I have been playing since I was 19”


Well it’s easy to resolve because we know the method and this is the following:

Dim text As String = "I have been playing tennis since I was a child"
Dim character As String = "I was a child"
Dim number As Integer

number = InStr(1,text, character, CompareMethod.Binary)

text = text.remove(number-1,13)'Add -1 because visual basic remove the text one position before the text which we want to remove.

replace(text, " ", "")'remove all spaces

text = text & "I was 19"

'We will see: “I have been playing since I was 19"

miércoles, 2 de octubre de 2013

How to make a graph with datas already save in binary files? (Use timestamp already save too)

In my last entry I was explain how to save information in binary files and how to save timestamp in binary files too In order to save up space in disk. Well in this entry I going to explain how use these information In order to graph it.

I have been making “graph XY” since I was start in Labview, but already exist many others methods that you can use, in this example I prefer this method because is more easy and fast.
For this example (If you decide follow my instructions) you need 2 files (Information file like a random numbers that it must be save as array number (don’t use array dbl) –you can use random number that includes in Labview- and timestamp files already save). These files must be save at the same time because this example explains how to graph information already captured in x time. Remember if you use the tool random number that includes in labview, you must be converts these dbl numbers to integer numbers.



When you take these files then you repeat this example again and again J


1)  The first step is build your decoders (timestamp decoder and array date number decoder) like these:





 The second step is build a bundle and then make a graph (You must select the graph in the user interface in labview)





After that you must configure this graph as follows:


domingo, 29 de septiembre de 2013

Save data like binary format less weight in disk (integer data)

Sometimes us want save number data (integer or dbl number). However integer numbers are lightweight in disk, in fact if you want save this numbers in binary file, I think you should wonder why?. This is because no the integer data use decimals therefore exist the answer, yes, the dbl numbers are heavy becuase it use decimal numbers.
One morning when I was take my deskfast in my work (I think that because I work in one proyect where I needed save data from inclinometer and then save it in binary files) I think How Save my information from inclinometer in lightweight binary file?, I was trying all methods (Or I thought this)

-String, number, dbl
-String, hexadecimal, dbl
-String, array number, array dbl

In these methods the result was the same: 8-14 Mb per file thus Was the issue?, Well the problem wasn't in all my strings process, the problem was in the DBL data, and I thought, "Well If I trying omit dbl datas then may be I saw differents effects In fact the solution was the next:

I received the numbers in string format, well the next step was convert it in bdl datas (because this information was decimal data) and then the next step was convert this in integer data. And the next question follow me: Who can convert dbl in integer data? If my information was decimal numbers. Well the solution is more more easy and this is the next:

The string of numbers only multiply per 100, and this way I had integer numbers, for example:

(635.5)(100) = 63550

Very nice I said xD I was found the solution for my problem.

Well I share my experiencie because I think that most of people was the same problem.I presume.
This files weighed 2 MB per file per 86400 data of numbers




lunes, 23 de septiembre de 2013

Save Time stamp like binary format (Labview)

Timestamp is very important when we need build a waveform (graphic waveform) or XY graph. Unlike time string, Timestamp is compatible with waveforms. For example when you save the time in string format and then you want put it in the graph we have some issues with the graph because the graph do not recognize string format for time.

In this case I show as save timesramp in binary format. I don't like explain all the progress theferore I put the following image : One image say more that a thousand words. I wonder why :)




domingo, 15 de septiembre de 2013

¿Cómo minimizar, maximizar o cerrar un Form con la propiedad Formborderstyle = none?

Cuando nosotros deseamos trabajar con un Form sin control de este, es decir, que hacemos desaparecer los botones de control (cerrar, minimizar y maximizar), es lógico que perdemos el control de nuestro form, ya que no podemos ni minimizarlo y cerrarlo. En algunas aplicaciones es importante añadir este control, ya sea en botones o labels, en ambos el procedimiento para esta implementacion es la mismo.

Ya sea que habéis optado por uno u otro, solo es cuestión de hacer uso de estos códigos en la propiedad click de nuestro item.

  • Me.close() 'Si queréis que el form se cierre cuando demos click en nuestro elemento (botón o label
  • Me.WindowState = 1 'Si queréis que el form se minimize cuando hagamos click en nuestro elemento
  • Me.WindowState = 2 'Si queréis que el form se maximize
  • Me.WindowState = 0 'Si queréis que el form regrese a su tamaño original

Con esto no volveremos a preocuparnos si desactivamos el borderstyle de nuestro form.


jueves, 12 de septiembre de 2013

Guardar datos tipo string en formato binario en labview


Ya hace tiempo me había topado con esta cuestión, sin embargo, si uno no sabe resolver sus dudad correctamente puede caer en un circulo vicioso donde no encuentre solución.
Es importante guardar la información en formato binario, ya que en este tipo de formato los archivos pesan una cuarta parte menos de que si se guardasen en Ascii, la velocidad para hacer lectura de estos es mucho mas rápido (refiriéndome a lectura como al proceso de decodificación), y claro si os queréis salvar la información para que nadie pueda leerla mas que vosotros, esta es la mejor opción.
Pues bien ya hace tiempo que me tope con LabVIEW, al principio me pareció algo burdo, sin embargo, a uno como programador le ahorra mucho tiempo, pues la programación es en diagrama de bloques, os aseguro que si lo prueban se sorprenderán de todo lo que podéis hacer.

En muchos sitios me eh encontrado con gente que se confunde entre el formato binario y la codificación binaria, que os aclaro son cosas muy distintas. El pasar el Ascci en unos y ceros en formato BCD (binario codificado en decimal) no significa que estemos guardando en formato binario, de echo seguimos en Ascci. Os aseguro que vosotros nos hemos topado con archivos en formato binario, si aquellos archivos que los abrimos y nos encontramos con puros símbolos extraños

€H@     €J@      M@     €H@      I@      M@      H@      L@      "@     €H@     €J@      M@     €H@      I@      M@      H@     €L@

La codificación anterior es de un archivo binario, los símbolos que se encuentran antes y después del "@ indican una cadena, esta cadena es un timestamp en formato 12 horas (la hora 00:00:00), y del otro extremo se encontraría respectivamente 00:00:01, entonces "@ da a entender que es un espacio en blanco.

Pues bien no os daréis una cátedra de esta codificación, pasemos a lo interesante.

¿Como salvar cadenas string en este formato?

Primero tenéis que tener instalado el LabVIEW (os recomiendo que se familiaricen con el lenguaje), si ya lo conocéis y so entráis para consultar el tema abajo os explicareis el código.



Este código codifica en formato binario, y en otro tiempo decodifica esta información.

-Es importante pasar toda nuestra cadena string a su significado numérico (para cada elemento de la cadena), no todo es automático en labview, y esto es un algoritmo hecho por mi mismo. Esto es necesario porque el codificador no acepta ascii como tal, si os queréis grabar el ascii puro en binario, sencillamente labview no codificara nada.

-En la parte de la decodificacion es importante saber que en binario, como todo esta en formato numérico, es necesario medir el archivo (numero bytes) y partirlos para asi tomar cada elemento para leerlo y decodificarlo, por eso agregue el "Quotient & remainder" cual nos facilita este trabajo.

-Es importante transformar lo numérico a string al momento de visualizar la cadena en ascii.

Pues bien me hubiera gustado profundizar mas en el tema pero carezco de tiempo, si os tenéis una duda podéis contactarme.

domingo, 8 de septiembre de 2013

How to install audacious in Centos RHEL 6 or other distributions of Linux

Well I promise that everyone who visited mi site know about this problem.

Normally when you trying install Audacious we find with the problem of the “audacious-plugins>= x.x.x version” needed for the installation, well the solution is very easy.

The first steep is go to this site: http://pkgs.org/download/audacious-plugins

And then select your distro linux (in my case is Centos 6 (RHEL 6)), when you select the distro the site requires that mirror download, I always select “ATrpms mirror” is taste affair, well in all mirrors exist various versions of audacious plugins (the version is not important). In the page find this: (of course Go ahead the steeps!, in my case for my distribution I followed this steep, change in each distros)

Install How to

Download the latest atrpms-repo rpm from

http://dl.atrpms.net/el6-x86_64/atrpms/stable/

Install atrpms-repo rpm:

# rpm -Uvh atrpms-repo*rpm

Install audacious-plugins rpm package:
# yum install audacious-plugins

 After that you try install Audacious
# yum install audacious