Тема: EXPLODE Function for text params
Description of the issue
Currently most RS232 messages appear in raw data as a text param, let's call it text_param as example,
some external device connected to the gps serial port can send multiple values using a separator, just for name a few (,.<>|&- = or any custom character or more than one character ##)
This kind of data must be parsed in order to be used, otherwise is just a text with no sense.
The idea
Implement the function EXPLODE to be used with text params, that can be used also with any params (casting to string if needed)
The proposed function is:
string new_params_list_n = EXPLODE(string input_param, string separator, int limit=0)
string new_params_list_n: Will generate a 'list of new params' with the contents of 'input_params' exploded with 'separator' until 'limit' items, the list will contain 'n' items and will create a new parameter identified by the name input_param + n, where n is the index.
string input_param: the string that will be exploded, if input_param is not a string it will be casted to string
string separator: used to define the character or characters used for the explode function
int limit: used to define the max number of items created from the explode, by default there is no limit, same as define limit as 0, if you define a number > 0 the number of returned items will be set to this limit
Example:
RAW data received by the gps:
text_param=hello|world|from|any|gps, event_type=1, others_params=dontcare
Note that can be any GPS no matter wich one, even if it havent an rs232 port, the solution proposed here is for data manipulation, not a especific solution linked to a gps model or application.
Then on 'Sensors' (or any other side, the 'Where' it's a gurtam decision)
We configure:
EXPLODE(text_param,"|",0)
then the new list of params available become
text_param=hello|world|from|any|gps, event_type=1, others_params=dontcare, text_param1=hello,text_param2=world,text_param3=from,text_param4=any,text_param5=gps
Now, same example but using the limit function:
We configure:
EXPLODE(text_param,"|",2)
then the new list of params available become
text_param=hello|world|from|any|gps, event_type=1, others_params=dontcare, text_param1=hello,text_param2=world
Now a real life example:
RAW data received by the gps:
text_param=21.5;22.0;47.8, event_type=1,hdop=12
We configure:
EXPLODE(text_param,";",0)
we get
text_param=21.5;22.0;47.8, event_type=1,hdop=12,text_param1=21.5,text_param2=22.0,text_param3=47.8
End users:
This will apply to any one that wants to access data present in some param, in order to create sensors and feed applications.
This can be used to track fuel, rpm, speed, etc with third party accesories connected by rs232 to any gps in transparent mode.
We are implementing CAN BUS reading for most trucks usign an external reader that can be connected with any GPS with an available RS232 port.
Today, we got this implemented using our own middleware that receive the data and then feed wialon with the parsed data using IPS. It's works like a charm, but would be better if we can skip this in first place.
Remarks:
Explode function is available in every computer language, thus can be easyly implemented, the only hard part is make the UI in order to set, and configure the function.
Hope that other developers can support this idea, because it will allow to integrate plenty of other complementary devices to wialon in a quickly manner.
Best regards and happy coding
With love from Chile
System development and integration
Разработка системы и интеграция
www.techdev.cl