Skip to content

TextForward

Michiel TJampens edited this page Mar 26, 2021 · 2 revisions

Being a forward means that it can receive data from one or more sources do something with it and provide the resulting data as a source for multiple targets.

This particular forward:

  • Will apply text operations on the data after splitting it

Purpose

Alter data received so that it can easily be processed by a generic.

Main features

  • Change the formatting of a date or time eg. 10-10-21 to 2021_Oct_10
  • Add text to the front or back of the data
  • Use regex to redo the delimiting
  • Replace a given text or regex result with another text (or nothing)
  • Remove everything from data except the result of regex

Use case

Because the functionality uses are so diverse, various examples will be given instead.

<!-- Received data: Line of text -->

<!-- To add text to the front of the received data -->
<edit type="prepend">start</edit>  <!-- Result: startLine of text -->
<!-- To add text to the back of the received data -->
<edit type="append"> or end it?</edit>  <!-- Result: Line of text or end it?-->

<!-- Change the format of a timestamp (including date), input: 211010,12.25,1245 -->
<edit type="redate" delimiter="," index="0" from="yyMMdd">dd-MM-yyyy</edit>  <!-- Result: 10-10-2021,12.25.1245 -->
<!-- Change the format of a time (not including date), input: 21110,12.25,1245 -->
<edit type="retime" delimiter=";" index="1" from="HHmmss">HH:mm:ss</edit>  <!-- Result: 21:11:10,12.25,1245 -->

<!-- 
     Change the way the text is delimited, including changing the order or merging fields 
     Because this one might be rather complicated and the uses extensive, multiple examples will be given
     The whole idea is that the data is split according to a delimiter, then put together again as wanted.
     The first element is i0, second i1 and so on. 
     Note: The code will look for i followed by up to two digits, so make sure it can't miss between an index and
     something to add
-->
<!-- Input: 10,12,35 -->
<edit type="resplit" delimiter="," >i0;i2:i1</edit> <!-- Result: 10;35:12 -->
<edit type="resplit" delimiter=",">i0 ducks, i2 dogs, i3 cats</edit> <!-- Result: 10 ducks, 12 dogs, 13 cats -->
<edit type="resplit" delimiter=",">i003+i2!=i3</edit> <!-- Result: 103+12!=35 -->

<!-- The leftover attribute determines what happens with the entries not mentioned -->
<!-- append means that they will be added at the end using the original delimiter -->
<!-- Input: 10,12,35,16,27 -->
<edit type="resplit" delimiter="," leftover="append">i0;i2;i4</edit> <!-- Result: 10;35;27,12,16 -->
<!-- remove means that they will be forgotten -->
<edit type="resplit" delimiter="," leftover="append">i0;i2;i4</edit> <!-- Result: 10;35;27   -->

<!-- Rexsplit used a regex to split the received data and then puts it back together with the given delimiter -->
<edit type="rexsplit" delimiter=";">[0-9]</edit> <!-- Result: 1;0;1;2;3;5;1;6;2;7 -->

<!-- Replace is a simple look for x and replace with y -->
<!-- Input: 10,12,35,16,27 -->
<edit type="replace" find="2">8</edit> <!-- Result: 10,18,35,16,87 -->
<!-- Rexreplace looks for the result of a regex and replaces it, in the example digits 5 till 9 replaced by A  -->
<edit type="rexreplace" find="[5-9]">A</edit><!-- Input: 10,12,3A,1A,2A -->

<!-- (Rex)Remove does works the same as replace, but instead it's removed -->
<!-- Input: 10,12,35,16,27 -->
<edit type="remove" find="2"></edit> <!-- Result: 10,1,35,16,7 -->
 <!-- Rexremove looks for the result of a regex and removes it, in the example digits 5 till 9 are removed  -->
<edit type="rexremove" find="[5-9]"></edit><!-- Input: 10,12,3,1,2 -->

<!-- Rexkeep is similar to rexsplit but no delimiter is added -->
<edit type="rexkeep" find=""></edit>

Reference Guide

Commands

ef:addblank,id,source -> Create a blank math in the xml with the given id and optional source ef:addop,id,index=equation -> Add an operation to the given math that writes the result to the given index ef:addsource,id,source -> Add the given source to the id ef:reload,id -> Reload the given id

ef:list -> List all the available maths and their operations ef:debug,on/off -> Turn debugging on or off this will show how the op's are executed ef:test,id,data -> Give data to test it

Additional functionality

Defaults

If an attribute is considered default, it can be omitted from the node.

  • The default delimiter is ','
  • The default leftover attribute is 'append'
  • The default label is empty

Multiple sources

Multiple sources is possible and this is how this looks in the node.

<edit id="degrees">
      <src>raw:id:gps</src>
      <src>raw:id:rtk</src>  
</edit>

Label

Another main attribute is label. This does the same as the label of a stream (see Streampool) and can be used to give the altered data to a generic (see Generics).

<edit id="degrees" src="raw:id:gps" label="generic:coords">   
      <op index="3">(i3-i3%100) + (i3%100)/60</op> <!-- latitude -->
</edit>

Some rules/tips for the edits

todo

How it is implemented

todo

Clone this wiki locally